raiden-network / raiden-contracts

Raiden Network Smart Contracts
MIT License
53 stars 45 forks source link

Improve package release of deliverables - security #355

Open loredanacirstea opened 5 years ago

loredanacirstea commented 5 years ago

Our current development & release process is:

We can see that there are ways to fail in the above process - e.g. forgetting that we changed the source code and releasing a package without updating the deployment addresses. Also, always having to change the compiled data for each source code changing PRs is not that clean in my opinion.

I am proposing some changes:

pirapira commented 5 years ago

I'm not seeing the big picture.

How does the Python codebase specify the expected contract version(s)? By the hash of the deployed code? By a commit id in GitHub? By an address and a chain_id?

When are the contracts checked against the expectation? During the packaging of Raiden clients? At runtime? Both?

loredanacirstea commented 5 years ago

We have a:

When are the contracts checked against the expectation? During the packaging of Raiden clients? At runtime? Both?

So, currently:

pirapira commented 5 years ago

Consider using the metadata info from Solidity. The deployed bytecode contains the keccack hash of this metadata at the end. The onchain metadata hash changes whenever the Solidity source or the compiler binary changes. Web3 exposes an interface for checking the code of an address.

The metadata hash can be found on chain like this:

The current version of the Solidity compiler thus adds the following to the end of the deployed bytecode: 0xa1 0x65 'b' 'z' 'z' 'r' '0' 0x58 0x20 <32 bytes swarm hash> 0x00 0x29

pirapira commented 5 years ago

Should a package release also contain deployment_mainnet.json and its siblings? Should the release happen before the deployment or after the deployment?

Maybe the first step is to document the current release process. I can try to follow the draft, and you'll notice I'm doing something wrong, and you can fix the draft, and so on.

loredanacirstea commented 5 years ago

Should a package release also contain deployment_mainnet.json and its siblings?

The package release should contain deployment_mainnet.json and this should only contain the info for the contracts that are mainnet ready - in our case, only the core contracts (not services).

Should the release happen before the deployment or after the deployment?

After deployment, because it needs to contain the deployment addresses.

Maybe the first step is to document the current release process.

Agree. We should have this documented - maybe a Release.md file. In short, this is:

  1. create and verify that contracts.json file matches the current source code
  2. deploy contracts with our deployment scripts and verify them on etherscan (we have a script for this that needs improvements)
  3. Step 2 also creates the deployment_*.json files automatically & also verifies the correctness of the info against the chain.
  4. Commit, make a PR
  5. Push the release tag on master directly -> this triggers the package release in travis; at this point everything should be checked and verified already by the CI tests (compiled data from contracts.json) and the checks that we have in place (deployment info, checks are in the deployment scripts)