Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add positive output to the verify-bytecodes script #5398

Merged
merged 11 commits into from
Oct 16, 2020
8 changes: 6 additions & 2 deletions packages/protocol/lib/compatibility/verify-bytecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const getImplementationAddress = async (contract: string, context: VerificationC
proxyAddress = context.libraryAddresses.addresses[contract]
// Before the first contracts upgrade libraries are not proxied.
if (context.isBeforeRelease1) {
return proxyAddress
return `0x${proxyAddress}`
}
} else {
// contract is registered but we need to check if the proxy is affected by the proposal
Expand Down Expand Up @@ -124,6 +124,10 @@ const dfsStep = async (queue: string[], visited: Set<string>, context: Verificat

if (onchainBytecode !== linkedSourceBytecode) {
throw new Error(`${contract}'s onchain and compiled bytecodes do not match`)
} else {
// tslint:disable-next-line: no-console
console.log(
`${isLibrary(contract, context) ? 'Library' : 'Contract'} deployed at ${implementationAddress} matches ${contract}`)
}

// push unvisited libraries to DFS queue
Expand All @@ -144,7 +148,7 @@ export const verifyBytecodes = async (
proposal: ProposalTx[],
Proxy: Truffle.Contract<ProxyInstance>,
web3: Web3,
isBeforeRelease1: boolean = false
isBeforeRelease1: boolean = false,
) => {
const queue = contracts.filter((contract) => !ignoredContracts.includes(contract))
const visited: Set<string> = new Set(queue)
Expand Down
20 changes: 12 additions & 8 deletions packages/protocol/scripts/truffle/verify-bytecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ import fs = require('fs')
* proposal description.
*
* Expects the following flags:
* build_artifacts: The directory in which smart contract build artifacts can
* be found.
* proposal (optional): The JSON file containing a Governance proposal that
* --build_artifacts: The directory in which smart contract build artifacts
* can be found (defaults to ./build/contracts/)
* --proposal: The JSON file containing a Governance proposal that
* repoints the Registry to newly deployed Proxies and/or repoints existing
* Proxies to new implementation addresses.
* before_release_1 (optional): a temporary feature flag needed before the
* first contracts upgrades establishes new conventions around how smart
* contracts are handled on chain. Specifically, after the first release,
* linked libraries will be proxied, so libraries before this release have to
* be handled differently by this script.
* --before_release_1: a temporary feature flag needed before the first
* contracts upgrade establishes new conventions around how smart contracts
* are handled on chain. Specifically, after the first release, linked
* libraries will be proxied, so libraries before this release have to be
* handled differently by this script.
* TODO: remove --before_release_1 after the first release
*
* Run using truffle exec, e.g.:
* truffle exec scripts/truffle/verify-bytecode \
Expand Down Expand Up @@ -54,6 +55,9 @@ module.exports = async (callback: (error?: any) => number) => {
web3,
beforeRelease1
)

// tslint:disable-next-line: no-console
console.log('Success, no bytecode mismatches found!')
} catch (error) {
callback(error)
}
Expand Down