Skip to content

Commit d8a2d6d

Browse files
ImTeispacesailor24
authored andcommitted
Use engine API that matches hardfork version (#9253)
* 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
1 parent bd5d8bc commit d8a2d6d

File tree

10 files changed

+98
-45
lines changed

10 files changed

+98
-45
lines changed

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,10 @@ workflows:
15611561
name: op-challenger-tests
15621562
module: op-challenger
15631563
requires: ["go-mod-download"]
1564+
- go-test:
1565+
name: op-dispute-mon-tests
1566+
module: op-dispute-mon
1567+
requires: ["go-mod-download"]
15641568
- go-test:
15651569
name: op-conductor-tests
15661570
module: op-conductor

op-chain-ops/cmd/check-ecotone/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,10 @@ func execTx(ctx context.Context, to *common.Address, data []byte, expectRevert b
335335
if err != nil {
336336
return fmt.Errorf("failed to get chainID: %w", err)
337337
}
338-
tx := types.NewTx(&types.DynamicFeeTx{ChainID: chainID, Nonce: nonce,
339-
GasTipCap: tip, GasFeeCap: maxFee, Gas: 500000, To: to, Data: data})
338+
tx := types.NewTx(&types.DynamicFeeTx{
339+
ChainID: chainID, Nonce: nonce,
340+
GasTipCap: tip, GasFeeCap: maxFee, Gas: 500000, To: to, Data: data,
341+
})
340342
signer := types.NewCancunSigner(chainID)
341343
signedTx, err := types.SignTx(tx, signer, env.key)
342344
if err != nil {
@@ -657,8 +659,9 @@ func checkL1Fees(ctx context.Context, env *actionEnv) error {
657659
return fmt.Errorf("failed to retrieve matching L1 block %s: %w", headRef, err)
658660
}
659661
gasTip := big.NewInt(2 * params.GWei)
662+
baseFee := (*uint256.Int)(&payload.ExecutionPayload.BaseFeePerGas).ToBig()
660663
gasMaxFee := new(big.Int).Add(
661-
new(big.Int).Mul(big.NewInt(2), payload.ExecutionPayload.BaseFeePerGas.ToBig()), gasTip)
664+
new(big.Int).Mul(big.NewInt(2), baseFee), gasTip)
662665
to := common.Address{1, 2, 3, 5}
663666
txData := &types.DynamicFeeTx{
664667
ChainID: rollupCfg.L2ChainID,

op-chain-ops/cmd/receipt-reference-builder/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import (
66

77
"github.com/mattn/go-isatty"
88
"github.com/urfave/cli/v2"
9+
"golang.org/x/exp/slog"
910

1011
"github.com/ethereum/go-ethereum/common"
1112
"github.com/ethereum/go-ethereum/log"
1213

1314
opservice "github.com/ethereum-optimism/optimism/op-service"
15+
oplog "github.com/ethereum-optimism/optimism/op-service/log"
1416
)
1517

1618
const EnvPrefix = "OP_CHAIN_OPS_RECEIPT_REFERENCE_BUILDER"
@@ -75,7 +77,8 @@ var (
7577
)
7678

7779
func main() {
78-
log.Root().SetHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(isatty.IsTerminal(os.Stderr.Fd()))))
80+
color := isatty.IsTerminal(os.Stderr.Fd())
81+
oplog.SetGlobalLogHandler(log.NewTerminalHandlerWithLevel(os.Stdout, slog.LevelDebug, color))
7982

8083
app := &cli.App{
8184
Name: "receipt-reference-builder",

op-e2e/faultproofs/output_cannon_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ func TestOutputCannonDefendStep(t *testing.T) {
213213
}
214214

215215
func TestOutputCannonStepWithLargePreimage(t *testing.T) {
216-
// TODO(client-pod#525): Investigate and fix flakiness
217-
t.Skip("Skipping until the flakiness can be resolved")
218-
219216
op_e2e.InitParallel(t, op_e2e.UsesCannon)
220217

221218
ctx := context.Background()

op-e2e/faultproofs/util.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ type faultDisputeConfigOpts func(cfg *op_e2e.SystemConfig)
1212

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

packages/contracts-bedrock/deploy-config/devnetL1-template.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"baseFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
2525
"l1FeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
2626
"sequencerFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
27-
"baseFeeVaultWithdrawalNetwork": "remote",
28-
"l1FeeVaultWithdrawalNetwork": "remote",
29-
"sequencerFeeVaultWithdrawalNetwork": "remote",
27+
"baseFeeVaultWithdrawalNetwork": 0,
28+
"l1FeeVaultWithdrawalNetwork": 0,
29+
"sequencerFeeVaultWithdrawalNetwork": 0,
3030
"proxyAdminOwner": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
3131
"finalSystemOwner": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
3232
"superchainConfigGuardian": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",

packages/contracts-bedrock/deploy-config/hardhat.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
"proofMaturityDelaySeconds": 12,
5656
"disputeGameFinalityDelaySeconds": 6,
5757
"respectedGameType": 0,
58-
"useFaultProofs": false
58+
"useFaultProofs": false,
59+
"fundDevAccounts": false
5960
}

packages/contracts-bedrock/scripts/DeployConfig.s.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Chains } from "scripts/Chains.sol";
99

1010
// Global constant for the `useFaultProofs` slot in the DeployConfig contract, which can be overridden in the testing
1111
// environment.
12-
bytes32 constant USE_FAULT_PROOFS_SLOT = bytes32(uint256(61));
12+
bytes32 constant USE_FAULT_PROOFS_SLOT = bytes32(uint256(63));
1313

1414
/// @title DeployConfig
1515
/// @notice Represents the configuration required to deploy the system. It is expected
@@ -35,13 +35,15 @@ contract DeployConfig is Script {
3535
address public l2OutputOracleProposer;
3636
address public l2OutputOracleChallenger;
3737
uint256 public finalizationPeriodSeconds;
38+
bool public fundDevAccounts;
3839
address public proxyAdminOwner;
3940
address public baseFeeVaultRecipient;
4041
uint256 public baseFeeVaultMinimumWithdrawalAmount;
4142
address public l1FeeVaultRecipient;
4243
uint256 public l1FeeVaultMinimumWithdrawalAmount;
4344
address public sequencerFeeVaultRecipient;
4445
uint256 public sequencerFeeVaultMinimumWithdrawalAmount;
46+
uint256 public sequencerFeeVaultWithdrawalNetwork;
4547
string public governanceTokenName;
4648
string public governanceTokenSymbol;
4749
address public governanceTokenOwner;
@@ -95,13 +97,15 @@ contract DeployConfig is Script {
9597
l2OutputOracleProposer = stdJson.readAddress(_json, "$.l2OutputOracleProposer");
9698
l2OutputOracleChallenger = stdJson.readAddress(_json, "$.l2OutputOracleChallenger");
9799
finalizationPeriodSeconds = stdJson.readUint(_json, "$.finalizationPeriodSeconds");
100+
fundDevAccounts = stdJson.readBool(_json, "$.fundDevAccounts");
98101
proxyAdminOwner = stdJson.readAddress(_json, "$.proxyAdminOwner");
99102
baseFeeVaultRecipient = stdJson.readAddress(_json, "$.baseFeeVaultRecipient");
100103
baseFeeVaultMinimumWithdrawalAmount = stdJson.readUint(_json, "$.baseFeeVaultMinimumWithdrawalAmount");
101104
l1FeeVaultRecipient = stdJson.readAddress(_json, "$.l1FeeVaultRecipient");
102105
l1FeeVaultMinimumWithdrawalAmount = stdJson.readUint(_json, "$.l1FeeVaultMinimumWithdrawalAmount");
103106
sequencerFeeVaultRecipient = stdJson.readAddress(_json, "$.sequencerFeeVaultRecipient");
104107
sequencerFeeVaultMinimumWithdrawalAmount = stdJson.readUint(_json, "$.sequencerFeeVaultMinimumWithdrawalAmount");
108+
sequencerFeeVaultWithdrawalNetwork = stdJson.readUint(_json, "$.sequencerFeeVaultWithdrawalNetwork");
105109
governanceTokenName = stdJson.readString(_json, "$.governanceTokenName");
106110
governanceTokenSymbol = stdJson.readString(_json, "$.governanceTokenSymbol");
107111
governanceTokenOwner = stdJson.readAddress(_json, "$.governanceTokenOwner");

packages/contracts-bedrock/scripts/L2Genesis.s.sol

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,35 @@ import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC2
1717
import { L1Block } from "src/L2/L1Block.sol";
1818
import { GovernanceToken } from "src/governance/GovernanceToken.sol";
1919
import { EIP1967Helper } from "test/mocks/EIP1967Helper.sol";
20+
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
2021

2122
interface IInitializable {
2223
function initialize(address _addr) external;
2324
}
2425

2526
/// @dev The general flow of adding a predeploy is:
26-
/// 1. _setProxies uses vm.etch to set the Proxy.sol deployed bytecode for proxy address `0x420...000` to `0x420...000 + PROXY_COUNT - 1`.
27+
/// 1. _setPredeployProxies uses vm.etch to set the Proxy.sol deployed bytecode for proxy address `0x420...000` to
28+
/// `0x420...000 + PROXY_COUNT - 1`.
2729
/// Additionally, the PROXY_ADMIN_ADDRESS and PROXY_IMPLEMENTATION_ADDRESS storage slots are set for the proxy
2830
/// address.
29-
/// 2. vm.etch sets the deployed bytecode for each predeploy at the implementation address (i.e. `0xc0d3` namespace).
30-
/// 3. The `initialize` method is called at the implementation address with zero/dummy vaules if it exists.
31-
/// 4. The `initialize` method is called at the proxy address with actual vaules if it exists.
31+
/// 2. `vm.etch` sets the deployed bytecode for each predeploy at the implementation address (i.e. `0xc0d3`
32+
/// namespace).
33+
/// 3. The `initialize` method is called at the implementation address with zero/dummy vaules if the method exists.
34+
/// 4. The `initialize` method is called at the proxy address with actual vaules if the method exists.
3235
/// 5. A `require` check to verify the expected implementation address is set for the proxy.
3336
/// @notice The following safety invariants are used when setting state:
3437
/// 1. `vm.getDeployedBytecode` can only be used with `vm.etch` when there are no side
3538
/// effects in the constructor and no immutables in the bytecode.
3639
/// 2. A contract must be deployed using the `new` syntax if there are immutables in the code.
3740
/// Any other side effects from the init code besides setting the immutables must be cleaned up afterwards.
38-
/// 3. A contract is deployed using the `new` syntax because it's not proxied, but still needs to be set
39-
/// at a specific address. Because just deploying a new instance doesn't give us the contract at our desired
40-
/// address,
41-
/// we must use `vm.etch` to set the deployed bytecode, and `vm.store` to set any storage slots. Lastly, we reset
42-
/// the account the contract was initially deployed by so it's not included in the `vm.dumpState`.
41+
/// 3. A contract is deployed using the `new` syntax, however it's not proxied and is still expected to exist at
42+
/// a
43+
/// specific implementation address (i.e. `0xc0d3` namespace). In this case we deploy an instance of the
44+
/// contract
45+
/// using `new` syntax, use `contract.code` to retrieve it's deployed bytecode, `vm.etch` the bytecode at the
46+
/// expected implementation address, and `vm.store` to set any storage slots that are
47+
/// expected to be set after a new deployment. Lastly, we reset the account code and storage slots the contract
48+
/// was initially deployed to so it's not included in the `vm.dumpState`.
4349
contract L2Genesis is Script, Artifacts {
4450
uint256 constant PROXY_COUNT = 2048;
4551
uint256 constant PRECOMPILE_COUNT = 256;
@@ -54,6 +60,20 @@ contract L2Genesis is Script, Artifacts {
5460
/// @notice The storage slot that holds the address of the owner.
5561
/// @dev `bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)`
5662
bytes32 internal constant PROXY_ADMIN_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
63+
uint80 internal constant DEV_ACCOUNT_FUND_AMT = 10_000 ether;
64+
/// @notice Default Anvil dev accounts. Only funded if `cfg.fundDevAccounts == true`.
65+
address[10] internal devAccounts = [
66+
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266,
67+
0x70997970C51812dc3A010C7d01b50e0d17dc79C8,
68+
0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC,
69+
0x90F79bf6EB2c4f870365E785982E1f101E93b906,
70+
0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65,
71+
0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc,
72+
0x976EA74026E726554dB657fA54763abd0C3a0aa9,
73+
0x14dC79964da2C08b23698B3D3cc7Ca32193d9955,
74+
0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f,
75+
0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
76+
];
5777

5878
string internal outfile;
5979

@@ -77,9 +97,13 @@ contract L2Genesis is Script, Artifacts {
7797
/// to generate a L2 genesis alloc.
7898
/// @notice The alloc object is sorted numerically by address.
7999
function run() public {
80-
_setPrecompiles();
81-
_setProxies();
82-
_setImplementations();
100+
_dealEthToPrecompiles();
101+
_setPredeployProxies();
102+
_setPredeployImplementations();
103+
104+
if (cfg.fundDevAccounts()) {
105+
_fundDevAccounts();
106+
}
83107

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

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

@@ -129,7 +153,7 @@ contract L2Genesis is Script, Artifacts {
129153
/// @notice LEGACY_ERC20_ETH is not being predeployed since it's been deprecated.
130154
/// @dev Sets all the implementations for the predeploy proxies. For contracts without proxies,
131155
/// sets the deployed bytecode at their expected predeploy address.
132-
function _setImplementations() internal {
156+
function _setPredeployImplementations() internal {
133157
_setLegacyMessagePasser();
134158
_setDeployerWhitelist();
135159
_setWETH9();
@@ -228,7 +252,7 @@ contract L2Genesis is Script, Artifacts {
228252
SequencerFeeVault vault = new SequencerFeeVault({
229253
_recipient: cfg.sequencerFeeVaultRecipient(),
230254
_minWithdrawalAmount: cfg.sequencerFeeVaultMinimumWithdrawalAmount(),
231-
_withdrawalNetwork: FeeVault.WithdrawalNetwork.L1
255+
_withdrawalNetwork: FeeVault.WithdrawalNetwork(cfg.sequencerFeeVaultWithdrawalNetwork())
232256
});
233257

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

@@ -363,6 +387,15 @@ contract L2Genesis is Script, Artifacts {
363387
vm.ffi(commands);
364388
}
365389

390+
function _fundDevAccounts() internal {
391+
for (uint256 i; i < devAccounts.length; i++) {
392+
console.log("Funding dev account %s with %s ETH", devAccounts[i], DEV_ACCOUNT_FUND_AMT / 1e18);
393+
vm.deal(devAccounts[i], DEV_ACCOUNT_FUND_AMT);
394+
}
395+
396+
_checkDevAccountsFunded();
397+
}
398+
366399
//////////////////////////////////////////////////////
367400
/// Post Checks
368401
//////////////////////////////////////////////////////
@@ -384,4 +417,16 @@ contract L2Genesis is Script, Artifacts {
384417
_verifyCantReinitialize(_impl, address(0));
385418
_verifyCantReinitialize(Predeploys.OPTIMISM_MINTABLE_ERC20_FACTORY, Predeploys.L2_STANDARD_BRIDGE);
386419
}
420+
421+
function _checkDevAccountsFunded() internal view {
422+
for (uint256 i; i < devAccounts.length; i++) {
423+
if (devAccounts[i].balance != DEV_ACCOUNT_FUND_AMT) {
424+
revert(
425+
string.concat(
426+
"Dev account not funded with expected amount of ETH: ", Strings.toHexString(devAccounts[i])
427+
)
428+
);
429+
}
430+
}
431+
}
387432
}

0 commit comments

Comments
 (0)