Skip to content

Commit

Permalink
feat: setup to deploy on base network
Browse files Browse the repository at this point in the history
  • Loading branch information
yum0e committed Aug 17, 2023
1 parent 96dca1c commit ab19c2a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
16 changes: 10 additions & 6 deletions script/01_DeployAll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ contract DeployAll is Script, BaseDeploymentConfig {
);
sismoConnectVerifier = _deploySismoConnectVerifier(msg.sender);

sismoConnectVerifier.registerVerifier(
hydraS3Verifier.HYDRA_S3_VERSION(),
address(hydraS3Verifier)
);

sismoConnectVerifier.transferOwnership(config.owner);
// only register and transfer ownership if the sismoConnectVerifier contract is not already deployed
if (config.sismoConnectVerifier == address(0)) {
sismoConnectVerifier.registerVerifier(
hydraS3Verifier.HYDRA_S3_VERSION(),
address(hydraS3Verifier)
);

sismoConnectVerifier.transferOwnership(config.owner);
}

contracts.availableRootsRegistry = availableRootsRegistry;
contracts.commitmentMapperRegistry = commitmentMapperRegistry;
Expand Down Expand Up @@ -146,6 +149,7 @@ contract DeployAll is Script, BaseDeploymentConfig {
address sismoConnectVerifierAddress = config.sismoConnectVerifier;
if (sismoConnectVerifierAddress != address(0)) {
console.log("Using existing sismoConnectVerifier:", sismoConnectVerifierAddress);
console.log("Be careful to register the new HydraS3Verifier contract if there is one!");
return SismoConnectVerifier(sismoConnectVerifierAddress);
}
SismoConnectVerifier sismoConnectVerifierImplem = new SismoConnectVerifier(owner);
Expand Down
40 changes: 29 additions & 11 deletions script/BaseConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract BaseDeploymentConfig is Script {
address immutable MAIN_POLYGON_ROOTS_OWNER = 0xF0a0B692e1c764281c211948D03edEeF5Fb57111;
address immutable MAIN_OPTIMISM_ROOTS_OWNER = 0xf8640cE5532BCbc788489Bf5A786635ae585258B;
address immutable MAIN_ARBITRUM_ONE_ROOTS_OWNER = 0x1BB9AD70F529e36B7Ffed0cfA44fA4cf0213Fa09;
address immutable MAIN_BASE_ROOTS_OWNER = 0x8f9c04d7bA132Fd0CbA124eFCE3936328d217458;
address immutable MAIN_MAINNET_ROOTS_OWNER = 0x2a265b954B96d4940B94eb69E8Fc8E7346369D05;

// Testnet Env
Expand All @@ -54,6 +55,7 @@ contract BaseDeploymentConfig is Script {
0xe807B5153e3eD4767C3F4EB50b65Fab90c57596B;
address immutable TESTNET_ARBITRUM_GOERLI_ROOTS_OWNER =
0x8eAb4616d47F82C890fdb6eE311A4C0aE34ba7fb;
address immutable TESTNET_BASE_GOERLI_ROOTS_OWNER = 0x8f9c04d7bA132Fd0CbA124eFCE3936328d217458;
address immutable TESTNET_SCROLL_GOERLI_ROOTS_OWNER = 0x8f9c04d7bA132Fd0CbA124eFCE3936328d217458;

// Sismo Staging env (Sismo internal use only)
Expand All @@ -77,11 +79,13 @@ contract BaseDeploymentConfig is Script {
Polygon,
Optimism,
ArbitrumOne,
Base,
TestnetGoerli,
TestnetSepolia,
TestnetMumbai,
OptimismGoerli,
ArbitrumGoerli,
BaseGoerli,
ScrollTestnetGoerli,
StagingGoerli,
StagingMumbai,
Expand All @@ -99,6 +103,8 @@ contract BaseDeploymentConfig is Script {
return DeployChain.Optimism;
} else if (_compareStrings(chainName, "arbitrum-one")) {
return DeployChain.ArbitrumOne;
} else if (_compareStrings(chainName, "base")) {
return DeployChain.Base;
} else if (_compareStrings(chainName, "testnet-goerli")) {
return DeployChain.TestnetGoerli;
} else if (_compareStrings(chainName, "testnet-sepolia")) {
Expand All @@ -109,6 +115,8 @@ contract BaseDeploymentConfig is Script {
return DeployChain.OptimismGoerli;
} else if (_compareStrings(chainName, "arbitrum-goerli")) {
return DeployChain.ArbitrumGoerli;
} else if (_compareStrings(chainName, "base-goerli")) {
return DeployChain.BaseGoerli;
} else if (_compareStrings(chainName, "scroll-testnet-goerli")) {
return DeployChain.ScrollTestnetGoerli;
} else if (_compareStrings(chainName, "staging-goerli")) {
Expand Down Expand Up @@ -192,6 +200,16 @@ contract BaseDeploymentConfig is Script {
PROD_BETA_COMMITMENT_MAPPER_PUB_KEY_Y
]
});
} else if (chain == DeployChain.Base) {
minimalConfig = MinimalConfig({
proxyAdmin: MAIN_PROXY_ADMIN,
owner: MAIN_OWNER,
rootsOwner: MAIN_BASE_ROOTS_OWNER,
commitmentMapperEdDSAPubKey: [
PROD_BETA_COMMITMENT_MAPPER_PUB_KEY_X,
PROD_BETA_COMMITMENT_MAPPER_PUB_KEY_Y
]
});
} else if (chain == DeployChain.TestnetGoerli) {
minimalConfig = MinimalConfig({
proxyAdmin: TESTNET_PROXY_ADMIN,
Expand Down Expand Up @@ -242,6 +260,16 @@ contract BaseDeploymentConfig is Script {
PROD_BETA_COMMITMENT_MAPPER_PUB_KEY_Y
]
});
} else if (chain == DeployChain.BaseGoerli) {
minimalConfig = MinimalConfig({
proxyAdmin: TESTNET_PROXY_ADMIN,
owner: TESTNET_OWNER,
rootsOwner: TESTNET_BASE_GOERLI_ROOTS_OWNER,
commitmentMapperEdDSAPubKey: [
PROD_BETA_COMMITMENT_MAPPER_PUB_KEY_X,
PROD_BETA_COMMITMENT_MAPPER_PUB_KEY_Y
]
});
} else if (chain == DeployChain.ScrollTestnetGoerli) {
minimalConfig = MinimalConfig({
proxyAdmin: TESTNET_PROXY_ADMIN,
Expand Down Expand Up @@ -350,24 +378,14 @@ contract BaseDeploymentConfig is Script {
});
}

function _readAddressFromDeploymentConfigAtKey(
string memory key
) internal view returns (address) {
bytes memory encodedAddress = vm.parseJson(vm.readFile(_deploymentConfigFilePath()), key);
return
abi.decode(encodedAddress, (address)) == address(0x20)
? address(0)
: abi.decode(encodedAddress, (address));
}

function _tryReadingAddressFromDeploymentConfigAtKey(
string memory key
) internal view returns (address) {
try vm.parseJson(vm.readFile(_deploymentConfigFilePath()), key) returns (
bytes memory encodedAddress
) {
return
abi.decode(encodedAddress, (address)) == address(0x20)
keccak256(encodedAddress) == keccak256(abi.encodePacked(("")))
? address(0)
: abi.decode(encodedAddress, (address));
} catch {
Expand Down

0 comments on commit ab19c2a

Please sign in to comment.