Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Pe 1108 forge deploy #130

Draft
wants to merge 6 commits into
base: PE-1108
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
all :; DAPP_LIBRARIES=' lib/dss-exec-lib/src/DssExecLib.sol:DssExecLib:$(shell cat DssExecLib.address)' \
DAPP_BUILD_OPTIMIZE=0 DAPP_BUILD_OPTIMIZE_RUNS=200 \
dapp --use solc:0.6.12 build
clean :; dapp clean
forge build --use solc:0.6.12
clean :; forge clean
# Usage example: make test match=SpellIsCast
test :; ./scripts/test-dssspell.sh match="$(match)" optimizer="$(optimizer)" optimizer-runs="$(optimizer-runs)" block="$(block)"
test :; ./scripts/test-dssspell-forge.sh match="$(match)" block="$(block)"
test-forge :; ./scripts/test-dssspell-forge.sh match="$(match)" block="$(block)"
test-dapp :; ./scripts/test-dssspell.sh match="$(match)" optimizer="$(optimizer)" optimizer-runs="$(optimizer-runs)" block="$(block)"
estimate :; ./scripts/estimate-deploy-gas.sh
deploy :; ./scripts/deploy.sh
deploy-stamp :; ./scripts/get-created-timestamp.sh tx=$(tx)
flatten :; hevm flatten --source-file "src/Goerli-DssSpell.sol" > out/flat.sol
flatten :; forge flatten "src/Goerli-DssSpell.sol" > out/flat.sol
cast-spell :; ./scripts/cast-dssspell.sh $(spell)
archive-spell :; ./scripts/archive-dssspell.sh "$(if $(date),$(date),$(shell date +'%Y-%m-%d'))"
diff-archive-spell :; ./scripts/diff-archive-dssspell.sh "$(if $(date),$(date),$(shell date +'%Y-%m-%d'))"
Expand Down
16 changes: 14 additions & 2 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#!/usr/bin/env bash
set -e
set -e # prod
#set -x # testing

[[ "$(cast chain --rpc-url="$ETH_RPC_URL")" == "goerli" ]] || { echo "Please set a Goerli ETH_RPC_URL"; exit 1; }
[[ "$ETHERSCAN_API_KEY" ]] || { echo "Please set ETHERSCAN_API_KEY"; exit 1; }

# TODO Test ETH_FROM is set
ETH_FROM_TRIMMED="${ETH_FROM:2}"
ETH_KEYFILE="$(find $ETH_KEYSTORE | grep ${ETH_FROM_TRIMMED,,})"

make && \
dapp create DssSpell | \
forge create DssSpell \
--keystore "$ETH_KEYFILE" \
--password "$(cat $ETH_PASSWORD)" \
--gas-price "$ETH_GAS_PRICE" \
--gas-limit "$ETH_GAS" \
--priority-gas-price "$ETH_PRIO_FEE" \
--libraries "lib/dss-exec-lib/src/DssExecLib.sol:DssExecLib:$(cat DssExecLib.address)" | \
xargs ./scripts/verify.py DssSpell
#xargs python3 -m trace -t ./scripts/verify.py DssSpell
83 changes: 60 additions & 23 deletions scripts/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
import os, sys, subprocess, time, re, json, requests
from datetime import datetime

# TODO remove debug
## FOUNDRY OUTPUT:
EXAMPLE_ARGS = ['./scripts/verify.py', 'DssSpell', 'Compiling', '76', 'files', 'with', '0.6.12', 'Solc', '0.6.12', 'finished', 'in', '2238.39s', 'Compiler', 'run', 'successful', '(with', 'warnings)', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:19:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'add(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:25:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'mul(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:22:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'sub(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:19:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'add(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:25:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'mul(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:22:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'sub(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:19:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'add(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:25:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'mul(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:22:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'sub(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:19:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'add(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:25:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'mul(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:22:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'sub(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:19:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'add(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:25:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'mul(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:22:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'sub(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:19:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'add(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:25:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'mul(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:22:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'sub(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:19:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'add(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:25:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'mul(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[8261]:', '\x1b[0m\x1b[33mlib/ds-math/src/math.sol:22:5:', 'Warning:', 'Variable', 'is', 'shadowed', 'in', 'inline', 'assembly', 'by', 'an', 'instruction', 'of', 'the', 'same', 'name', 'function', 'sub(uint', 'x,', 'uint', 'y)', 'internal', 'pure', 'returns', '(uint', 'z)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', '\x1b[33mwarning[2072]:', '\x1b[0m\x1b[33msrc/Goerli-DssSpell.t.sol:514:9:', 'Warning:', 'Unused', 'local', 'variable.', 'bytes32', 'ilk', '=', 'TELEPORT-FW-A;', '^---------^', '\x1b[0m', '\x1b[33mwarning[2018]:', '\x1b[0m\x1b[33mlib/dss-exec-lib/src/DssAction.sol:42:5:', 'Warning:', 'Function', 'state', 'mutability', 'can', 'be', 'restricted', 'to', 'pure', 'function', 'officeHours()', 'public', 'virtual', 'returns', '(bool)', '{', '^', '(Relevant', 'source', 'part', 'starts', 'here', 'and', 'spans', 'across', 'multiple', 'lines).', '\x1b[0m', 'Deployer:', '0xC1E6d8136441FC66612Df3584007f7CB68765e5D', 'Deployed', 'to:', '0xE0b8ea01093c96eC54E0616cC3EbaBb477B38307', 'Transaction', 'hash:', '0xf0d00eccb0f8371605f03f9baa865a9ff7ea43792fe47cee3b73f4c76dabd7e7']

#print(EXAMPLE_ARGS)
#print(sys.argv)
sysargs = sys.argv
#print(sysargs)
sysargs = EXAMPLE_ARGS

dappargs = {}
for (i, arg) in enumerate(sysargs):
if i == 1:
dappargs['contractname'] = arg
if arg == "to:":
dappargs['address'] = sysargs[i + 1]

print(dappargs)


api_key = ''
try:
api_key = os.environ['ETHERSCAN_API_KEY']
Expand All @@ -15,22 +35,23 @@

document = ''
try:
document = open('out/dapp.sol.json')
document = open('out/Goerli-DssSpell.sol/DssSpell.json')
except FileNotFoundError:
exit('run dapp build first')
exit('run forge build first')
try:
content = json.load(document)
except json.decoder.JSONDecodeError:
exit('run dapp build again')
exit('run forge build again')

if len(sys.argv) not in [3, 4]:
print('''usage:\n
./verify.py <contractname> <address> [constructorArgs]
''')
exit()

contract_name = sys.argv[1]
contract_address = sys.argv[2]
#if len(sysargs) not in [3, 4]:
# print('''usage:\n
#./verify.py <contractname> <address> [constructorArgs]
#''')
# exit()

contract_name = dappargs['contractname']
contract_address = dappargs['address']
print('Attempting to verify contract {0} at address {1} ...'.format(
contract_name,
contract_address
Expand All @@ -39,45 +60,60 @@
if len(contract_address) != 42:
exit('malformed address')
constructor_arguments = ''
if len(sys.argv) == 4:
constructor_arguments = sys.argv[3]
#if len(sysargs) == 4:
# constructor_arguments = sysargs[3]

print(content.keys())
print(content['ast'].keys())
print(content['metadata'].keys())
print(content['metadata']['sources'].keys())

contract_path = ''
for path in content['contracts'].keys():
try:
content['contracts'][path][contract_name]
contract_path = path
except KeyError:
continue
#for path in content['contracts'].keys():
# try:
# content['metadata']['sources'][path][contract_name]
# contract_path = path
# except KeyError:
# continue
contract_path = content['ast']['absolutePath']
if contract_path == '':
exit('contract name not found.')


print('Obtaining chain... ')
seth_chain = subprocess.run(['seth', 'chain'], capture_output=True)
chain = seth_chain.stdout.decode('ascii').replace('\n', '')
cast_chain = subprocess.run(['cast', 'chain'], capture_output=True)
chain = cast_chain.stdout.decode('ascii').replace('\n', '')
print(chain)

text_metadata = content['contracts'][contract_path][contract_name]['metadata']
#text_metadata = content['contracts'][contract_path][contract_name]['metadata']
text_metadata = content['rawMetadata']
metadata = json.loads(text_metadata)
#print(metadata)
compiler_version = 'v' + metadata['compiler']['version']
print(compiler_version)
evm_version = metadata['settings']['evmVersion']
print(evm_version)
optimizer_enabled = metadata['settings']['optimizer']['enabled']
print(metadata['settings']['optimizer'])
print(optimizer_enabled)
optimizer_runs = metadata['settings']['optimizer']['runs']
print(optimizer_runs)
license_name = metadata['sources'][contract_path]['license']
print(license_name)
license_numbers = {
'GPL-3.0-or-later': 5,
'AGPL-3.0-or-later': 13
}
license_number = license_numbers[license_name]
print(license_number)

module = 'contract'
action = 'verifysourcecode'
code_format = 'solidity-single-file'

flatten = subprocess.run([
'hevm',
'forge',
'flatten',
'--source-file',
contract_path
], capture_output=True)
code = flatten.stdout.decode('utf-8')
Expand Down Expand Up @@ -226,6 +262,7 @@ def get_library_info():
'libraryname1': library_name,
'libraryaddress1': library_address,
}
#print(data)

if chain in ['mainnet', 'ethlive']:
chain_separator = False
Expand Down
44 changes: 44 additions & 0 deletions src/Goerli-DssSpell.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,50 @@ contract DssSpellAction is DssAction, DssSpellCollateralAction {
DssExecLib.setChangelogAddress("STARKNET_TELEPORT_BRIDGE", TELEPORT_GATEWAY_STA);
DssExecLib.setChangelogAddress("STARKNET_TELEPORT_FEE", LINEAR_FEE);

// MAINNET ONLY


// CU Offboarding - Yank DAI Streams
// https://forum.makerdao.com/t/executive-vote-cu-offboarding-next-steps/18522
// Yank DAI Stream #4 (EVENTS-001)
// https://mips.makerdao.com/mips/details/MIP39c3SP4#sentence-summary
// Yank DAI Stream #5 (SH-001)
// https://mips.makerdao.com/mips/details/MIP39c3SP3#sentence-summary
// Yank DAI Stream #35 (RWF-001)
// https://mips.makerdao.com/mips/details/MIP39c3SP5#sentence-summary


// CU Offboarding - Yank MKR Stream
// Yank MKR Stream #23 (SH-001)
// https://mips.makerdao.com/mips/details/MIP39c3SP3#sentence-summary


// CU Offboarding - DAI Golden Parachutes
// EVENTS-001 - 167,666 DAI - 0x3D274fbAc29C92D2F624483495C0113B44dBE7d2
// https://mips.makerdao.com/mips/details/MIP39c3SP4#sentence-summary
// SH-001 - 43,332.0 DAI - 0xc657aC882Fb2D6CcF521801da39e910F8519508d
// https://mips.makerdao.com/mips/details/MIP39c3SP3#sentence-summary


// CU Offboarding - MKR Golden Parachutes
// https://forum.makerdao.com/t/executive-vote-cu-offboarding-next-steps/18522
// SH-001 - 26.04 MKR - 0xc657aC882Fb2D6CcF521801da39e910F8519508d
// https://mips.makerdao.com/mips/details/MIP39c3SP4#sentence-summary
// RWF-001 - 143.46 MKR - 0x96d7b01Cc25B141520C717fa369844d34FF116ec
// https://mips.makerdao.com/mips/details/MIP39c3SP5#sentence-summary


// SPF Funding
// BlockTower Legal and Risk Work SPF - 258,000 DAI - 0x117786ad59BC2f13cf25B2359eAa521acB0aDCD9
// https://mips.makerdao.com/mips/details/MIP39c3SP5#sentence-summary


// Oracle Whitelisting - carried over from last week, see confirms from Nik in week 43 sheet
// https://vote.makerdao.com/polling/QmZzFPFs#vote-breakdown
// Whitelist Oasis.app on RETH/USD oracle
// https://forum.makerdao.com/t/mip10c9-sp31-proposal-to-whitelist-oasis-app-on-rethusd-oracle/18195
// Oasis.app - 0x55Dc2Be8020bCa72E58e665dC931E03B749ea5E0 - OSM

}
}

Expand Down