-
Notifications
You must be signed in to change notification settings - Fork 135
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
feat(ethportal-api): add BeaconState
type
#1150
Conversation
89ea6ea
to
73241e8
Compare
cae5d3e
to
f104d1f
Compare
BeaconState
typeBeaconState
type
f104d1f
to
9dddd60
Compare
I think these test files should go in portal-test-specs. |
Hmm, not sure, those are test assets for ethereum beacon network, not related to portal network specs. |
The repo is just has spec in the name because of convention ( So the general direction should be a migration from |
Those test files are extracted from Those files here are used for testing serialization/deserialization for the
I don't think this is true. If we just want to have a repo for storing large files for testing in trin, it should be called @njgheorghita, @morph-dev what do you think? |
I'm not sure I have enough knowledge of beacon network and these files to provide opinion on this specific case. I'm also missing broader context of what My feeling is that I also believe that we probably have some files in |
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.
A few questions about automatically deriving traits, just to double check that there's a good reason for manually implementing them, rather than automatically deriving them.
With regards to the test assets location...
I also don't have a clear understanding of the spec repo's defined purpose.
- Is it strictly for client-agnostic json test vectors for clients to test against?
or...
- Is it a dump for all large test files b/c we don't want to increase the size of
trin
?
This is probably something that needs defining, and inscribing in the readme's, so we don't have to repeat this debate for every future test vector. For the purpose of this pr, I think it's ok to move ahead as-is (eg. test files inside trin
). Let's discuss this in the next sync, figure out how we want to define what test assets go where. And then if we do decide that these test vectors are better suited in the specs repo, then we can make that change later.
use tree_hash::{Hash256, PackedEncoding, TreeHash, TreeHashType}; | ||
|
||
#[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize)] | ||
#[serde(transparent)] |
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.
Can you add a docstring here
@@ -0,0 +1,312 @@ | |||
#[cfg(test)] |
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.
?
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 reasoning as this comment .
use std::sync::Arc; | ||
use superstruct::superstruct; | ||
use tree_hash::{Hash256, TreeHash}; | ||
use tree_hash_derive::TreeHash; |
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.
Don't we have a clippy lint for ordering imports into groups? eg. std
first, exterior second, internal third
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 what ordering we use but this can be changed in the config. I think now it is internal first, std next and external latest.
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.
Based on the rustfmt
documentation, the default is (what we use) to preserve the source file's import groups.
Alternative, which we could enable, is closer to what @njgheorghita said:
std
,core
andalloc
,- external crates,
self
,super
andcrate
imports.
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 that would be nice to enable in the lint, since it is what we use throughout the majority of the codebase
} | ||
|
||
impl BeaconState { | ||
#[cfg(test)] |
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.
Really? Why do we only want to ssz decode the state inside our tests? Is this to avoid the dead_code
lint? If so, then I'd prefer to use allow[clippy::dead_code]
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.
yes, it is to avoid the dead_code
lint. I prefer this because that way we will not forget to remove the dead code attribute if it is not used.
Anyways, in #1167 I'm removing this.
9dddd60
to
8c1efb8
Compare
8c1efb8
to
7887212
Compare
What was wrong?
To add support for Era files, we need to deserialize the beacon state. No
BeaconState
type is available inethportal-api
.How was it fixed?
Implement
BeaconState
typeTo-Do