-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use serde_json to export hardcoded sync #11601
Use serde_json to export hardcoded sync #11601
Conversation
Example hardcoded sync generated with this commit:
|
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.
lgtm, thanks! :)
d6284dc
to
de9baca
Compare
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.
Looks good.
ethcore/spec/src/spec.rs
Outdated
impl Serialize for SpecHardcodedSync { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
let mut serialized = serializer.serialize_struct("SpecHardcodedSync", 3)?; | ||
|
||
let header_str = format!("{:x}", self.header); | ||
serialized.serialize_field("header", &header_str)?; | ||
|
||
let total_difficulty_str = format!("{:?}", self.total_difficulty); | ||
serialized.serialize_field("totalDifficulty", &total_difficulty_str)?; | ||
|
||
serialized.serialize_field("CHTs", &self.chts)?; | ||
serialized.end() | ||
} | ||
} |
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 would use a derived implementation for serde with custom attributes like
https://serde.rs/field-attrs.html#rename
https://serde.rs/field-attrs.html#serialize_with
as it's more future-proof e.g. when adding new fields.
But it'll probably be also more code, so it's fine as is.
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.
Ah good idea -- it didn't turn out to even be too much more code. Added in latest update
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.
Thank you for fixing this.
9448819
to
10d6ca7
Compare
The exported hardcoded sync was previously generating invalid JSON, with the CHT list ending in a trailing comma. In order to remedy this, this commit uses serde_json to serialize the SpecHardcodedSync struct into valid JSON. Fixes openethereum#11415
10d6ca7
to
c866ada
Compare
* master: (25 commits) Update .gitmodules (#11628) ethcore/res: activate ecip-1088 phoenix on classic (#11598) Upgrade parity-common deps to latest (#11620) Fix Goerli syncing (#11604) deps: switch to upstream ctrlc (#11617) Deduplicating crate dependencies (part 3 of n) (#11614) Deduplicating crate dependencies (part 2 of n, `slab`) (#11613) Actually save ENR on creation and modification (#11602) Activate POSDAO on xDai chain and update bootnodes (#11610) Activate on-chain randomness in POA Core (#11609) Deduplicating crate dependencies (part 1 of n) (#11606) Update enodes for POA Sokol (#11611) Remove .git folder from dogerignore file so vergen library can get build date and commit hash in the binary generatio vergen library can get build date and commit hash in the binary generation (#11608) Reduced gas cost for static calls made to precompiles EIP2046/1352 (#11583) [easy] `ethcore-bloom-journal` was renamed to `accounts-bloom` (#11605) Use serde_json to export hardcoded sync (#11601) Node Discovery v4 ENR Extension (EIP-868) (#11540) Fix compile warnings (#11595) Update version to 3.0.0-alpha.1 (#11592) ethcore/res: bump canon fork hash for mordor and kotti testnets (#11584) ...
The exported hardcoded sync was previously generating invalid JSON, with
the CHT list ending in a trailing comma. In order to remedy this, this
commit uses serde_json to serialize the SpecHardcodedSync struct
into valid JSON.
Fixes #11415