@@ -117,27 +117,48 @@ func ApplyInternalTxUpdate(tx *types.ArbitrumInternalTx, state *arbosState.Arbos
117117 }
118118 batchTimestamp := util .SafeMapGet [* big.Int ](inputs , "batchTimestamp" )
119119 batchPosterAddress := util .SafeMapGet [common.Address ](inputs , "batchPosterAddress" )
120+ batchDataGas := util .SafeMapGet [uint64 ](inputs , "batchDataGas" )
121+ l1BaseFeeWei := util .SafeMapGet [* big.Int ](inputs , "l1BaseFeeWei" )
122+
123+ l1p := state .L1PricingState ()
124+ perBatchGas , err := l1p .PerBatchGasCost ()
125+ if err != nil {
126+ log .Warn ("L1Pricing PerBatchGas failed" , "err" , err )
127+ }
128+ gasSpent := arbmath .SaturatingAdd (perBatchGas , arbmath.SaturatingCast [int64 ](batchDataGas ))
129+ weiSpent := arbmath .BigMulByUint (l1BaseFeeWei , arbmath.SaturatingUCast [uint64 ](gasSpent ))
130+ err = l1p .UpdateForBatchPosterSpending (
131+ evm .StateDB ,
132+ evm ,
133+ state .ArbOSVersion (),
134+ batchTimestamp .Uint64 (),
135+ evm .Context .Time ,
136+ batchPosterAddress ,
137+ weiSpent ,
138+ l1BaseFeeWei ,
139+ util .TracingDuringEVM ,
140+ )
141+ if err != nil {
142+ log .Warn ("L1Pricing UpdateForSequencerSpending failed" , "err" , err )
143+ }
144+ return nil
145+ case InternalTxBatchPostingReportV2MethodID :
146+ inputs , err := util .UnpackInternalTxDataBatchPostingReportV2 (tx .Data )
147+ if err != nil {
148+ return err
149+ }
150+ batchTimestamp := util .SafeMapGet [* big.Int ](inputs , "batchTimestamp" )
151+ batchPosterAddress := util .SafeMapGet [common.Address ](inputs , "batchPosterAddress" )
120152 batchCalldataLength := util .SafeMapGet [uint64 ](inputs , "batchCalldataLength" )
121153 batchCalldataNonZeros := util .SafeMapGet [uint64 ](inputs , "batchCalldataNonZeros" )
122- batchLegacyGas := util .SafeMapGet [uint64 ](inputs , "batchLegacyGas" )
123154 batchExtraGas := util .SafeMapGet [uint64 ](inputs , "batchExtraGas" )
124155 l1BaseFeeWei := util .SafeMapGet [* big.Int ](inputs , "l1BaseFeeWei" )
125156
126- var gasSpent uint64
127- if batchCalldataLength == ^ uint64 (0 ) {
128- if state .ArbOSVersion () >= params .ArbosVersion_50 {
129- return fmt .Errorf ("missing batch calldata stats for arbos >= 50" )
130- }
131- gasSpent = batchLegacyGas
132- } else {
133- gasSpent = arbostypes .LegacyCostForStats (& arbostypes.BatchDataStats {
134- Length : batchCalldataLength ,
135- NonZeros : batchCalldataNonZeros ,
136- })
137- if batchLegacyGas != ^ uint64 (0 ) && batchLegacyGas != gasSpent {
138- log .Error ("legacy gas doesn't fit local compute" , "local" , gasSpent , "legacy" , batchLegacyGas , "timestamp" , batchTimestamp )
139- }
140- }
157+ gasSpent := arbostypes .LegacyCostForStats (& arbostypes.BatchDataStats {
158+ Length : batchCalldataLength ,
159+ NonZeros : batchCalldataNonZeros ,
160+ })
161+
141162 gasSpent = arbmath .SaturatingUAdd (gasSpent , batchExtraGas )
142163
143164 l1p := state .L1PricingState ()
@@ -172,9 +193,10 @@ func ApplyInternalTxUpdate(tx *types.ArbitrumInternalTx, state *arbosState.Arbos
172193 util .TracingDuringEVM ,
173194 )
174195 if err != nil {
175- log .Warn ("L1Pricing UpdateForSequencerSpending failed" , "err" , err )
196+ log .Warn ("L1Pricing UpdateForSequencerSpending failed (v2 report) " , "err" , err )
176197 }
177198 return nil
199+
178200 default :
179201 return fmt .Errorf ("unknown internal tx method selector: %v" , hex .EncodeToString (tx .Data [:4 ]))
180202 }
0 commit comments