epoch generation proof fixes
This commit is contained in:
parent
023c45f302
commit
7ab92f0807
@ -256,10 +256,8 @@ impl Client {
|
|||||||
|
|
||||||
// ensure genesis epoch proof in the DB.
|
// ensure genesis epoch proof in the DB.
|
||||||
{
|
{
|
||||||
let mut batch = DBTransaction::new();
|
|
||||||
let chain = client.chain.read();
|
let chain = client.chain.read();
|
||||||
client.generate_epoch_proof(&mut batch, &spec.genesis_header(), 0, &*chain);
|
client.generate_epoch_proof(&spec.genesis_header(), 0, &*chain);
|
||||||
client.db.read().write_buffered(batch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(reg_addr) = client.additional_params().get("registrar").and_then(|s| Address::from_str(s).ok()) {
|
if let Some(reg_addr) = client.additional_params().get("registrar").and_then(|s| Address::from_str(s).ok()) {
|
||||||
@ -611,10 +609,6 @@ impl Client {
|
|||||||
state.journal_under(&mut batch, number, hash).expect("DB commit failed");
|
state.journal_under(&mut batch, number, hash).expect("DB commit failed");
|
||||||
let route = chain.insert_block(&mut batch, block_data, receipts);
|
let route = chain.insert_block(&mut batch, block_data, receipts);
|
||||||
|
|
||||||
if let Some((header, epoch)) = entering_new_epoch {
|
|
||||||
self.generate_epoch_proof(&mut batch, &header, epoch, &chain);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.tracedb.read().import(&mut batch, TraceImportRequest {
|
self.tracedb.read().import(&mut batch, TraceImportRequest {
|
||||||
traces: traces.into(),
|
traces: traces.into(),
|
||||||
block_hash: hash.clone(),
|
block_hash: hash.clone(),
|
||||||
@ -634,14 +628,19 @@ impl Client {
|
|||||||
warn!("Failed to prune ancient state data: {}", e);
|
warn!("Failed to prune ancient state data: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some((header, epoch)) = entering_new_epoch {
|
||||||
|
self.generate_epoch_proof(&header, epoch, &chain);
|
||||||
|
}
|
||||||
|
|
||||||
route
|
route
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate an epoch transition proof at the given block, and write it into the given blockchain.
|
// generate an epoch transition proof at the given block, and write it into the given blockchain.
|
||||||
fn generate_epoch_proof(&self, batch: &mut DBTransaction, header: &Header, epoch_number: u64, chain: &BlockChain) {
|
fn generate_epoch_proof(&self, header: &Header, epoch_number: u64, chain: &BlockChain) {
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
|
let mut batch = DBTransaction::new();
|
||||||
let hash = header.hash();
|
let hash = header.hash();
|
||||||
debug!(target: "client", "Generating validation proof for block {}", hash);
|
debug!(target: "client", "Generating validation proof for block {}", hash);
|
||||||
|
|
||||||
@ -664,13 +663,16 @@ impl Client {
|
|||||||
|
|
||||||
// insert into database, using the generated proof.
|
// insert into database, using the generated proof.
|
||||||
match proof {
|
match proof {
|
||||||
Ok(proof) =>
|
Ok(proof) => {
|
||||||
chain.insert_epoch_transition(batch, epoch_number, EpochTransition {
|
chain.insert_epoch_transition(&mut batch, epoch_number, EpochTransition {
|
||||||
block_hash: hash.clone(),
|
block_hash: hash.clone(),
|
||||||
block_number: header.number(),
|
block_number: header.number(),
|
||||||
proof: proof,
|
proof: proof,
|
||||||
state_proof: read_values.into_inner().into_iter().collect(),
|
state_proof: read_values.into_inner().into_iter().collect(),
|
||||||
}),
|
});
|
||||||
|
|
||||||
|
self.db.read().write_buffered(batch);
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!(target: "client", "Error generating epoch change proof for block {}: {}", hash, e);
|
warn!(target: "client", "Error generating epoch change proof for block {}: {}", hash, e);
|
||||||
warn!(target: "client", "Snapshots generated by this node will be incomplete.");
|
warn!(target: "client", "Snapshots generated by this node will be incomplete.");
|
||||||
|
@ -170,8 +170,8 @@ impl ValidatorSet for ValidatorSafeContract {
|
|||||||
Some(matched_event) => {
|
Some(matched_event) => {
|
||||||
// decode log manually until the native contract generator is
|
// decode log manually until the native contract generator is
|
||||||
// good enough to do it for us.
|
// good enough to do it for us.
|
||||||
let &(_, _, ref nonce_token) = &matched_event.params[2];
|
let &(_, _, ref nonce_token) = &matched_event.params[1];
|
||||||
let &(_, _, ref validators_token) = &matched_event.params[3];
|
let &(_, _, ref validators_token) = &matched_event.params[2];
|
||||||
|
|
||||||
let nonce: Option<U256> = nonce_token.clone().to_uint()
|
let nonce: Option<U256> = nonce_token.clone().to_uint()
|
||||||
.map(H256).map(Into::into);
|
.map(H256).map(Into::into);
|
||||||
|
Loading…
Reference in New Issue
Block a user