-
Notifications
You must be signed in to change notification settings - Fork 322
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
Genesis schema #469
Genesis schema #469
Conversation
@ehildenb is this not blocked anymore? |
@pirapira I was hoping for some feedback from @winsvega and @arnetheduck on this issue, as they proposed having the schema in the AllCoreDevs meeting. If we want to merge anyway and fix the schema later, that's also fine with me. |
@pirapira I need to make a few more changes before this is ready, will let you know when. |
JSONSchema/genesis-schema.json
Outdated
"additionalProperties": false, | ||
"properties": { | ||
"author": { | ||
"$ref": "#/definitions/HexData" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
author is a hex address representation it hsouldbe a valid address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No comment. Only say happy new year Github. Thanks you very much.
should this script also check the possible range of the field or just the type of the field? |
Blocking this for #472. |
@winsvega I've changed the field "author" to be a Also, I've moved the file to I've updated the |
Just for the record, I'm not really involved with this issue, other than as a happy consumer (great to see this work!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start! A few comments ...
"balance", | ||
"code", | ||
"nonce", | ||
"storage" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I think storage should be required. Actually, I would prefer if all these four are optional, and defaults to 0
(balance, nonce) or empty
(code, storage).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can assert anything about the actual value held, just the JSON structure. I could be wrong though, have not read on JSON schemas, just learned by examples.
I'll make these not required.
"byzantiumForkBlock", | ||
"chainID", | ||
"constantinopleForkBlock", | ||
"homesteadForkBlock", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for these -- if we make these required, we'll have to update the genesis spec to make future fork blocks also required -- otherwise it'll be inconsistent. So I would instead say that all forkblocks are implicitly maxUint64
unless otherwise specified. Don't know how to express that in json spec though...
A wild idea would be to have a separate section for those: params/forks/xxx
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'll make these not required for now...
"constantinopleForkBlock": { | ||
"$ref": "#/definitions/IntegerOrConfusedHex" | ||
}, | ||
"homesteadForkBlock": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have the daoForkBlock
"nonce": { | ||
"$ref": "#/definitions/IntegerOrConfusedHex" | ||
}, | ||
"timestamp": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make sense to add an optional number
or blockNumber
to the genesis. Particularly if we want to go with EIP 210, blockhash, it will be good to run tests on high numbered blocks.
@holiman I've incorporated your suggestions. One thing I wasn't sure about was whether you meant for Let me know what else should be changed. If you can provide an example of a filled test as well, I can write the schema for that. |
Well, I don't have any clear opinion about those. |
@@ -59,6 +59,20 @@ | |||
}, | |||
"type": "object" | |||
}, | |||
"FillerInfo": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a test filler _info or a genesis json _info ?
a filled test _info has more fields that are required.
a filler test _info has only comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should version the fillers? I think it would be a good idea to start doing that (so that we can add a test like "all the fillers have been updated to the newest version").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean filler format version?
stateTest -> GeneralStateTest
not so many people used fillers. there has been no need to track test filler format as only me and Yoichi used it. ideally yes. test fillers could be versioned and we could have a documentation stating what are the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think for new formats (ie. Genesis) we should try for the "ideal" case. So I think the fillers should be versioned, and the filled should have hashes for the sources.
It will just make it easier to identify which fillers/filled need updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filled tests already has hash of the filler.
if there is going to be a vesrion of the filler format. that version would be different from genesis format version. I think we need different scheme validators here. if it is possible to split json validation into separate groups that would be great.
} | ||
] | ||
}, | ||
"PreStateAccount": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if its a preState account in tests then all fields are required.
if its a prestate account in Genesis then it has different scheme:
if (_obj.count(c_precompiled))
{
// A precompiled contract
requireJsonFields(_obj, "validateAccountObj",
{{c_precompiled, {{js::obj_type}, JsonFieldPresence::Required}},
{c_wei, {{js::str_type}, JsonFieldPresence::Optional}}});
}
else if (_obj.size() == 1)
{
// A genesis account with only balance set
if (_obj.count(c_balance))
requireJsonFields(_obj, "validateAccountObj",
{{c_balance, {{js::str_type}, JsonFieldPresence::Required}}});
else
requireJsonFields(_obj, "validateAccountObj",
{{c_wei, {{js::str_type}, JsonFieldPresence::Required}}});
}
so it could have only balance defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@winsvega not sure what you're suggesting here. Currently none of the fields in PreStateAccount
are required, are you saying we should require balance
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm. thats a good question. I think we should require balance.
account nonce is default. account code empty by default. same with storage.
but if we not declare any fields then what is the meaning of putting account into genesis?
"^.*$": { | ||
"properties": { | ||
"_info": { | ||
"$ref": "#/definitions/FillerInfo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a filler info then. its an info section of genesis.json
_ is added because json lib put _ first in a json.
the section could have version field so we have an idea what sheme version we are dealing with
"additionalProperties": false, | ||
"patternProperties": { | ||
"^(0x)?[0-9a-f]*": { | ||
"$ref": "#/definitions/PreStateAccount", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again a genesis pre state account are different from tests pre state accounts.
genesis account could have only one field - balance. or all 4 standart fields. or if we change the format in the future it might change.
"additionalProperties": false, | ||
"properties": { | ||
"author": { | ||
"$ref": "#/definitions/AddressMaybePrefixOrEmpty" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a question.
author field in genesis should not be empty I think.
and we should agree whether we use 0x prefix or not.
@winsvega I've tried incorporating your comments, but may have messed some things up, so take another look. I would recommend looking through the changes with I think we should require a |
changing the test fillers would require to regenerate all the tests at the current model. as tests has the hash of the test filler. or we could just copy the hash with a tool without generating a tests. but this should be done in a way that we promise that test itself has not been touched. I think filler _info section is another issue. here I see the mess around json scheme validators. it is easy to mix a validator with some other test field. like _info at genesis and _info at test filler and _info at filled test. |
src/GenesisTestsFiller/dummy.json
Outdated
@@ -1,6 +1,7 @@ | |||
{ | |||
"dummy_test": { | |||
"GenesisFillerTemplate": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenesisExampleTemplate
src/GenesisTestsFiller/dummy.json
Outdated
@@ -33,6 +31,7 @@ | |||
"byzantiumForkBlock": "0x00", | |||
"chainID": "0x01", | |||
"constantinopleForkBlock": "0x00", | |||
"daoForkBlock": "0x00", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this fields are not required, what is the default value? thats important cause some client has it set to 0x00 and other to infinity.
also the names of the fields are important issue here. Parity has EIP155.
are devs agreed to use homesteadForkBlock, byzantiumForkBlock, EIP158ForkBlock for the fork names?
With the version number, it's more about being able to have a script which cycles through the test fillers and makes sure they are all bigger than a certain version number. That way, if we update the format at some point, it's easy to enforce that all the test fillers have been updated (either programmatically or by hand). Either way, I think we should focus on "best practices" or the "ideal case" with any new test formats, so we don't end up in the same mess again. I can slowly work on making the old test-sets more conformant, so we have less of the stuff like |
It is not that we change the test filler format so often... |
It's more about best practices and future proofing than anything. I would like to begin evolving the VMTests format to make them simpler, for example, and it would be easier with versioning in place. It won't always be us in charge of this repository, eventually someone will have to inherit it, and having versioning in place makes that process easier (as they will inevitably want to change things). |
VMTests you could take and experement with. |
Regarding fork numbers and names. I think we could come to agreement about their names, if it's |
@winsvega I have removed @holiman I think I have implemented the change you are indicating with the hardfork numbers. The last commit (marked Anything else that should be changed? Can someone supply me with an example Filled GenesisTest so I can write the schema for that? |
I've also pushed a new commit (latest one marked That way the clients can have more limited code for reading in the test-sets instead of having to have lots of branches for the potential different ways that keys/values can be passed in. |
version field being required in genesis schema is ok |
…r testing Genesis Filler
I have added some initial genesis test templates at Someone should look over and let me know what needs to change, I'll adopt the templates in there to conform to the schema/update the schema a bit more this week. |
travis check fails. |
https://github.com/ehildenb/ethereum-tests/blob/4e24d411d67cde54bd1343501b6468a3d4f1489e/GenesisTests/basic_genesis_tests.json |
Initial attempt at a Genesis test schema. The example from ethereum/EIPs#1085 is at
GenesisTests/dummy.json
, and is passing the schema atJSONSchema/genesis-schema.json
.@winsvega and @arnetheduck