@@ -117,6 +117,23 @@ export async function dryrun({
117117 const estimation = await estimateGasCost ( rawtx , signer , config , l1GasPrice ) ;
118118 l1Cost = estimation . l1Cost ;
119119 gasLimit = ethers . BigNumber . from ( estimation . gas ) . mul ( config . gasLimitMultiplier ) . div ( 100 ) ;
120+
121+ // include dryrun headroom gas estimation in otel logs
122+ extendSpanAttributes (
123+ spanAttributes ,
124+ {
125+ gasLimit : estimation . gas . toString ( ) ,
126+ totalCost : estimation . totalGasCost . toString ( ) ,
127+ gasPrice : estimation . gasPrice . toString ( ) ,
128+ ...( config . isSpecialL2
129+ ? {
130+ l1Cost : estimation . l1Cost . toString ( ) ,
131+ l1GasPrice : estimation . l1GasPrice . toString ( ) ,
132+ }
133+ : { } ) ,
134+ } ,
135+ "gasEst.headroom" ,
136+ ) ;
120137 } catch ( e ) {
121138 // reason, code, method, transaction, error, stack, message
122139 const isNodeError = containsNodeError ( e as BaseError ) ;
@@ -146,6 +163,10 @@ export async function dryrun({
146163 // sender output which is already called above
147164 if ( config . gasCoveragePercentage !== "0" ) {
148165 const headroom = ( Number ( config . gasCoveragePercentage ) * 1.03 ) . toFixed ( ) ;
166+ spanAttributes [ "gasEst.headroom.minBountyExpected" ] = gasCost
167+ . mul ( headroom )
168+ . div ( "100" )
169+ . toString ( ) ;
149170 task . evaluable . bytecode = await parseRainlang (
150171 await getWithdrawEnsureRainlang (
151172 signer . account . address ,
@@ -179,12 +200,34 @@ export async function dryrun({
179200 . div ( 100 ) ;
180201 if ( gasLimit . isZero ( ) ) {
181202 throw new ExecutionRevertedError ( {
203+ cause : new BaseError ( "RPC returned 0 for eth_estimateGas" , {
204+ cause : new Error (
205+ "Failed to estimated gas, RPC returned 0 for eth_estimateGas call without rejection" ,
206+ ) ,
207+ } ) ,
182208 message :
183- "Failed to estimated gas, rpc returned 0 for gasEstimate call without rejection" ,
209+ "Failed to estimated gas, RPC returned 0 for eth_estimateGas call without rejection" ,
184210 } ) ;
185211 }
186212 rawtx . gas = gasLimit . toBigInt ( ) ;
187213 gasCost = gasLimit . mul ( gasPrice ) . add ( estimation . l1Cost ) ;
214+
215+ // include dryrun final gas estimation in otel logs
216+ extendSpanAttributes (
217+ spanAttributes ,
218+ {
219+ gasLimit : estimation . gas . toString ( ) ,
220+ totalCost : estimation . totalGasCost . toString ( ) ,
221+ gasPrice : estimation . gasPrice . toString ( ) ,
222+ ...( config . isSpecialL2
223+ ? {
224+ l1Cost : estimation . l1Cost . toString ( ) ,
225+ l1GasPrice : estimation . l1GasPrice . toString ( ) ,
226+ }
227+ : { } ) ,
228+ } ,
229+ "gasEst.final" ,
230+ ) ;
188231 task . evaluable . bytecode = await parseRainlang (
189232 await getWithdrawEnsureRainlang (
190233 signer . account . address ,
@@ -209,6 +252,10 @@ export async function dryrun({
209252 rawtx . data = obInterface . encodeFunctionData ( "multicall" , [
210253 [ clear2Calldata , withdrawInputCalldata , withdrawOutputCalldata ] ,
211254 ] ) ;
255+ spanAttributes [ "gasEst.final.minBountyExpected" ] = gasCost
256+ . mul ( config . gasCoveragePercentage )
257+ . div ( "100" )
258+ . toString ( ) ;
212259 } catch ( e ) {
213260 const isNodeError = containsNodeError ( e as BaseError ) ;
214261 const errMsg = errorSnapshot ( "" , e ) ;
0 commit comments