Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Chainspec validation #6197

Merged
merged 7 commits into from
Aug 2, 2017
Merged

Chainspec validation #6197

merged 7 commits into from
Aug 2, 2017

Conversation

debris
Copy link
Collaborator

@debris debris commented Jul 31, 2017

changes:

  • new executable which verifies chainspec json files
  • scrips/validate_chainspec.sh which validates our chainspecs
  • fixed invalid chainspecs

validate_chainspec.sh output looks like this:

ethcore/res/authority_round.json is valid
ethcore/res/basic_authority.json is valid
ethcore/res/constructor.json missing field `gasLimitBoundDivisor` at line 11 column 2
ethcore/res/instant_seal.json is valid
ethcore/res/null.json is valid
ethcore/res/null_morden.json is valid
ethcore/res/tendermint.json is valid
ethcore/res/validator_contract.json is valid
ethcore/res/validator_multi.json is valid
ethcore/res/validator_safe_contract.json unexpected field `engine.?.params.gasLimitBoundDivisor`
ethcore/res/validator_safe_contract.json unexpected field `engine.?.params.gasLimitBoundDivisor2`
ethcore/res/ethereum/classic.json is valid
ethcore/res/ethereum/eip150_test.json is valid
ethcore/res/ethereum/eip161_test.json is valid
ethcore/res/ethereum/expanse.json is valid
ethcore/res/ethereum/foundation.json is valid
ethcore/res/ethereum/frontier_like_test.json is valid
ethcore/res/ethereum/frontier_test.json is valid
ethcore/res/ethereum/homestead_test.json is valid
ethcore/res/ethereum/kovan.json is valid
ethcore/res/ethereum/metropolis_test.json is valid
ethcore/res/ethereum/morden.json is valid
ethcore/res/ethereum/olympic.json is valid
ethcore/res/ethereum/ropsten.json is valid
ethcore/res/ethereum/transition_test.json is valid

@debris debris requested review from rphmeier and eira-fransham July 31, 2017 16:06
@debris debris added A0-pleasereview 🤓 Pull request needs code review. M1-ci 🙉 Continuous integration. M4-core ⛓ Core client code / Rust. labels Jul 31, 2017
@debris
Copy link
Collaborator Author

debris commented Jul 31, 2017

According to gitlab, rust job succeeded. It was just not reported here

ERR=0
cargo build --release -p chainspec

for spec in `ls ethcore/res/*.json`; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary ls, just do for spec in path/to/dir/*; do. Iterating over ls output is unstable anyway. Also, backticks are deprecated and also smell and are bad.

Hey, instead of me telling you this stuff, go install Shellcheck since I think both of those notes are implemented as lints.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! I will check it out :D

use std::{fs, env, process};
use ethjson::spec::Spec;

fn quit<S: AsRef<str>>(s: S) -> ! {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that Foo: AsRef<Bar> as a type parameter is unnecessary because of Rust's automatic coercion (for example, foo(&bar) will succeed if foo takes a &T and bar implements AsRef<T>). I think I've made this same mistake in my latest PR with AsRef<Path>. So this could just take &str with the same API.

Copy link
Contributor

@eira-fransham eira-fransham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got some nits but I'd be happy with this being merged. You can fix them up if you like, but it's not a problem.

@arkpar
Copy link
Collaborator

arkpar commented Aug 1, 2017

But we already have a unit test that does that. See #6028

@debris
Copy link
Collaborator Author

debris commented Aug 1, 2017

So there are few reasons to actually have chainspec executable:

  1. currently there is no way to validate a json file which is not a part of parity repo. I needed this
  2. unused fields are not checked
  3. currently not every json file in ethcore/res/ and ethcore/res/ethereum/ is checked and we have to remember to update the test if we add new spec

2 && 3 can be addressed with improved unit tests, but 1 not

@debris
Copy link
Collaborator Author

debris commented Aug 2, 2017

@arkpar I removed existing tests

@arkpar arkpar added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Aug 2, 2017
@arkpar arkpar merged commit 0c7c34e into master Aug 2, 2017
@arkpar arkpar deleted the chainspec branch August 2, 2017 10:50
@rphmeier
Copy link
Contributor

rphmeier commented Aug 2, 2017

Agreed with @debris on this -- the broken chainspecs in the repo were all not covered by the tests when I made my PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M1-ci 🙉 Continuous integration. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants