Skip to content

Commit

Permalink
Add positive output to the verify-bytecodes script (#5398)
Browse files Browse the repository at this point in the history
### Description

Previously the script would just exit with code 0 and no stdout output about success. Added logs reporting which contracts have been checked and at which address on the network.

Added a `--quiet` flag to optionally suppress this new output (`-q` in the bash wrapper).

### Other changes

`getImplementationAddress` was previously returning pre-release 1 library addresses without a "0x" prefix, fixed this for consistency in logs.

Improved the documentation comment in `verify-bytecodes.ts`.

### Tested

`yarn verify-bytecodes -b rc1 -n rc1 -r -f` succeeds outputs the new logs. Adding `-q` still succeeds and suppresses output.

### Related issues

- Part of #4812 

### Backwards compatibility

Only cosmetic script change.
  • Loading branch information
m-chrzan authored Oct 16, 2020
1 parent baa87a0 commit ace4af2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
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

0 comments on commit ace4af2

Please sign in to comment.