Check existing L1 contracts deployment
This commit is contained in:
parent
2515878eeb
commit
4ebb42bc03
@ -14,6 +14,7 @@ services:
|
||||
"./wait-for-it.sh -h $${L1_HOST} -p $${L1_PORT} -s -t 60 -- ./run.sh"
|
||||
volumes:
|
||||
- ../config/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh
|
||||
- ../container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts:/app/packages/contracts-bedrock/tasks/verify-contract-deployment.ts
|
||||
- ../container-build/cerc-optimism-contracts/hardhat-tasks/rekey-json.ts:/app/packages/contracts-bedrock/tasks/rekey-json.ts
|
||||
- ../container-build/cerc-optimism-contracts/hardhat-tasks/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts
|
||||
- ../config/fixturenet-optimism/optimism-contracts/update-config.js:/app/packages/contracts-bedrock/update-config.js
|
||||
|
||||
@ -4,22 +4,42 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# TODO Support restarts; fixturenet-eth-geth currently starts fresh on a restart
|
||||
# Exit if a deployment already exists (on restarts)
|
||||
# if [ -d "deployments/getting-started" ]; then
|
||||
# echo "Deployment directory deployments/getting-started already exists, exiting"
|
||||
# exit 0
|
||||
# fi
|
||||
|
||||
echo "Using L1 RPC endpoint ${L1_RPC}"
|
||||
|
||||
# Append tasks/index.ts file
|
||||
echo "import './rekey-json'" >> tasks/index.ts
|
||||
echo "import './send-balance'" >> tasks/index.ts
|
||||
IMPORT_1="import './verify-contract-deployment'"
|
||||
IMPORT_2="import './rekey-json'"
|
||||
IMPORT_3="import './send-balance'"
|
||||
|
||||
# Append mounted tasks to tasks/index.ts file if not present
|
||||
if ! grep -Fxq "$IMPORT_1" tasks/index.ts; then
|
||||
echo "$IMPORT_1" >> tasks/index.ts
|
||||
echo "$IMPORT_2" >> tasks/index.ts
|
||||
echo "$IMPORT_3" >> tasks/index.ts
|
||||
fi
|
||||
|
||||
# Update the chainId in the hardhat config
|
||||
sed -i "/getting-started/ {n; s/.*chainId.*/ chainId: $L1_CHAIN_ID,/}" hardhat.config.ts
|
||||
|
||||
# Exit if a deployment already exists (on restarts)
|
||||
# Note: fixturenet-eth-geth currently starts fresh on a restart
|
||||
if [ -d "deployments/getting-started" ]; then
|
||||
echo "Deployment directory deployments/getting-started found, checking SystemDictator deployment"
|
||||
|
||||
# Read JSON file into variable
|
||||
SYSTEM_DICTATOR_DETAILS=$(cat deployments/getting-started/SystemDictator.json)
|
||||
|
||||
# Parse JSON into variables
|
||||
SYSTEM_DICTATOR_ADDRESS=$(echo "$SYSTEM_DICTATOR_DETAILS" | jq -r '.address')
|
||||
SYSTEM_DICTATOR_TXHASH=$(echo "$SYSTEM_DICTATOR_DETAILS" | jq -r '.transactionHash')
|
||||
|
||||
if yarn hardhat verify-contract-deployment --contract "${SYSTEM_DICTATOR_ADDRESS}" --transaction-hash "${SYSTEM_DICTATOR_TXHASH}"; then
|
||||
echo "Deployment verfication successful, exiting"
|
||||
exit 0
|
||||
else
|
||||
echo "Deployment verfication failed"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Generate the L2 account addresses
|
||||
yarn hardhat rekey-json --output /l2-accounts/keys.json
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ mkdir datadir
|
||||
echo "pwd" > datadir/password
|
||||
|
||||
# TODO: Add in container build or use other tool
|
||||
echo "installing jq"
|
||||
echo "Installing jq"
|
||||
apk update && apk add jq
|
||||
|
||||
# Get SEQUENCER KEY from keys.json
|
||||
@ -32,6 +32,8 @@ geth init --datadir=datadir genesis.json
|
||||
SEQUENCER_ADDRESS=$(jq -r '.Sequencer.address' /l2-accounts/keys.json | tr -d '"')
|
||||
echo "SEQUENCER_ADDRESS: ${SEQUENCER_ADDRESS}"
|
||||
cp /op-node/jwt.txt ./
|
||||
|
||||
# Run op-geth
|
||||
geth \
|
||||
--datadir ./datadir \
|
||||
--http \
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
import { task } from 'hardhat/config'
|
||||
import '@nomiclabs/hardhat-ethers'
|
||||
|
||||
task(
|
||||
'verify-contract-deployment',
|
||||
'Verifies the given contract deployment transaction'
|
||||
)
|
||||
.addParam('contract', 'Address of the contract deployed')
|
||||
.addParam('transactionHash', 'Hash of the deployment transaction')
|
||||
.setAction(async ({ contract, transactionHash }, { ethers }) => {
|
||||
// Open the wallet using sender's private key
|
||||
const provider = new ethers.providers.JsonRpcProvider(
|
||||
`${process.env.L1_RPC}`
|
||||
)
|
||||
|
||||
const receipt = await provider.getTransactionReceipt(transactionHash)
|
||||
if (
|
||||
receipt &&
|
||||
receipt.contractAddress &&
|
||||
receipt.contractAddress === contract
|
||||
) {
|
||||
console.log(
|
||||
`Deployment for contract ${contract} in transaction ${transactionHash} verified`
|
||||
)
|
||||
process.exit(0)
|
||||
} else {
|
||||
console.log(`Contract ${contract} deployment verification failed`)
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user