-
Notifications
You must be signed in to change notification settings - Fork 1.7k
get rid of hidden mutability of Spec #10904
Conversation
genesis_state: self.genesis_state.clone(), | ||
} | ||
} | ||
} | ||
|
||
/// Part of `Spec`. Describes the hardcoded synchronization parameters. | ||
#[derive(Debug, Clone)] |
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.
Clone
replaces impl Clone
bolierplate.
Debug
is has replaced to_json
which was used to print this structure
&Default::default(), | ||
BasicBackend(journaldb::new_memory_db()), | ||
)?; | ||
|
||
self.state_root_memo = root; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by running constructors always before Spec
is created, we ensure that spec_root_memo
is always correct
#[serde(deny_unknown_fields)] | ||
#[serde(rename_all = "camelCase")] | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be Bytes
, not String
. Someone did it out of laziness and, because of that we had to deal unparsed string in ethcore
@@ -68,7 +68,6 @@ fn make_spec(chain: &BlockChain) -> Spec { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's always valid now
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
db | ||
)?; | ||
|
||
assert_eq!(root, self.state_root(), "Spec's state root has not been precomputed correctly."); |
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 it safe / expected to panic here?
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, 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_memo
fromRwLock<H256>
toH256
SpecHardcodedSync
is being deserialized from json and printed