Skip to content

Commit

Permalink
do not rewrite verification logic
Browse files Browse the repository at this point in the history
  • Loading branch information
SidestreamColdMelon committed Jan 27, 2025
1 parent 7e238b9 commit 6223bd7
Showing 1 changed file with 18 additions and 40 deletions.
58 changes: 18 additions & 40 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
SPELL_CONTRACT_NAME = 'DssSpell'
PATH_TO_EXEC_LIB = './DssExecLib.address'
SOLIDITY_USE = 'solc:0.8.16'
SOLIDITY_VERSION = 'v0.8.16+commit.07a7930e'
PATH_TO_FLATTENED = 'out/flat.sol'
PATH_TO_CONFIG = 'src/test/config.sol'

# Read DssExecLib address
Expand All @@ -33,6 +31,7 @@
cast_chain_id = subprocess.run(['cast', 'chain-id'], stdout=subprocess.PIPE, text=True, check=True).stdout.strip()
if cast_chain_id != CHAIN_ID:
sys.exit(f'Please provide correct ETH_RPC_URL. Currently set to chain id "{cast_chain_id}", expected "{CHAIN_ID}"')
print(f'Using chain id {cast_chain_id}')

# Check env ETHERSCAN_API_KEY is set
ETHERSCAN_API_KEY = os.environ.get('ETHERSCAN_API_KEY')
Expand All @@ -48,16 +47,16 @@
# Deploy the spell
print('Deploying a spell...')
deploy_logs = subprocess.run([
'forge', 'create',
'--no-cache',
'--broadcast',
'--optimize', OPTIMIZER_ENABLED,
'--optimizer-runs', OPTIMIZER_RUNS,
'--use', SOLIDITY_USE,
'--libraries', f'lib/dss-exec-lib/src/DssExecLib.sol:DssExecLib:{EXEC_LIB_ADDRESS}',
'--keystore', ETH_KEYSTORE,
f'{PATH_TO_SPELL}:{SPELL_CONTRACT_NAME}'
], stdout=subprocess.PIPE, text=True, check=True).stdout
'forge', 'create',
'--no-cache',
'--broadcast',
'--optimize', OPTIMIZER_ENABLED,
'--optimizer-runs', OPTIMIZER_RUNS,
'--use', SOLIDITY_USE,
'--libraries', f'lib/dss-exec-lib/src/DssExecLib.sol:DssExecLib:{EXEC_LIB_ADDRESS}',
'--keystore', ETH_KEYSTORE,
f'{PATH_TO_SPELL}:{SPELL_CONTRACT_NAME}',
], stdout=subprocess.PIPE, text=True, check=True).stdout
print(deploy_logs)

# Get spell address
Expand Down Expand Up @@ -96,36 +95,16 @@
with open(PATH_TO_CONFIG, 'w') as f:
f.write(config_content)

# Flatten the contract
print(f'Flattening the spell to {PATH_TO_FLATTENED}')
# Verify the contract
subprocess.run([
'forge', 'flatten',
'--output', PATH_TO_FLATTENED,
f'{PATH_TO_SPELL}'
], text=True)

# Verify deployed code
print('Verifying the flattened spell...')
verify_command = [
'forge', 'verify-contract',
'--verifier', 'etherscan',
'--chain-id', CHAIN_ID,
'--compiler-version', SOLIDITY_VERSION,
'--watch',
'--flatten',
'--libraries', f'lib/dss-exec-lib/src/DssExecLib.sol:DssExecLib:{EXEC_LIB_ADDRESS}',
spell_address,
f'{PATH_TO_FLATTENED}:{SPELL_CONTRACT_NAME}'
]
if OPTIMIZER_ENABLED != 'false':
verify_command.extend(['--optimizer-runs', OPTIMIZER_RUNS,])
subprocess.run(verify_command, check=True)
'make', 'verify',
f'addr={spell_address}',
], check=True)

# Re-run the tests
print(f'Re-running the tests...')
test_logs = subprocess.run([
'make',
'test',
'make', 'test',
f'block="{tx_block}"',
], capture_output=True, text=True)
print(test_logs.stdout)
Expand All @@ -138,8 +117,7 @@
# Commit the changes
print('Commiting changes to the `config.sol`...')
subprocess.run([
'git',
'commit',
'git', 'commit',
'-m', "add deployed spell info",
'--', PATH_TO_CONFIG
'--', PATH_TO_CONFIG,
], check=True)

0 comments on commit 6223bd7

Please sign in to comment.