1
+ import { toHex } from '@aztec/foundation/bigint-buffer' ;
1
2
import { type Logger } from '@aztec/foundation/log' ;
2
3
import { ForwarderAbi , ForwarderBytecode } from '@aztec/l1-artifacts' ;
3
4
@@ -15,11 +16,12 @@ import {
15
16
16
17
import { type L1Clients , deployL1Contract } from '../deploy_l1_contracts.js' ;
17
18
import { type L1BlobInputs , type L1GasConfig , type L1TxRequest , type L1TxUtils } from '../l1_tx_utils.js' ;
19
+ import { RollupContract } from './rollup.js' ;
18
20
19
21
export class ForwarderContract {
20
22
private readonly forwarder : GetContractReturnType < typeof ForwarderAbi , PublicClient < HttpTransport , Chain > > ;
21
23
22
- constructor ( public readonly client : L1Clients [ 'publicClient' ] , address : Hex ) {
24
+ constructor ( public readonly client : L1Clients [ 'publicClient' ] , address : Hex , public readonly rollupAddress : Hex ) {
23
25
this . forwarder = getContract ( { address, abi : ForwarderAbi , client } ) ;
24
26
}
25
27
@@ -28,6 +30,7 @@ export class ForwarderContract {
28
30
walletClient : WalletClient < HttpTransport , Chain , Account > ,
29
31
publicClient : PublicClient < HttpTransport , Chain > ,
30
32
logger : Logger ,
33
+ rollupAddress : Hex ,
31
34
) {
32
35
logger . info ( 'Deploying forwarder contract' ) ;
33
36
@@ -48,7 +51,7 @@ export class ForwarderContract {
48
51
49
52
logger . info ( `Forwarder contract deployed at ${ address } with owner ${ owner } ` ) ;
50
53
51
- return new ForwarderContract ( publicClient , address . toString ( ) ) ;
54
+ return new ForwarderContract ( publicClient , address . toString ( ) , rollupAddress ) ;
52
55
}
53
56
54
57
public getAddress ( ) {
@@ -60,6 +63,7 @@ export class ForwarderContract {
60
63
l1TxUtils : L1TxUtils ,
61
64
gasConfig : L1GasConfig | undefined ,
62
65
blobConfig : L1BlobInputs | undefined ,
66
+ logger : Logger ,
63
67
) {
64
68
requests = requests . filter ( request => request . to !== null ) ;
65
69
const toArgs = requests . map ( request => request . to ! ) ;
@@ -83,6 +87,7 @@ export class ForwarderContract {
83
87
const stats = await l1TxUtils . getTransactionStats ( receipt . transactionHash ) ;
84
88
return { receipt, gasPrice, stats } ;
85
89
} else {
90
+ logger . error ( 'Forwarder transaction failed' , { receipt } ) ;
86
91
const args = {
87
92
args : [ toArgs , dataArgs ] ,
88
93
functionName : 'forward' ,
@@ -97,14 +102,30 @@ export class ForwarderContract {
97
102
if ( maxFeePerBlobGas === undefined ) {
98
103
errorMsg = 'maxFeePerBlobGas is required to get the error message' ;
99
104
} else {
100
- errorMsg = await l1TxUtils . tryGetErrorFromRevertedTx ( data , args , {
101
- blobs : blobConfig . blobs ,
102
- kzg : blobConfig . kzg ,
103
- maxFeePerBlobGas,
104
- } ) ;
105
+ errorMsg = await l1TxUtils . tryGetErrorFromRevertedTx (
106
+ data ,
107
+ args ,
108
+ {
109
+ blobs : blobConfig . blobs ,
110
+ kzg : blobConfig . kzg ,
111
+ maxFeePerBlobGas,
112
+ } ,
113
+ [
114
+ {
115
+ address : this . rollupAddress ,
116
+ stateDiff : [
117
+ {
118
+ slot : toHex ( RollupContract . checkBlobSlot , true ) ,
119
+ value : toHex ( 0n , true ) ,
120
+ } ,
121
+ ] ,
122
+ } ,
123
+ ] ,
124
+ ) ;
105
125
}
106
126
} else {
107
- errorMsg = await l1TxUtils . tryGetErrorFromRevertedTx ( data , args ) ;
127
+ logger . info ( 'Trying to get error from reverted tx without blob config' ) ;
128
+ errorMsg = await l1TxUtils . tryGetErrorFromRevertedTx ( data , args , undefined , [ ] ) ;
108
129
}
109
130
110
131
return { receipt, gasPrice, errorMsg } ;
0 commit comments