[beta] Backporting (#6352)
* Better check the created accounts before showing Startup Wizard * Tweaked snapshot params
This commit is contained in:
parent
7bf840f80a
commit
f90bdcd1e5
@ -62,6 +62,6 @@ impl Engine for NullEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_components(&self) -> Option<Box<::snapshot::SnapshotComponents>> {
|
fn snapshot_components(&self) -> Option<Box<::snapshot::SnapshotComponents>> {
|
||||||
Some(Box::new(::snapshot::PowSnapshot(10000)))
|
Some(Box::new(::snapshot::PowSnapshot::new(10000, 10000)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,10 @@ pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]);
|
|||||||
|
|
||||||
/// Number of blocks in an ethash snapshot.
|
/// Number of blocks in an ethash snapshot.
|
||||||
// make dependent on difficulty incrment divisor?
|
// make dependent on difficulty incrment divisor?
|
||||||
const SNAPSHOT_BLOCKS: u64 = 30000;
|
const SNAPSHOT_BLOCKS: u64 = 5000;
|
||||||
|
/// Maximum number of blocks allowed in an ethash snapshot.
|
||||||
|
const MAX_SNAPSHOT_BLOCKS: u64 = 30000;
|
||||||
|
|
||||||
|
|
||||||
/// Ethash params.
|
/// Ethash params.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@ -416,7 +419,7 @@ impl Engine for Arc<Ethash> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_components(&self) -> Option<Box<::snapshot::SnapshotComponents>> {
|
fn snapshot_components(&self) -> Option<Box<::snapshot::SnapshotComponents>> {
|
||||||
Some(Box::new(::snapshot::PowSnapshot(SNAPSHOT_BLOCKS)))
|
Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,11 +37,24 @@ use rand::OsRng;
|
|||||||
/// Snapshot creation and restoration for PoW chains.
|
/// Snapshot creation and restoration for PoW chains.
|
||||||
/// This includes blocks from the head of the chain as a
|
/// This includes blocks from the head of the chain as a
|
||||||
/// loose assurance that the chain is valid.
|
/// loose assurance that the chain is valid.
|
||||||
///
|
|
||||||
/// The field is the number of blocks from the head of the chain
|
|
||||||
/// to include in the snapshot.
|
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub struct PowSnapshot(pub u64);
|
pub struct PowSnapshot {
|
||||||
|
/// Number of blocks from the head of the chain
|
||||||
|
/// to include in the snapshot.
|
||||||
|
pub blocks: u64,
|
||||||
|
/// Number of to allow in the snapshot when restoring.
|
||||||
|
pub max_restore_blocks: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PowSnapshot {
|
||||||
|
/// Create a new instance.
|
||||||
|
pub fn new(blocks: u64, max_restore_blocks: u64) -> PowSnapshot {
|
||||||
|
PowSnapshot {
|
||||||
|
blocks: blocks,
|
||||||
|
max_restore_blocks: max_restore_blocks,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SnapshotComponents for PowSnapshot {
|
impl SnapshotComponents for PowSnapshot {
|
||||||
fn chunk_all(
|
fn chunk_all(
|
||||||
@ -57,7 +70,7 @@ impl SnapshotComponents for PowSnapshot {
|
|||||||
current_hash: block_at,
|
current_hash: block_at,
|
||||||
writer: chunk_sink,
|
writer: chunk_sink,
|
||||||
preferred_size: preferred_size,
|
preferred_size: preferred_size,
|
||||||
}.chunk_all(self.0)
|
}.chunk_all(self.blocks)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rebuilder(
|
fn rebuilder(
|
||||||
@ -66,7 +79,7 @@ impl SnapshotComponents for PowSnapshot {
|
|||||||
db: Arc<KeyValueDB>,
|
db: Arc<KeyValueDB>,
|
||||||
manifest: &ManifestData,
|
manifest: &ManifestData,
|
||||||
) -> Result<Box<Rebuilder>, ::error::Error> {
|
) -> Result<Box<Rebuilder>, ::error::Error> {
|
||||||
PowRebuilder::new(chain, db, manifest, self.0).map(|r| Box::new(r) as Box<_>)
|
PowRebuilder::new(chain, db, manifest, self.max_restore_blocks).map(|r| Box::new(r) as Box<_>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn min_supported_version(&self) -> u64 { ::snapshot::MIN_SUPPORTED_STATE_CHUNK_VERSION }
|
fn min_supported_version(&self) -> u64 { ::snapshot::MIN_SUPPORTED_STATE_CHUNK_VERSION }
|
||||||
@ -218,7 +231,7 @@ impl Rebuilder for PowRebuilder {
|
|||||||
trace!(target: "snapshot", "restoring block chunk with {} blocks.", item_count - 3);
|
trace!(target: "snapshot", "restoring block chunk with {} blocks.", item_count - 3);
|
||||||
|
|
||||||
if self.fed_blocks + num_blocks > self.snapshot_blocks {
|
if self.fed_blocks + num_blocks > self.snapshot_blocks {
|
||||||
return Err(Error::TooManyBlocks(self.snapshot_blocks, self.fed_blocks).into())
|
return Err(Error::TooManyBlocks(self.snapshot_blocks, self.fed_blocks + num_blocks).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: assert here that these values are consistent with chunks being in order.
|
// todo: assert here that these values are consistent with chunks being in order.
|
||||||
|
@ -30,7 +30,7 @@ use util::kvdb::{self, KeyValueDB, DBTransaction};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
|
|
||||||
const SNAPSHOT_MODE: ::snapshot::PowSnapshot = ::snapshot::PowSnapshot(30000);
|
const SNAPSHOT_MODE: ::snapshot::PowSnapshot = ::snapshot::PowSnapshot { blocks: 30000, max_restore_blocks: 30000 };
|
||||||
|
|
||||||
fn chunk_and_restore(amount: u64) {
|
fn chunk_and_restore(amount: u64) {
|
||||||
let mut canon_chain = ChainGenerator::default();
|
let mut canon_chain = ChainGenerator::default();
|
||||||
|
@ -28,11 +28,18 @@ export default class Store {
|
|||||||
this._migrateStore();
|
this._migrateStore();
|
||||||
|
|
||||||
this._api = api;
|
this._api = api;
|
||||||
// Show the first run if it hasn't been shown before
|
|
||||||
// (thus an undefined value)
|
|
||||||
this.firstrunVisible = store.get(LS_FIRST_RUN_KEY) === undefined;
|
|
||||||
|
|
||||||
this._checkAccounts();
|
// Show the first run the storage doesn't hold `false` value
|
||||||
|
const firstrunVisible = store.get(LS_FIRST_RUN_KEY) !== false;
|
||||||
|
|
||||||
|
// Only check accounts if we might show the first run
|
||||||
|
if (firstrunVisible) {
|
||||||
|
api.transport.once('open', () => {
|
||||||
|
this._checkAccounts();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.firstrunVisible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@action closeFirstrun = () => {
|
@action closeFirstrun = () => {
|
||||||
@ -50,7 +57,7 @@ export default class Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migrate the old LocalStorage ket format
|
* Migrate the old LocalStorage key format
|
||||||
* to the new one
|
* to the new one
|
||||||
*/
|
*/
|
||||||
_migrateStore () {
|
_migrateStore () {
|
||||||
@ -70,12 +77,16 @@ export default class Store {
|
|||||||
this._api.parity.allAccountsInfo()
|
this._api.parity.allAccountsInfo()
|
||||||
])
|
])
|
||||||
.then(([ vaults, info ]) => {
|
.then(([ vaults, info ]) => {
|
||||||
const accounts = Object.keys(info).filter((address) => info[address].uuid);
|
const accounts = Object.keys(info)
|
||||||
|
.filter((address) => info[address].uuid)
|
||||||
|
// In DEV mode, the empty phrase account is already added
|
||||||
|
.filter((address) => address.toLowerCase() !== '0x00a329c0648769a73afac7f9381e08fb43dbea72');
|
||||||
|
|
||||||
// Has accounts if any vaults or accounts
|
// Has accounts if any vaults or accounts
|
||||||
const hasAccounts = (accounts && accounts.length > 0) || (vaults && vaults.length > 0);
|
const hasAccounts = (accounts && accounts.length > 0) || (vaults && vaults.length > 0);
|
||||||
|
|
||||||
// Show First Run if no accounts and no vaults
|
// Show First Run if no accounts and no vaults
|
||||||
this.toggleFirstrun(this.firstrunVisible || !hasAccounts);
|
this.toggleFirstrun(!hasAccounts);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('checkAccounts', error);
|
console.error('checkAccounts', error);
|
||||||
|
@ -56,7 +56,7 @@ use signer;
|
|||||||
use url;
|
use url;
|
||||||
|
|
||||||
// how often to take periodic snapshots.
|
// how often to take periodic snapshots.
|
||||||
const SNAPSHOT_PERIOD: u64 = 10000;
|
const SNAPSHOT_PERIOD: u64 = 5000;
|
||||||
|
|
||||||
// how many blocks to wait before starting a periodic snapshot.
|
// how many blocks to wait before starting a periodic snapshot.
|
||||||
const SNAPSHOT_HISTORY: u64 = 100;
|
const SNAPSHOT_HISTORY: u64 = 100;
|
||||||
|
@ -131,7 +131,7 @@ const MAX_TRANSACTION_PACKET_SIZE: usize = 8 * 1024 * 1024;
|
|||||||
// Maximal number of transactions in sent in single packet.
|
// Maximal number of transactions in sent in single packet.
|
||||||
const MAX_TRANSACTIONS_TO_PROPAGATE: usize = 64;
|
const MAX_TRANSACTIONS_TO_PROPAGATE: usize = 64;
|
||||||
// Min number of blocks to be behind for a snapshot sync
|
// Min number of blocks to be behind for a snapshot sync
|
||||||
const SNAPSHOT_RESTORE_THRESHOLD: BlockNumber = 100000;
|
const SNAPSHOT_RESTORE_THRESHOLD: BlockNumber = 10000;
|
||||||
const SNAPSHOT_MIN_PEERS: usize = 3;
|
const SNAPSHOT_MIN_PEERS: usize = 3;
|
||||||
|
|
||||||
const STATUS_PACKET: u8 = 0x00;
|
const STATUS_PACKET: u8 = 0x00;
|
||||||
|
Loading…
Reference in New Issue
Block a user