Skip to content

Commit

Permalink
feat(contracts): numerous improvements to deploy scripts (+). (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk authored Aug 15, 2024
1 parent ea94452 commit 4777940
Show file tree
Hide file tree
Showing 39 changed files with 689 additions and 1,559 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-deploy-contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
run: |
cd contracts
npm install --save hardhat
output=$(make deploy-ipc NETWORK=calibrationnet)
output=$(make deploy-stack NETWORK=calibrationnet)
echo "deploy_output<<EOF" >> $GITHUB_OUTPUT
echo "$output" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/contracts-deployment-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
export PATH="$PATH:/home/runner/.config/.foundry/bin"
pnpm exec ganache-cli -g0 -p1337 --account 0x$PRIVATE_KEY,1001901919191919191 &
sleep 5
make deploy-ipc
make deploy-stack
2 changes: 1 addition & 1 deletion .github/workflows/contracts-pnpm-audit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
- name: NPM Audit
run: |
cd contracts
pnpm audit
pnpm audit --audit-level=moderate
19 changes: 4 additions & 15 deletions .github/workflows/contracts-sast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ jobs:
- name: Force an ordinary npm install
run: cd contracts && rm -rf node_modules && npm install

- name: Print Aderyn version
run: aderyn --version

- name: Run aderyn
run: aderyn ./ -o report.json
run: cd contracts && aderyn ./ -o report.json

- name: Check results
run: cd contracts && ./tools/check_aderyn.sh
Expand All @@ -78,17 +81,3 @@ jobs:
run: cd contracts && pnpm exec prettier --check 'contracts/**/*.sol' 'test/*.sol'
- name: Solhint check
run: cd contracts && pnpm exec solhint 'contracts/**/*.sol'

codespell:
name: Codespell check
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v3
- name: CodeSpell check
uses: codespell-project/[email protected]
with:
check_hidden: true
check_filenames: true
path: contracts/contracts/*,contracts/script/*,contracts/scripts/*,contracts/test/*
ignore_words_file: contracts/.codespellignore
3 changes: 2 additions & 1 deletion .github/workflows/lint-pr.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Lint PR"

on:
pull_request_target:
pull_request:
types:
- opened
- edited
Expand Down Expand Up @@ -29,6 +29,7 @@ jobs:
cli
contracts
core
ci
deps
docker
ethapi
Expand Down
1 change: 0 additions & 1 deletion contracts/.codespellignore

This file was deleted.

1 change: 1 addition & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ solidity-files-cache.json
typechain

# Deploment assets
deployments/
deployments.json
scripts/*.out
scripts/deploy-registry.ts
Expand Down
22 changes: 3 additions & 19 deletions contracts/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Targets that are commands.
COMMANDS := deploy-ipc deploy-subnet-registry deploy-subnet upgrade-gw-diamond upgrade-sa-diamond \
upgrade-sr-diamond gen compile-abi rust-binding slither lint fmt deps build \
COMMANDS := deploy-stack gen compile-abi rust-binding slither lint fmt deps build \
test install-dev install-npm-package install-eth-abi storage clean coverage \
prepare build-selector-library forge

Expand Down Expand Up @@ -32,23 +31,8 @@ NETWORK ?= auto
# It is required by docker builds, but shouldn't be checked into git.
OUTPUT ?= out

deploy-ipc:
./ops/deploy.sh $(NETWORK)

deploy-subnet-registry:
./ops/deploy-subnet-registry.sh $(NETWORK)

deploy-subnet:
./ops/deploy-subnet.sh $(NETWORK)

upgrade-gw-diamond:
./ops/upgrade-gw-diamond.sh $(NETWORK)

upgrade-sa-diamond:
./ops/upgrade-sa-diamond.sh $(NETWORK) $(SUBNET_ACTOR_ADDRESS)

upgrade-sr-diamond:
./ops/upgrade-sr-diamond.sh $(NETWORK)
deploy-stack:
pnpm exec hardhat deploy-stack --network $(NETWORK)

# ==============================================================================
# Code generation
Expand Down
48 changes: 48 additions & 0 deletions contracts/extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { extendProvider } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers'

const emptyBlock = {
number: '0x0',
hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
nonce: '0x0000000000000000',
sha3Uncles: '0x0000000000000000000000000000000000000000000000000000000000000000',
logsBloom: '0x' + '00'.repeat(256),
transactionsRoot: '0x0000000000000000000000000000000000000000000000000000000000000000',
stateRoot: '0x0000000000000000000000000000000000000000000000000000000000000000',
receiptsRoot: '0x0000000000000000000000000000000000000000000000000000000000000000',
miner: '0x0000000000000000000000000000000000000000',
difficulty: '0x0',
totalDifficulty: '0x0',
extraData: '0x',
size: '0x0',
gasLimit: '0x0',
gasUsed: '0x0',
timestamp: '0x0',
transactions: [],
uncles: [],
}

extendProvider((provider) => {
const interceptedRpcMethods = ['eth_getBlockByNumber', 'eth_getBlockByHash']

const originalProvider = provider.request.bind(provider)
provider.request = async (args) => {
try {
return await originalProvider(args)
} catch (err) {
if (
interceptedRpcMethods.includes(args.method) &&
err.message.includes('requested epoch was a null round')
) {
console.warn(`[${args.method}] null round hit, returning empty block`)
return emptyBlock
}
console.log(`Rethrowing error ${err}`)
throw err
}
}

return provider
})
Loading

0 comments on commit 4777940

Please sign in to comment.