@@ -254,9 +254,11 @@ impl<F: Field> ExecutionGadget<F> for EndTxGadget<F> {
254
254
let current_cumulative_gas_used: u64 = if tx. id == 1 {
255
255
0
256
256
} else {
257
+ // first transaction needs TxReceiptFieldTag::COUNT(3) lookups to tx receipt,
258
+ // while later transactions need 4 (with one extra cumulative gas read) lookups
257
259
let rw = & block. rws [ (
258
260
RwTableTag :: TxReceipt ,
259
- ( tx. id - 1 ) * TxReceiptFieldTag :: COUNT - 1 ,
261
+ ( tx. id - 2 ) * ( TxReceiptFieldTag :: COUNT + 1 ) + 2 ,
260
262
) ] ;
261
263
rw. receipt_value ( )
262
264
} ;
@@ -280,8 +282,8 @@ mod test {
280
282
use crate :: evm_circuit:: {
281
283
test:: run_test_circuit_incomplete_fixed_table, witness:: block_convert,
282
284
} ;
283
- use eth_types:: { self , address , bytecode, geth_types:: GethData , Word } ;
284
- use mock:: TestContext ;
285
+ use eth_types:: { self , bytecode, geth_types:: GethData } ;
286
+ use mock:: { eth , test_ctx :: helpers :: account_0_code_account_1_no_code , TestContext } ;
285
287
286
288
fn test_ok ( block : GethData ) {
287
289
let block_data = bus_mapping:: mock:: BlockData :: new_from_geth_data ( block) ;
@@ -313,26 +315,22 @@ mod test {
313
315
// Multiple txs
314
316
test_ok (
315
317
// Get the execution steps from the external tracer
316
- TestContext :: < 2 , 2 > :: new (
318
+ TestContext :: < 2 , 3 > :: new (
317
319
None ,
318
- |accs| {
319
- accs[ 0 ]
320
- . address ( address ! ( "0x00000000000000000000000000000000000000fe" ) )
321
- . balance ( Word :: from ( 10u64 . pow ( 19 ) ) )
322
- . code ( bytecode ! { STOP } ) ;
323
- accs[ 1 ]
324
- . address ( address ! ( "0x00000000000000000000000000000000000000fd" ) )
325
- . balance ( Word :: from ( 10u64 . pow ( 19 ) ) ) ;
326
- } ,
320
+ account_0_code_account_1_no_code ( bytecode ! { STOP } ) ,
327
321
|mut txs, accs| {
328
322
txs[ 0 ]
329
323
. to ( accs[ 0 ] . address )
330
324
. from ( accs[ 1 ] . address )
331
- . value ( Word :: from ( 10u64 . pow ( 17 ) ) ) ;
325
+ . value ( eth ( 1 ) ) ;
332
326
txs[ 1 ]
333
327
. to ( accs[ 0 ] . address )
334
328
. from ( accs[ 1 ] . address )
335
- . value ( Word :: from ( 10u64 . pow ( 17 ) ) ) ;
329
+ . value ( eth ( 1 ) ) ;
330
+ txs[ 2 ]
331
+ . to ( accs[ 0 ] . address )
332
+ . from ( accs[ 1 ] . address )
333
+ . value ( eth ( 1 ) ) ;
336
334
} ,
337
335
|block, _tx| block. number ( 0xcafeu64 ) ,
338
336
)
0 commit comments