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 7, 2024
1 parent 1af01ea commit 2b18baf
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 34 deletions.
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,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 Expand Up @@ -1635,6 +1639,9 @@ workflows:
requires:
- go-mod-download
- devnet:
matrix:
parameters:
devnet_fpac: ["false", "true"]
requires:
- pnpm-monorepo
- op-batcher-docker-build
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
33 changes: 17 additions & 16 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,24 @@ interface IInitializable {
}

/// @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 Down Expand Up @@ -77,9 +78,9 @@ 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();

/// Reset so its not included state dump
vm.etch(address(cfg), "");
Expand All @@ -90,7 +91,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 +101,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 +130,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 @@ -350,7 +351,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 Down
4 changes: 2 additions & 2 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
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 2b18baf

Please sign in to comment.