Skip to content

Commit

Permalink
Use engine API that matches hardfork version (#9253)
Browse files Browse the repository at this point in the history
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
  • Loading branch information
ImTei authored and spacesailor24 committed Feb 8, 2024
1 parent 1b1f494 commit fd63302
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 39 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,10 @@ workflows:
name: op-challenger-tests
module: op-challenger
requires: ["go-mod-download"]
- go-test:
name: op-dispute-mon-tests
module: op-dispute-mon
requires: ["go-mod-download"]
- go-test:
name: op-conductor-tests
module: op-conductor
Expand Down
2 changes: 1 addition & 1 deletion op-bindings/bindings/faultdisputegame.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-bindings/bindings/faultdisputegame_more.go

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions op-chain-ops/cmd/check-ecotone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,10 @@ func execTx(ctx context.Context, to *common.Address, data []byte, expectRevert b
if err != nil {
return fmt.Errorf("failed to get chainID: %w", err)
}
tx := types.NewTx(&types.DynamicFeeTx{ChainID: chainID, Nonce: nonce,
GasTipCap: tip, GasFeeCap: maxFee, Gas: 500000, To: to, Data: data})
tx := types.NewTx(&types.DynamicFeeTx{
ChainID: chainID, Nonce: nonce,
GasTipCap: tip, GasFeeCap: maxFee, Gas: 500000, To: to, Data: data,
})
signer := types.NewCancunSigner(chainID)
signedTx, err := types.SignTx(tx, signer, env.key)
if err != nil {
Expand Down Expand Up @@ -657,8 +659,9 @@ func checkL1Fees(ctx context.Context, env *actionEnv) error {
return fmt.Errorf("failed to retrieve matching L1 block %s: %w", headRef, err)
}
gasTip := big.NewInt(2 * params.GWei)
baseFee := (*uint256.Int)(&payload.ExecutionPayload.BaseFeePerGas).ToBig()
gasMaxFee := new(big.Int).Add(
new(big.Int).Mul(big.NewInt(2), payload.ExecutionPayload.BaseFeePerGas.ToBig()), gasTip)
new(big.Int).Mul(big.NewInt(2), baseFee), gasTip)
to := common.Address{1, 2, 3, 5}
txData := &types.DynamicFeeTx{
ChainID: rollupCfg.L2ChainID,
Expand Down
5 changes: 4 additions & 1 deletion op-chain-ops/cmd/receipt-reference-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (

"github.com/mattn/go-isatty"
"github.com/urfave/cli/v2"
"golang.org/x/exp/slog"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

opservice "github.com/ethereum-optimism/optimism/op-service"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
)

const EnvPrefix = "OP_CHAIN_OPS_RECEIPT_REFERENCE_BUILDER"
Expand Down Expand Up @@ -75,7 +77,8 @@ var (
)

func main() {
log.Root().SetHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(isatty.IsTerminal(os.Stderr.Fd()))))
color := isatty.IsTerminal(os.Stderr.Fd())
oplog.SetGlobalLogHandler(log.NewTerminalHandlerWithLevel(os.Stdout, slog.LevelDebug, color))

app := &cli.App{
Name: "receipt-reference-builder",
Expand Down
3 changes: 0 additions & 3 deletions op-e2e/faultproofs/output_cannon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ func TestOutputCannonDefendStep(t *testing.T) {
}

func TestOutputCannonStepWithLargePreimage(t *testing.T) {
// TODO(client-pod#525): Investigate and fix flakiness
t.Skip("Skipping until the flakiness can be resolved")

op_e2e.InitParallel(t, op_e2e.UsesCannon)

ctx := context.Background()
Expand Down
6 changes: 1 addition & 5 deletions op-e2e/faultproofs/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ type faultDisputeConfigOpts func(cfg *op_e2e.SystemConfig)

func withBatcherStopped() faultDisputeConfigOpts {
return func(cfg *op_e2e.SystemConfig) {
maxTxDataSize := uint64(131072) // As per the Ethereum spec.
// Allow the batcher to produce really huge calldata transactions.
// Make the max deliberately bigger than the target but still with some padding below the actual limit
cfg.BatcherTargetL1TxSizeBytes = maxTxDataSize - 5000
cfg.BatcherMaxL1TxSizeBytes = maxTxDataSize - 1000
cfg.DisableBatcher = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"baseFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"l1FeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"sequencerFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"baseFeeVaultWithdrawalNetwork": "remote",
"l1FeeVaultWithdrawalNetwork": "remote",
"sequencerFeeVaultWithdrawalNetwork": "remote",
"baseFeeVaultWithdrawalNetwork": 0,
"l1FeeVaultWithdrawalNetwork": 0,
"sequencerFeeVaultWithdrawalNetwork": 0,
"proxyAdminOwner": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
"finalSystemOwner": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
"superchainConfigGuardian": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts-bedrock/scripts/DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ contract DeployConfig is Script {
address public l2OutputOracleProposer;
address public l2OutputOracleChallenger;
uint256 public finalizationPeriodSeconds;
bool public fundDevAccounts;
address public proxyAdminOwner;
address public baseFeeVaultRecipient;
uint256 public baseFeeVaultMinimumWithdrawalAmount;
address public l1FeeVaultRecipient;
uint256 public l1FeeVaultMinimumWithdrawalAmount;
address public sequencerFeeVaultRecipient;
uint256 public sequencerFeeVaultMinimumWithdrawalAmount;
uint256 public sequencerFeeVaultWithdrawalNetwork;
string public governanceTokenName;
string public governanceTokenSymbol;
address public governanceTokenOwner;
Expand Down Expand Up @@ -95,13 +97,15 @@ contract DeployConfig is Script {
l2OutputOracleProposer = stdJson.readAddress(_json, "$.l2OutputOracleProposer");
l2OutputOracleChallenger = stdJson.readAddress(_json, "$.l2OutputOracleChallenger");
finalizationPeriodSeconds = stdJson.readUint(_json, "$.finalizationPeriodSeconds");
fundDevAccounts = stdJson.readBool(_json, "$.fundDevAccounts");
proxyAdminOwner = stdJson.readAddress(_json, "$.proxyAdminOwner");
baseFeeVaultRecipient = stdJson.readAddress(_json, "$.baseFeeVaultRecipient");
baseFeeVaultMinimumWithdrawalAmount = stdJson.readUint(_json, "$.baseFeeVaultMinimumWithdrawalAmount");
l1FeeVaultRecipient = stdJson.readAddress(_json, "$.l1FeeVaultRecipient");
l1FeeVaultMinimumWithdrawalAmount = stdJson.readUint(_json, "$.l1FeeVaultMinimumWithdrawalAmount");
sequencerFeeVaultRecipient = stdJson.readAddress(_json, "$.sequencerFeeVaultRecipient");
sequencerFeeVaultMinimumWithdrawalAmount = stdJson.readUint(_json, "$.sequencerFeeVaultMinimumWithdrawalAmount");
sequencerFeeVaultWithdrawalNetwork = stdJson.readUint(_json, "$.sequencerFeeVaultWithdrawalNetwork");
governanceTokenName = stdJson.readString(_json, "$.governanceTokenName");
governanceTokenSymbol = stdJson.readString(_json, "$.governanceTokenSymbol");
governanceTokenOwner = stdJson.readAddress(_json, "$.governanceTokenOwner");
Expand Down
66 changes: 49 additions & 17 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,31 @@ import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC2
import { L1Block } from "src/L2/L1Block.sol";
import { GovernanceToken } from "src/governance/GovernanceToken.sol";
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

interface IInitializable {
function initialize(address _addr) external;
}

/// @dev The general flow of adding a predeploy is:
/// 1. _setProxies uses vm.etch to set the Proxy.sol deployed bytecode for proxy address `0x420...000` to `0x420...000 + PROXY_COUNT - 1`.
/// 1. _setPredeployProxies uses vm.etch to set the Proxy.sol deployed bytecode for proxy address `0x420...000` to `0x420...000 + PROXY_COUNT - 1`.
/// Additionally, the PROXY_ADMIN_ADDRESS and PROXY_IMPLEMENTATION_ADDRESS storage slots are set for the proxy
/// address.
/// 2. vm.etch sets the deployed bytecode for each predeploy at the implementation address (i.e. `0xc0d3` namespace).
/// 3. The `initialize` method is called at the implementation address with zero/dummy vaules if it exists.
/// 4. The `initialize` method is called at the proxy address with actual vaules if it exists.
/// 2. `vm.etch` sets the deployed bytecode for each predeploy at the implementation address (i.e. `0xc0d3` namespace).
/// 3. The `initialize` method is called at the implementation address with zero/dummy vaules if the method exists.
/// 4. The `initialize` method is called at the proxy address with actual vaules if the method exists.
/// 5. A `require` check to verify the expected implementation address is set for the proxy.
/// @notice The following safety invariants are used when setting state:
/// 1. `vm.getDeployedBytecode` can only be used with `vm.etch` when there are no side
/// effects in the constructor and no immutables in the bytecode.
/// 2. A contract must be deployed using the `new` syntax if there are immutables in the code.
/// Any other side effects from the init code besides setting the immutables must be cleaned up afterwards.
/// 3. A contract is deployed using the `new` syntax because it's not proxied, but still needs to be set
/// at a specific address. Because just deploying a new instance doesn't give us the contract at our desired
/// address,
/// we must use `vm.etch` to set the deployed bytecode, and `vm.store` to set any storage slots. Lastly, we reset
/// the account the contract was initially deployed by so it's not included in the `vm.dumpState`.
/// 3. A contract is deployed using the `new` syntax, however it's not proxied and is still expected to exist at a
/// specific implementation address (i.e. `0xc0d3` namespace). In this case we deploy an instance of the contract
/// using `new` syntax, use `contract.code` to retrieve it's deployed bytecode, `vm.etch` the bytecode at the
/// expected implementation address, and `vm.store` to set any storage slots that are
/// expected to be set after a new deployment. Lastly, we reset the account code and storage slots the contract
/// was initially deployed to so it's not included in the `vm.dumpState`.
contract L2Genesis is Script, Artifacts {
uint256 constant PROXY_COUNT = 2048;
uint256 constant PRECOMPILE_COUNT = 256;
Expand All @@ -54,6 +56,15 @@ contract L2Genesis is Script, Artifacts {
/// @notice The storage slot that holds the address of the owner.
/// @dev `bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)`
bytes32 internal constant PROXY_ADMIN_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
uint80 internal constant devAccountFundAmt = 10_000 ether;
/// @notice Default Anvil dev accounts. Only funded if `cfg.fundDevAccounts == true`.
address[10] internal devAccounts = [
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, 0x70997970C51812dc3A010C7d01b50e0d17dc79C8,
0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC, 0x90F79bf6EB2c4f870365E785982E1f101E93b906,
0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65, 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc,
0x976EA74026E726554dB657fA54763abd0C3a0aa9, 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955,
0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f, 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
];

string internal outfile;

Expand All @@ -77,9 +88,13 @@ contract L2Genesis is Script, Artifacts {
/// to generate a L2 genesis alloc.
/// @notice The alloc object is sorted numerically by address.
function run() public {
_setPrecompiles();
_setProxies();
_setImplementations();
_dealEthToPrecompiles();
_setPredeployProxies();
_setPredeployImplementations();

if (cfg.fundDevAccounts()) {
_fundDevAccounts();
}

/// Reset so its not included state dump
vm.etch(address(cfg), "");
Expand All @@ -90,7 +105,7 @@ contract L2Genesis is Script, Artifacts {

/// @notice Give all of the precompiles 1 wei so that they are
/// not considered empty accounts.
function _setPrecompiles() internal {
function _dealEthToPrecompiles() internal {
for (uint256 i; i < PRECOMPILE_COUNT; i++) {
vm.deal(address(uint160(i)), 1);
}
Expand All @@ -100,7 +115,7 @@ contract L2Genesis is Script, Artifacts {
/// The Proxy bytecode should be set. All proxied predeploys should have
/// the 1967 admin slot set to the ProxyAdmin predeploy. All defined predeploys
/// should have their implementations set.
function _setProxies() internal {
function _setPredeployProxies() internal {
bytes memory code = vm.getDeployedCode("Proxy.sol:Proxy");
uint160 prefix = uint160(0x420) << 148;

Expand Down Expand Up @@ -129,7 +144,7 @@ contract L2Genesis is Script, Artifacts {
/// @notice LEGACY_ERC20_ETH is not being predeployed since it's been deprecated.
/// @dev Sets all the implementations for the predeploy proxies. For contracts without proxies,
/// sets the deployed bytecode at their expected predeploy address.
function _setImplementations() internal {
function _setPredeployImplementations() internal {
_setLegacyMessagePasser();
_setDeployerWhitelist();
_setWETH9();
Expand Down Expand Up @@ -228,7 +243,7 @@ contract L2Genesis is Script, Artifacts {
SequencerFeeVault vault = new SequencerFeeVault({
_recipient: cfg.sequencerFeeVaultRecipient(),
_minWithdrawalAmount: cfg.sequencerFeeVaultMinimumWithdrawalAmount(),
_withdrawalNetwork: FeeVault.WithdrawalNetwork.L1
_withdrawalNetwork: FeeVault.WithdrawalNetwork(cfg.sequencerFeeVaultWithdrawalNetwork())
});

address impl = _predeployToCodeNamespace(Predeploys.SEQUENCER_FEE_WALLET);
Expand Down Expand Up @@ -350,7 +365,7 @@ contract L2Genesis is Script, Artifacts {
/// @notice There isn't a good way to know if the resulting revering is due to abi mismatch
/// or because it's already been initialized
function _verifyCantReinitialize(address _contract, address _arg) internal {
vm.expectRevert();
vm.expectRevert("Initializable: contract is already initialized");
IInitializable(_contract).initialize(_arg);
}

Expand All @@ -363,6 +378,15 @@ contract L2Genesis is Script, Artifacts {
vm.ffi(commands);
}

function _fundDevAccounts() internal {
for (uint256 i; i < devAccounts.length; i++) {
console.log("Funding dev account %s with %s ETH", devAccounts[i], devAccountFundAmt / 1e18);
vm.deal(devAccounts[i], devAccountFundAmt);
}

_checkDevAccountsFunded();
}

//////////////////////////////////////////////////////
/// Post Checks
//////////////////////////////////////////////////////
Expand All @@ -384,4 +408,12 @@ contract L2Genesis is Script, Artifacts {
_verifyCantReinitialize(_impl, address(0));
_verifyCantReinitialize(Predeploys.OPTIMISM_MINTABLE_ERC20_FACTORY, Predeploys.L2_STANDARD_BRIDGE);
}

function _checkDevAccountsFunded() internal view {
for (uint256 i; i < devAccounts.length; i++) {
if (devAccounts[i].balance != devAccountFundAmt) {
revert(string.concat("Dev account not funded with expected amount of ETH: ", Strings.toHexString(devAccounts[i])));
}
}
}
}
6 changes: 3 additions & 3 deletions packages/contracts-bedrock/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
"sourceCodeHash": "0xe1891e7e6a1928b9a2ddc47d1f010650f1125a0617b8bf32190176a3bb674b4f"
},
"src/dispute/FaultDisputeGame.sol": {
"initCodeHash": "0x471c66c96f233d0d1589c18efada49e14bf52e22e1bafc6d7768ee10b5b4f1de",
"sourceCodeHash": "0x34d7af1f21b12900721a11eabb4131b99920047830c6784d06aacf648156d993"
"initCodeHash": "0x04fc1926f2ccd02a2c065e4dd0e562be7c8c498d76d6d860cc394fd74fffca06",
"sourceCodeHash": "0x1e539ba88487b2ec1359577dbd82270fddbabc3b8982dc6dc1a4a5169318e479"
},
"src/legacy/DeployerWhitelist.sol": {
"initCodeHash": "0x8de80fb23b26dd9d849f6328e56ea7c173cd9e9ce1f05c9beea559d1720deb3d",
Expand Down Expand Up @@ -147,4 +147,4 @@
"initCodeHash": "0xb656d2aa6aff3e6435e747a0c23236d1b66f1f5c0b45e4b1a10d290a90223c5a",
"sourceCodeHash": "0xebfc968e6b78d7ea355547d427300739f14d000a11ff35f29d9ded3ddb7882da"
}
}
}
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {
bool internal initialized;

/// @notice Semantic version.
/// @custom:semver 0.0.26
string public constant version = "0.0.26";
/// @custom:semver 0.2.0
string public constant version = "0.2.0";

/// @param _gameType The type ID of the game.
/// @param _absolutePrestate The absolute prestate of the instruction trace.
Expand Down

0 comments on commit fd63302

Please sign in to comment.