Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 2ba35d5

Browse files
z2trillionMason Liang
andauthored
Add test for the codehash of the coinbase account. (privacy-scaling-explorations#1511)
### Description Previously we did not set the code hash for coinbase accounts in the EndTxGadget. This was fixed in 242d38b. This PR adds a regression test. ### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update Co-authored-by: Mason Liang <[email protected]>
1 parent 86c35ba commit 2ba35d5

File tree

1 file changed

+28
-0
lines changed
  • zkevm-circuits/src/evm_circuit/execution

1 file changed

+28
-0
lines changed

zkevm-circuits/src/evm_circuit/execution/end_tx.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,4 +510,32 @@ mod test {
510510
.unwrap(),
511511
);
512512
}
513+
514+
#[test]
515+
fn end_tx_gadget_nonexisting_coinbase() {
516+
// Check that the code hash of the coinbase address is correctly set to be the empty code
517+
// hash when it is created because of receiving the gas fees from the first tx.
518+
test_ok(
519+
TestContext::<2, 2>::new(
520+
None,
521+
account_0_code_account_1_no_code(bytecode! {
522+
COINBASE
523+
EXTCODEHASH
524+
}), /* EXTCODEHASH will return 0 for the first tx and the empty code hash for
525+
* the second tx. */
526+
|mut txs, accs| {
527+
txs[0]
528+
.to(accs[0].address)
529+
.from(accs[1].address)
530+
.value(eth(1));
531+
txs[1]
532+
.to(accs[0].address)
533+
.from(accs[1].address)
534+
.value(eth(1));
535+
},
536+
|block, _| block,
537+
)
538+
.unwrap(),
539+
);
540+
}
513541
}

0 commit comments

Comments
 (0)