Commit 86c293c3 authored by Mark Tyneway's avatar Mark Tyneway Committed by Maurelian

contracts-bedrock: be mindful of nonce management

Right now the `generate-l2-genesis.sh` script has to be ran from
within the solidity context so that the contract addresses that it
creates match what the contract addresses are in the `Deploy` script.
Otherwise, the L2 genesis generation will have the wrong L1 addresses
embedded into the L2 state, resulting in failing tests. This happens
because of the way that nonce management is handled. The nonce
determines the address that CREATE sets the code at. So we use not the
standard account for deploying contracts that we don't care about to
make the nonces line up more. The ideal is that we no longer need to
call the `generate-l2-genesis.sh` script from solidity and can call
it once before inside of a `pnpm` command and still have all the
contract addresses line up.
parent e4fd1317
......@@ -17,7 +17,13 @@ contract CommonTest is Setup, Test, Events {
FFIInterface ffi;
function setUp() public virtual override {
alice = makeAddr("alice");
bob = makeAddr("bob");
vm.deal(alice, 10000 ether);
vm.deal(bob, 10000 ether);
Setup.setUp();
vm.prank(alice);
ffi = new FFIInterface();
// Make sure the base fee is non zero
......@@ -27,11 +33,6 @@ contract CommonTest is Setup, Test, Events {
vm.warp(deploy.cfg().l2OutputOracleStartingTimestamp() + 1);
vm.roll(deploy.cfg().l2OutputOracleStartingBlockNumber() + 1);
alice = makeAddr("alice");
bob = makeAddr("bob");
vm.deal(alice, 10000 ether);
vm.deal(bob, 10000 ether);
// Deploy L1
Setup.L1();
// Deploy L2
......
......@@ -80,8 +80,12 @@ contract Setup {
deploy.setUp();
}
/// @dev Simple wrapper around the `create` opcode
/// @dev Simple wrapper around the `create` opcode that uses a particular
/// deployer account.
function _create(bytes memory _code) internal returns (address addr_) {
address deployer = address(0xd3607);
vm.deal(deployer, 1 ether);
vm.prank(deployer);
assembly {
addr_ := create(0, add(_code, 0x20), mload(_code))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment