Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sep/027: upgrade and re-initialize SystemConfig #418

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

geoknee
Copy link
Contributor

@geoknee geoknee commented Dec 17, 2024

TODO

  • upgrade to a multi chain task when things are working for OP Sepolia
  • add some breadcrumbs to the previous task 020 to signify that it was incorrect and that this task supercedes it
  • Build on top of @sebastianst 's new validation framework 3591eec

Closes #394

@geoknee geoknee changed the title first pass at task sep 025 Sep 026: upgrade and re-initialize SystemConfig Dec 17, 2024
@geoknee geoknee changed the title Sep 026: upgrade and re-initialize SystemConfig Sep 027: upgrade and re-initialize SystemConfig Dec 18, 2024
@geoknee geoknee force-pushed the gk/025-holocene-sys-cfg branch 2 times, most recently from 50aeb48 to 2e881b4 Compare December 19, 2024 14:58
@geoknee geoknee requested review from a team as code owners January 4, 2025 00:23
Comment on lines 38 to 39
constructor(string memory l1ChainName, string memory l2ChainName, string memory release)
SuperchainRegistry(l1ChainName, l2ChainName, release)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since l1ChainName and l2ChainName are storage variable names in the SuperchainRegistry contract, using them as argument names in the constructors shadows those variable names

Suggested change
constructor(string memory l1ChainName, string memory l2ChainName, string memory release)
SuperchainRegistry(l1ChainName, l2ChainName, release)
constructor(string memory _l1ChainName, string memory _l2ChainName, string memory _release)
SuperchainRegistry(_l1ChainName, _l1ChainName, _release)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import {Simulation} from "@base-contracts/script/universal/Simulation.sol";
import {NestedMultisigBuilder} from "@base-contracts/script/universal/NestedMultisigBuilder.sol";

contract SystemConfigUpgrade is SuperchainRegistry {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comments explaining what this contract is supposed to do and when it should be used? Would be good to have explanatory comments in Verification.s.sol as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 4 to 13
import {console2 as console} from "forge-std/console2.sol";
import {Vm} from "forge-std/Vm.sol";
import {LibString} from "solady/utils/LibString.sol";
import {SuperchainRegistry} from "script/verification/Verification.s.sol";
import "@eth-optimism-bedrock/src/dispute/lib/Types.sol";
import {ISystemConfig} from "./ISystemConfig.sol";
import {IResourceMetering} from "./IResourceMetering.sol";
import {MIPS} from "@eth-optimism-bedrock/src/cannon/MIPS.sol";
import {Simulation} from "@base-contracts/script/universal/Simulation.sol";
import {NestedMultisigBuilder} from "@base-contracts/script/universal/NestedMultisigBuilder.sol";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing unused imports

Suggested change
import {console2 as console} from "forge-std/console2.sol";
import {Vm} from "forge-std/Vm.sol";
import {LibString} from "solady/utils/LibString.sol";
import {SuperchainRegistry} from "script/verification/Verification.s.sol";
import "@eth-optimism-bedrock/src/dispute/lib/Types.sol";
import {ISystemConfig} from "./ISystemConfig.sol";
import {IResourceMetering} from "./IResourceMetering.sol";
import {MIPS} from "@eth-optimism-bedrock/src/cannon/MIPS.sol";
import {Simulation} from "@base-contracts/script/universal/Simulation.sol";
import {NestedMultisigBuilder} from "@base-contracts/script/universal/NestedMultisigBuilder.sol";
import {LibString} from "solady/utils/LibString.sol";
import {SuperchainRegistry} from "script/verification/Verification.s.sol";
import {ISystemConfig} from "./ISystemConfig.sol";
import {IResourceMetering} from "./IResourceMetering.sol";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +75 to +79
address[] memory exceptions = new address[](4);
exceptions[0] = previous.owner; // NOTE this can be removed for mainnet
exceptions[1] = address(uint160(uint256((previous.batcherHash))));
exceptions[2] = previous.unsafeBlockSigner;
exceptions[3] = previous.batchInbox;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make this conditional based off chain ID to remove the need for the note (untested code, please review/test it before applying suggestion)

Suggested change
address[] memory exceptions = new address[](4);
exceptions[0] = previous.owner; // NOTE this can be removed for mainnet
exceptions[1] = address(uint160(uint256((previous.batcherHash))));
exceptions[2] = previous.unsafeBlockSigner;
exceptions[3] = previous.batchInbox;
uint256 len = block.chainid == 1 ? 3 : 4; // Mainnet doesn't need owner exception.
address[] memory exceptions = new address[](len);
uint256 i = 0;
exceptions[i++] = address(uint160(uint256((previous.batcherHash))));
exceptions[i++] = previous.unsafeBlockSigner;
exceptions[i++] = previous.batchInbox;
if (block.chainid != 1) exceptions[i++] = previous.owner;

Comment on lines 19 to 20
constructor(string memory l1ChainName, string memory l2ChainName, string memory release)
SystemConfigUpgrade(l1ChainName, l2ChainName, release)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment on variable shadowing

Suggested change
constructor(string memory l1ChainName, string memory l2ChainName, string memory release)
SystemConfigUpgrade(l1ChainName, l2ChainName, release)
constructor(string memory _l1ChainName, string memory _l2ChainName, string memory _release)
SystemConfigUpgrade(_l1ChainName, _l2ChainName, _release)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 4 to 13
import {console2 as console} from "forge-std/console2.sol";
import {Vm} from "forge-std/Vm.sol";
import {LibString} from "solady/utils/LibString.sol";
import {SuperchainRegistry} from "script/verification/Verification.s.sol";
import "@eth-optimism-bedrock/src/dispute/lib/Types.sol";
import {ISystemConfig} from "./ISystemConfig.sol";
import {IResourceMetering} from "./IResourceMetering.sol";
import {MIPS} from "@eth-optimism-bedrock/src/cannon/MIPS.sol";
import {Simulation} from "@base-contracts/script/universal/Simulation.sol";
import {NestedMultisigBuilder} from "@base-contracts/script/universal/NestedMultisigBuilder.sol";
Copy link
Contributor

@mds1 mds1 Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing unused imports

Suggested change
import {console2 as console} from "forge-std/console2.sol";
import {Vm} from "forge-std/Vm.sol";
import {LibString} from "solady/utils/LibString.sol";
import {SuperchainRegistry} from "script/verification/Verification.s.sol";
import "@eth-optimism-bedrock/src/dispute/lib/Types.sol";
import {ISystemConfig} from "./ISystemConfig.sol";
import {IResourceMetering} from "./IResourceMetering.sol";
import {MIPS} from "@eth-optimism-bedrock/src/cannon/MIPS.sol";
import {Simulation} from "@base-contracts/script/universal/Simulation.sol";
import {NestedMultisigBuilder} from "@base-contracts/script/universal/NestedMultisigBuilder.sol";
import {console2 as console} from "forge-std/console2.sol";
import {LibString} from "solady/utils/LibString.sol";
import {ISystemConfig} from "./ISystemConfig.sol";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import {NestedMultisigBuilder} from "@base-contracts/script/universal/NestedMultisigBuilder.sol";
import {SystemConfigUpgrade} from "script/verification/SystemConfigUpgrade.s.sol";

contract SystemConfigUpgradeEcotoneScalars is SystemConfigUpgrade {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about adding explanatory code comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +26 to +27
uint256 reencodedScalar =
(uint256(0x01) << 248) | (uint256(sysCfg.blobbasefeeScalar()) << 32) | sysCfg.basefeeScalar();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only needed temporarily since we are upgrading the SystemConfig to a version that no longer needs encoding?

Comment on lines +33 to +35
if (
uint8(previous.scalar >> 248) == 1 // most significant bit
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this behind an if block? A code comment for what this method is testing would be helpful for people not familiar with this encoding

Comment on lines +117 to +124
function tryReadAddress(string memory toml, string memory key) internal pure returns (address) {
try vmSafe.parseTomlAddress(toml, key) returns (address a) {
return a;
} catch {
console.log("failed to read address for ", key);
return address(0);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can delete this, update our forge-std version to the latest release, and instead use: https://github.com/foundry-rs/forge-std/blob/b5a86914561f38735ef1fc357685de3e7c92dc48/src/StdToml.sol#L148

You can either use it like this:

stdToml.readAddressOr(toml, "$.addresses.AnchorStateRegistryProxy", address(0));

or like this, similar to LibString

using StdToml for string;

// --- snip ---

toml.readAddressOr("$.addresses.AnchorStateRegistryProxy", address(0));

@@ -2,6 +2,8 @@

Status: [EXECUTED](https://sepolia.etherscan.io/tx/0x88bd1d85740af3741e2ed96d6fd07f2abb4541afc667625480bf6a28451c4d6d)

> ⚠️ **Warning:** This task is incorrect and is superceded by [Task 027](../027-holocene-system-config-upgrade-and-init-multi-chain/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (according to my spellchecker extension, I also thought your spelling was correct)

Suggested change
> ⚠️ **Warning:** This task is incorrect and is superceded by [Task 027](../027-holocene-system-config-upgrade-and-init-multi-chain/)
> ⚠️ **Warning:** This task is incorrect and is superseded by [Task 027](../027-holocene-system-config-upgrade-and-init-multi-chain/)


contract NestedSignFromJson is OriginalNestedSignFromJson, CouncilFoundationNestedSign {
string constant l1ChainName = "sepolia";
string constant release = "v1.8.0-rc.4";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gov proposal has passed so we don't need to use the RC anymore and should be using the finalized release, which is what we want for mainnet also

Suggested change
string constant release = "v1.8.0-rc.4";
string constant release = "v1.8.0";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest deleting this file since we don't need it, just one less thing to review

@@ -0,0 +1,30 @@
# Holocene Hardfork Upgrade - `SystemConfig`

Status: DRAFT, NOT READY TO SIGN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do we need for this to become ready to sign?

Suggested change
Status: DRAFT, NOT READY TO SIGN
Status: DRAFT, NOT READY TO SIGN

Comment on lines +9 to +10
This upgrades the `SystemConfig` in the
[v1.8.0-rc.4](https://github.com/ethereum-optimism/optimism/tree/v1.8.0-rc.4) release.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should just use 1.8.0 now that it's passed

Suggested change
This upgrades the `SystemConfig` in the
[v1.8.0-rc.4](https://github.com/ethereum-optimism/optimism/tree/v1.8.0-rc.4) release.
This upgrades the `SystemConfig` in the
[v1.8.0](https://github.com/ethereum-optimism/optimism/tree/v1.8.0) release.


## Pre-deployments

- `SystemConfig` - `0x33b83E4C305c908B2Fc181dDa36e230213058d7d`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any messages you can link to so I can verify this address?

## Simulation

Please see the "Simulating and Verifying the Transaction" instructions in [NESTED.md](../../../NESTED.md).
When simulating, ensure the logs say `Using script /your/path/to/superchain-ops/tasks/<path>/NestedSignFromJson.s.sol`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When simulating, ensure the logs say `Using script /your/path/to/superchain-ops/tasks/<path>/NestedSignFromJson.s.sol`.
When simulating, ensure the logs say `Using script /your/path/to/superchain-ops/tasks/027-holocene-system-config-upgrade-and-init-multi-chain/NestedSignFromJson.s.sol`.

@@ -0,0 +1,85 @@
# Validation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not yet validated this file or run the simulation

require(reencodedScalar == previous.scalar, "scalar-100 (reencoding produced incorrect result)");
// We do this check last because it would fail if the scalar is wrong, and we get less debug info from it.
// It checks all of the other fields which should not have changed (via a hash).
super.checkSystemConfigUpgrade();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should call this unconditionally, and pull the scalar check out of the base contract into this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in SystemConfig Holocene Upgrade
3 participants