Skip to content

Commit

Permalink
Merge branch 'main' into security-council-mgmt--base: fix makefile co…
Browse files Browse the repository at this point in the history
…nflict
  • Loading branch information
DZGoldman committed Aug 23, 2023
1 parent c9e7c7e commit 54af24e
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 16 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,35 @@ jobs:
- name: Check gas snapshot
run: make gas-check

test-action-storage:
name: Test action storage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup node/yarn
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install packages
run: yarn

- name: Check if jq is installed
run: jq --version

- name: Check action storage
run: make test-action-storage

test-only-doesnt-exist:
name: No .only
runs-on: ubuntu-latest
Expand Down
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
-include .env

# deps
install :; yarn
install :; yarn

# Build & test
build :; forge build
coverage :; forge coverage
gas :; forge test --gas-report
gas-check :; forge snapshot --check --tolerance 1
snapshot :; forge snapshot
test-unit :; forge test -vvv
clean :; forge clean
fmt :; forge fmt
gen-network :; yarn gen:network
test : test-unit
sc-election-test:; FOUNDRY_MATCH_PATH='test/security-council-mgmt/**/*.t.sol' make test
test-integration:; yarn test:integration
build :; forge build
coverage :; forge coverage
gas :; forge test --gas-report
gas-check :; forge snapshot --check --tolerance 1
snapshot :; forge snapshot
test-unit :; forge test -vvv
clean :; forge clean
fmt :; forge fmt
gen-network :; yarn gen:network
test : test-unit
test-action-storage :; ./scripts/test-action-storage.sh
sc-election-test :; FOUNDRY_MATCH_PATH='test/security-council-mgmt/**/*.t.sol' make test
test-integration :; yarn test:integration

9 changes: 6 additions & 3 deletions scripts/contractVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export class ContractVerifier {
ArbGoerliSetInitialGovParamsAction: "src/gov-action-contracts/goerli/ArbGoerliSetInitialGovParamsAction.sol:ArbGoerliSetInitialGovParamsAction",
AIP1Point2Action: "src/gov-action-contracts/AIPs/AIP1Point2Action.sol:AIP1Point2Action",
AIP4Action: "src/gov-action-contracts/AIPs/AIP4Action.sol:AIP4Action",
SetSweepReceiverAction: "src/gov-action-contracts/AIPs/MiscAIP/SetSweepReceiverAction.sol:SetSweepReceiverAction",
UpdateGasChargeAction: "src/gov-action-contracts/AIPs/MiscAIP/UpdateGasChargeAction.sol:UpdateGasChargeAction",
UpdateL1CoreTimelockAction: "src/gov-action-contracts/AIPs/MiscAIP/UpdateL1CoreTimelockAction.sol:UpdateL1CoreTimelockAction",
ArbitrumFoundationVestingWalletProxy: this.TUP,
ArbitrumFoundationVestingWalletLogic: "src/ArbitrumFoundationVestingWallet.sol:ArbitrumFoundationVestingWallet",
};
Expand All @@ -78,7 +81,7 @@ export class ContractVerifier {
this.verifyCommand = `forge verify-contract --chain-id ${chainId} --num-of-optimizations ${this.NUM_OF_OPTIMIZATIONS} --compiler-version ${this.COMPILER_VERSION}`;
}

async verify(name: string, constructorArgs?: string) {
async verify(name: keyof typeof this.contractToSource, constructorArgs?: string) {
const contractAddress = this.deployedContracts[name as keyof DeployProgressCache] as string;
if (!contractAddress) {
console.log(name, " not found");
Expand All @@ -87,11 +90,11 @@ export class ContractVerifier {
await this.verifyWithAddress(name, contractAddress, constructorArgs);
}

async verifyWithAddress(name: string, contractAddress: string, constructorArgs?: string) {
async verifyWithAddress(name: keyof typeof this.contractToSource, contractAddress: string, constructorArgs?: string) {
// avoid rate limiting
await new Promise((resolve) => setTimeout(resolve, 1000));

const sourceFile = this.contractToSource[name as keyof typeof this.contractToSource];
const sourceFile = this.contractToSource[name];

let command = this.verifyCommand;
if (constructorArgs) {
Expand Down
133 changes: 133 additions & 0 deletions scripts/proposals/misc-actions/deployAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { importDeployedContracts } from "../../../src-ts/utils";
import { Wallet } from "@ethersproject/wallet";
import { JsonRpcProvider } from "@ethersproject/providers";
import {
SetSweepReceiverAction__factory,
UpdateGasChargeAction__factory,
UpdateL1CoreTimelockAction__factory,
L1ArbitrumTimelock__factory
} from "../../../typechain-types";

import { ContractVerifier } from "../../contractVerifier";
import { utils } from "ethers";
import dotenv from "dotenv";
dotenv.config();

const abi = utils.defaultAbiCoder;

const mainnetDeployedContracts = importDeployedContracts("./files/mainnet/deployedContracts.json");
const mainnetTokenDistributor = "0x67a24CE4321aB3aF51c2D0a4801c3E111D88C9d9"
const newPerBatchGasCharge = 240000

const ARB_URL = process.env.ARB_URL;
const ARB_KEY = process.env.ARB_KEY;
const ARBISCAN_API_KEY = process.env.ARBISCAN_API_KEY;

const ETH_URL = process.env.ETH_URL;
const ETH_KEY = process.env.ETH_KEY;
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY;


if (!ARB_URL) throw new Error("ARB_URL required");
if (!ARB_KEY) throw new Error("ARB_KEY required");
if (!ARBISCAN_API_KEY) throw new Error("ARBISCAN_API_KEY required");

if (!ETH_URL) throw new Error("ETH_URL required");
if (!ETH_KEY) throw new Error("ETH_KEY required");
if (!ETHERSCAN_API_KEY) throw new Error("ETHERSCAN_API_KEY required");

const main = async () => {
const l1Provider = new JsonRpcProvider(ETH_URL);
const l1Deployer = new Wallet(ETH_KEY, l1Provider);

const l2Provider = new JsonRpcProvider(ARB_URL);
const l2Deployer = new Wallet(ARB_KEY, l2Provider);

const { chainId: l1ChainId } = await l1Provider.getNetwork();
const { chainId: l2ChainId } = await l2Provider.getNetwork();

const deployedContracts = (() => {
if (l2ChainId === 42161 && l1ChainId === 1) {
return mainnetDeployedContracts;
} else {
throw new Error("Invalid ChainId");
}
})();

const l1Verifier = new ContractVerifier(l1ChainId, ETHERSCAN_API_KEY, {});
const l2Verifier = new ContractVerifier(l2ChainId, ARBISCAN_API_KEY, {});


const action1 = await new SetSweepReceiverAction__factory(l2Deployer).deploy(
deployedContracts.l2AddressRegistry,
mainnetTokenDistributor
);

await action1.deployed();
console.log("SetSweepReceiverAction deployed at", action1.address);

await l2Verifier.verifyWithAddress(
"SetSweepReceiverAction",
action1.address,
abi.encode(
["address", "address"],
[deployedContracts.l2AddressRegistry, mainnetTokenDistributor]
)
);



const action2 = await new UpdateGasChargeAction__factory(l2Deployer).deploy(
newPerBatchGasCharge
);

await action2.deployed();
console.log("UpdateGasChargeAction deployed at", action2.address);

await l2Verifier.verifyWithAddress(
"UpdateGasChargeAction",
action2.address,
abi.encode(["int64"], [newPerBatchGasCharge])
);



// layer 1 side

const newTimelockLogic = await new L1ArbitrumTimelock__factory(l1Deployer).deploy();
await newTimelockLogic.deployed()
console.log("L1ArbitrumTimelock deployed at", newTimelockLogic.address);

const action3 = await new UpdateL1CoreTimelockAction__factory(l1Deployer).deploy(
deployedContracts.l1ProxyAdmin,
deployedContracts.l1AddressRegistry,
newTimelockLogic.address
);

await action3.deployed();
console.log("UpdateL1CoreTimelockAction deployed at", action3.address);

await l1Verifier.verifyWithAddress(
"l1Timelock",
newTimelockLogic.address,
);

await l1Verifier.verifyWithAddress(
"UpdateL1CoreTimelockAction",
action3.address,
abi.encode(
["address", "address", "address"],
[
deployedContracts.l1ProxyAdmin,
deployedContracts.l1AddressRegistry,
newTimelockLogic.address
]
)
);


};

main().then(() => {
console.log("Done");
});
22 changes: 22 additions & 0 deletions scripts/test-action-storage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# compile contracts so out/ directory is populated
forge build

CONTRACTS=$(find out/ -name "*Action.json" | sed 's/\.json$//' | awk -F/ '{print $NF}')

EXIT_CODE=0

for CONTRACT in $CONTRACTS; do
IS_NO_STORAGE=$(forge inspect $CONTRACT storage | jq '.storage == []')
if [ "$IS_NO_STORAGE" = "false" ]; then
echo "$CONTRACT has storage"
EXIT_CODE=1
fi
done;

if [ $EXIT_CODE -eq 0 ]; then
echo "All action contracts have no storage"
fi

exit $EXIT_CODE

0 comments on commit 54af24e

Please sign in to comment.