get rid of hidden mutability of Spec#10904
Conversation
| } | ||
|
|
||
| /// Part of `Spec`. Describes the hardcoded synchronization parameters. | ||
| #[derive(Debug, Clone)] |
There was a problem hiding this comment.
Clone replaces impl Clone bolierplate.
Debug is has replaced to_json which was used to print this structure
| BasicBackend(journaldb::new_memory_db()), | ||
| )?; | ||
|
|
||
| self.state_root_memo = root; |
There was a problem hiding this comment.
run_constructors no longer mutates self.state_root_memo, so we need to set the root manutally
| .collect(); | ||
| let genesis_state: PodState = s.accounts.into(); | ||
|
|
||
| let (state_root_memo, _) = run_constructors( |
There was a problem hiding this comment.
by running constructors always before Spec is created, we ensure that spec_root_memo is always correct
| pub struct HardcodedSync { | ||
| /// Hexadecimal of the RLP encoding of the header of the block to start synchronization from. | ||
| pub header: String, | ||
| pub header: Bytes, |
There was a problem hiding this comment.
it should be Bytes, not String. Someone did it out of laziness and, because of that we had to deal unparsed string in ethcore
| let state = chain.pre_state.clone().into(); | ||
| spec.set_genesis_state(state).expect("unable to set genesis state"); | ||
| spec.overwrite_genesis_params(genesis); | ||
| assert!(spec.is_state_root_valid()); |
There was a problem hiding this comment.
it's always valid now
| db | ||
| )?; | ||
|
|
||
| assert_eq!(root, self.state_root(), "Spec's state root has not been precomputed correctly."); |
There was a problem hiding this comment.
Is it safe / expected to panic here?
There was a problem hiding this comment.
yes, cause self.state_root() is always created during init with the same constructors
* master: journaldb changes (#10929) Allow default block parameter to be blockHash (#10932) Enable sealing when engine is ready (#10938) Fix some warnings and typos. (#10941) Updated security@parity.io key (#10939) Change the return type of step_inner function. (#10940) get rid of hidden mutability of Spec (#10904) simplify BlockReward::reward implementation (#10906) Kaspersky AV whitelisting (#10919) additional arithmetic EVM opcode benchmarks (#10916) [Cargo.lock] cargo update -p crossbeam-epoch (#10921) Fixes incorrect comment. (#10913) Add file path to disk map write/read warnings (#10911)
changes in this pr:
Spec::state_root_memofromRwLock<H256>toH256SpecHardcodedSyncis being deserialized from json and printed