Skip to content
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
14 changes: 8 additions & 6 deletions script/Build.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ struct GeneratedContract {
/// lib writers and the freeze.
contract Build is Script, RegistryDeploySuites {
/// Every contract this repo generates deploy pins for.
/// @return contracts The generated contracts.
function generatedContracts() internal pure returns (GeneratedContract[] memory contracts) {
contracts = new GeneratedContract[](2);
/// @return The generated contracts.
function generatedContracts() internal pure returns (GeneratedContract[] memory) {
GeneratedContract[] memory contracts = new GeneratedContract[](2);
contracts[0] = GeneratedContract({
contractName: "AddressRegistry", constantPrefix: "ADDRESS_REGISTRY", candidate: addressRegistryCandidate()
});
Expand All @@ -51,17 +51,19 @@ contract Build is Script, RegistryDeploySuites {
constantPrefix: "MIGRATION_REGISTRY",
candidate: migrationRegistryCandidate()
});
return contracts;
}

/// Every generated contract's name, in declaration order — the order the
/// aggregate emits its entries in. Read by the freeze and the aggregate.
/// @return names The contract names.
function generatedContractNames() internal pure returns (string[] memory names) {
/// @return The contract names.
function generatedContractNames() internal pure returns (string[] memory) {
GeneratedContract[] memory contracts = generatedContracts();
names = new string[](contracts.length);
string[] memory names = new string[](contracts.length);
for (uint256 i = 0; i < contracts.length; i++) {
names[i] = contracts[i].contractName;
}
return names;
}

/// @notice Regenerate the rolling snapshots, their alias libs, the
Expand Down
21 changes: 13 additions & 8 deletions src/abstract/RainDeploySuitesBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ abstract contract RainDeploySuitesBase {
/// Guarding each reader separately would be two spellings of one rule, and
/// the reader that got the second spelling wrong is the one that silently
/// stops asserting.
/// @return candidates The candidates.
function checkedCandidateSuites() internal pure returns (DeployCandidate[] memory candidates) {
candidates = candidateSuites();
/// @return The candidates.
function checkedCandidateSuites() internal pure returns (DeployCandidate[] memory) {
DeployCandidate[] memory candidates = candidateSuites();
if (candidates.length == 0) {
revert NoDeployCandidates();
}
return candidates;
}

/// EVERY candidate MUST record the creation code this repo compiles.
Expand Down Expand Up @@ -232,12 +233,12 @@ abstract contract RainDeploySuitesBase {
/// One pairwise pass over the whole set, so a candidate colliding with
/// another candidate is caught by the same code that catches a candidate
/// colliding with a release — there is no second rule to keep in step.
/// @return suites Every declared suite.
function allSuites() internal pure returns (DeploySuite[] memory suites) {
/// @return Every declared suite.
function allSuites() internal pure returns (DeploySuite[] memory) {
DeploySuite[] memory released = releasedSuites();
DeployCandidate[] memory candidates = checkedCandidateSuites();

suites = new DeploySuite[](released.length + candidates.length);
DeploySuite[] memory suites = new DeploySuite[](released.length + candidates.length);
for (uint256 i = 0; i < released.length; i++) {
suites[i] = released[i];
}
Expand All @@ -252,15 +253,19 @@ abstract contract RainDeploySuitesBase {
}
}
}

return suites;
}

/// Every declared key, comma separated, for the unknown-suite error.
/// @return names The declared keys.
function suiteNames() internal pure returns (string memory names) {
/// @return The declared keys.
function suiteNames() internal pure returns (string memory) {
DeploySuite[] memory suites = allSuites();
string memory names;
for (uint256 i = 0; i < suites.length; i++) {
names = i == 0 ? suites[i].suite : string.concat(names, ", ", suites[i].suite);
}
return names;
}

/// The suite a key selects.
Expand Down
15 changes: 9 additions & 6 deletions src/abstract/RainDeployVerifyBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ abstract contract RainDeployVerifyBase is RainDeploySuitesBase, Test {
/// against itself, and every chain would pass whether or not anything is
/// deployed there.
/// @param suite The suite to derive from.
/// @return derived The address and code hash the creation code produces.
function deriveDeployment(DeploySuite memory suite) internal returns (DerivedDeploy memory derived) {
/// @return The address and code hash the creation code produces.
function deriveDeployment(DeploySuite memory suite) internal returns (DerivedDeploy memory) {
address formulaAddress = LibRainDeploy.zoltuAddress(suite.creationCode);

uint256 snapshotId = vm.snapshotState();
Expand All @@ -107,7 +107,7 @@ abstract contract RainDeployVerifyBase is RainDeploySuitesBase, Test {
revert ZoltuDerivationMismatch(suite.suite, formulaAddress, factoryAddress);
}

derived =
DerivedDeploy memory derived =
DerivedDeploy({suite: suite.suite, deployedAddress: formulaAddress, bytecodeHash: factoryAddress.codehash});

// A failed revert is unrecoverable, not a warning to silence. The etch
Expand All @@ -117,18 +117,21 @@ abstract contract RainDeployVerifyBase is RainDeploySuitesBase, Test {
if (!vm.revertToState(snapshotId)) {
revert DerivationSnapshotRevertFailed(suite.suite, snapshotId);
}

return derived;
}

/// Derives every suite once, before anything forks. Callers that compare
/// against chains need the derivation to have already happened on a local
/// EVM, because on a fork the derived address is exactly the address the
/// deployment under test occupies.
/// @param suites The suites to derive.
/// @return derived The derivation of each, positionally paired.
function deriveDeployments(DeploySuite[] memory suites) internal returns (DerivedDeploy[] memory derived) {
derived = new DerivedDeploy[](suites.length);
/// @return The derivation of each, positionally paired.
function deriveDeployments(DeploySuite[] memory suites) internal returns (DerivedDeploy[] memory) {
DerivedDeploy[] memory derived = new DerivedDeploy[](suites.length);
for (uint256 i = 0; i < suites.length; i++) {
derived[i] = deriveDeployment(suites[i]);
}
return derived;
}
}
5 changes: 3 additions & 2 deletions src/abstract/RegistryDeploySuites.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ abstract contract RegistryDeploySuites is RainDeploySuitesBase {
/// fourth place to edit: `script/Build.sol` generates the per-contract
/// released lib AND the aggregate `releasedSuites()` reads from that one
/// list.
function candidateSuites() internal pure override returns (DeployCandidate[] memory candidates) {
candidates = new DeployCandidate[](2);
function candidateSuites() internal pure override returns (DeployCandidate[] memory) {
DeployCandidate[] memory candidates = new DeployCandidate[](2);
candidates[0] = addressRegistryCandidate();
candidates[1] = migrationRegistryCandidate();
return candidates;
}

/// This repo's rolling `AddressRegistry` candidate.
Expand Down
5 changes: 3 additions & 2 deletions src/concrete/AddressRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ contract AddressRegistry is IAddressRegistryV1 {
/// @dev Returns whatever root has bound most recently. A caller that needs
/// an answer that cannot move reads once and stores it, which is what a
/// consumer resolving a name in its constructor does.
function get(bytes32 name) external view returns (address account) {
account = sAddresses[name];
function get(bytes32 name) external view returns (address) {
address account = sAddresses[name];
if (account == address(0)) {
revert NameNotRegistered(name);
}
return account;
}
}
8 changes: 4 additions & 4 deletions src/generated/candidate/AddressRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ pragma solidity ^0.8.25;
// THIS FILE IS AUTOGENERATED BY THE BUILD SCRIPT. DO NOT EDIT BY HAND.

/// @dev Hash of the known bytecode.
bytes32 constant BYTECODE_HASH = bytes32(0xef835570415a69bdf98ea5cacd8c4d2caba4730d06c2218bf102cb4473f4ea73);
bytes32 constant BYTECODE_HASH = bytes32(0x6c37a6ad35101c07818fd5ea57c8d7ed4ed54f4a9ba7b0fce86e27cfc6510097);

/// @dev The deterministic deploy address of the contract when deployed via
/// the Zoltu factory.
address constant DEPLOYED_ADDRESS = address(0x25aC2b82915f191dbE64e65BAeDDD68b97b68fe1);
address constant DEPLOYED_ADDRESS = address(0x8cACfbD5d78b6D87080cE0839708ac2dA5461F78);

/// @dev The creation bytecode of the contract.
bytes constant CREATION_CODE =
hex"6080604052348015600e575f80fd5b506102558061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80638eaa6ac014610038578063d22057a914610074575b5f80fd5b61004b6100463660046101f8565b610089565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61008761008236600461020f565b6100f1565b005b5f8181526020819052604090205473ffffffffffffffffffffffffffffffffffffffff16806100ec576040517fe9b7924f000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b919050565b331561012b576040517f8c7257830000000000000000000000000000000000000000000000000000000081523360048201526024016100e3565b73ffffffffffffffffffffffffffffffffffffffff811661017b576040517f657fb0ff000000000000000000000000000000000000000000000000000000008152600481018390526024016100e3565b5f8281526020819052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091559051909184917f1082cda15f9606da555bb7e9bf4eeee2f8e34abe85d3924bf9bacb716f8feca69190a35050565b5f60208284031215610208575f80fd5b5035919050565b5f8060408385031215610220575f80fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff8116811461024a575f80fd5b80915050925092905056";
hex"6080604052348015600e575f80fd5b506102568061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80638eaa6ac014610038578063d22057a914610074575b5f80fd5b61004b6100463660046101f9565b610089565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b610087610082366004610210565b6100f2565b005b5f8181526020819052604081205473ffffffffffffffffffffffffffffffffffffffff16806100ec576040517fe9b7924f000000000000000000000000000000000000000000000000000000008152600481018490526024015b60405180910390fd5b92915050565b331561012c576040517f8c7257830000000000000000000000000000000000000000000000000000000081523360048201526024016100e3565b73ffffffffffffffffffffffffffffffffffffffff811661017c576040517f657fb0ff000000000000000000000000000000000000000000000000000000008152600481018390526024016100e3565b5f8281526020819052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091559051909184917f1082cda15f9606da555bb7e9bf4eeee2f8e34abe85d3924bf9bacb716f8feca69190a35050565b5f60208284031215610209575f80fd5b5035919050565b5f8060408385031215610221575f80fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff8116811461024b575f80fd5b80915050925092905056";

/// @dev The runtime bytecode of the contract.
bytes constant RUNTIME_CODE =
hex"608060405234801561000f575f80fd5b5060043610610034575f3560e01c80638eaa6ac014610038578063d22057a914610074575b5f80fd5b61004b6100463660046101f8565b610089565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61008761008236600461020f565b6100f1565b005b5f8181526020819052604090205473ffffffffffffffffffffffffffffffffffffffff16806100ec576040517fe9b7924f000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b919050565b331561012b576040517f8c7257830000000000000000000000000000000000000000000000000000000081523360048201526024016100e3565b73ffffffffffffffffffffffffffffffffffffffff811661017b576040517f657fb0ff000000000000000000000000000000000000000000000000000000008152600481018390526024016100e3565b5f8281526020819052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091559051909184917f1082cda15f9606da555bb7e9bf4eeee2f8e34abe85d3924bf9bacb716f8feca69190a35050565b5f60208284031215610208575f80fd5b5035919050565b5f8060408385031215610220575f80fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff8116811461024a575f80fd5b80915050925092905056";
hex"608060405234801561000f575f80fd5b5060043610610034575f3560e01c80638eaa6ac014610038578063d22057a914610074575b5f80fd5b61004b6100463660046101f9565b610089565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b610087610082366004610210565b6100f2565b005b5f8181526020819052604081205473ffffffffffffffffffffffffffffffffffffffff16806100ec576040517fe9b7924f000000000000000000000000000000000000000000000000000000008152600481018490526024015b60405180910390fd5b92915050565b331561012c576040517f8c7257830000000000000000000000000000000000000000000000000000000081523360048201526024016100e3565b73ffffffffffffffffffffffffffffffffffffffff811661017c576040517f657fb0ff000000000000000000000000000000000000000000000000000000008152600481018390526024016100e3565b5f8281526020819052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff85169081179091559051909184917f1082cda15f9606da555bb7e9bf4eeee2f8e34abe85d3924bf9bacb716f8feca69190a35050565b5f60208284031215610209575f80fd5b5035919050565b5f8060408385031215610221575f80fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff8116811461024b575f80fd5b80915050925092905056";

/// @dev The addresses that MUST already have code on a network before
/// this release can be broadcast there, `abi.encode`d as an `address[]`
Expand Down
4 changes: 2 additions & 2 deletions src/interface/IAddressRegistryV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ interface IAddressRegistryV1 {
/// does. Reading at the point of use instead means reading whatever root
/// has bound most recently.
/// @param name The name to read.
/// @return account The address bound to `name`. Never the zero address.
function get(bytes32 name) external view returns (address account);
/// @return The address bound to `name`. Never the zero address.
function get(bytes32 name) external view returns (address);
}
7 changes: 4 additions & 3 deletions src/lib/LibAddressRegistryReleased.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import {DeploySuite} from "../abstract/RainDeploySuitesBase.sol";
/// back in to preserve what it last said.
library LibAddressRegistryReleased {
/// Every frozen release, in tag order.
/// @return suites The released suites.
function releasedSuites() internal pure returns (DeploySuite[] memory suites) {
suites = new DeploySuite[](0);
/// @return The released suites.
function releasedSuites() internal pure returns (DeploySuite[] memory) {
DeploySuite[] memory suites = new DeploySuite[](0);
return suites;
}
}
7 changes: 4 additions & 3 deletions src/lib/LibMigrationRegistryReleased.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import {DeploySuite} from "../abstract/RainDeploySuitesBase.sol";
/// back in to preserve what it last said.
library LibMigrationRegistryReleased {
/// Every frozen release, in tag order.
/// @return suites The released suites.
function releasedSuites() internal pure returns (DeploySuite[] memory suites) {
suites = new DeploySuite[](0);
/// @return The released suites.
function releasedSuites() internal pure returns (DeploySuite[] memory) {
DeploySuite[] memory suites = new DeploySuite[](0);
return suites;
}
}
Loading
Loading