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

perf: reduce build time #528

Merged
merged 4 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ jobs:
just simulate-council
just prepare-json
just simulate-council # simulate again to make sure the json is still valid

just_simulate_ink_respected_game_type:
docker:
- image: << pipeline.parameters.ci_builder_image >>
steps:
- simulate:
task: "/eth/ink-002-set-respected-game-type"

just_simulate_eth_029_holocene_system_config_upgrade_and_init_base:
docker:
- image: << pipeline.parameters.ci_builder_image >>
Expand Down Expand Up @@ -298,7 +298,11 @@ workflows:
# expect the ceremony to work continuously), and remove it once
# the ceremony is for historical archive only (e.g. the
# ceremony is done).
- just_simulate_sc_rehearsal_1
#
# We skip rehearsal 1 because we already have completed this rehearsal (https://github.com/ethereum-optimism/superchain-ops/pull/459),
# and now it fails with stack too deep after https://github.com/ethereum-optimism/superchain-ops/pull/528.
# We wll need to rewrite the rehearsals with the new superchain-ops structure anyway, so this is ok.
# - just_simulate_sc_rehearsal_1
- just_simulate_sc_rehearsal_2
- just_simulate_sc_rehearsal_4
- just_simulate_ink_respected_game_type
Expand Down
4 changes: 1 addition & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
src = "src"
out = "out"
libs = ["lib"]
optimizer = true
optimizer_runs = 999999
optimizer = false
solc_version = "0.8.15"
evm_version = "cancun"
via_ir = true
fs_permissions = [{ access = "read-write", path = "./" }]
# Enable FFI for reading lib/superchain-registry files in scripts SignFromJson.s.sol, NestedSignFromJson.s.sol within tasks
ffi = true
Expand Down
8 changes: 7 additions & 1 deletion src/fps/AddressRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ contract AddressRegistry is IAddressRegistry, Test {
revert(string.concat("Failed to parse network config file path: ", networkConfigFilePath));
}

chains = abi.decode(chainListContent, (ChainInfo[]));
// Cannot assign the abi.decode result to `chains` directly because it's a storage array, so
// compiling without via-ir will fail with:
// Unimplemented feature (/solidity/libsolidity/codegen/ArrayUtils.cpp:228):Copying of type struct AddressRegistry.ChainInfo memory[] memory to storage not yet supported.
ChainInfo[] memory _chains = abi.decode(chainListContent, (ChainInfo[]));
for (uint256 i = 0; i < _chains.length; i++) {
chains.push(_chains[i]);
}

/// should never revert
string memory chainAddressesContent = vm.readFile(SUPERCHAIN_REGISTRY_PATH);
Expand Down
33 changes: 17 additions & 16 deletions test/task/NestedMultisigTask.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {AddressRegistry as Addresses} from "src/fps/AddressRegistry.sol";
contract NestedMultisigTaskTest is Test {
MultisigTask private multisigTask;
Addresses private addresses;
/// ProxyAdminOwner safe for task-01 is a nested multisig for Op mainnet L2 chain.
// ProxyAdminOwner safe for task-01 is a nested multisig for Op mainnet L2 chain.
string taskConfigFilePath = "src/fps/example/task-01/mainnetConfig.toml";

function setUp() public {
Expand All @@ -32,11 +32,11 @@ contract NestedMultisigTaskTest is Test {
IGnosisSafe parentMultisig = IGnosisSafe(multisigTask.multisig());
address[] memory childOwnerMultisigs = parentMultisig.getOwners();

/// child multisigs have to approve the transaction that the parent multisig is going to execute.
/// hashToApproveByChildMultisig is the hash of the transaction that the parent multisig is going
/// to execute which the child multisigs have to approve.
/// nonce is decremented by 1 because when we ran the task, in simulation, execTransaction is called
/// which increments the nonce by 1 and we want to generate the hash by using the nonce before it was incremented.
// child multisigs have to approve the transaction that the parent multisig is going to execute.
// hashToApproveByChildMultisig is the hash of the transaction that the parent multisig is going
// to execute which the child multisigs have to approve.
// nonce is decremented by 1 because when we ran the task, in simulation, execTransaction is called
// which increments the nonce by 1 and we want to generate the hash by using the nonce before it was incremented.
bytes32 hashToApproveByChildMultisig = parentMultisig.getTransactionHash(
MULTICALL3_ADDRESS,
0,
Expand All @@ -60,17 +60,18 @@ contract NestedMultisigTaskTest is Test {
IMulticall3.Call3Value[] memory calls = new IMulticall3.Call3Value[](1);
calls[0] = call;

/// callDataToApprove is the data that the child multisig has to execute to
/// approve the transaction that the parent multisig is going to execute.
// callDataToApprove is the data that the child multisig has to execute to
// approve the transaction that the parent multisig is going to execute.
bytes memory callDataToApprove =
abi.encodeWithSignature("aggregate3Value((address,bool,uint256,bytes)[])", calls);
assertEq(callDataToApprove, multisigTask.generateApproveMulticallData(), "Wrong callDataToApprove");
for (uint256 i; i < childOwnerMultisigs.length; i++) {
/// dataToSign is the data that the EOA owners of the child multisig has to sign to help
/// execute the child multisig approval of hashToApproveByChildMultisig
// dataToSign is the data that the EOA owners of the child multisig has to sign to help
// execute the child multisig approval of hashToApproveByChildMultisig
bytes memory dataToSign = getNestedDataToSign(childOwnerMultisigs[i]);
/// nonce is not decremented by 1 because in task simulation approveHash is called by
/// the child multisig which does not increment the nonce
// nonce is not decremented by 1 because in task simulation approveHash is called by
// the child multisig which does not increment the nonce
uint256 nonce = IGnosisSafe(childOwnerMultisigs[i]).nonce();
bytes memory expectedDataToSign = IGnosisSafe(childOwnerMultisigs[i]).encodeTransactionData({
to: MULTICALL3_ADDRESS,
value: 0,
Expand All @@ -81,12 +82,12 @@ contract NestedMultisigTaskTest is Test {
gasPrice: 0,
gasToken: address(0),
refundReceiver: address(0),
_nonce: IGnosisSafe(childOwnerMultisigs[i]).nonce()
_nonce: nonce
});
assertEq(dataToSign, expectedDataToSign, "Wrong data to sign");

/// nestedHashToApprove is the hash that the EOA owners of the child multisig has to approve to help
/// execute the child multisig approval of hashToApproveByChildMultisig
// nestedHashToApprove is the hash that the EOA owners of the child multisig has to approve to help
// execute the child multisig approval of hashToApproveByChildMultisig
bytes32 nestedHashToApprove = keccak256(dataToSign);
bytes32 expectedNestedHashToApprove = IGnosisSafe(childOwnerMultisigs[i]).getTransactionHash(
MULTICALL3_ADDRESS,
Expand All @@ -98,7 +99,7 @@ contract NestedMultisigTaskTest is Test {
0,
address(0),
address(0),
IGnosisSafe(childOwnerMultisigs[i]).nonce()
nonce
);
assertEq(nestedHashToApprove, expectedNestedHashToApprove, "Wrong nested hash to approve");
}
Expand Down