chore(deployments): update deployments script (#6)

This commit is contained in:
Aaryamann Challani 2024-05-28 17:56:10 +05:30 committed by GitHub
parent 4c6b8fb253
commit 834cdbf5bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 37 additions and 24 deletions

View File

@ -7,7 +7,7 @@ WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__LargerThanField()
WakuRlnV2Test:test__InvalidRegistration__InvalidIdCommitment__Zero() (gas: 9139)
WakuRlnV2Test:test__InvalidRegistration__InvalidUserMessageLimit__LargerThanMax() (gas: 10147)
WakuRlnV2Test:test__InvalidRegistration__InvalidUserMessageLimit__Zero() (gas: 9242)
WakuRlnV2Test:test__ValidPaginationQuery(uint32) (runs: 1002, μ: 403497, ~: 136269)
WakuRlnV2Test:test__ValidPaginationQuery(uint32) (runs: 1001, μ: 394880, ~: 136269)
WakuRlnV2Test:test__ValidPaginationQuery__OneElement() (gas: 128461)
WakuRlnV2Test:test__ValidRegistration(uint256,uint32) (runs: 1001, μ: 133518, ~: 133518)
WakuRlnV2Test:test__ValidRegistration__kats() (gas: 108902)

View File

@ -56,7 +56,7 @@ $ forge coverage
### Deploy
Deploy to Anvil:
#### Deploy to Anvil:
```sh
$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545
@ -65,8 +65,16 @@ $ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545
For this script to work, you need to have a `MNEMONIC` environment variable set to a valid
[BIP39 mnemonic](https://iancoleman.io/bip39/).
For instructions on how to deploy to a testnet or mainnet, check out the
[Solidity Scripting](https://book.getfoundry.sh/tutorials/solidity-scripting.html) tutorial.
#### Deploy to Sepolia:
Ensure that you use the [cast wallet](https://book.getfoundry.sh/reference/cast/cast-wallet) to store private keys that
will be used in deployments.
```sh
$ export RPC_URL=<rpc-url>
$ export ACCOUNT=<account name in foundry keystore>
$ pnpm deploy:sepolia
```
### Format

13
envCheck.sh Executable file
View File

@ -0,0 +1,13 @@
# This script is used to assert if require env vars are present for deployment
# RPC_URL: RPC URL for the network
# ACCOUNT: Accessed with `cast wallet` command
if [ -z "$RPC_URL" ]; then
echo "RPC_URL is required"
exit 1
fi
if [ -z "$ACCOUNT" ]; then
echo "ACCOUNT is required"
exit 1
fi

View File

@ -25,14 +25,7 @@ max_test_rejects = 128_000
verbosity = 4
[etherscan]
arbitrum = { key = "${API_KEY_ARBISCAN}" }
avalanche = { key = "${API_KEY_SNOWTRACE}" }
bnb_smart_chain = { key = "${API_KEY_BSCSCAN}" }
gnosis_chain = { key = "${API_KEY_GNOSISSCAN}" }
goerli = { key = "${API_KEY_ETHERSCAN}" }
mainnet = { key = "${API_KEY_ETHERSCAN}" }
optimism = { key = "${API_KEY_OPTIMISTIC_ETHERSCAN}" }
polygon = { key = "${API_KEY_POLYGONSCAN}" }
sepolia = { key = "${API_KEY_ETHERSCAN}" }
[fmt]
@ -46,13 +39,5 @@ max_test_rejects = 128_000
wrap_comments = true
[rpc_endpoints]
arbitrum = "https://arbitrum-mainnet.infura.io/v3/${API_KEY_INFURA}"
avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}"
bnb_smart_chain = "https://bsc-dataseed.binance.org"
gnosis_chain = "https://rpc.gnosischain.com"
goerli = "https://goerli.infura.io/v3/${API_KEY_INFURA}"
localhost = "http://localhost:8545"
mainnet = "https://eth-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
optimism = "https://optimism-mainnet.infura.io/v3/${API_KEY_INFURA}"
polygon = "https://polygon-mainnet.infura.io/v3/${API_KEY_INFURA}"
sepolia = "https://sepolia.infura.io/v3/${API_KEY_INFURA}"
sepolia = "https://eth-sepolia.g.alchemy.com/v2/${API_KEY_ALCHEMY}"

View File

@ -33,6 +33,8 @@
"prettier:write": "prettier --write **/*.{json,md,yml} --ignore-path=.prettierignore",
"gas-report": "forge test --gas-report 2>&1 | (tee /dev/tty | awk '/Test result:/ {found=1; buffer=\"\"; next} found && !/Ran/ {buffer=buffer $0 ORS} /Ran/ {found=0} END {printf \"%s\", buffer}' > .gas-report)",
"release": "commit-and-tag-version",
"adorno": "pnpm prettier:write && forge fmt && forge snapshot && pnpm gas-report"
"adorno": "pnpm prettier:write && forge fmt && forge snapshot && pnpm gas-report",
"deploy:sepolia": "./envCheck.sh && forge script --chain sepolia script/Deploy.s.sol:Deploy --rpc-url $RPC_URL --broadcast --verify -vv --account $ACCOUNT --legacy",
"deploy:localhost": "./envCheck.sh && forge script script/Deploy.s.sol:Deploy --rpc-url $RPC_URL --broadcast -vv --account $ACCOUNT"
}
}

View File

@ -6,8 +6,7 @@ import { BaseScript } from "./Base.s.sol";
import { DeploymentConfig } from "./DeploymentConfig.s.sol";
contract Deploy is BaseScript {
function run() public returns (WakuRlnV2 w, DeploymentConfig deploymentConfig) {
deploymentConfig = new DeploymentConfig(broadcaster);
function run() public broadcast returns (WakuRlnV2 w) {
w = new WakuRlnV2(20);
}
}

View File

@ -21,6 +21,8 @@ contract DeploymentConfig is Script {
deployer = _broadcaster;
if (block.chainid == 31_337) {
activeNetworkConfig = getOrCreateAnvilEthConfig();
} else if (block.chainid == 11_155_111) {
activeNetworkConfig = getOrCreateSepoliaConfig();
} else {
revert DeploymentConfig_NoConfigForChain(block.chainid);
}
@ -30,6 +32,10 @@ contract DeploymentConfig is Script {
return NetworkConfig({ deployer: deployer });
}
function getOrCreateSepoliaConfig() public view returns (NetworkConfig memory) {
return NetworkConfig({ deployer: deployer });
}
// This function is a hack to have it excluded by `forge coverage` until
// https://github.com/foundry-rs/foundry/issues/2988 is fixed.
// See: https://github.com/foundry-rs/foundry/issues/2988#issuecomment-1437784542

View File

@ -20,7 +20,7 @@ contract WakuRlnV2Test is Test {
function setUp() public virtual {
Deploy deployment = new Deploy();
(w, deploymentConfig) = deployment.run();
w = deployment.run();
}
function test__ValidRegistration__kats() external {