Skip to content

Commit

Permalink
Add test for the codehash of the coinbase account. (privacy-scaling-e…
Browse files Browse the repository at this point in the history
…xplorations#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]>
  • Loading branch information
z2trillion and Mason Liang authored Sep 19, 2023
1 parent 86c35ba commit 2ba35d5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions zkevm-circuits/src/evm_circuit/execution/end_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,32 @@ mod test {
.unwrap(),
);
}

#[test]
fn end_tx_gadget_nonexisting_coinbase() {
// Check that the code hash of the coinbase address is correctly set to be the empty code
// hash when it is created because of receiving the gas fees from the first tx.
test_ok(
TestContext::<2, 2>::new(
None,
account_0_code_account_1_no_code(bytecode! {
COINBASE
EXTCODEHASH
}), /* EXTCODEHASH will return 0 for the first tx and the empty code hash for
* the second tx. */
|mut txs, accs| {
txs[0]
.to(accs[0].address)
.from(accs[1].address)
.value(eth(1));
txs[1]
.to(accs[0].address)
.from(accs[1].address)
.value(eth(1));
},
|block, _| block,
)
.unwrap(),
);
}
}

0 comments on commit 2ba35d5

Please sign in to comment.