diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a01f9e005..26b1cc753 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -452,6 +452,7 @@ darwin: export COMMIT=$(git rev-parse HEAD) export PLATFORM=x86_64-apple-darwin rustup default stable + cargo clean cargo build -j 8 --features final --release #$CARGOFLAGS cargo build -j 8 --release -p ethstore-cli #$CARGOFLAGS cargo build -j 8 --release -p ethkey-cli #$CARGOFLAGS @@ -500,6 +501,7 @@ windows: - set RUST_BACKTRACE=1 - set RUSTFLAGS=%RUSTFLAGS% - rustup default stable-x86_64-pc-windows-msvc + - cargo clean - cargo build --features final --release #%CARGOFLAGS% - cargo build --release -p ethstore-cli #%CARGOFLAGS% - cargo build --release -p ethkey-cli #%CARGOFLAGS% diff --git a/Cargo.lock b/Cargo.lock index 8ecffa16f..63597b890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -317,7 +317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "elastic-array" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -635,7 +635,7 @@ version = "1.7.0" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "elastic-array 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)", "ethcore-bigint 0.1.3", @@ -2130,7 +2130,7 @@ name = "rlp" version = "0.2.0" dependencies = [ "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "elastic-array 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-bigint 0.1.3", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2951,7 +2951,7 @@ dependencies = [ "checksum docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab32ea6e284d87987066f21a9e809a73c14720571ef34516f0890b3d355ccfd8" "checksum dtoa 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5edd69c67b2f8e0911629b7e6b8a34cb3956613cd7c6e6414966dee349c2db4f" "checksum either 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2b503c86dad62aaf414ecf2b8c527439abedb3f8d812537f0b12bfd6f32a91" -"checksum elastic-array 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "561b1b1bb58e6d9212b75a28cca442f8a87cceb35cb1b6d6f39f5df5346a9160" +"checksum elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258ff6a9a94f648d0379dbd79110e057edbb53eb85cc237e33eadf8e5a30df85" "checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83" "checksum eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)" = "" "checksum ethabi 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "65f71b9ac0b0f8e6230d32dbf5acf7c2c61334af1148175d0a7e72b14c3d475e" diff --git a/ethcore/light/src/cht.rs b/ethcore/light/src/cht.rs index 91a5496f6..7f2ccc3a8 100644 --- a/ethcore/light/src/cht.rs +++ b/ethcore/light/src/cht.rs @@ -126,7 +126,7 @@ pub fn compute_root(cht_num: u64, iterable: I) -> Option let start_num = start_number(cht_num) as usize; for (i, (h, td)) in iterable.into_iter().take(SIZE as usize).enumerate() { - v.push((key!(i + start_num).to_vec(), val!(h, td).to_vec())) + v.push((key!(i + start_num).into_vec(), val!(h, td).into_vec())) } if v.len() == SIZE as usize { diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index 35e6d996c..eb70242de 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -388,7 +388,7 @@ impl HeaderChain { None => { match self.db.get(self.col, &hash) { Ok(db_value) => { - db_value.map(|x| x.to_vec()).map(encoded::Header::new) + db_value.map(|x| x.into_vec()).map(encoded::Header::new) .and_then(|header| { cache.insert_block_header(hash.clone(), header.clone()); Some(header) diff --git a/ethcore/light/src/net/tests/mod.rs b/ethcore/light/src/net/tests/mod.rs index a4c9754ba..ef86c08f5 100644 --- a/ethcore/light/src/net/tests/mod.rs +++ b/ethcore/light/src/net/tests/mod.rs @@ -137,7 +137,7 @@ impl Provider for TestProvider { fn storage_proof(&self, req: request::CompleteStorageRequest) -> Option { Some(StorageResponse { - proof: vec![::rlp::encode(&req.key_hash).to_vec()], + proof: vec![::rlp::encode(&req.key_hash).into_vec()], value: req.key_hash | req.address_hash, }) } diff --git a/ethcore/light/src/on_demand/request.rs b/ethcore/light/src/on_demand/request.rs index 3ad9a28d5..ea90fa97b 100644 --- a/ethcore/light/src/on_demand/request.rs +++ b/ethcore/light/src/on_demand/request.rs @@ -738,7 +738,7 @@ impl BlockReceipts { /// Check a response with receipts against the stored header. pub fn check_response(&self, cache: &Mutex<::cache::Cache>, receipts: &[Receipt]) -> Result, Error> { let receipts_root = self.0.as_ref()?.receipts_root(); - let found_root = ::util::triehash::ordered_trie_root(receipts.iter().map(|r| ::rlp::encode(r).to_vec())); + let found_root = ::util::triehash::ordered_trie_root(receipts.iter().map(|r| ::rlp::encode(r).into_vec())); match receipts_root == found_root { true => { @@ -902,7 +902,7 @@ mod tests { header.set_number(10_000); header.set_extra_data(b"test_header".to_vec()); let hash = header.hash(); - let raw_header = encoded::Header::new(::rlp::encode(&header).to_vec()); + let raw_header = encoded::Header::new(::rlp::encode(&header).into_vec()); let cache = Mutex::new(make_cache()); assert!(HeaderByHash(hash.into()).check_response(&cache, &hash.into(), &[raw_header]).is_ok()) @@ -916,10 +916,10 @@ mod tests { let mut body_stream = RlpStream::new_list(2); body_stream.begin_list(0).begin_list(0); - let req = Body(encoded::Header::new(::rlp::encode(&header).to_vec()).into()); + let req = Body(encoded::Header::new(::rlp::encode(&header).into_vec()).into()); let cache = Mutex::new(make_cache()); - let response = encoded::Body::new(body_stream.drain().to_vec()); + let response = encoded::Body::new(body_stream.drain().into_vec()); assert!(req.check_response(&cache, &response).is_ok()) } @@ -934,12 +934,12 @@ mod tests { let mut header = Header::new(); let receipts_root = ::util::triehash::ordered_trie_root( - receipts.iter().map(|x| ::rlp::encode(x).to_vec()) + receipts.iter().map(|x| ::rlp::encode(x).into_vec()) ); header.set_receipts_root(receipts_root); - let req = BlockReceipts(encoded::Header::new(::rlp::encode(&header).to_vec()).into()); + let req = BlockReceipts(encoded::Header::new(::rlp::encode(&header).into_vec()).into()); let cache = Mutex::new(make_cache()); assert!(req.check_response(&cache, &receipts).is_ok()) @@ -987,7 +987,7 @@ mod tests { header.set_state_root(root.clone()); let req = Account { - header: encoded::Header::new(::rlp::encode(&header).to_vec()).into(), + header: encoded::Header::new(::rlp::encode(&header).into_vec()).into(), address: addr, }; @@ -1001,7 +1001,7 @@ mod tests { let code_hash = ::util::Hashable::sha3(&code); let header = Header::new(); let req = Code { - header: encoded::Header::new(::rlp::encode(&header).to_vec()).into(), + header: encoded::Header::new(::rlp::encode(&header).into_vec()).into(), code_hash: code_hash.into(), }; diff --git a/ethcore/light/src/types/request/mod.rs b/ethcore/light/src/types/request/mod.rs index 5b15a0180..ceba60dda 100644 --- a/ethcore/light/src/types/request/mod.rs +++ b/ethcore/light/src/types/request/mod.rs @@ -1673,7 +1673,7 @@ mod tests { let full_req = Request::Headers(req.clone()); let res = HeadersResponse { headers: vec![ - ::ethcore::encoded::Header::new(::rlp::encode(&Header::default()).to_vec()) + ::ethcore::encoded::Header::new(::rlp::encode(&Header::default()).into_vec()) ] }; let full_res = Response::Headers(res.clone()); diff --git a/ethcore/native_contracts/build.rs b/ethcore/native_contracts/build.rs index 6b3b4bfac..cec830929 100644 --- a/ethcore/native_contracts/build.rs +++ b/ethcore/native_contracts/build.rs @@ -28,7 +28,7 @@ const SECRETSTORE_ACL_STORAGE_ABI: &'static str = include_str!("res/secretstore_ const VALIDATOR_SET_ABI: &'static str = include_str!("res/validator_set.json"); const VALIDATOR_REPORT_ABI: &'static str = include_str!("res/validator_report.json"); -const TEST_VALIDATOR_SET_ABI: &'static str = r#"[{"constant":true,"inputs":[],"name":"transitionNonce","outputs":[{"name":"n","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newValidators","type":"address[]"}],"name":"setValidators","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"vals","type":"address[]"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_parent_hash","type":"bytes32"},{"indexed":true,"name":"_nonce","type":"uint256"},{"indexed":false,"name":"_new_set","type":"address[]"}],"name":"ValidatorsChanged","type":"event"}]"#; +const TEST_VALIDATOR_SET_ABI: &'static str = include_str!("res/test_validator_set.json"); fn build_file(name: &str, abi: &str, filename: &str) { let code = ::native_contract_generator::generate_module(name, abi).unwrap(); diff --git a/ethcore/native_contracts/generator/src/lib.rs b/ethcore/native_contracts/generator/src/lib.rs index 540d2ec2b..08ce1c97b 100644 --- a/ethcore/native_contracts/generator/src/lib.rs +++ b/ethcore/native_contracts/generator/src/lib.rs @@ -108,7 +108,7 @@ fn generate_functions(contract: &Contract) -> Result { /// Outputs: {abi_outputs:?} pub fn {snake_name}(&self, call: F, {params}) -> BoxFuture<{output_type}, String> where - F: Fn(util::Address, Vec) -> U, + F: FnOnce(util::Address, Vec) -> U, U: IntoFuture, Error=String>, U::Future: Send + 'static {{ diff --git a/ethcore/native_contracts/res/test_validator_set.json b/ethcore/native_contracts/res/test_validator_set.json new file mode 100644 index 000000000..7ed6a000f --- /dev/null +++ b/ethcore/native_contracts/res/test_validator_set.json @@ -0,0 +1,8 @@ +[ + {"constant":false,"inputs":[{"name":"_validators","type":"address[]"}],"name":"setValidators","outputs":[],"payable":false,"type":"function"}, + {"constant":false,"inputs":[{"name":"","type":"address"},{"name":"","type":"bytes"}],"name":"reportMalicious","outputs":[],"payable":false,"type":"function"}, + {"constant":false,"inputs":[],"name":"finalizeChange","outputs":[],"payable":false,"type":"function"}, + {"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"_validators","type":"address[]"}],"payable":false,"type":"function"}, + {"constant":false,"inputs":[{"name":"","type":"address"}],"name":"reportBenign","outputs":[],"payable":false,"type":"function"}, + {"anonymous":false,"inputs":[{"indexed":true,"name":"_parent_hash","type":"bytes32"},{"indexed":false,"name":"_new_set","type":"address[]"}],"name":"InitiateChange","type":"event"} +] diff --git a/ethcore/native_contracts/res/validator_set.json b/ethcore/native_contracts/res/validator_set.json index 8c2a5e8c8..d861e16fd 100644 --- a/ethcore/native_contracts/res/validator_set.json +++ b/ethcore/native_contracts/res/validator_set.json @@ -1,5 +1,5 @@ [ - {"constant":true,"inputs":[],"name":"transitionNonce","outputs":[{"name":"nonce","type":"uint256"}],"payable":false,"type":"function"}, + {"constant":false,"inputs":[],"name":"finalizeChange","outputs":[],"payable":false,"type":"function"}, {"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"validators","type":"address[]"}],"payable":false,"type":"function"}, - {"anonymous":false,"inputs":[{"indexed":true,"name":"_parent_hash","type":"bytes32"},{"indexed":true,"name":"_nonce","type":"uint256"},{"indexed":false,"name":"_new_set","type":"address[]"}],"name":"ValidatorsChanged","type":"event"} + {"anonymous":false,"inputs":[{"indexed":true,"name":"_parent_hash","type":"bytes32"},{"indexed":false,"name":"_new_set","type":"address[]"}],"name":"InitiateChange","type":"event"} ] diff --git a/ethcore/res/authority_round.json b/ethcore/res/authority_round.json index dba7e28a5..d8014ff25 100644 --- a/ethcore/res/authority_round.json +++ b/ethcore/res/authority_round.json @@ -11,7 +11,8 @@ "0x7d577a597b2742b498cb5cf0c26cdcd726d39e6e", "0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1" ] - } + }, + "immediateTransitions": true } } }, diff --git a/ethcore/res/validator_contract.json b/ethcore/res/validator_contract.json index 4ef27e30e..3faec7665 100644 --- a/ethcore/res/validator_contract.json +++ b/ethcore/res/validator_contract.json @@ -8,7 +8,8 @@ "startStep": 2, "validators": { "contract": "0x0000000000000000000000000000000000000005" - } + }, + "immediateTransitions": true } } }, diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 12b7430b8..c0294c364 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -260,6 +260,7 @@ impl<'x> OpenBlock<'x> { author: Address, gas_range_target: (U256, U256), extra_data: Bytes, + is_epoch_begin: bool, ) -> Result { let number = parent.number() + 1; let state = State::from_existing(db, parent.state_root().clone(), engine.account_start_nonce(number), factories)?; @@ -279,7 +280,8 @@ impl<'x> OpenBlock<'x> { let gas_floor_target = cmp::max(gas_range_target.0, engine.params().min_gas_limit); let gas_ceil_target = cmp::max(gas_range_target.1, gas_floor_target); engine.populate_from_parent(&mut r.block.header, parent, gas_floor_target, gas_ceil_target); - engine.on_new_block(&mut r.block, last_hashes)?; + engine.on_new_block(&mut r.block, last_hashes, is_epoch_begin)?; + Ok(r) } @@ -380,11 +382,11 @@ impl<'x> OpenBlock<'x> { if let Err(e) = s.block.state.commit() { warn!("Encountered error on state commit: {}", e); } - s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().to_vec()))); + s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().into_vec()))); let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out(); s.block.header.set_uncles_hash(uncle_bytes.sha3()); s.block.header.set_state_root(s.block.state.root().clone()); - s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().to_vec()))); + s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().into_vec()))); s.block.header.set_log_bloom(s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b})); //TODO: use |= operator s.block.header.set_gas_used(s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used)); @@ -408,14 +410,14 @@ impl<'x> OpenBlock<'x> { warn!("Encountered error on state commit: {}", e); } if s.block.header.transactions_root().is_zero() || s.block.header.transactions_root() == &SHA3_NULL_RLP { - s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().to_vec()))); + s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().into_vec()))); } let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out(); if s.block.header.uncles_hash().is_zero() { s.block.header.set_uncles_hash(uncle_bytes.sha3()); } if s.block.header.receipts_root().is_zero() || s.block.header.receipts_root() == &SHA3_NULL_RLP { - s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().to_vec()))); + s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().into_vec()))); } s.block.header.set_state_root(s.block.state.root().clone()); @@ -430,7 +432,7 @@ impl<'x> OpenBlock<'x> { #[cfg(test)] /// Return mutable block reference. To be used in tests only. - pub fn block_mut (&mut self) -> &mut ExecutedBlock { &mut self.block } + pub fn block_mut(&mut self) -> &mut ExecutedBlock { &mut self.block } } impl<'x> IsBlock for OpenBlock<'x> { @@ -508,7 +510,7 @@ impl LockedBlock { for receipt in &mut block.block.receipts { receipt.state_root = None; } - block.block.header.set_receipts_root(ordered_trie_root(block.block.receipts.iter().map(|r| r.rlp_bytes().to_vec()))); + block.block.header.set_receipts_root(ordered_trie_root(block.block.receipts.iter().map(|r| r.rlp_bytes().into_vec()))); block } } @@ -554,6 +556,7 @@ pub fn enact( parent: &Header, last_hashes: Arc, factories: Factories, + is_epoch_begin: bool, ) -> Result { { if ::log::max_log_level() >= ::log::LogLevel::Trace { @@ -563,7 +566,19 @@ pub fn enact( } } - let mut b = OpenBlock::new(engine, factories, tracing, db, parent, last_hashes, Address::new(), (3141562.into(), 31415620.into()), vec![])?; + let mut b = OpenBlock::new( + engine, + factories, + tracing, + db, + parent, + last_hashes, + Address::new(), + (3141562.into(), 31415620.into()), + vec![], + is_epoch_begin, + )?; + b.set_difficulty(*header.difficulty()); b.set_gas_limit(*header.gas_limit()); b.set_timestamp(header.timestamp()); @@ -618,9 +633,22 @@ pub fn enact_verified( parent: &Header, last_hashes: Arc, factories: Factories, + is_epoch_begin: bool, ) -> Result { let view = BlockView::new(&block.bytes); - enact(&block.header, &block.transactions, &view.uncles(), engine, tracing, db, parent, last_hashes, factories) + + enact( + &block.header, + &block.transactions, + &view.uncles(), + engine, + tracing, + db, + parent, + last_hashes, + factories, + is_epoch_begin, + ) } #[cfg(test)] @@ -653,7 +681,7 @@ mod tests { let header = block.header(); let transactions: Result, Error> = block.transactions().into_iter().map(SignedTransaction::new).collect(); let transactions = transactions?; - enact(&header, &transactions, &block.uncles(), engine, tracing, db, parent, last_hashes, factories) + enact(&header, &transactions, &block.uncles(), engine, tracing, db, parent, last_hashes, factories, false) } /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header. Seal the block aferwards @@ -678,7 +706,7 @@ mod tests { let genesis_header = spec.genesis_header(); let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let b = OpenBlock::new(&*spec.engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap(); + let b = OpenBlock::new(&*spec.engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap(); let b = b.close_and_lock(); let _ = b.seal(&*spec.engine, vec![]); } @@ -692,7 +720,7 @@ mod tests { let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap() + let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap() .close_and_lock().seal(engine, vec![]).unwrap(); let orig_bytes = b.rlp_bytes(); let orig_db = b.drain(); @@ -716,7 +744,7 @@ mod tests { let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let mut open_block = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap(); + let mut open_block = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap(); let mut uncle1_header = Header::new(); uncle1_header.set_extra_data(b"uncle1".to_vec()); let mut uncle2_header = Header::new(); diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 2690564e5..8f66c270d 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -35,6 +35,7 @@ use blockchain::{CacheSize, ImportRoute, Config}; use db::{self, Writable, Readable, CacheUpdatePolicy}; use cache_manager::CacheManager; use encoded; +use engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition}; const LOG_BLOOMS_LEVELS: usize = 3; const LOG_BLOOMS_ELEMENTS_PER_INDEX: usize = 16; @@ -145,6 +146,10 @@ pub trait BlockProvider { where F: Fn(&LogEntry) -> bool, Self: Sized; } +macro_rules! otry { + ($e:expr) => { match $e { Some(x) => x, None => return None } } +} + #[derive(Debug, Hash, Eq, PartialEq, Clone)] enum CacheId { BlockHeader(H256), @@ -261,7 +266,7 @@ impl BlockProvider for BlockChain { let result = match opt { Some(b) => { - let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).to_vec(); + let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).into_vec(); let mut write = self.block_headers.write(); write.insert(hash.clone(), bytes.clone()); Some(encoded::Header::new(bytes)) @@ -297,7 +302,7 @@ impl BlockProvider for BlockChain { let result = match opt { Some(b) => { - let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).to_vec(); + let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).into_vec(); let mut write = self.block_bodies.write(); write.insert(hash.clone(), bytes.clone()); Some(encoded::Body::new(bytes)) @@ -508,7 +513,7 @@ impl BlockChain { number: header.number(), total_difficulty: header.difficulty(), parent: header.parent_hash(), - children: vec![] + children: vec![], }; let mut batch = DBTransaction::new(); @@ -531,7 +536,7 @@ impl BlockChain { let best_block_rlp = bc.block(&best_block_hash).unwrap().into_inner(); let best_block_timestamp = BlockView::new(&best_block_rlp).header().timestamp(); - let raw_first = bc.db.get(db::COL_EXTRA, b"first").unwrap().map(|v| v.to_vec()); + let raw_first = bc.db.get(db::COL_EXTRA, b"first").unwrap().map(|v| v.into_vec()); let mut best_ancient = bc.db.get(db::COL_EXTRA, b"ancient").unwrap().map(|h| H256::from_slice(&h)); let best_ancient_number; if best_ancient.is_none() && best_block_number > 1 && bc.block_hash(1).is_none() { @@ -698,10 +703,6 @@ impl BlockChain { /// If the tree route verges into pruned or unknown blocks, /// `None` is returned. pub fn tree_route(&self, from: H256, to: H256) -> Option { - macro_rules! otry { - ($e:expr) => { match $e { Some(x) => x, None => return None } } - } - let mut from_branch = vec![]; let mut to_branch = vec![]; @@ -878,16 +879,60 @@ impl BlockChain { } } - /// Get a specific epoch transition by epoch number and provided block hash. - pub fn epoch_transition(&self, epoch_num: u64, block_hash: H256) -> Option { - trace!(target: "blockchain", "Loading epoch {} transition at block {}", - epoch_num, block_hash); + /// Get a specific epoch transition by block number and provided block hash. + pub fn epoch_transition(&self, block_num: u64, block_hash: H256) -> Option { + trace!(target: "blockchain", "Loading epoch transition at block {}, {}", + block_num, block_hash); - self.db.read(db::COL_EXTRA, &epoch_num).and_then(|transitions: EpochTransitions| { + self.db.read(db::COL_EXTRA, &block_num).and_then(|transitions: EpochTransitions| { transitions.candidates.into_iter().find(|c| c.block_hash == block_hash) }) } + /// Get the transition to the epoch the given parent hash is part of + /// or transitions to. + /// This will give the epoch that any children of this parent belong to. + /// + /// The block corresponding the the parent hash must be stored already. + pub fn epoch_transition_for(&self, parent_hash: H256) -> Option { + // slow path: loop back block by block + for hash in otry!(self.ancestry_iter(parent_hash)) { + let details = otry!(self.block_details(&hash)); + + // look for transition in database. + if let Some(transition) = self.epoch_transition(details.number, hash) { + return Some(transition) + } + + // canonical hash -> fast breakout: + // get the last epoch transition up to this block. + // + // if `block_hash` is canonical it will only return transitions up to + // the parent. + if otry!(self.block_hash(details.number)) == hash { + return self.epoch_transitions() + .map(|(_, t)| t) + .take_while(|t| t.block_number <= details.number) + .last() + } + } + + // should never happen as the loop will encounter genesis before concluding. + None + } + + /// Write a pending epoch transition by block hash. + pub fn insert_pending_transition(&self, batch: &mut DBTransaction, hash: H256, t: PendingEpochTransition) { + batch.write(db::COL_EXTRA, &hash, &t); + } + + /// Get a pending epoch transition by block hash. + // TODO: implement removal safely: this can only be done upon finality of a block + // that _uses_ the pending transition. + pub fn get_pending_transition(&self, hash: H256) -> Option { + self.db.read(db::COL_EXTRA, &hash) + } + /// Add a child to a given block. Assumes that the block hash is in /// the chain and the child's parent is this block. /// @@ -1165,12 +1210,12 @@ impl BlockChain { let mut parent_details = self.block_details(&parent_hash).unwrap_or_else(|| panic!("Invalid parent hash: {:?}", parent_hash)); parent_details.children.push(info.hash.clone()); - // create current block details + // create current block details. let details = BlockDetails { number: header.number(), total_difficulty: info.total_difficulty, parent: parent_hash.clone(), - children: vec![] + children: vec![], }; // write to batch @@ -2201,7 +2246,7 @@ mod tests { #[test] fn epoch_transitions_iter() { - use blockchain::extras::EpochTransition; + use ::engines::EpochTransition; let mut canon_chain = ChainGenerator::default(); let mut finalizer = BlockFinalizer::default(); @@ -2223,7 +2268,6 @@ mod tests { block_hash: hash, block_number: i + 1, proof: vec![], - state_proof: vec![], }); bc.commit(); } @@ -2236,7 +2280,6 @@ mod tests { block_hash: hash, block_number: 1, proof: vec![], - state_proof: vec![] }); db.write(batch).unwrap(); @@ -2252,4 +2295,85 @@ mod tests { assert_eq!(bc.best_block_number(), 5); assert_eq!(bc.epoch_transitions().map(|(i, _)| i).collect::>(), vec![0, 1, 2, 3, 4]); } + + #[test] + fn epoch_transition_for() { + use ::engines::EpochTransition; + + let mut canon_chain = ChainGenerator::default(); + let mut finalizer = BlockFinalizer::default(); + let genesis = canon_chain.generate(&mut finalizer).unwrap(); + + let db = new_db(); + + let bc = new_chain(&genesis, db.clone()); + + let mut batch = db.transaction(); + bc.insert_epoch_transition(&mut batch, 0, EpochTransition { + block_hash: bc.genesis_hash(), + block_number: 0, + proof: vec![], + }); + db.write(batch).unwrap(); + + // set up a chain where we have a canonical chain of 10 blocks + // and a non-canonical fork of 8 from genesis. + let fork_hash = { + let mut fork_chain = canon_chain.fork(1); + let mut fork_finalizer = finalizer.fork(); + + for _ in 0..7 { + let mut batch = db.transaction(); + let fork_block = fork_chain.generate(&mut fork_finalizer).unwrap(); + + bc.insert_block(&mut batch, &fork_block, vec![]); + bc.commit(); + db.write(batch).unwrap(); + } + + assert_eq!(bc.best_block_number(), 7); + bc.chain_info().best_block_hash + }; + + for _ in 0..10 { + let mut batch = db.transaction(); + let canon_block = canon_chain.generate(&mut finalizer).unwrap(); + + bc.insert_block(&mut batch, &canon_block, vec![]); + bc.commit(); + + db.write(batch).unwrap(); + } + + assert_eq!(bc.best_block_number(), 10); + + let mut batch = db.transaction(); + bc.insert_epoch_transition(&mut batch, 4, EpochTransition { + block_hash: bc.block_hash(4).unwrap(), + block_number: 4, + proof: vec![], + }); + db.write(batch).unwrap(); + + // blocks where the parent is one of the first 4 will be part of genesis epoch. + for i in 0..4 { + let hash = bc.block_hash(i).unwrap(); + assert_eq!(bc.epoch_transition_for(hash).unwrap().block_number, 0); + } + + // blocks where the parent is the transition at 4 or after will be + // part of that epoch. + for i in 4..11 { + let hash = bc.block_hash(i).unwrap(); + assert_eq!(bc.epoch_transition_for(hash).unwrap().block_number, 4); + } + + let fork_hashes = bc.ancestry_iter(fork_hash).unwrap().collect::>(); + assert_eq!(fork_hashes.len(), 8); + + // non-canonical fork blocks should all have genesis transition + for fork_hash in fork_hashes { + assert_eq!(bc.epoch_transition_for(fork_hash).unwrap().block_number, 0); + } + } } diff --git a/ethcore/src/blockchain/extras.rs b/ethcore/src/blockchain/extras.rs index 7de49f3bf..04c12d53a 100644 --- a/ethcore/src/blockchain/extras.rs +++ b/ethcore/src/blockchain/extras.rs @@ -17,13 +17,16 @@ //! Blockchain DB extras. use bloomchain; -use util::*; -use util::kvdb::PREFIX_LEN as DB_PREFIX_LEN; -use rlp::*; +use blooms::{GroupPosition, BloomGroup}; +use db::Key; +use engines::epoch::{Transition as EpochTransition}; use header::BlockNumber; use receipt::Receipt; -use db::Key; -use blooms::{GroupPosition, BloomGroup}; + +use rlp::*; +use util::*; +use util::kvdb::PREFIX_LEN as DB_PREFIX_LEN; + /// Represents index of extra data in database #[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)] @@ -40,6 +43,8 @@ pub enum ExtrasIndex { BlockReceipts = 4, /// Epoch transition data index. EpochTransitions = 5, + /// Pending epoch transition data index. + PendingEpochTransition = 6, } fn with_index(hash: &H256, i: ExtrasIndex) -> H264 { @@ -137,6 +142,14 @@ impl Key for H256 { } } +impl Key<::engines::epoch::PendingTransition> for H256 { + type Target = H264; + + fn key(&self) -> H264 { + with_index(self, ExtrasIndex::PendingEpochTransition) + } +} + /// length of epoch keys. pub const EPOCH_KEY_LEN: usize = DB_PREFIX_LEN + 16; @@ -296,41 +309,6 @@ impl Decodable for EpochTransitions { } } -#[derive(Debug, Clone)] -pub struct EpochTransition { - pub block_hash: H256, // block hash at which the transition occurred. - pub block_number: BlockNumber, // block number at which the tranition occurred. - pub proof: Vec, // "transition/epoch" proof from the engine. - pub state_proof: Vec, // state items necessary to regenerate proof. -} - -impl Encodable for EpochTransition { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(4) - .append(&self.block_hash) - .append(&self.block_number) - .append(&self.proof) - .begin_list(self.state_proof.len()); - - for item in &self.state_proof { - s.append(&&**item); - } - } -} - -impl Decodable for EpochTransition { - fn decode(rlp: &UntrustedRlp) -> Result { - Ok(EpochTransition { - block_hash: rlp.val_at(0)?, - block_number: rlp.val_at(1)?, - proof: rlp.val_at(2)?, - state_proof: rlp.at(3)?.iter().map(|x| { - Ok(DBValue::from_slice(x.data()?)) - }).collect::, _>>()?, - }) - } -} - #[cfg(test)] mod tests { use rlp::*; diff --git a/ethcore/src/blockchain/generator/block.rs b/ethcore/src/blockchain/generator/block.rs index 9dacb070e..05fd15031 100644 --- a/ethcore/src/blockchain/generator/block.rs +++ b/ethcore/src/blockchain/generator/block.rs @@ -67,6 +67,6 @@ impl WithTransaction for Block { impl CompleteBlock for Block { fn complete(mut self, parent_hash: H256) -> Bytes { self.header.set_parent_hash(parent_hash); - encode(&self).to_vec() + encode(&self).into_vec() } } diff --git a/ethcore/src/blockchain/mod.rs b/ethcore/src/blockchain/mod.rs index 2d6d6ddb3..55a67e2b6 100644 --- a/ethcore/src/blockchain/mod.rs +++ b/ethcore/src/blockchain/mod.rs @@ -31,6 +31,5 @@ pub mod generator; pub use self::blockchain::{BlockProvider, BlockChain}; pub use self::cache::CacheSize; pub use self::config::Config; -pub use self::extras::EpochTransition; pub use types::tree_route::TreeRoute; pub use self::import_route::ImportRoute; diff --git a/ethcore/src/client/ancient_import.rs b/ethcore/src/client/ancient_import.rs index b62450641..d4d8696d2 100644 --- a/ethcore/src/client/ancient_import.rs +++ b/ethcore/src/client/ancient_import.rs @@ -18,8 +18,8 @@ use std::sync::Arc; -use engines::{Engine, EpochVerifier, EpochChange}; -use error::Error; +use blockchain::BlockChain; +use engines::{Engine, EpochVerifier}; use header::Header; use rand::Rng; @@ -46,21 +46,21 @@ impl AncientVerifier { /// Verify the next block header, randomly choosing whether to do heavy or light /// verification. If the block is the end of an epoch, updates the epoch verifier. - pub fn verify Result, Error>>( + pub fn verify( &self, rng: &mut R, header: &Header, - block: &[u8], - receipts: &[::receipt::Receipt], - load_verifier: F, + chain: &BlockChain, ) -> Result<(), ::error::Error> { match rng.gen::() <= HEAVY_VERIFY_RATE { true => self.cur_verifier.read().verify_heavy(header)?, false => self.cur_verifier.read().verify_light(header)?, } - if let EpochChange::Yes(num) = self.engine.is_epoch_end(header, Some(block), Some(receipts)) { - *self.cur_verifier.write() = load_verifier(num)?; + // ancient import will only use transitions obtained from the snapshot. + if let Some(transition) = chain.epoch_transition(header.number(), header.hash()) { + let v = self.engine.epoch_verifier(&header, &transition.proof).known_confirmed()?; + *self.cur_verifier.write() = v; } Ok(()) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 8b71ec0de..98cefdabd 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -32,7 +32,7 @@ use util::kvdb::*; // other use basic_types::Seal; use block::*; -use blockchain::{BlockChain, BlockProvider, EpochTransition, TreeRoute, ImportRoute}; +use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute}; use blockchain::extras::TransactionAddress; use client::ancient_import::AncientVerifier; use client::Error as ClientError; @@ -42,7 +42,7 @@ use client::{ ChainNotify, PruningInfo, ProvingBlockChainClient, }; use encoded; -use engines::Engine; +use engines::{Engine, EpochTransition}; use env_info::EnvInfo; use env_info::LastHashes; use error::{ImportError, ExecutionError, CallError, BlockError, ImportResult, Error as EthcoreError}; @@ -256,9 +256,31 @@ impl Client { { let chain = client.chain.read(); let gh = spec.genesis_header(); - if chain.epoch_transition(0, spec.genesis_header().hash()).is_none() { + if chain.epoch_transition(0, gh.hash()).is_none() { trace!(target: "client", "No genesis transition found."); - client.generate_epoch_proof(&gh, 0, &*chain); + + let proof = client.with_proving_caller( + BlockId::Number(0), + |call| client.engine.genesis_epoch_data(&gh, call) + ); + let proof = match proof { + Ok(proof) => proof, + Err(e) => { + warn!(target: "client", "Error generating genesis epoch data: {}. Snapshots generated may not be complete.", e); + Vec::new() + } + }; + + debug!(target: "client", "Obtained genesis transition proof: {:?}", proof); + + let mut batch = DBTransaction::new(); + chain.insert_epoch_transition(&mut batch, 0, EpochTransition { + block_hash: gh.hash(), + block_number: 0, + proof: proof, + }); + + client.db.read().write_buffered(batch); } } @@ -405,7 +427,16 @@ impl Client { let last_hashes = self.build_last_hashes(header.parent_hash().clone()); let db = self.state_db.lock().boxed_clone_canon(header.parent_hash()); - let enact_result = enact_verified(block, engine, self.tracedb.read().tracing_enabled(), db, &parent, last_hashes, self.factories.clone()); + let is_epoch_begin = chain.epoch_transition(parent.number(), *header.parent_hash()).is_some(); + let enact_result = enact_verified(block, + engine, + self.tracedb.read().tracing_enabled(), + db, + &parent, + last_hashes, + self.factories.clone(), + is_epoch_begin, + ); let mut locked_block = enact_result.map_err(|e| { warn!(target: "client", "Block import failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); })?; @@ -555,18 +586,9 @@ impl Client { { // closure for verifying a block. let verify_with = |verifier: &AncientVerifier| -> Result<(), ::error::Error> { - // verify the block, passing a closure used to load an epoch verifier - // by number. - verifier.verify( - &mut *self.rng.lock(), - &header, - &block_bytes, - &receipts, - |epoch_num| chain.epoch_transition(epoch_num, hash) - .ok_or(BlockError::UnknownEpochTransition(epoch_num)) - .map_err(Into::into) - .and_then(|t| self.engine.epoch_verifier(&header, &t.proof)) - ) + // verify the block, passing the chain for updating the epoch + // verifier. + verifier.verify(&mut *self.rng.lock(), &header, &chain) }; // initialize the ancient block verifier if we don't have one already. @@ -583,7 +605,8 @@ impl Client { .map(|(_, t)| t.proof) .expect("At least one epoch entry (genesis) always stored; qed"); - let current_verifier = self.engine.epoch_verifier(&header, ¤t_epoch_data)?; + let current_verifier = self.engine.epoch_verifier(&header, ¤t_epoch_data) + .known_confirmed()?; let current_verifier = AncientVerifier::new(self.engine.clone(), current_verifier); verify_with(¤t_verifier)?; @@ -606,6 +629,7 @@ impl Client { fn commit_block(&self, block: B, hash: &H256, block_data: &[u8]) -> ImportRoute where B: IsBlock + Drain { let number = block.header().number(); let parent = block.header().parent_hash().clone(); + let header = block.header().clone(); // TODO: optimize and avoid copy. let chain = self.chain.read(); // Commit results @@ -619,28 +643,13 @@ impl Client { let mut batch = DBTransaction::new(); - // generate validation proof if the engine requires them. - // TODO: make conditional? - let entering_new_epoch = { - use engines::EpochChange; - match self.engine.is_epoch_end(block.header(), Some(block_data), Some(&receipts)) { - EpochChange::Yes(e) => Some((block.header().clone(), e)), - EpochChange::No => None, - EpochChange::Unsure(_) => { - warn!(target: "client", "Detected invalid engine implementation."); - warn!(target: "client", "Engine claims to require more block data, but everything provided."); - None - } - } - }; - // CHECK! I *think* this is fine, even if the state_root is equal to another // already-imported block of the same number. // TODO: Prove it with a test. let mut state = block.drain(); 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.clone()); self.tracedb.read().import(&mut batch, TraceImportRequest { traces: traces.into(), @@ -655,65 +664,102 @@ impl Client { // Final commit to the DB self.db.read().write_buffered(batch); chain.commit(); + + // check for epoch end. do this after writing first batch so we can prove + // transactions on the block's state. + // TODO: work these changes into the existing DBTransaction. + self.check_epoch_end_signal(&header, block_data, &receipts, &chain); + self.check_epoch_end(&header, &chain); + self.update_last_hashes(&parent, hash); if let Err(e) = self.prune_ancient(state, &chain) { warn!("Failed to prune ancient state data: {}", e); } - if let Some((header, epoch)) = entering_new_epoch { - self.generate_epoch_proof(&header, epoch, &chain); - } - route } - // generate an epoch transition proof at the given block, and write it into the given blockchain. - fn generate_epoch_proof(&self, header: &Header, epoch_number: u64, chain: &BlockChain) { - use std::cell::RefCell; - use std::collections::BTreeSet; + // check for epoch end signal and write pending transition if it occurs. + // state for the given block must be available. + fn check_epoch_end_signal(&self, header: &Header, block: &[u8], receipts: &[Receipt], chain: &BlockChain) { + use engines::EpochChange; - let mut batch = DBTransaction::new(); let hash = header.hash(); - debug!(target: "client", "Generating validation proof for epoch {} at block {}", - epoch_number, hash); + match self.engine.signals_epoch_end(header, Some(block), Some(&receipts)) { + EpochChange::Yes(proof) => { + use engines::epoch::PendingTransition; + use engines::Proof; - // proof is two-part. state items read in lexicographical order, - // and the secondary "proof" part. - let read_values = RefCell::new(BTreeSet::new()); - let block_id = BlockId::Hash(hash.clone()); - let proof = { - let call = |a, d| { - let tx = self.contract_call_tx(block_id, a, d); - let (result, items) = self.prove_transaction(tx, block_id) - .ok_or_else(|| format!("Unable to make call to generate epoch proof."))?; + let proof = match proof { + Proof::Known(proof) => proof, + Proof::WithState(with_state) => + match self.with_proving_caller(BlockId::Hash(hash), move |c| with_state(c)) { + Ok(proof) => proof, + Err(e) => { + warn!(target: "client", "Failed to generate transition proof for block {}: {}", hash, e); + warn!(target: "client", "Snapshots produced by this client may be incomplete"); - read_values.borrow_mut().extend(items); - Ok(result) - }; + Vec::new() + } + }, + }; - self.engine.epoch_proof(&header, &call) - }; + debug!(target: "client", "Block {} signals epoch end.", hash); - // insert into database, using the generated proof. - match proof { - Ok(proof) => { - chain.insert_epoch_transition(&mut batch, epoch_number, EpochTransition { - block_hash: hash.clone(), - block_number: header.number(), - proof: proof, - state_proof: read_values.into_inner().into_iter().collect(), - }); + // write pending transition to DB. + let mut batch = DBTransaction::new(); + + let pending = PendingTransition { proof: proof }; + chain.insert_pending_transition(&mut batch, hash, pending); self.db.read().write_buffered(batch); - } - Err(e) => { - warn!(target: "client", "Error generating epoch change proof for block {}: {}", hash, e); - warn!(target: "client", "Snapshots generated by this node will be incomplete."); + }, + EpochChange::No => {}, + EpochChange::Unsure(_) => { + warn!(target: "client", "Detected invalid engine implementation."); + warn!(target: "client", "Engine claims to require more block data, but everything provided."); } } } + // check for ending of epoch and write transition if it occurs. + fn check_epoch_end<'a>(&self, header: &'a Header, chain: &BlockChain) { + let is_epoch_end = self.engine.is_epoch_end( + header, + &(|hash| chain.block_header(&hash)), + &(|hash| chain.get_pending_transition(hash)), // TODO: limit to current epoch. + ); + + if let Some(proof) = is_epoch_end { + debug!(target: "client", "Epoch transition at block {}", header.hash()); + + let mut batch = DBTransaction::new(); + chain.insert_epoch_transition(&mut batch, header.number(), EpochTransition { + block_hash: header.hash(), + block_number: header.number(), + proof: proof, + }); + self.db.read().write_buffered(batch); + } + } + + // use a state-proving closure for the given block. + fn with_proving_caller(&self, id: BlockId, with_call: F) -> T + where F: FnOnce(&::engines::Call) -> T + { + let call = |a, d| { + let tx = self.contract_call_tx(id, a, d); + let (result, items) = self.prove_transaction(tx, id) + .ok_or_else(|| format!("Unable to make call. State unavailable?"))?; + + let items = items.into_iter().map(|x| x.to_vec()).collect(); + Ok((result, items)) + }; + + with_call(&call) + } + // prune ancient states until below the memory limit or only the minimum amount remain. fn prune_ancient(&self, mut state_db: StateDB, chain: &BlockChain) -> Result<(), ClientError> { let number = match state_db.journal_db().latest_era() { @@ -1397,7 +1443,7 @@ impl BlockChainClient for Client { } fn block_receipts(&self, hash: &H256) -> Option { - self.chain.read().block_receipts(hash).map(|receipts| ::rlp::encode(&receipts).to_vec()) + self.chain.read().block_receipts(hash).map(|receipts| ::rlp::encode(&receipts).into_vec()) } fn import_block(&self, bytes: Bytes) -> Result { @@ -1622,17 +1668,21 @@ impl MiningBlockChainClient for Client { let engine = &*self.engine; let chain = self.chain.read(); let h = chain.best_block_hash(); + let best_header = &chain.block_header(&h) + .expect("h is best block hash: so its header must exist: qed"); + let is_epoch_begin = chain.epoch_transition(best_header.number(), h).is_some(); let mut open_block = OpenBlock::new( engine, self.factories.clone(), false, // TODO: this will need to be parameterised once we want to do immediate mining insertion. self.state_db.lock().boxed_clone_canon(&h), - &chain.block_header(&h).expect("h is best block hash: so its header must exist: qed"), + best_header, self.build_last_hashes(h.clone()), author, gas_range_target, extra_data, + is_epoch_begin, ).expect("OpenBlock::new only fails if parent state root invalid; state root of best block's header is never invalid; qed"); // Add uncles @@ -1717,6 +1767,10 @@ impl EngineClient for Client { fn broadcast_consensus_message(&self, message: Bytes) { self.notify(|notify| notify.broadcast(message.clone())); } + + fn epoch_transition_for(&self, parent_hash: H256) -> Option<::engines::EpochTransition> { + self.chain.read().epoch_transition_for(parent_hash) + } } impl ProvingBlockChainClient for Client { @@ -1746,7 +1800,10 @@ impl ProvingBlockChainClient for Client { match res { Err(ExecutionError::Internal(_)) => None, - Err(_) => Some((Vec::new(), state.drop().1.extract_proof())), + Err(e) => { + trace!(target: "client", "Proved call failed: {}", e); + Some((Vec::new(), state.drop().1.extract_proof())) + } Ok(res) => Some((res.output, state.drop().1.extract_proof())), } } diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 19c208b45..19fdd74c8 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -372,7 +372,8 @@ impl MiningBlockChainClient for TestBlockChainClient { Arc::new(last_hashes), author, gas_range_target, - extra_data + extra_data, + false, ).expect("Opening block for tests will not fail."); // TODO [todr] Override timestamp for predictability (set_timestamp_now kind of sucks) open_block.set_timestamp(*self.latest_block_timestamp.read()); @@ -786,4 +787,8 @@ impl EngineClient for TestBlockChainClient { } fn broadcast_consensus_message(&self, _message: Bytes) {} + + fn epoch_transition_for(&self, _block_hash: H256) -> Option<::engines::EpochTransition> { + None + } } diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index d65642610..879620f0a 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -311,6 +311,13 @@ pub trait EngineClient: MiningBlockChainClient { /// Broadcast a consensus message to the network. fn broadcast_consensus_message(&self, message: Bytes); + + /// Get the transition to the epoch the given parent hash is part of + /// or transitions to. + /// This will give the epoch that any children of this parent belong to. + /// + /// The block corresponding the the parent hash must be stored already. + fn epoch_transition_for(&self, parent_hash: H256) -> Option<::engines::EpochTransition>; } /// Extended client interface for providing proofs of the state. diff --git a/ethcore/src/engines/authority_round/finality.rs b/ethcore/src/engines/authority_round/finality.rs new file mode 100644 index 000000000..a6bee1ce4 --- /dev/null +++ b/ethcore/src/engines/authority_round/finality.rs @@ -0,0 +1,187 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +//! Finality proof generation and checking. + +use std::collections::{VecDeque}; +use std::collections::hash_map::{HashMap, Entry}; + +use util::{Address, H256}; + +use engines::validator_set::SimpleList; + +/// Error indicating unknown validator. +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub struct UnknownValidator; + +/// Rolling finality checker for authority round consensus. +/// Stores a chain of unfinalized hashes that can be pushed onto. +pub struct RollingFinality { + headers: VecDeque<(H256, Address)>, + signers: SimpleList, + sign_count: HashMap, + last_pushed: Option, +} + +impl RollingFinality { + /// Create a blank finality checker under the given validator set. + pub fn blank(signers: Vec
) -> Self { + RollingFinality { + headers: VecDeque::new(), + signers: SimpleList::new(signers), + sign_count: HashMap::new(), + last_pushed: None, + } + } + + /// Extract unfinalized subchain from ancestry iterator. + /// Clears the current subchain. + /// + /// Fails if any provided signature isn't part of the signers set. + pub fn build_ancestry_subchain(&mut self, iterable: I) -> Result<(), UnknownValidator> + where I: IntoIterator + { + self.clear(); + for (hash, signer) in iterable { + if !self.signers.contains(&signer) { return Err(UnknownValidator) } + if self.last_pushed.is_none() { self.last_pushed = Some(hash) } + + // break when we've got our first finalized block. + { + let current_signed = self.sign_count.len(); + let would_be_finalized = (current_signed + 1) * 2 > self.signers.len(); + + let entry = self.sign_count.entry(signer); + if let (true, &Entry::Vacant(_)) = (would_be_finalized, &entry) { + break + } + + *entry.or_insert(0) += 1; + } + + self.headers.push_front((hash, signer)); + } + + Ok(()) + } + + /// Clear the finality status, but keeps the validator set. + pub fn clear(&mut self) { + self.headers.clear(); + self.sign_count.clear(); + self.last_pushed = None; + } + + /// Returns the last pushed hash. + pub fn subchain_head(&self) -> Option { + self.last_pushed + } + + /// Get an iterator over stored hashes in order. + pub fn unfinalized_hashes(&self) -> Iter { Iter(self.headers.iter()) } + + /// Get the validator set. + pub fn validators(&self) -> &SimpleList { &self.signers } + + /// Push a hash onto the rolling finality checker (implying `subchain_head` == head.parent) + /// + /// Fails if `signer` isn't a member of the active validator set. + /// Returns a list of all newly finalized headers. + // TODO: optimize with smallvec. + pub fn push_hash(&mut self, head: H256, signer: Address) -> Result, UnknownValidator> { + if !self.signers.contains(&signer) { return Err(UnknownValidator) } + + self.headers.push_back((head, signer)); + *self.sign_count.entry(signer).or_insert(0) += 1; + + let mut newly_finalized = Vec::new(); + + while self.sign_count.len() * 2 > self.signers.len() { + let (hash, signer) = self.headers.pop_front() + .expect("headers length always greater than sign count length; qed"); + + newly_finalized.push(hash); + + match self.sign_count.entry(signer) { + Entry::Occupied(mut entry) => { + // decrement count for this signer and purge on zero. + *entry.get_mut() -= 1; + + if *entry.get() == 0 { + entry.remove(); + } + } + Entry::Vacant(_) => panic!("all hashes in `header` should have an entry in `sign_count` for their signer; qed"), + } + } + + Ok(newly_finalized) + } +} + +pub struct Iter<'a>(::std::collections::vec_deque::Iter<'a, (H256, Address)>); + +impl<'a> Iterator for Iter<'a> { + type Item = H256; + + fn next(&mut self) -> Option { + self.0.next().map(|&(h, _)| h) + } +} + +#[cfg(test)] +mod tests { + use util::{Address, H256}; + use super::RollingFinality; + + #[test] + fn rejects_unknown_signer() { + let signers = (0..3).map(|_| Address::random()).collect(); + let mut finality = RollingFinality::blank(signers); + assert!(finality.push_hash(H256::random(), Address::random()).is_err()); + } + + #[test] + fn finalize_multiple() { + let signers: Vec<_> = (0..6).map(|_| Address::random()).collect(); + + let mut finality = RollingFinality::blank(signers.clone()); + let hashes: Vec<_> = (0..7).map(|_| H256::random()).collect(); + + // 3 / 6 signers is < 51% so no finality. + for (i, hash) in hashes.iter().take(6).cloned().enumerate() { + let i = i % 3; + assert!(finality.push_hash(hash, signers[i]).unwrap().len() == 0); + } + + // after pushing a block signed by a fourth validator, the first four + // blocks of the unverified chain become verified. + assert_eq!(finality.push_hash(hashes[6], signers[4]).unwrap(), + vec![hashes[0], hashes[1], hashes[2], hashes[3]]); + } + + #[test] + fn from_ancestry() { + let signers: Vec<_> = (0..6).map(|_| Address::random()).collect(); + let hashes: Vec<_> = (0..12).map(|i| (H256::random(), signers[i % 6])).collect(); + + let mut finality = RollingFinality::blank(signers.clone()); + finality.build_ancestry_subchain(hashes.iter().rev().cloned()).unwrap(); + + assert_eq!(finality.unfinalized_hashes().count(), 3); + assert_eq!(finality.subchain_head(), Some(hashes[11].0)); + } +} diff --git a/ethcore/src/engines/authority_round.rs b/ethcore/src/engines/authority_round/mod.rs similarity index 60% rename from ethcore/src/engines/authority_round.rs rename to ethcore/src/engines/authority_round/mod.rs index a00fe70ca..ba9ab6745 100644 --- a/ethcore/src/engines/authority_round.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -19,24 +19,32 @@ use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering}; use std::sync::Weak; use std::time::{UNIX_EPOCH, Duration}; -use util::*; -use ethkey::{verify_address, Signature}; -use rlp::{UntrustedRlp, encode}; + use account_provider::AccountProvider; use block::*; -use spec::CommonParams; -use engines::{Call, Engine, Seal, EngineError}; -use header::Header; +use builtin::Builtin; +use client::{Client, EngineClient}; +use engines::{Call, Engine, Seal, EngineError, ConstructedVerifier}; use error::{Error, TransactionError, BlockError}; use ethjson; -use io::{IoContext, IoHandler, TimerToken, IoService}; -use builtin::Builtin; -use transaction::UnverifiedTransaction; -use client::{Client, EngineClient}; +use header::{Header, BlockNumber}; +use spec::CommonParams; use state::CleanupMode; +use transaction::UnverifiedTransaction; + use super::signer::EngineSigner; use super::validator_set::{ValidatorSet, SimpleList, new_validator_set}; +use self::finality::RollingFinality; + +use ethkey::{verify_address, Signature}; +use io::{IoContext, IoHandler, TimerToken, IoService}; +use itertools::{self, Itertools}; +use rlp::{UntrustedRlp, encode}; +use util::*; + +mod finality; + /// `AuthorityRound` params. pub struct AuthorityRoundParams { /// Gas limit divisor. @@ -57,6 +65,8 @@ pub struct AuthorityRoundParams { pub eip155_transition: u64, /// Monotonic step validation transition block. pub validate_step_transition: u64, + /// Immediate transitions. + pub immediate_transitions: bool, } impl From for AuthorityRoundParams { @@ -71,6 +81,7 @@ impl From for AuthorityRoundParams { validate_score_transition: p.validate_score_transition.map_or(0, Into::into), eip155_transition: p.eip155_transition.map_or(0, Into::into), validate_step_transition: p.validate_step_transition.map_or(0, Into::into), + immediate_transitions: p.immediate_transitions.unwrap_or(false), } } } @@ -114,6 +125,92 @@ impl Step { } } +struct EpochManager { + epoch_transition_hash: H256, + epoch_transition_number: BlockNumber, + finality_checker: RollingFinality, + force: bool, +} + +impl EpochManager { + fn blank() -> Self { + EpochManager { + epoch_transition_hash: H256::default(), + epoch_transition_number: 0, + finality_checker: RollingFinality::blank(Vec::new()), + force: true, + } + } + + // zoom to epoch for given header. returns true if succeeded, false otherwise. + fn zoom_to(&mut self, client: &EngineClient, engine: &Engine, validators: &ValidatorSet, header: &Header) -> bool { + let last_was_parent = self.finality_checker.subchain_head() == Some(header.parent_hash().clone()); + + // early exit for current target == chain head, but only if the epochs are + // the same. + if last_was_parent && !self.force { + return true; + } + + self.force = false; + debug!(target: "engine", "Zooming to epoch for block {}", header.hash()); + + // epoch_transition_for can be an expensive call, but in the absence of + // forks it will only need to be called for the block directly after + // epoch transition, in which case it will be O(1) and require a single + // DB lookup. + let last_transition = match client.epoch_transition_for(*header.parent_hash()) { + Some(t) => t, + None => { + // this really should never happen unless the block passed + // hasn't got a parent in the database. + debug!(target: "engine", "No genesis transition found."); + return false; + } + }; + + + // extract other epoch set if it's not the same as the last. + if last_transition.block_hash != self.epoch_transition_hash { + let (signal_number, set_proof, _) = destructure_proofs(&last_transition.proof) + .expect("proof produced by this engine; therefore it is valid; qed"); + + trace!(target: "engine", "extracting epoch set for epoch ({}, {}) signalled at #{}", + last_transition.block_number, last_transition.block_hash, signal_number); + + let first = signal_number == 0; + let epoch_set = validators.epoch_set( + first, + engine, + signal_number, // use signal number so multi-set first calculation is correct. + set_proof, + ) + .ok() + .map(|(list, _)| list.into_inner()) + .expect("proof produced by this engine; therefore it is valid; qed"); + + self.finality_checker = RollingFinality::blank(epoch_set); + } + + self.epoch_transition_hash = last_transition.block_hash; + self.epoch_transition_number = last_transition.block_number; + + true + } + + // note new epoch hash. this will force the next block to re-load + // the epoch set + // TODO: optimize and don't require re-loading after epoch change. + fn note_new_epoch(&mut self) { + self.force = true; + } + + /// Get validator set. Zoom to the correct epoch first. + fn validators(&self) -> &SimpleList { + self.finality_checker.validators() + } +} + /// Engine using `AuthorityRound` proof-of-authority BFT consensus. pub struct AuthorityRound { params: CommonParams, @@ -130,22 +227,63 @@ pub struct AuthorityRound { validate_score_transition: u64, eip155_transition: u64, validate_step_transition: u64, + epoch_manager: Mutex, + immediate_transitions: bool, } // header-chain validator. struct EpochVerifier { - epoch_number: u64, step: Arc, subchain_validators: SimpleList, } impl super::EpochVerifier for EpochVerifier { - fn epoch_number(&self) -> u64 { self.epoch_number.clone() } fn verify_light(&self, header: &Header) -> Result<(), Error> { // always check the seal since it's fast. // nothing heavier to do. - verify_external(header, &self.subchain_validators, &*self.step) + verify_external(header, &self.subchain_validators, &*self.step, |_| {}) } + + fn check_finality_proof(&self, proof: &[u8]) -> Option> { + macro_rules! otry { + ($e: expr) => { + match $e { + Some(x) => x, + None => return None, + } + } + } + + let mut finality_checker = RollingFinality::blank(self.subchain_validators.clone().into_inner()); + let mut finalized = Vec::new(); + + let headers: Vec
= otry!(UntrustedRlp::new(proof).as_list().ok()); + + + for header in &headers { + // ensure all headers have correct number of seal fields so we can `verify_external` + // without panic. + // + // `verify_external` checks that signature is correct and author == signer. + if header.seal().len() != 2 { return None } + otry!(verify_external(header, &self.subchain_validators, &*self.step, |_| {}).ok()); + + let newly_finalized = otry!(finality_checker.push_hash(header.hash(), header.author().clone()).ok()); + finalized.extend(newly_finalized); + } + + if finalized.is_empty() { None } else { Some(finalized) } + } +} + +// Report misbehavior +#[derive(Debug)] +#[allow(dead_code)] +enum Report { + // Malicious behavior + Malicious(Address, BlockNumber, Bytes), + // benign misbehavior + Benign(Address, BlockNumber), } fn header_step(header: &Header) -> Result { @@ -156,13 +294,25 @@ fn header_signature(header: &Header) -> Result { UntrustedRlp::new(&header.seal().get(1).expect("was checked with verify_block_basic; has 2 fields; qed")).as_val::().map(Into::into) } -fn verify_external(header: &Header, validators: &ValidatorSet, step: &Step) -> Result<(), Error> { +fn step_proposer(validators: &ValidatorSet, bh: &H256, step: usize) -> Address { + let proposer = validators.get(bh, step); + trace!(target: "engine", "Fetched proposer for step {}: {}", step, proposer); + proposer +} + +fn is_step_proposer(validators: &ValidatorSet, bh: &H256, step: usize, address: &Address) -> bool { + step_proposer(validators, bh, step) == *address +} + +fn verify_external(header: &Header, validators: &ValidatorSet, step: &Step, report: F) + -> Result<(), Error> +{ let header_step = header_step(header)?; // Give one step slack if step is lagging, double vote is still not possible. if step.is_future(header_step) { trace!(target: "engine", "verify_block_unordered: block from the future"); - validators.report_benign(header.author(), header.number()); + report(Report::Benign(*header.author(), header.number())); Err(BlockError::InvalidSeal)? } else { let proposer_signature = header_signature(header)?; @@ -179,6 +329,21 @@ fn verify_external(header: &Header, validators: &ValidatorSet, step: &Step) -> R } } +fn combine_proofs(signal_number: BlockNumber, set_proof: &[u8], finality_proof: &[u8]) -> Vec { + let mut stream = ::rlp::RlpStream::new_list(3); + stream.append(&signal_number).append(&set_proof).append(&finality_proof); + stream.out() +} + +fn destructure_proofs(combined: &[u8]) -> Result<(BlockNumber, &[u8], &[u8]), Error> { + let rlp = UntrustedRlp::new(combined); + Ok(( + rlp.at(0)?.as_val()?, + rlp.at(1)?.data()?, + rlp.at(2)?.data()?, + )) +} + trait AsMillis { fn as_millis(&self) -> u64; } @@ -214,7 +379,10 @@ impl AuthorityRound { validate_score_transition: our_params.validate_score_transition, eip155_transition: our_params.eip155_transition, validate_step_transition: our_params.validate_step_transition, + epoch_manager: Mutex::new(EpochManager::blank()), + immediate_transitions: our_params.immediate_transitions, }); + // Do not initialize timeouts for tests. if should_timeout { let handler = TransitionHandler { engine: Arc::downgrade(&engine) }; @@ -222,14 +390,6 @@ impl AuthorityRound { } Ok(engine) } - - fn step_proposer(&self, bh: &H256, step: usize) -> Address { - self.validators.get(bh, step) - } - - fn is_step_proposer(&self, bh: &H256, step: usize, address: &Address) -> bool { - self.step_proposer(bh, step) == *address - } } fn unix_now() -> Duration { @@ -325,23 +485,81 @@ impl Engine for AuthorityRound { let header = block.header(); let step = self.step.load(); - if self.is_step_proposer(header.parent_hash(), step, header.author()) { + + // fetch correct validator set for current epoch, taking into account + // finality of previous transitions. + let active_set; + + let validators = if self.immediate_transitions { + &*self.validators + } else { + let mut epoch_manager = self.epoch_manager.lock(); + let client = match self.client.read().as_ref().and_then(|weak| weak.upgrade()) { + Some(client) => client, + None => { + warn!(target: "engine", "Unable to generate seal: missing client ref."); + return Seal::None; + } + }; + + if !epoch_manager.zoom_to(&*client, self, &*self.validators, header) { + debug!(target: "engine", "Unable to zoom to epoch."); + return Seal::None; + } + + active_set = epoch_manager.validators().clone(); + &active_set as &_ + }; + + if is_step_proposer(validators, header.parent_hash(), step, header.author()) { if let Ok(signature) = self.signer.sign(header.bare_hash()) { trace!(target: "engine", "generate_seal: Issuing a block for step {}.", step); // only issue the seal if we were the first to reach the compare_and_swap. if !self.proposed.compare_and_swap(false, true, AtomicOrdering::SeqCst) { - return Seal::Regular(vec![encode(&step).to_vec(), encode(&(&H520::from(signature) as &[u8])).to_vec()]); + return Seal::Regular(vec![encode(&step).into_vec(), encode(&(&H520::from(signature) as &[u8])).into_vec()]); } } else { warn!(target: "engine", "generate_seal: FAIL: Accounts secret key unavailable."); } } else { - trace!(target: "engine", "generate_seal: Not a proposer for step {}.", step); + trace!(target: "engine", "generate_seal: {} not a proposer for step {}.", + header.author(), step); } Seal::None } + fn on_new_block( + &self, + block: &mut ExecutedBlock, + last_hashes: Arc<::env_info::LastHashes>, + epoch_begin: bool, + ) -> Result<(), Error> { + let parent_hash = block.fields().header.parent_hash().clone(); + ::engines::common::push_last_hash(block, last_hashes.clone(), self, &parent_hash)?; + + if !epoch_begin { return Ok(()) } + + // genesis is never a new block, but might as well check. + let header = block.fields().header.clone(); + let first = header.number() == 0; + + let mut call = |to, data| { + let result = ::engines::common::execute_as_system( + block, + last_hashes.clone(), + self, + to, + U256::max_value(), // unbounded gas? maybe make configurable. + Some(data), + ); + + result.map_err(|e| format!("{}", e)) + }; + + self.validators.on_epoch_begin(first, &header, &mut call) + } + /// Apply the block reward on finalisation of the block. fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error> { let fields = block.fields_mut(); @@ -386,19 +604,26 @@ impl Engine for AuthorityRound { } let parent_step = header_step(parent)?; + // Ensure header is from the step after parent. if step == parent_step || (header.number() >= self.validate_step_transition && step <= parent_step) { trace!(target: "engine", "Multiple blocks proposed for step {}.", parent_step); - self.validators.report_malicious(header.author(), header.number(), Default::default()); + + self.validators.report_malicious(header.author(), header.number(), header.number(), Default::default()); Err(EngineError::DoubleVote(header.author().clone()))?; } // Report skipped primaries. if step > parent_step + 1 { + // TODO: use epochmanager to get correct validator set for reporting? + // or just rely on the fact that in general these will be the same + // and some reports might go missing? + trace!(target: "engine", "Author {} built block with step gap. current step: {}, parent step: {}", + header.author(), step, parent_step); + for s in parent_step + 1..step { - let skipped_primary = self.step_proposer(&parent.hash(), s); - trace!(target: "engine", "Author {} did not build his block on top of the intermediate designated primary {}.", header.author(), skipped_primary); - self.validators.report_benign(&skipped_primary, header.number()); + let skipped_primary = step_proposer(&*self.validators, &parent.hash(), s); + self.validators.report_benign(&skipped_primary, header.number(), header.number()); } } @@ -413,30 +638,164 @@ impl Engine for AuthorityRound { // Check the validators. fn verify_block_external(&self, header: &Header, _block: Option<&[u8]>) -> Result<(), Error> { - verify_external(header, &*self.validators, &*self.step) + // fetch correct validator set for current epoch, taking into account + // finality of previous transitions. + let active_set; + + let (validators, set_number) = if self.immediate_transitions { + (&*self.validators, header.number()) + } else { + // get correct validator set for epoch. + let client = match self.client.read().as_ref().and_then(|weak| weak.upgrade()) { + Some(client) => client, + None => { + debug!(target: "engine", "Unable to verify sig: missing client ref."); + return Err(EngineError::RequiresClient.into()) + } + }; + + let mut epoch_manager = self.epoch_manager.lock(); + if !epoch_manager.zoom_to(&*client, self, &*self.validators, header) { + debug!(target: "engine", "Unable to zoom to epoch."); + return Err(EngineError::RequiresClient.into()) + } + + active_set = epoch_manager.validators().clone(); + (&active_set as &_, epoch_manager.epoch_transition_number) + }; + + let report = |report| match report { + Report::Benign(address, block_number) => + self.validators.report_benign(&address, set_number, block_number), + Report::Malicious(address, block_number, proof) => + self.validators.report_malicious(&address, set_number, block_number, proof), + }; + + // verify signature against fixed list, but reports should go to the + // contract itself. + verify_external(header, validators, &*self.step, report) } - // the proofs we need just allow us to get the full validator set. - fn epoch_proof(&self, header: &Header, caller: &Call) -> Result { - self.validators.epoch_proof(header, caller) - .map_err(|e| EngineError::InsufficientProof(e).into()) + fn genesis_epoch_data(&self, header: &Header, call: &Call) -> Result, String> { + self.validators.genesis_epoch_data(header, call) + .map(|set_proof| combine_proofs(0, &set_proof, &[])) } - fn is_epoch_end(&self, header: &Header, block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) + fn signals_epoch_end(&self, header: &Header, block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) -> super::EpochChange { - self.validators.is_epoch_end(header, block, receipts) + if self.immediate_transitions { return super::EpochChange::No } + + let first = header.number() == 0; + self.validators.signals_epoch_end(first, header, block, receipts) } - fn epoch_verifier(&self, header: &Header, proof: &[u8]) -> Result, Error> { - // extract a simple list from the proof. - let (num, simple_list) = self.validators.epoch_set(header, proof)?; + fn is_epoch_end( + &self, + chain_head: &Header, + chain: &super::Headers, + transition_store: &super::PendingTransitionStore, + ) -> Option> { + // epochs only matter if we want to support light clients. + if self.immediate_transitions { return None } - Ok(Box::new(EpochVerifier { - epoch_number: num, - step: self.step.clone(), - subchain_validators: simple_list, - })) + let first = chain_head.number() == 0; + + // apply immediate transitions. + if let Some(change) = self.validators.is_epoch_end(first, chain_head) { + return Some(change) + } + + let client = match self.client.read().as_ref().and_then(|weak| weak.upgrade()) { + Some(client) => client, + None => { + warn!(target: "engine", "Unable to check for epoch end: missing client ref."); + return None; + } + }; + + // find most recently finalized blocks, then check transition store for pending transitions. + let mut epoch_manager = self.epoch_manager.lock(); + if !epoch_manager.zoom_to(&*client, self, &*self.validators, chain_head) { + return None; + } + + if epoch_manager.finality_checker.subchain_head() != Some(*chain_head.parent_hash()) { + // build new finality checker from ancestry of chain head, + // not including chain head itself yet. + let mut hash = chain_head.parent_hash().clone(); + let epoch_transition_hash = epoch_manager.epoch_transition_hash; + + // walk the chain within current epoch backwards. + // author == ec_recover(sig) known since + // the blocks are in the DB. + let ancestry_iter = itertools::repeat_call(move || { + chain(hash).and_then(|header| { + if header.number() == 0 { return None } + + let res = (hash, header.author().clone()); + hash = header.parent_hash().clone(); + Some(res) + }) + }) + .while_some() + .take_while(|&(h, _)| h != epoch_transition_hash); + + if let Err(_) = epoch_manager.finality_checker.build_ancestry_subchain(ancestry_iter) { + debug!(target: "engine", "inconsistent validator set within epoch"); + return None; + } + } + + { + if let Ok(finalized) = epoch_manager.finality_checker.push_hash(chain_head.hash(), *chain_head.author()) { + let mut finalized = finalized.into_iter(); + while let Some(hash) = finalized.next() { + if let Some(pending) = transition_store(hash) { + let finality_proof = ::std::iter::once(hash) + .chain(finalized) + .chain(epoch_manager.finality_checker.unfinalized_hashes()) + .map(|hash| chain(hash) + .expect("these headers fetched before when constructing finality checker; qed")) + .collect::>(); + + // this gives us the block number for `hash`, assuming it's ancestry. + let signal_number = chain_head.number() + - finality_proof.len() as BlockNumber + + 1; + let finality_proof = ::rlp::encode_list(&finality_proof); + epoch_manager.note_new_epoch(); + + return Some(combine_proofs(signal_number, &pending.proof, &*finality_proof)); + } + } + } + } + + None + } + + fn epoch_verifier<'a>(&self, _header: &Header, proof: &'a [u8]) -> ConstructedVerifier<'a> { + let (signal_number, set_proof, finality_proof) = match destructure_proofs(proof) { + Ok(x) => x, + Err(e) => return ConstructedVerifier::Err(e), + }; + + let first = signal_number == 0; + match self.validators.epoch_set(first, self, signal_number, set_proof) { + Ok((list, finalize)) => { + let verifier = Box::new(EpochVerifier { + step: self.step.clone(), + subchain_validators: list, + }); + + match finalize { + Some(finalize) => ConstructedVerifier::Unconfirmed(verifier, finality_proof, finalize), + None => ConstructedVerifier::Trusted(verifier), + } + } + Err(e) => ConstructedVerifier::Err(e), + } } fn verify_transaction_basic(&self, t: &UnverifiedTransaction, header: &Header) -> result::Result<(), Error> { @@ -465,7 +824,11 @@ impl Engine for AuthorityRound { } fn snapshot_components(&self) -> Option> { - Some(Box::new(::snapshot::PoaSnapshot)) + if self.immediate_transitions { + None + } else { + Some(Box::new(::snapshot::PoaSnapshot)) + } } } @@ -517,7 +880,7 @@ mod tests { fn can_do_signature_verification_fail() { let engine = Spec::new_test_round().engine; let mut header: Header = Header::default(); - header.set_seal(vec![encode(&H520::default()).to_vec()]); + header.set_seal(vec![encode(&H520::default()).into_vec()]); let verify_result = engine.verify_block_external(&header, None); assert!(verify_result.is_err()); @@ -535,9 +898,9 @@ mod tests { let db1 = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let db2 = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let b1 = OpenBlock::new(engine, Default::default(), false, db1, &genesis_header, last_hashes.clone(), addr1, (3141562.into(), 31415620.into()), vec![]).unwrap(); + let b1 = OpenBlock::new(engine, Default::default(), false, db1, &genesis_header, last_hashes.clone(), addr1, (3141562.into(), 31415620.into()), vec![], false).unwrap(); let b1 = b1.close_and_lock(); - let b2 = OpenBlock::new(engine, Default::default(), false, db2, &genesis_header, last_hashes, addr2, (3141562.into(), 31415620.into()), vec![]).unwrap(); + let b2 = OpenBlock::new(engine, Default::default(), false, db2, &genesis_header, last_hashes, addr2, (3141562.into(), 31415620.into()), vec![], false).unwrap(); let b2 = b2.close_and_lock(); engine.set_signer(tap.clone(), addr1, "1".into()); @@ -560,7 +923,7 @@ mod tests { let tap = AccountProvider::transient_provider(); let addr = tap.insert_account("0".sha3().into(), "0").unwrap(); let mut parent_header: Header = Header::default(); - parent_header.set_seal(vec![encode(&0usize).to_vec()]); + parent_header.set_seal(vec![encode(&0usize).into_vec()]); parent_header.set_gas_limit(U256::from_str("222222").unwrap()); let mut header: Header = Header::default(); header.set_number(1); @@ -572,10 +935,10 @@ mod tests { let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); // Two validators. // Spec starts with step 2. - header.set_seal(vec![encode(&2usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); + header.set_seal(vec![encode(&2usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_external(&header, None).is_err()); - header.set_seal(vec![encode(&1usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); + header.set_seal(vec![encode(&1usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_external(&header, None).is_ok()); } @@ -586,7 +949,7 @@ mod tests { let addr = tap.insert_account("0".sha3().into(), "0").unwrap(); let mut parent_header: Header = Header::default(); - parent_header.set_seal(vec![encode(&0usize).to_vec()]); + parent_header.set_seal(vec![encode(&0usize).into_vec()]); parent_header.set_gas_limit(U256::from_str("222222").unwrap()); let mut header: Header = Header::default(); header.set_number(1); @@ -598,10 +961,10 @@ mod tests { let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); // Two validators. // Spec starts with step 2. - header.set_seal(vec![encode(&1usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); + header.set_seal(vec![encode(&1usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_external(&header, None).is_ok()); - header.set_seal(vec![encode(&5usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); + header.set_seal(vec![encode(&5usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_external(&header, None).is_err()); } @@ -612,7 +975,7 @@ mod tests { let addr = tap.insert_account("0".sha3().into(), "0").unwrap(); let mut parent_header: Header = Header::default(); - parent_header.set_seal(vec![encode(&4usize).to_vec()]); + parent_header.set_seal(vec![encode(&4usize).into_vec()]); parent_header.set_gas_limit(U256::from_str("222222").unwrap()); let mut header: Header = Header::default(); header.set_number(1); @@ -624,9 +987,9 @@ mod tests { let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); // Two validators. // Spec starts with step 2. - header.set_seal(vec![encode(&5usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); + header.set_seal(vec![encode(&5usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); - header.set_seal(vec![encode(&3usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); + header.set_seal(vec![encode(&3usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]); assert!(engine.verify_block_family(&header, &parent_header, None).is_err()); } @@ -643,16 +1006,17 @@ mod tests { validate_score_transition: 0, validate_step_transition: 0, eip155_transition: 0, + immediate_transitions: true, }; let aura = AuthorityRound::new(Default::default(), params, Default::default()).unwrap(); let mut parent_header: Header = Header::default(); - parent_header.set_seal(vec![encode(&1usize).to_vec()]); + parent_header.set_seal(vec![encode(&1usize).into_vec()]); parent_header.set_gas_limit(U256::from_str("222222").unwrap()); let mut header: Header = Header::default(); header.set_number(1); header.set_gas_limit(U256::from_str("222222").unwrap()); - header.set_seal(vec![encode(&3usize).to_vec()]); + header.set_seal(vec![encode(&3usize).into_vec()]); assert!(aura.verify_block_family(&header, &parent_header, None).is_ok()); assert_eq!(last_benign.load(AtomicOrdering::SeqCst), 1); diff --git a/ethcore/src/engines/basic_authority.rs b/ethcore/src/engines/basic_authority.rs index 75a4806b8..4623352d1 100644 --- a/ethcore/src/engines/basic_authority.rs +++ b/ethcore/src/engines/basic_authority.rs @@ -23,7 +23,7 @@ use account_provider::AccountProvider; use block::*; use builtin::Builtin; use spec::CommonParams; -use engines::{Engine, EngineError, Seal, Call, EpochChange}; +use engines::{Engine, Seal, Call, ConstructedVerifier, EngineError}; use error::{BlockError, Error}; use evm::Schedule; use ethjson; @@ -51,12 +51,10 @@ impl From for BasicAuthorityParams { } struct EpochVerifier { - epoch_number: u64, list: SimpleList, } impl super::EpochVerifier for EpochVerifier { - fn epoch_number(&self) -> u64 { self.epoch_number.clone() } fn verify_light(&self, header: &Header) -> Result<(), Error> { verify_external(header, &self.list) } @@ -141,7 +139,7 @@ impl Engine for BasicAuthority { if self.validators.contains(header.parent_hash(), author) { // account should be pernamently unlocked, otherwise sealing will fail if let Ok(signature) = self.signer.sign(header.bare_hash()) { - return Seal::Regular(vec![::rlp::encode(&(&H520::from(signature) as &[u8])).to_vec()]); + return Seal::Regular(vec![::rlp::encode(&(&H520::from(signature) as &[u8])).into_vec()]); } else { trace!(target: "basicauthority", "generate_seal: FAIL: accounts secret key unavailable"); } @@ -187,26 +185,54 @@ impl Engine for BasicAuthority { verify_external(header, &*self.validators) } - // the proofs we need just allow us to get the full validator set. - fn epoch_proof(&self, header: &Header, caller: &Call) -> Result { - self.validators.epoch_proof(header, caller) - .map_err(|e| EngineError::InsufficientProof(e).into()) + fn genesis_epoch_data(&self, header: &Header, call: &Call) -> Result, String> { + self.validators.genesis_epoch_data(header, call) } - fn is_epoch_end(&self, header: &Header, block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) - -> EpochChange + #[cfg(not(test))] + fn signals_epoch_end(&self, _header: &Header, _block: Option<&[u8]>, _receipts: Option<&[::receipt::Receipt]>) + -> super::EpochChange { - self.validators.is_epoch_end(header, block, receipts) + // don't bother signalling even though a contract might try. + super::EpochChange::No } - fn epoch_verifier(&self, header: &Header, proof: &[u8]) -> Result, Error> { - // extract a simple list from the proof. - let (num, simple_list) = self.validators.epoch_set(header, proof)?; + #[cfg(test)] + fn signals_epoch_end(&self, header: &Header, block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) + -> super::EpochChange + { + // in test mode, always signal even though they don't be finalized. + let first = header.number() == 0; + self.validators.signals_epoch_end(first, header, block, receipts) + } - Ok(Box::new(EpochVerifier { - epoch_number: num, - list: simple_list, - })) + fn is_epoch_end( + &self, + chain_head: &Header, + _chain: &super::Headers, + _transition_store: &super::PendingTransitionStore, + ) -> Option> { + let first = chain_head.number() == 0; + + // finality never occurs so only apply immediate transitions. + self.validators.is_epoch_end(first, chain_head) + } + + fn epoch_verifier<'a>(&self, header: &Header, proof: &'a [u8]) -> ConstructedVerifier<'a> { + let first = header.number() == 0; + + match self.validators.epoch_set(first, self, header.number(), proof) { + Ok((list, finalize)) => { + let verifier = Box::new(EpochVerifier { list: list }); + + // our epoch verifier will ensure no unverified verifier is ever verified. + match finalize { + Some(finalize) => ConstructedVerifier::Unconfirmed(verifier, proof, finalize), + None => ConstructedVerifier::Trusted(verifier), + } + } + Err(e) => ConstructedVerifier::Err(e), + } } fn register_client(&self, client: Weak) { @@ -222,7 +248,7 @@ impl Engine for BasicAuthority { } fn snapshot_components(&self) -> Option> { - Some(Box::new(::snapshot::PoaSnapshot)) + None } } @@ -275,7 +301,7 @@ mod tests { fn can_do_signature_verification_fail() { let engine = new_test_authority().engine; let mut header: Header = Header::default(); - header.set_seal(vec![::rlp::encode(&H520::default()).to_vec()]); + header.set_seal(vec![::rlp::encode(&H520::default()).into_vec()]); let verify_result = engine.verify_block_family(&header, &Default::default(), None); assert!(verify_result.is_err()); @@ -292,7 +318,7 @@ mod tests { let genesis_header = spec.genesis_header(); let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![]).unwrap(); + let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![], false).unwrap(); let b = b.close_and_lock(); if let Seal::Regular(seal) = engine.generate_seal(b.block()) { assert!(b.try_seal(engine, seal).is_ok()); diff --git a/ethcore/src/engines/epoch.rs b/ethcore/src/engines/epoch.rs new file mode 100644 index 000000000..f738113cf --- /dev/null +++ b/ethcore/src/engines/epoch.rs @@ -0,0 +1,102 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +//! Epoch verifiers and transitions. + +use error::Error; +use header::Header; + +use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp}; +use util::H256; + +/// A full epoch transition. +#[derive(Debug, Clone)] +pub struct Transition { + /// Block hash at which the transition occurred. + pub block_hash: H256, + /// Block number at which the transition occurred. + pub block_number: u64, + /// "transition/epoch" proof from the engine combined with a finality proof. + pub proof: Vec, +} + +impl Encodable for Transition { + fn rlp_append(&self, s: &mut RlpStream) { + s.begin_list(3) + .append(&self.block_hash) + .append(&self.block_number) + .append(&self.proof); + } +} + +impl Decodable for Transition { + fn decode(rlp: &UntrustedRlp) -> Result { + Ok(Transition { + block_hash: rlp.val_at(0)?, + block_number: rlp.val_at(1)?, + proof: rlp.val_at(2)?, + }) + } +} + +/// An epoch transition pending a finality proof. +/// Not all transitions need one. +pub struct PendingTransition { + /// "transition/epoch" proof from the engine. + pub proof: Vec, +} + +impl Encodable for PendingTransition { + fn rlp_append(&self, s: &mut RlpStream) { + s.append(&self.proof); + } +} + +impl Decodable for PendingTransition { + fn decode(rlp: &UntrustedRlp) -> Result { + Ok(PendingTransition { + proof: rlp.as_val()?, + }) + } +} + +/// Verifier for all blocks within an epoch with self-contained state. +/// +/// See docs on `Engine` relating to proving functions for more details. +pub trait EpochVerifier: Send + Sync { + /// Lightly verify the next block header. + /// This may not be a header belonging to a different epoch. + fn verify_light(&self, header: &Header) -> Result<(), Error>; + + /// Perform potentially heavier checks on the next block header. + fn verify_heavy(&self, header: &Header) -> Result<(), Error> { + self.verify_light(header) + } + + /// Check a finality proof against this epoch verifier. + /// Returns `Some(hashes)` if the proof proves finality of these hashes. + /// Returns `None` if the proof doesn't prove anything. + fn check_finality_proof(&self, _proof: &[u8]) -> Option> { + None + } +} + +/// Special "no-op" verifier for stateless, epoch-less engines. +pub struct NoOp; + +impl EpochVerifier for NoOp { + fn verify_light(&self, _header: &Header) -> Result<(), Error> { Ok(()) } +} diff --git a/ethcore/src/engines/epoch_verifier.rs b/ethcore/src/engines/epoch_verifier.rs deleted file mode 100644 index 5fc794ec1..000000000 --- a/ethcore/src/engines/epoch_verifier.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -// Epoch verifiers. - -use error::Error; -use header::Header; - -/// Verifier for all blocks within an epoch with self-contained state. -/// -/// See docs on `Engine` relating to proving functions for more details. -pub trait EpochVerifier: Send + Sync { - /// Get the epoch number. - fn epoch_number(&self) -> u64; - - /// Lightly verify the next block header. - /// This may not be a header belonging to a different epoch. - fn verify_light(&self, header: &Header) -> Result<(), Error>; - - /// Perform potentially heavier checks on the next block header. - fn verify_heavy(&self, header: &Header) -> Result<(), Error> { - self.verify_light(header) - } -} - -/// Special "no-op" verifier for stateless, epoch-less engines. -pub struct NoOp; - -impl EpochVerifier for NoOp { - fn epoch_number(&self) -> u64 { 0 } - fn verify_light(&self, _header: &Header) -> Result<(), Error> { Ok(()) } -} diff --git a/ethcore/src/engines/instant_seal.rs b/ethcore/src/engines/instant_seal.rs index 249aa8ac2..38834622c 100644 --- a/ethcore/src/engines/instant_seal.rs +++ b/ethcore/src/engines/instant_seal.rs @@ -79,7 +79,7 @@ mod tests { let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let genesis_header = spec.genesis_header(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::default(), (3141562.into(), 31415620.into()), vec![]).unwrap(); + let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::default(), (3141562.into(), 31415620.into()), vec![], false).unwrap(); let b = b.close_and_lock(); if let Seal::Regular(seal) = engine.generate_seal(b.block()) { assert!(b.try_seal(engine, seal).is_ok()); @@ -93,7 +93,7 @@ mod tests { assert!(engine.verify_block_basic(&header, None).is_ok()); - header.set_seal(vec![::rlp::encode(&H520::default()).to_vec()]); + header.set_seal(vec![::rlp::encode(&H520::default()).into_vec()]); assert!(engine.verify_block_unordered(&header, None).is_ok()); } diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index 922eb11be..d24325803 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -18,7 +18,6 @@ mod authority_round; mod basic_authority; -mod epoch_verifier; mod instant_seal; mod null_engine; mod signer; @@ -27,15 +26,19 @@ mod transition; mod validator_set; mod vote_collector; +pub mod epoch; + pub use self::authority_round::AuthorityRound; pub use self::basic_authority::BasicAuthority; -pub use self::epoch_verifier::EpochVerifier; +pub use self::epoch::{EpochVerifier, Transition as EpochTransition}; pub use self::instant_seal::InstantSeal; pub use self::null_engine::NullEngine; pub use self::tendermint::Tendermint; use std::sync::Weak; +use self::epoch::PendingTransition; + use account_provider::AccountProvider; use block::ExecutedBlock; use builtin::Builtin; @@ -72,6 +75,10 @@ pub enum EngineError { BadSealFieldSize(OutOfBounds), /// Validation proof insufficient. InsufficientProof(String), + /// Failed system call. + FailedSystemCall(String), + /// Requires client ref, but none registered. + RequiresClient, } impl fmt::Display for EngineError { @@ -84,6 +91,8 @@ impl fmt::Display for EngineError { UnexpectedMessage => "This Engine should not be fed messages.".into(), BadSealFieldSize(ref oob) => format!("Seal field has an unexpected length: {}", oob), InsufficientProof(ref msg) => format!("Insufficient validation proof: {}", msg), + FailedSystemCall(ref msg) => format!("Failed to make system call: {}", msg), + RequiresClient => format!("Call requires client but none registered"), }; f.write_fmt(format_args!("Engine error ({})", msg)) @@ -102,17 +111,53 @@ pub enum Seal { } /// Type alias for a function we can make calls through synchronously. -pub type Call<'a> = Fn(Address, Bytes) -> Result + 'a; +/// Returns the call result and state proof for each call. +pub type Call<'a> = Fn(Address, Bytes) -> Result<(Bytes, Vec>), String> + 'a; + +/// Type alias for a function we can get headers by hash through. +pub type Headers<'a> = Fn(H256) -> Option
+ 'a; + +/// Type alias for a function we can query pending transitions by block hash through. +pub type PendingTransitionStore<'a> = Fn(H256) -> Option + 'a; + +/// Proof generated on epoch change. +pub enum Proof { + /// Known proof (exctracted from signal) + Known(Vec), + /// Extract proof from caller. + WithState(Box Result, String>>), +} + +/// Generated epoch verifier. +pub enum ConstructedVerifier<'a> { + /// Fully trusted verifier. + Trusted(Box), + /// Verifier unconfirmed. Check whether given finality proof finalizes given hash + /// under previous epoch. + Unconfirmed(Box, &'a [u8], H256), + /// Error constructing verifier. + Err(Error), +} + +impl<'a> ConstructedVerifier<'a> { + /// Convert to a result, indicating that any necessary confirmation has been done + /// already. + pub fn known_confirmed(self) -> Result, Error> { + match self { + ConstructedVerifier::Trusted(v) | ConstructedVerifier::Unconfirmed(v, _, _) => Ok(v), + ConstructedVerifier::Err(e) => Err(e), + } + } +} /// Results of a query of whether an epoch change occurred at the given block. -#[derive(Debug, Clone, PartialEq)] pub enum EpochChange { /// Cannot determine until more data is passed. Unsure(Unsure), /// No epoch change. No, - /// Validation proof required, and the new epoch number. - Yes(u64), + /// The epoch will change, with proof. + Yes(Proof), } /// More data required to determine if an epoch change occurred at a given block. @@ -171,7 +216,13 @@ pub trait Engine : Sync + Send { } /// Block transformation functions, before the transactions. - fn on_new_block(&self, block: &mut ExecutedBlock, last_hashes: Arc) -> Result<(), Error> { + /// `epoch_begin` set to true if this block kicks off an epoch. + fn on_new_block( + &self, + block: &mut ExecutedBlock, + last_hashes: Arc, + _epoch_begin: bool, + ) -> Result<(), Error> { let parent_hash = block.fields().header.parent_hash().clone(); common::push_last_hash(block, last_hashes, self, &parent_hash) } @@ -233,46 +284,44 @@ pub trait Engine : Sync + Send { self.verify_block_basic(header, None).and_then(|_| self.verify_block_unordered(header, None)) } - /// Generate epoch change proof. - /// - /// This will be used to generate proofs of epoch change as well as verify them. - /// Must be called on blocks that have already passed basic verification. - /// - /// Return the "epoch proof" generated. - /// This must be usable to generate a `EpochVerifier` for verifying all blocks - /// from the supplied header up to the next one where proof is required. - /// - /// For example, for PoA chains the proof will be a validator set, - /// and the corresponding `EpochVerifier` can be used to correctly validate - /// all blocks produced under that `ValidatorSet` - /// - /// It must be possible to generate an epoch proof for any block in an epoch, - /// and it should always be equivalent to the proof of the transition block. - fn epoch_proof(&self, _header: &Header, _caller: &Call) - -> Result, Error> - { - Ok(Vec::new()) - } + /// Genesis epoch data. + fn genesis_epoch_data(&self, _header: &Header, _call: &Call) -> Result, String> { Ok(Vec::new()) } - /// Whether an epoch change occurred at the given header. + /// Whether an epoch change is signalled at the given header but will require finality. + /// If a change can be enacted immediately then return `No` from this function but + /// `Yes` from `is_epoch_end`. /// /// If the block or receipts are required, return `Unsure` and the function will be /// called again with them. /// Return `Yes` or `No` when the answer is definitively known. /// /// Should not interact with state. - fn is_epoch_end(&self, _header: &Header, _block: Option<&[u8]>, _receipts: Option<&[Receipt]>) + fn signals_epoch_end(&self, _header: &Header, _block: Option<&[u8]>, _receipts: Option<&[Receipt]>) -> EpochChange { EpochChange::No } - /// Create an epoch verifier from validation proof. + /// Whether a block is the end of an epoch. /// - /// The proof should be one generated by `epoch_proof`. - /// See docs of `epoch_proof` for description. - fn epoch_verifier(&self, _header: &Header, _proof: &[u8]) -> Result, Error> { - Ok(Box::new(self::epoch_verifier::NoOp)) + /// This either means that an immediate transition occurs or a block signalling transition + /// has reached finality. The `Headers` given are not guaranteed to return any blocks + /// from any epoch other than the current. + /// + /// Return optional transition proof. + fn is_epoch_end( + &self, + _chain_head: &Header, + _chain: &Headers, + _transition_store: &PendingTransitionStore, + ) -> Option> { + None + } + + /// Create an epoch verifier from validation proof and a flag indicating + /// whether finality is required. + fn epoch_verifier<'a>(&self, _header: &Header, _proof: &'a [u8]) -> ConstructedVerifier<'a> { + ConstructedVerifier::Trusted(Box::new(self::epoch::NoOp)) } /// Populate a header's fields based on its parent's header. @@ -329,7 +378,11 @@ pub trait Engine : Sync + Send { /// Returns new contract address generation scheme at given block number. fn create_address_scheme(&self, number: BlockNumber) -> CreateContractAddress { - if number >= self.params().eip86_transition { CreateContractAddress::FromCodeHash } else { CreateContractAddress::FromSenderAndNonce } + if number >= self.params().eip86_transition { + CreateContractAddress::FromCodeHash + } else { + CreateContractAddress::FromSenderAndNonce + } } } @@ -349,6 +402,52 @@ pub mod common { use util::*; use super::Engine; + /// Execute a call as the system address. + pub fn execute_as_system( + block: &mut ExecutedBlock, + last_hashes: Arc, + engine: &E, + contract_address: Address, + gas: U256, + data: Option, + ) -> Result { + let env_info = { + let header = block.fields().header; + EnvInfo { + number: header.number(), + author: header.author().clone(), + timestamp: header.timestamp(), + difficulty: header.difficulty().clone(), + last_hashes: last_hashes, + gas_used: U256::zero(), + gas_limit: gas, + } + }; + + let mut state = block.fields_mut().state; + let params = ActionParams { + code_address: contract_address.clone(), + address: contract_address.clone(), + sender: SYSTEM_ADDRESS.clone(), + origin: SYSTEM_ADDRESS.clone(), + gas: gas, + gas_price: 0.into(), + value: ActionValue::Transfer(0.into()), + code: state.code(&contract_address)?, + code_hash: state.code_hash(&contract_address)?, + data: data, + call_type: CallType::Call, + }; + let mut ex = Executive::new(&mut state, &env_info, engine); + let mut substate = Substate::new(); + let mut output = Vec::new(); + if let Err(e) = ex.call(params, &mut substate, BytesRef::Flexible(&mut output), &mut NoopTracer, &mut NoopVMTracer) { + warn!("Encountered error on making system call: {}", e); + } + + Ok(output) + } + /// Push last known block hash to the state. pub fn push_last_hash(block: &mut ExecutedBlock, last_hashes: Arc, engine: &E, hash: &H256) -> Result<(), Error> { if block.fields().header.number() == engine.params().eip210_transition { @@ -356,39 +455,14 @@ pub mod common { state.init_code(&engine.params().eip210_contract_address, engine.params().eip210_contract_code.clone())?; } if block.fields().header.number() >= engine.params().eip210_transition { - let env_info = { - let header = block.fields().header; - EnvInfo { - number: header.number(), - author: header.author().clone(), - timestamp: header.timestamp(), - difficulty: header.difficulty().clone(), - last_hashes: last_hashes, - gas_used: U256::zero(), - gas_limit: engine.params().eip210_contract_gas, - } - }; - let mut state = block.fields_mut().state; - let contract_address = engine.params().eip210_contract_address; - let params = ActionParams { - code_address: contract_address.clone(), - address: contract_address.clone(), - sender: SYSTEM_ADDRESS.clone(), - origin: SYSTEM_ADDRESS.clone(), - gas: engine.params().eip210_contract_gas, - gas_price: 0.into(), - value: ActionValue::Transfer(0.into()), - code: state.code(&contract_address)?, - code_hash: state.code_hash(&contract_address)?, - data: Some(hash.to_vec()), - call_type: CallType::Call, - }; - let mut ex = Executive::new(&mut state, &env_info, engine); - let mut substate = Substate::new(); - let mut output = []; - if let Err(e) = ex.call(params, &mut substate, BytesRef::Fixed(&mut output), &mut NoopTracer, &mut NoopVMTracer) { - warn!("Encountered error on updating last hashes: {}", e); - } + let _ = execute_as_system( + block, + last_hashes, + engine, + engine.params().eip210_contract_address, + engine.params().eip210_contract_gas, + Some(hash.to_vec()), + )?; } Ok(()) } diff --git a/ethcore/src/engines/tendermint/message.rs b/ethcore/src/engines/tendermint/message.rs index 8c2b44325..b9465f429 100644 --- a/ethcore/src/engines/tendermint/message.rs +++ b/ethcore/src/engines/tendermint/message.rs @@ -228,7 +228,7 @@ mod tests { }, block_hash: Some("1".sha3()) }; - let raw_rlp = ::rlp::encode(&message).to_vec(); + let raw_rlp = ::rlp::encode(&message).into_vec(); let rlp = Rlp::new(&raw_rlp); assert_eq!(message, rlp.as_val()); @@ -265,8 +265,8 @@ mod tests { fn proposal_message() { let mut header = Header::default(); let seal = vec![ - ::rlp::encode(&0u8).to_vec(), - ::rlp::encode(&H520::default()).to_vec(), + ::rlp::encode(&0u8).into_vec(), + ::rlp::encode(&H520::default()).into_vec(), Vec::new() ]; diff --git a/ethcore/src/engines/tendermint/mod.rs b/ethcore/src/engines/tendermint/mod.rs index 2fc227eaf..70d4e0ced 100644 --- a/ethcore/src/engines/tendermint/mod.rs +++ b/ethcore/src/engines/tendermint/mod.rs @@ -342,9 +342,9 @@ impl Tendermint { let precommits = self.votes.round_signatures(vote_step, &bh); trace!(target: "engine", "Collected seal: {:?}", precommits); let seal = vec![ - ::rlp::encode(&vote_step.view).to_vec(), + ::rlp::encode(&vote_step.view).into_vec(), ::rlp::NULL_RLP.to_vec(), - ::rlp::encode_list(&precommits).to_vec() + ::rlp::encode_list(&precommits).into_vec() ]; self.submit_seal(bh, seal); self.votes.throw_out_old(&vote_step); @@ -446,8 +446,8 @@ impl Engine for Tendermint { *self.proposal.write() = bh; *self.proposal_parent.write() = header.parent_hash().clone(); Seal::Proposal(vec![ - ::rlp::encode(&view).to_vec(), - ::rlp::encode(&signature).to_vec(), + ::rlp::encode(&view).into_vec(), + ::rlp::encode(&signature).into_vec(), ::rlp::EMPTY_LIST_RLP.to_vec() ]) } else { @@ -466,7 +466,8 @@ impl Engine for Tendermint { } self.broadcast_message(rlp.as_raw().to_vec()); if let Some(double) = self.votes.vote(message.clone(), &sender) { - self.validators.report_malicious(&sender, message.vote_step.height as BlockNumber, ::rlp::encode(&double).to_vec()); + let height = message.vote_step.height as BlockNumber; + self.validators.report_malicious(&sender, height, height, ::rlp::encode(&double).into_vec()); return Err(EngineError::DoubleVote(sender).into()); } trace!(target: "engine", "Handling a valid {:?} from {}.", message, sender); @@ -555,7 +556,7 @@ impl Engine for Tendermint { let min_gas = parent.gas_limit().clone() - parent.gas_limit().clone() / gas_limit_divisor; let max_gas = parent.gas_limit().clone() + parent.gas_limit().clone() / gas_limit_divisor; if header.gas_limit() <= &min_gas || header.gas_limit() >= &max_gas { - self.validators.report_malicious(header.author(), header.number(), Default::default()); + self.validators.report_malicious(header.author(), header.number(), header.number(), Default::default()); return Err(BlockError::InvalidGasLimit(OutOfBounds { min: Some(min_gas), max: Some(max_gas), found: header.gas_limit().clone() }).into()); } @@ -607,7 +608,7 @@ impl Engine for Tendermint { // Report the proposer if no proposal was received. let height = self.height.load(AtomicOrdering::SeqCst); let current_proposer = self.view_proposer(&*self.proposal_parent.read(), height, self.view.load(AtomicOrdering::SeqCst)); - self.validators.report_benign(¤t_proposer, height as BlockNumber); + self.validators.report_benign(¤t_proposer, height as BlockNumber, height as BlockNumber); } Step::Prevote }, @@ -674,7 +675,7 @@ mod tests { let db = spec.ensure_db_good(db, &Default::default()).unwrap(); let genesis_header = spec.genesis_header(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let b = OpenBlock::new(spec.engine.as_ref(), Default::default(), false, db.boxed_clone(), &genesis_header, last_hashes, proposer, (3141562.into(), 31415620.into()), vec![]).unwrap(); + let b = OpenBlock::new(spec.engine.as_ref(), Default::default(), false, db.boxed_clone(), &genesis_header, last_hashes, proposer, (3141562.into(), 31415620.into()), vec![], false).unwrap(); let b = b.close(); if let Seal::Proposal(seal) = spec.engine.generate_seal(b.block()) { (b, seal) @@ -695,8 +696,8 @@ mod tests { let vote_info = message_info_rlp(&VoteStep::new(header.number() as Height, view, Step::Propose), Some(header.bare_hash())); let signature = tap.sign(*author, None, vote_info.sha3()).unwrap(); vec![ - ::rlp::encode(&view).to_vec(), - ::rlp::encode(&H520::from(signature)).to_vec(), + ::rlp::encode(&view).into_vec(), + ::rlp::encode(&H520::from(signature)).into_vec(), ::rlp::EMPTY_LIST_RLP.to_vec() ] } @@ -812,7 +813,7 @@ mod tests { let signature1 = tap.sign(proposer, None, vote_info.sha3()).unwrap(); seal[1] = ::rlp::NULL_RLP.to_vec(); - seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).to_vec(); + seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).into_vec(); header.set_seal(seal.clone()); // One good signature is not enough. @@ -824,7 +825,7 @@ mod tests { let voter = insert_and_unlock(&tap, "0"); let signature0 = tap.sign(voter, None, vote_info.sha3()).unwrap(); - seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone()), H520::from(signature0.clone())]).to_vec(); + seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone()), H520::from(signature0.clone())]).into_vec(); header.set_seal(seal.clone()); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); @@ -832,7 +833,7 @@ mod tests { let bad_voter = insert_and_unlock(&tap, "101"); let bad_signature = tap.sign(bad_voter, None, vote_info.sha3()).unwrap(); - seal[2] = ::rlp::encode_list(&vec![H520::from(signature1), H520::from(bad_signature)]).to_vec(); + seal[2] = ::rlp::encode_list(&vec![H520::from(signature1), H520::from(bad_signature)]).into_vec(); header.set_seal(seal); // One good and one bad signature. diff --git a/ethcore/src/engines/transition.rs b/ethcore/src/engines/transition.rs index 0211d21a8..590fb6db2 100644 --- a/ethcore/src/engines/transition.rs +++ b/ethcore/src/engines/transition.rs @@ -36,7 +36,7 @@ pub struct TransitionHandler { timeouts: Box>, } -impl TransitionHandler where S: Sync + Send + Clone { +impl TransitionHandler where S: Sync + Send + Clone { /// New step caller by timeouts. pub fn new(engine: Weak, timeouts: Box>) -> Self { TransitionHandler { @@ -54,7 +54,7 @@ fn set_timeout(io: &IoContext, timeout: Duration) { .unwrap_or_else(|e| warn!(target: "engine", "Failed to set consensus step timeout: {}.", e)) } -impl IoHandler for TransitionHandler where S: Sync + Send + Clone + 'static { +impl IoHandler for TransitionHandler where S: Sync + Send + Clone + 'static { fn initialize(&self, io: &IoContext) { let initial = self.timeouts.initial(); trace!(target: "engine", "Setting the initial timeout to {}.", initial); diff --git a/ethcore/src/engines/validator_set/contract.rs b/ethcore/src/engines/validator_set/contract.rs index b3c06aed1..c2d3fd064 100644 --- a/ethcore/src/engines/validator_set/contract.rs +++ b/ethcore/src/engines/validator_set/contract.rs @@ -24,10 +24,10 @@ use futures::Future; use native_contracts::ValidatorReport as Provider; use client::{Client, BlockChainClient}; -use engines::Call; +use engines::{Call, Engine}; use header::{Header, BlockNumber}; -use super::ValidatorSet; +use super::{ValidatorSet, SimpleList, SystemCall}; use super::safe_contract::ValidatorSafeContract; /// A validator contract with reporting. @@ -51,7 +51,7 @@ impl ValidatorContract { // could be `impl Trait`. // note: dispatches transactions to network as well as execute. // TODO [keorn]: Make more general. - fn transact(&self) -> Box { + fn transact(&self) -> Box Result> { let client = self.client.read().clone(); Box::new(move |a, d| client.as_ref() .and_then(Weak::upgrade) @@ -66,18 +66,30 @@ impl ValidatorSet for ValidatorContract { self.validators.default_caller(id) } - fn is_epoch_end(&self, header: &Header, block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) - -> ::engines::EpochChange - { - self.validators.is_epoch_end(header, block, receipts) + fn on_epoch_begin(&self, first: bool, header: &Header, call: &mut SystemCall) -> Result<(), ::error::Error> { + self.validators.on_epoch_begin(first, header, call) } - fn epoch_proof(&self, header: &Header, caller: &Call) -> Result, String> { - self.validators.epoch_proof(header, caller) + fn genesis_epoch_data(&self, header: &Header, call: &Call) -> Result, String> { + self.validators.genesis_epoch_data(header, call) } - fn epoch_set(&self, header: &Header, proof: &[u8]) -> Result<(u64, super::SimpleList), ::error::Error> { - self.validators.epoch_set(header, proof) + fn is_epoch_end(&self, first: bool, chain_head: &Header) -> Option> { + self.validators.is_epoch_end(first, chain_head) + } + + fn signals_epoch_end( + &self, + first: bool, + header: &Header, + block: Option<&[u8]>, + receipts: Option<&[::receipt::Receipt]>, + ) -> ::engines::EpochChange { + self.validators.signals_epoch_end(first, header, block, receipts) + } + + fn epoch_set(&self, first: bool, engine: &Engine, number: BlockNumber, proof: &[u8]) -> Result<(SimpleList, Option), ::error::Error> { + self.validators.epoch_set(first, engine, number, proof) } fn contains_with_caller(&self, bh: &H256, address: &Address, caller: &Call) -> bool { @@ -92,14 +104,14 @@ impl ValidatorSet for ValidatorContract { self.validators.count_with_caller(bh, caller) } - fn report_malicious(&self, address: &Address, block: BlockNumber, proof: Bytes) { + fn report_malicious(&self, address: &Address, _set_block: BlockNumber, block: BlockNumber, proof: Bytes) { match self.provider.report_malicious(&*self.transact(), *address, block.into(), proof).wait() { Ok(_) => warn!(target: "engine", "Reported malicious validator {}", address), Err(s) => warn!(target: "engine", "Validator {} could not be reported {}", address, s), } } - fn report_benign(&self, address: &Address, block: BlockNumber) { + fn report_benign(&self, address: &Address, _set_block: BlockNumber, block: BlockNumber) { match self.provider.report_benign(&*self.transact(), *address, block.into()).wait() { Ok(_) => warn!(target: "engine", "Reported benign validator misbehaviour {}", address), Err(s) => warn!(target: "engine", "Validator {} could not be reported {}", address, s), @@ -149,7 +161,7 @@ mod tests { client.miner().set_engine_signer(v1, "".into()).unwrap(); let mut header = Header::default(); - let seal = vec![encode(&5u8).to_vec(), encode(&(&H520::default() as &[u8])).to_vec()]; + let seal = vec![encode(&5u8).into_vec(), encode(&(&H520::default() as &[u8])).into_vec()]; header.set_seal(seal); header.set_author(v1); header.set_number(2); diff --git a/ethcore/src/engines/validator_set/mod.rs b/ethcore/src/engines/validator_set/mod.rs index 622793a73..56cff365f 100644 --- a/ethcore/src/engines/validator_set/mod.rs +++ b/ethcore/src/engines/validator_set/mod.rs @@ -37,7 +37,10 @@ use self::contract::ValidatorContract; use self::safe_contract::ValidatorSafeContract; use self::multi::Multi; -use super::Call; +use super::{Call, Engine}; + +/// A system-calling closure. Enacts calls on a block's state from the system address. +pub type SystemCall<'a> = FnMut(Address, Bytes) -> Result + 'a; /// Creates a validator set from spec. pub fn new_validator_set(spec: ValidatorSpec) -> Box { @@ -64,6 +67,7 @@ pub trait ValidatorSet: Send + Sync { let default = self.default_caller(BlockId::Hash(*parent)); self.contains_with_caller(parent, address, &*default) } + /// Draws an validator nonce modulo number of validators. fn get(&self, parent: &H256, nonce: usize) -> Address { let default = self.default_caller(BlockId::Hash(*parent)); @@ -76,48 +80,66 @@ pub trait ValidatorSet: Send + Sync { self.count_with_caller(parent, &*default) } + /// Signalling that a new epoch has begun. + /// + /// All calls here will be from the `SYSTEM_ADDRESS`: 2^160 - 2 + /// and will have an effect on the block's state. + /// The caller provided here may not generate proofs. + /// + /// `first` is true if this is the first block in the set. + fn on_epoch_begin(&self, _first: bool, _header: &Header, _call: &mut SystemCall) -> Result<(), ::error::Error> { + Ok(()) + } + + /// Extract genesis epoch data from the genesis state and header. + fn genesis_epoch_data(&self, _header: &Header, _call: &Call) -> Result, String> { Ok(Vec::new()) } + /// Whether this block is the last one in its epoch. - /// Usually indicates that the validator set changed at the given block. /// - /// Should not inspect state! This is used in situations where - /// state is not generally available. + /// Indicates that the validator set changed at the given block in a manner + /// that doesn't require finality. /// - /// Return `Yes` or `No` indicating whether it changed at the given header, - /// or `Unsure` indicating a need for more information. - /// - /// If block or receipts are provided, do not return `Unsure` indicating - /// need for them. - fn is_epoch_end(&self, header: &Header, block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) - -> super::EpochChange; + /// `first` is true if this is the first block in the set. + fn is_epoch_end(&self, first: bool, chain_head: &Header) -> Option>; - /// Generate epoch proof. - /// Must interact with state only through the given caller! - /// Otherwise, generated proofs may be wrong. - fn epoch_proof(&self, header: &Header, caller: &Call) -> Result, String>; + /// Whether the given block signals the end of an epoch, but change won't take effect + /// until finality. + /// + /// Engine should set `first` only if the header is genesis. Multiplexing validator + /// sets can set `first` to internal changes. + fn signals_epoch_end( + &self, + first: bool, + header: &Header, + block: Option<&[u8]>, + receipts: Option<&[::receipt::Receipt]>, + ) -> ::engines::EpochChange; - /// Recover the validator set for all + /// Recover the validator set from the given proof, the block number, and + /// whether this header is first in its set. /// /// May fail if the given header doesn't kick off an epoch or /// the proof is invalid. /// - /// Returns the epoch number and proof. - fn epoch_set(&self, header: &Header, proof: &[u8]) -> Result<(u64, SimpleList), ::error::Error>; + /// Returns the set, along with a flag indicating whether finality of a specific + /// hash should be proven. + fn epoch_set(&self, first: bool, engine: &Engine, number: BlockNumber, proof: &[u8]) + -> Result<(SimpleList, Option), ::error::Error>; /// Checks if a given address is a validator, with the given function /// for executing synchronous calls to contracts. fn contains_with_caller(&self, parent_block_hash: &H256, address: &Address, caller: &Call) -> bool; /// Draws an validator nonce modulo number of validators. - /// fn get_with_caller(&self, parent_block_hash: &H256, nonce: usize, caller: &Call) -> Address; /// Returns the current number of validators. fn count_with_caller(&self, parent_block_hash: &H256, caller: &Call) -> usize; /// Notifies about malicious behaviour. - fn report_malicious(&self, _validator: &Address, _block: BlockNumber, _proof: Bytes) {} + fn report_malicious(&self, _validator: &Address, _set_block: BlockNumber, _block: BlockNumber, _proof: Bytes) {} /// Notifies about benign misbehaviour. - fn report_benign(&self, _validator: &Address, _block: BlockNumber) {} + fn report_benign(&self, _validator: &Address, _set_block: BlockNumber, _block: BlockNumber) {} /// Allows blockchain state access. fn register_contract(&self, _client: Weak) {} } diff --git a/ethcore/src/engines/validator_set/multi.rs b/ethcore/src/engines/validator_set/multi.rs index 27570ed27..5835dbcdb 100644 --- a/ethcore/src/engines/validator_set/multi.rs +++ b/ethcore/src/engines/validator_set/multi.rs @@ -18,12 +18,12 @@ use std::collections::BTreeMap; use std::sync::Weak; -use engines::{Call, EpochChange}; +use engines::{Call, Engine}; use util::{Bytes, H256, Address, RwLock}; use ids::BlockId; use header::{BlockNumber, Header}; use client::{Client, BlockChainClient}; -use super::ValidatorSet; +use super::{SystemCall, ValidatorSet}; type BlockNumberLookup = Box Result + Send + Sync + 'static>; @@ -72,49 +72,38 @@ impl ValidatorSet for Multi { .unwrap_or(Box::new(|_, _| Err("No validator set for given ID.".into()))) } - fn is_epoch_end(&self, header: &Header, block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) - -> EpochChange + fn on_epoch_begin(&self, _first: bool, header: &Header, call: &mut SystemCall) -> Result<(), ::error::Error> { + let (set_block, set) = self.correct_set_by_number(header.number()); + let first = set_block == header.number(); + + set.on_epoch_begin(first, header, call) + } + + fn genesis_epoch_data(&self, header: &Header, call: &Call) -> Result, String> { + self.correct_set_by_number(0).1.genesis_epoch_data(header, call) + } + + fn is_epoch_end(&self, _first: bool, chain_head: &Header) -> Option> { + let (set_block, set) = self.correct_set_by_number(chain_head.number()); + let first = set_block == chain_head.number(); + + set.is_epoch_end(first, chain_head) + } + + fn signals_epoch_end(&self, _first: bool, header: &Header, block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) + -> ::engines::EpochChange { let (set_block, set) = self.correct_set_by_number(header.number()); - let (next_set_block, _) = self.correct_set_by_number(header.number() + 1); + let first = set_block == header.number(); - // multi-set transitions require epoch changes. - if next_set_block != set_block { - return EpochChange::Yes(next_set_block); - } - - match set.is_epoch_end(header, block, receipts) { - EpochChange::Yes(num) => EpochChange::Yes(set_block + num), - other => other, - } + set.signals_epoch_end(first, header, block, receipts) } - fn epoch_proof(&self, header: &Header, caller: &Call) -> Result, String> { - let (set_block, set) = self.correct_set_by_number(header.number()); - let (next_set_block, next_set) = self.correct_set_by_number(header.number() + 1); + fn epoch_set(&self, _first: bool, engine: &Engine, number: BlockNumber, proof: &[u8]) -> Result<(super::SimpleList, Option), ::error::Error> { + let (set_block, set) = self.correct_set_by_number(number); + let first = set_block == number; - if next_set_block != set_block { - return next_set.epoch_proof(header, caller); - } - - set.epoch_proof(header, caller) - } - - fn epoch_set(&self, header: &Header, proof: &[u8]) -> Result<(u64, super::SimpleList), ::error::Error> { - // "multi" epoch is the inner set's epoch plus the transition block to that set. - // ensures epoch increases monotonically. - let (set_block, set) = self.correct_set_by_number(header.number()); - let (next_set_block, next_set) = self.correct_set_by_number(header.number() + 1); - - // this block kicks off a new validator set -- get the validator set - // starting there. - if next_set_block != set_block { - let (inner_epoch, list) = next_set.epoch_set(header, proof)?; - Ok((next_set_block + inner_epoch, list)) - } else { - let (inner_epoch, list) = set.epoch_set(header, proof)?; - Ok((set_block + inner_epoch, list)) - } + set.epoch_set(first, engine, number, proof) } fn contains_with_caller(&self, bh: &H256, address: &Address, caller: &Call) -> bool { @@ -132,12 +121,12 @@ impl ValidatorSet for Multi { .map_or_else(usize::max_value, |set| set.count_with_caller(bh, caller)) } - fn report_malicious(&self, validator: &Address, block: BlockNumber, proof: Bytes) { - self.correct_set_by_number(block).1.report_malicious(validator, block, proof); + fn report_malicious(&self, validator: &Address, set_block: BlockNumber, block: BlockNumber, proof: Bytes) { + self.correct_set_by_number(set_block).1.report_malicious(validator, set_block, block, proof); } - fn report_benign(&self, validator: &Address, block: BlockNumber) { - self.correct_set_by_number(block).1.report_benign(validator, block); + fn report_benign(&self, validator: &Address, set_block: BlockNumber, block: BlockNumber) { + self.correct_set_by_number(set_block).1.report_benign(validator, set_block, block); } fn register_contract(&self, client: Weak) { @@ -153,18 +142,24 @@ impl ValidatorSet for Multi { #[cfg(test)] mod tests { - use util::*; - use types::ids::BlockId; - use spec::Spec; use account_provider::AccountProvider; use client::{BlockChainClient, EngineClient}; + use engines::EpochChange; + use engines::validator_set::ValidatorSet; use ethkey::Secret; + use header::Header; use miner::MinerService; + use spec::Spec; use tests::helpers::{generate_dummy_client_with_spec_and_accounts, generate_dummy_client_with_spec_and_data}; + use types::ids::BlockId; + use util::*; + + use super::Multi; #[test] fn uses_current_set() { - ::env_logger::init().unwrap(); + let _ = ::env_logger::init(); + let tap = Arc::new(AccountProvider::transient_provider()); let s0: Secret = "0".sha3().into(); let v0 = tap.insert_account(s0.clone(), "").unwrap(); @@ -205,4 +200,39 @@ mod tests { sync_client.flush_queue(); assert_eq!(sync_client.chain_info().best_block_number, 3); } + + #[test] + fn transition_to_fixed_list_instant() { + use super::super::SimpleList; + + let mut map: BTreeMap<_, Box> = BTreeMap::new(); + let list1: Vec<_> = (0..10).map(|_| Address::random()).collect(); + let list2 = { + let mut list = list1.clone(); + list.push(Address::random()); + list + }; + + map.insert(0, Box::new(SimpleList::new(list1))); + map.insert(500, Box::new(SimpleList::new(list2))); + + let multi = Multi::new(map); + + let mut header = Header::new(); + header.set_number(499); + + match multi.signals_epoch_end(false, &header, None, None) { + EpochChange::No => {}, + _ => panic!("Expected no epoch signal change."), + } + assert!(multi.is_epoch_end(false, &header).is_none()); + + header.set_number(500); + + match multi.signals_epoch_end(false, &header, None, None) { + EpochChange::No => {}, + _ => panic!("Expected no epoch signal change."), + } + assert!(multi.is_epoch_end(false, &header).is_some()); + } } diff --git a/ethcore/src/engines/validator_set/safe_contract.rs b/ethcore/src/engines/validator_set/safe_contract.rs index 27415418e..de8d16ddc 100644 --- a/ethcore/src/engines/validator_set/safe_contract.rs +++ b/ethcore/src/engines/validator_set/safe_contract.rs @@ -22,21 +22,23 @@ use native_contracts::ValidatorSet as Provider; use util::*; use util::cache::MemoryLruCache; +use rlp::{UntrustedRlp, RlpStream}; use basic_types::LogBloom; use client::{Client, BlockChainClient}; -use engines::Call; +use engines::{Call, Engine}; use header::Header; use ids::BlockId; use log_entry::LogEntry; +use receipt::Receipt; -use super::ValidatorSet; +use super::{SystemCall, ValidatorSet}; use super::simple_list::SimpleList; const MEMOIZE_CAPACITY: usize = 500; // TODO: ethabi should be able to generate this. -const EVENT_NAME: &'static [u8] = &*b"ValidatorsChanged(bytes32,uint256,address[])"; +const EVENT_NAME: &'static [u8] = &*b"InitiateChange(bytes32,address[])"; lazy_static! { static ref EVENT_NAME_HASH: H256 = EVENT_NAME.sha3(); @@ -50,12 +52,66 @@ pub struct ValidatorSafeContract { client: RwLock>>, // TODO [keorn]: remove } -fn encode_proof(nonce: U256, validators: &[Address]) -> Bytes { - use rlp::RlpStream; - +// first proof is just a state proof call of `getValidators` at header's state. +fn encode_first_proof(header: &Header, state_items: &[Vec]) -> Bytes { let mut stream = RlpStream::new_list(2); - stream.append(&nonce).append_list(validators); - stream.drain().to_vec() + stream.append(header).begin_list(state_items.len()); + for item in state_items { + stream.append(item); + } + + stream.out() +} + +fn decode_first_proof(rlp: &UntrustedRlp) -> Result<(Header, Vec), ::error::Error> { + let header = rlp.val_at(0)?; + let state_items = rlp.at(1)?.iter().map(|x| { + let mut val = DBValue::new(); + val.append_slice(x.data()?); + Ok(val) + }).collect::>()?; + + Ok((header, state_items)) +} + +// inter-contract proofs are a header and receipts. +// checking will involve ensuring that the receipts match the header and +// extracting the validator set from the receipts. +fn encode_proof(header: &Header, receipts: &[Receipt]) -> Bytes { + let mut stream = RlpStream::new_list(2); + stream.append(header).append_list(receipts); + stream.drain().into_vec() +} + +fn decode_proof(rlp: &UntrustedRlp) -> Result<(Header, Vec), ::error::Error> { + Ok((rlp.val_at(0)?, rlp.list_at(1)?)) +} + +// given a provider and caller, generate proof. this will just be a state proof +// of `getValidators`. +fn prove_initial(provider: &Provider, header: &Header, caller: &Call) -> Result, String> { + use std::cell::RefCell; + + let epoch_proof = RefCell::new(None); + let res = { + let caller = |a, d| { + let (result, proof) = caller(a, d)?; + *epoch_proof.borrow_mut() = Some(encode_first_proof(header, &proof)); + Ok(result) + }; + + provider.get_validators(caller) + .wait() + }; + + res.map(|validators| { + let proof = epoch_proof.into_inner().expect("epoch_proof always set after call; qed"); + + trace!(target: "engine", "obtained proof for initial set: {} validators, {} bytes", + validators.len(), proof.len()); + + proof + }) } impl ValidatorSafeContract { @@ -70,6 +126,7 @@ impl ValidatorSafeContract { /// Queries the state and gets the set of validators. fn get_list(&self, caller: &Call) -> Option { + let caller = move |a, d| caller(a, d).map(|x| x.0); match self.provider.get_validators(caller).wait() { Ok(new) => { debug!(target: "engine", "Set of validators obtained: {:?}", new); @@ -82,17 +139,6 @@ impl ValidatorSafeContract { } } - /// Queries for the current validator set transition nonce. - fn get_nonce(&self, caller: &Call) -> Option<::util::U256> { - match self.provider.transition_nonce(caller).wait() { - Ok(nonce) => Some(nonce), - Err(s) => { - debug!(target: "engine", "Unable to fetch transition nonce: {}", s); - None - } - } - } - // Whether the header matches the expected bloom. // // The expected log should have 3 topics: @@ -109,12 +155,70 @@ impl ValidatorSafeContract { // // The log data is an array of all new validator addresses. fn expected_bloom(&self, header: &Header) -> LogBloom { + let topics = vec![*EVENT_NAME_HASH, *header.parent_hash()]; + + debug!(target: "engine", "Expected topics for header {}: {:?}", + header.hash(), topics); + LogEntry { address: self.address, - topics: vec![*EVENT_NAME_HASH, *header.parent_hash()], + topics: topics, data: Vec::new(), // irrelevant for bloom. }.bloom() } + + // check receipts for log event. bloom should be `expected_bloom` for the + // header the receipts correspond to. + fn extract_from_event(&self, bloom: LogBloom, header: &Header, receipts: &[Receipt]) -> Option { + let check_log = |log: &LogEntry| { + log.address == self.address && + log.topics.len() == 2 && + log.topics[0] == *EVENT_NAME_HASH && + log.topics[1] == *header.parent_hash() + }; + + let event = Provider::contract(&self.provider) + .event("InitiateChange".into()) + .expect("Contract known ahead of time to have `InitiateChange` event; qed"); + + // iterate in reverse because only the _last_ change in a given + // block actually has any effect. + // the contract should only increment the nonce once. + let mut decoded_events = receipts.iter() + .rev() + .filter(|r| &bloom & &r.log_bloom == bloom) + .flat_map(|r| r.logs.iter()) + .filter(move |l| check_log(l)) + .filter_map(|log| { + let topics = log.topics.iter().map(|x| x.0.clone()).collect(); + event.decode_log(topics, log.data.clone()).ok() + }); + + match decoded_events.next() { + None => None, + Some(matched_event) => { + + // decode log manually until the native contract generator is + // good enough to do it for us. + let &(_, _, ref validators_token) = &matched_event.params[1]; + + let validators = validators_token.clone().to_array() + .and_then(|a| a.into_iter() + .map(|x| x.to_address().map(H160)) + .collect::>>() + ) + .map(SimpleList::new); + + if validators.is_none() { + debug!(target: "engine", "Successfully decoded log turned out to be bad."); + } + + trace!(target: "engine", "decoded log. validators: {:?}", validators); + + validators + } + } + } } impl ValidatorSet for ValidatorSafeContract { @@ -123,97 +227,144 @@ impl ValidatorSet for ValidatorSafeContract { Box::new(move |addr, data| client.as_ref() .and_then(Weak::upgrade) .ok_or("No client!".into()) - .and_then(|c| c.call_contract(id, addr, data))) + .and_then(|c| c.call_contract(id, addr, data)) + .map(|out| (out, Vec::new()))) // generate no proofs in general } - fn is_epoch_end(&self, header: &Header, _block: Option<&[u8]>, receipts: Option<&[::receipt::Receipt]>) + fn on_epoch_begin(&self, first: bool, _header: &Header, caller: &mut SystemCall) -> Result<(), ::error::Error> { + if first { return Ok(()) } // only signalled changes need to be noted. + + self.provider.finalize_change(caller) + .wait() + .map_err(::engines::EngineError::FailedSystemCall) + .map_err(Into::into) + } + + fn genesis_epoch_data(&self, header: &Header, call: &Call) -> Result, String> { + prove_initial(&self.provider, header, call) + } + + fn is_epoch_end(&self, _first: bool, _chain_head: &Header) -> Option> { + None // no immediate transitions to contract. + } + + fn signals_epoch_end(&self, first: bool, header: &Header, _block: Option<&[u8]>, receipts: Option<&[Receipt]>) -> ::engines::EpochChange { + // transition to the first block of a contract requires finality but has no log event. + if first { + debug!(target: "engine", "signalling transition to fresh contract."); + let (provider, header) = (self.provider.clone(), header.clone()); + let with_caller: Box _> = Box::new(move |caller| prove_initial(&provider, &header, caller)); + return ::engines::EpochChange::Yes(::engines::Proof::WithState(with_caller)) + } + + // otherwise, we're checking for logs. let bloom = self.expected_bloom(header); let header_bloom = header.log_bloom(); if &bloom & header_bloom != bloom { return ::engines::EpochChange::No } + trace!(target: "engine", "detected epoch change event bloom"); + match receipts { None => ::engines::EpochChange::Unsure(::engines::Unsure::NeedsReceipts), - Some(receipts) => { - let check_log = |log: &LogEntry| { - log.address == self.address && - log.topics.len() == 3 && - log.topics[0] == *EVENT_NAME_HASH && - log.topics[1] == *header.parent_hash() - // don't have anything to compare nonce to yet. - }; + Some(receipts) => match self.extract_from_event(bloom, header, receipts) { + None => ::engines::EpochChange::No, + Some(_) => { + debug!(target: "engine", "signalling transition within contract"); - let event = Provider::contract(&self.provider) - .event("ValidatorsChanged".into()) - .expect("Contract known ahead of time to have `ValidatorsChanged` event; qed"); - - // iterate in reverse because only the _last_ change in a given - // block actually has any effect. - // the contract should only increment the nonce once. - let mut decoded_events = receipts.iter() - .rev() - .filter(|r| &bloom & &r.log_bloom == bloom) - .flat_map(|r| r.logs.iter()) - .filter(move |l| check_log(l)) - .filter_map(|log| { - let topics = log.topics.iter().map(|x| x.0.clone()).collect(); - match event.decode_log(topics, log.data.clone()) { - Ok(decoded) => Some(decoded), - Err(_) => None, - } - }); - - match decoded_events.next() { - None => ::engines::EpochChange::No, - Some(matched_event) => { - // decode log manually until the native contract generator is - // good enough to do it for us. - let &(_, _, ref nonce_token) = &matched_event.params[1]; - let &(_, _, ref validators_token) = &matched_event.params[2]; - - let nonce: Option = nonce_token.clone().to_uint() - .map(H256).map(Into::into); - let validators = validators_token.clone().to_array() - .and_then(|a| a.into_iter() - .map(|x| x.to_address().map(H160)) - .collect::>>() - ); - - match (nonce, validators) { - (Some(nonce), Some(_)) => { - let new_epoch = nonce.low_u64(); - ::engines::EpochChange::Yes(new_epoch) - } - _ => { - debug!(target: "engine", "Successfully decoded log turned out to be bad."); - ::engines::EpochChange::No - } - } - } + let proof = encode_proof(&header, receipts); + ::engines::EpochChange::Yes(::engines::Proof::Known(proof)) } - } + }, } } - // the proof we generate is an RLP list containing two parts. - // (nonce, validators) - fn epoch_proof(&self, _header: &Header, caller: &Call) -> Result, String> { - match (self.get_nonce(caller), self.get_list(caller)) { - (Some(nonce), Some(list)) => Ok(encode_proof(nonce, &list.into_inner())), - _ => Err("Caller insufficient to generate validator proof.".into()), - } - } - - fn epoch_set(&self, _header: &Header, proof: &[u8]) -> Result<(u64, SimpleList), ::error::Error> { - use rlp::UntrustedRlp; + fn epoch_set(&self, first: bool, engine: &Engine, _number: ::header::BlockNumber, proof: &[u8]) + -> Result<(SimpleList, Option), ::error::Error> + { + use transaction::{Action, Transaction}; let rlp = UntrustedRlp::new(proof); - let nonce: u64 = rlp.val_at(0)?; - let validators: Vec
= rlp.list_at(1)?; - Ok((nonce, SimpleList::new(validators))) + if first { + trace!(target: "engine", "Recovering initial epoch set"); + + // TODO: match client contract_call_tx more cleanly without duplication. + const PROVIDED_GAS: u64 = 50_000_000; + + let (old_header, state_items) = decode_first_proof(&rlp)?; + let old_hash = old_header.hash(); + + let env_info = ::env_info::EnvInfo { + number: old_header.number(), + author: *old_header.author(), + difficulty: *old_header.difficulty(), + gas_limit: PROVIDED_GAS.into(), + timestamp: old_header.timestamp(), + last_hashes: { + // this will break if we don't inclue all 256 last hashes. + let mut last_hashes: Vec<_> = (0..256).map(|_| H256::default()).collect(); + last_hashes[255] = *old_header.parent_hash(); + Arc::new(last_hashes) + }, + gas_used: 0.into(), + }; + + // check state proof using given engine. + let number = old_header.number(); + let addresses = self.provider.get_validators(move |a, d| { + let from = Address::default(); + let tx = Transaction { + nonce: engine.account_start_nonce(number), + action: Action::Call(a), + gas: PROVIDED_GAS.into(), + gas_price: U256::default(), + value: U256::default(), + data: d, + }.fake_sign(from); + + let res = ::state::check_proof( + &state_items, + *old_header.state_root(), + &tx, + engine, + &env_info, + ); + + match res { + ::state::ProvedExecution::BadProof => Err("Bad proof".into()), + ::state::ProvedExecution::Failed(e) => Err(format!("Failed call: {}", e)), + ::state::ProvedExecution::Complete(e) => Ok(e.output), + } + }).wait().map_err(::engines::EngineError::InsufficientProof)?; + + trace!(target: "engine", "extracted epoch set at #{}: {} addresses", + number, addresses.len()); + + Ok((SimpleList::new(addresses), Some(old_hash))) + } else { + let (old_header, receipts) = decode_proof(&rlp)?; + + // ensure receipts match header. + // TODO: optimize? these were just decoded. + let found_root = ::util::triehash::ordered_trie_root( + receipts.iter().map(::rlp::encode).map(|x| x.to_vec()) + ); + if found_root != *old_header.receipts_root() { + return Err(::error::BlockError::InvalidReceiptsRoot( + Mismatch { expected: *old_header.receipts_root(), found: found_root } + ).into()); + } + + let bloom = self.expected_bloom(&old_header); + + match self.extract_from_event(bloom, &old_header, &receipts) { + Some(list) => Ok((list, Some(old_header.hash()))), + None => Err(::engines::EngineError::InsufficientProof("No log event in proof.".into()).into()), + } + } } fn contains_with_caller(&self, block_hash: &H256, address: &Address, caller: &Call) -> bool { @@ -371,6 +522,7 @@ mod tests { let last_hash = client.best_block_header().hash(); let mut new_header = Header::default(); new_header.set_parent_hash(last_hash); + new_header.set_number(1); // so the validator set looks for a log. // first, try without the parent hash. let mut event = LogEntry { @@ -380,12 +532,35 @@ mod tests { }; new_header.set_log_bloom(event.bloom()); - assert_eq!(engine.is_epoch_end(&new_header, None, None), EpochChange::No); + match engine.signals_epoch_end(&new_header, None, None) { + EpochChange::No => {}, + _ => panic!("Expected bloom to be unrecognized."), + }; // with the last hash, it should need the receipts. event.topics.push(last_hash); new_header.set_log_bloom(event.bloom()); - assert_eq!(engine.is_epoch_end(&new_header, None, None), - EpochChange::Unsure(Unsure::NeedsReceipts)); + + match engine.signals_epoch_end(&new_header, None, None) { + EpochChange::Unsure(Unsure::NeedsReceipts) => {}, + _ => panic!("Expected bloom to be recognized."), + }; + } + + #[test] + fn initial_contract_is_signal() { + use header::Header; + use engines::{EpochChange, Proof}; + + let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_safe_contract, None); + let engine = client.engine().clone(); + + let mut new_header = Header::default(); + new_header.set_number(0); // so the validator set doesn't look for a log + + match engine.signals_epoch_end(&new_header, None, None) { + EpochChange::Yes(Proof::WithState(_)) => {}, + _ => panic!("Expected state to be required to prove initial signal"), + }; } } diff --git a/ethcore/src/engines/validator_set/simple_list.rs b/ethcore/src/engines/validator_set/simple_list.rs index 15cf141f6..8b8d1942d 100644 --- a/ethcore/src/engines/validator_set/simple_list.rs +++ b/ethcore/src/engines/validator_set/simple_list.rs @@ -18,8 +18,8 @@ use util::{H256, Address, HeapSizeOf}; -use engines::Call; -use header::Header; +use engines::{Call, Engine}; +use header::{BlockNumber, Header}; use super::ValidatorSet; /// Validator set containing a known set of addresses. @@ -42,6 +42,20 @@ impl SimpleList { } } +impl ::std::ops::Deref for SimpleList { + type Target = [Address]; + + fn deref(&self) -> &[Address] { &self.validators } +} + +impl From> for SimpleList { + fn from(validators: Vec
) -> Self { + SimpleList { + validators: validators, + } + } +} + impl HeapSizeOf for SimpleList { fn heap_size_of_children(&self) -> usize { self.validators.heap_size_of_children() @@ -53,18 +67,21 @@ impl ValidatorSet for SimpleList { Box::new(|_, _| Err("Simple list doesn't require calls.".into())) } - fn is_epoch_end(&self, _header: &Header, _block: Option<&[u8]>, _receipts: Option<&[::receipt::Receipt]>) + fn is_epoch_end(&self, first: bool, _chain_head: &Header) -> Option> { + match first { + true => Some(Vec::new()), // allow transition to fixed list, and instantly + false => None, + } + } + + fn signals_epoch_end(&self, _: bool, _: &Header, _: Option<&[u8]>, _: Option<&[::receipt::Receipt]>) -> ::engines::EpochChange { ::engines::EpochChange::No } - fn epoch_proof(&self, _header: &Header, _caller: &Call) -> Result, String> { - Ok(Vec::new()) - } - - fn epoch_set(&self, _header: &Header, _: &[u8]) -> Result<(u64, SimpleList), ::error::Error> { - Ok((0, self.clone())) + fn epoch_set(&self, _first: bool, _: &Engine, _: BlockNumber, _: &[u8]) -> Result<(SimpleList, Option), ::error::Error> { + Ok((self.clone(), None)) } fn contains_with_caller(&self, _bh: &H256, address: &Address, _: &Call) -> bool { @@ -73,6 +90,11 @@ impl ValidatorSet for SimpleList { fn get_with_caller(&self, _bh: &H256, nonce: usize, _: &Call) -> Address { let validator_n = self.validators.len(); + + if validator_n == 0 { + panic!("Cannot operate with an empty validator set."); + } + self.validators.get(nonce % validator_n).expect("There are validator_n authorities; taking number modulo validator_n gives number in validator_n range; qed").clone() } diff --git a/ethcore/src/engines/validator_set/test.rs b/ethcore/src/engines/validator_set/test.rs index f1d0e76cd..4960ee7be 100644 --- a/ethcore/src/engines/validator_set/test.rs +++ b/ethcore/src/engines/validator_set/test.rs @@ -20,7 +20,7 @@ use std::str::FromStr; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; use util::{Arc, Bytes, H256, Address, HeapSizeOf}; -use engines::Call; +use engines::{Call, Engine}; use header::{Header, BlockNumber}; use super::{ValidatorSet, SimpleList}; @@ -52,18 +52,16 @@ impl ValidatorSet for TestSet { Box::new(|_, _| Err("Test set doesn't require calls.".into())) } - fn is_epoch_end(&self, _header: &Header, _block: Option<&[u8]>, _receipts: Option<&[::receipt::Receipt]>) + fn is_epoch_end(&self, _first: bool, _chain_head: &Header) -> Option> { None } + + fn signals_epoch_end(&self, _: bool, _: &Header, _: Option<&[u8]>, _: Option<&[::receipt::Receipt]>) -> ::engines::EpochChange { ::engines::EpochChange::No } - fn epoch_proof(&self, _header: &Header, _caller: &Call) -> Result, String> { - Ok(Vec::new()) - } - - fn epoch_set(&self, _header: &Header, _: &[u8]) -> Result<(u64, SimpleList), ::error::Error> { - Ok((0, self.validator.clone())) + fn epoch_set(&self, _: bool, _: &Engine, _: BlockNumber, _: &[u8]) -> Result<(SimpleList, Option), ::error::Error> { + Ok((self.validator.clone(), None)) } fn contains_with_caller(&self, bh: &H256, address: &Address, _: &Call) -> bool { @@ -78,11 +76,11 @@ impl ValidatorSet for TestSet { 1 } - fn report_malicious(&self, _validator: &Address, block: BlockNumber, _proof: Bytes) { + fn report_malicious(&self, _validator: &Address, _set_block: BlockNumber, block: BlockNumber, _proof: Bytes) { self.last_malicious.store(block as usize, AtomicOrdering::SeqCst) } - fn report_benign(&self, _validator: &Address, block: BlockNumber) { + fn report_benign(&self, _validator: &Address, _set_block: BlockNumber, block: BlockNumber) { self.last_benign.store(block as usize, AtomicOrdering::SeqCst) } } diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index 8d4d18911..78f1efde4 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -166,7 +166,6 @@ impl Ethash { // in the future, we might move the Ethash epoch // caching onto this mechanism as well. impl ::engines::EpochVerifier for Arc { - fn epoch_number(&self) -> u64 { 0 } fn verify_light(&self, _header: &Header) -> Result<(), Error> { Ok(()) } fn verify_heavy(&self, header: &Header) -> Result<(), Error> { self.verify_block_unordered(header, None) @@ -256,7 +255,12 @@ impl Engine for Arc { // info!("ethash: populate_from_parent #{}: difficulty={} and gas_limit={}", header.number(), header.difficulty(), header.gas_limit()); } - fn on_new_block(&self, block: &mut ExecutedBlock, last_hashes: Arc) -> Result<(), Error> { + fn on_new_block( + &self, + block: &mut ExecutedBlock, + last_hashes: Arc, + _begins_epoch: bool, + ) -> Result<(), Error> { let parent_hash = block.fields().header.parent_hash().clone(); ::engines::common::push_last_hash(block, last_hashes, self, &parent_hash)?; if block.fields().header.number() == self.ethash_params.dao_hardfork_transition { @@ -400,8 +404,8 @@ impl Engine for Arc { Ok(()) } - fn epoch_verifier(&self, _header: &Header, _proof: &[u8]) -> Result, Error> { - Ok(Box::new(self.clone())) + fn epoch_verifier<'a>(&self, _header: &Header, _proof: &'a [u8]) -> ::engines::ConstructedVerifier<'a> { + ::engines::ConstructedVerifier::Trusted(Box::new(self.clone())) } fn snapshot_components(&self) -> Option> { @@ -536,7 +540,7 @@ impl Header { /// Set the nonce and mix hash fields of the header. pub fn set_nonce_and_mix_hash(&mut self, nonce: &H64, mix_hash: &H256) { - self.set_seal(vec![rlp::encode(mix_hash).to_vec(), rlp::encode(nonce).to_vec()]); + self.set_seal(vec![rlp::encode(mix_hash).into_vec(), rlp::encode(nonce).into_vec()]); } } @@ -559,7 +563,7 @@ mod tests { let genesis_header = spec.genesis_header(); let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap(); + let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap(); let b = b.close(); assert_eq!(b.state().balance(&Address::zero()).unwrap(), U256::from_str("4563918244f40000").unwrap()); } @@ -571,7 +575,7 @@ mod tests { let genesis_header = spec.genesis_header(); let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap(); let last_hashes = Arc::new(vec![genesis_header.hash()]); - let mut b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap(); + let mut b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap(); let mut uncle = Header::new(); let uncle_author: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".into(); uncle.set_author(uncle_author); @@ -618,7 +622,7 @@ mod tests { fn can_do_difficulty_verification_fail() { let engine = new_morden().engine; let mut header: Header = Header::default(); - header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); + header.set_seal(vec![rlp::encode(&H256::zero()).into_vec(), rlp::encode(&H64::zero()).into_vec()]); let verify_result = engine.verify_block_basic(&header, None); @@ -633,7 +637,7 @@ mod tests { fn can_do_proof_of_work_verification_fail() { let engine = new_morden().engine; let mut header: Header = Header::default(); - header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); + header.set_seal(vec![rlp::encode(&H256::zero()).into_vec(), rlp::encode(&H64::zero()).into_vec()]); header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap()); let verify_result = engine.verify_block_basic(&header, None); @@ -663,7 +667,7 @@ mod tests { fn can_do_seal256_verification_fail() { let engine = new_morden().engine; let mut header: Header = Header::default(); - header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); + header.set_seal(vec![rlp::encode(&H256::zero()).into_vec(), rlp::encode(&H64::zero()).into_vec()]); let verify_result = engine.verify_block_unordered(&header, None); match verify_result { @@ -677,7 +681,7 @@ mod tests { fn can_do_proof_of_work_unordered_verification_fail() { let engine = new_morden().engine; let mut header: Header = Header::default(); - header.set_seal(vec![rlp::encode(&H256::from("b251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d")).to_vec(), rlp::encode(&H64::zero()).to_vec()]); + header.set_seal(vec![rlp::encode(&H256::from("b251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d")).into_vec(), rlp::encode(&H64::zero()).into_vec()]); header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap()); let verify_result = engine.verify_block_unordered(&header, None); diff --git a/ethcore/src/header.rs b/ethcore/src/header.rs index e8b1fc430..aa114c01e 100644 --- a/ethcore/src/header.rs +++ b/ethcore/src/header.rs @@ -329,7 +329,7 @@ mod tests { let header_rlp = "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23".from_hex().unwrap(); let header: Header = rlp::decode(&header_rlp); - let encoded_header = rlp::encode(&header).to_vec(); + let encoded_header = rlp::encode(&header).into_vec(); assert_eq!(header_rlp, encoded_header); } diff --git a/ethcore/src/migrations/blocks/v8.rs b/ethcore/src/migrations/blocks/v8.rs index 2514db702..ddade6847 100644 --- a/ethcore/src/migrations/blocks/v8.rs +++ b/ethcore/src/migrations/blocks/v8.rs @@ -32,6 +32,6 @@ impl SimpleMigration for V8 { fn simple_migrate(&mut self, key: Vec, value: Vec) -> Option<(Vec, Vec)> { self.0.tick(); - Some((key,UntrustedRlp::new(&value).compress(RlpType::Blocks).to_vec())) + Some((key,UntrustedRlp::new(&value).compress(RlpType::Blocks).into_vec())) } } diff --git a/ethcore/src/migrations/extras/v6.rs b/ethcore/src/migrations/extras/v6.rs index 4589005dd..638a64a83 100644 --- a/ethcore/src/migrations/extras/v6.rs +++ b/ethcore/src/migrations/extras/v6.rs @@ -39,8 +39,7 @@ impl SimpleMigration for ToV6 { fn version(&self) -> u32 { 6 } - fn simple_migrate(&mut self, key: Vec, value: Vec) -> Option<(Vec, Vec)> { - + fn simple_migrate(&mut self, mut key: Vec, value: Vec) -> Option<(Vec, Vec)> { //// at this version all extras keys are 33 bytes long. if key.len() == 33 { // block details key changes: @@ -72,19 +71,21 @@ impl SimpleMigration for ToV6 { // - index is moved to the front // - index is changed 4 -> 3 if key[32] == 4 { + key.reverse(); // i have no idea why it was reversed - let reverse = key.into_iter().rev().collect::>(); - let mut result = [0u8; 6]; - // new extras index is 3 - result[0] = 3; - // 9th (+ prefix) byte was the level. Now it's second. - result[1] = reverse[9]; - result[2] = reverse[4]; - result[3] = reverse[3]; - result[4] = reverse[2]; - result[5] = reverse[1]; + let reverse = key; + let result = vec![ + // new extras index is 3 + 3, + // 9th (+ prefix) byte was the level. Now it's second. + reverse[9], + reverse[4], + reverse[3], + reverse[2], + reverse[1], + ]; - return Some((result.to_vec(), value)); + return Some((result, value)); } // blocks receipts key changes: diff --git a/ethcore/src/migrations/state/v7.rs b/ethcore/src/migrations/state/v7.rs index 174945c9b..9a9a65d7b 100644 --- a/ethcore/src/migrations/state/v7.rs +++ b/ethcore/src/migrations/state/v7.rs @@ -153,7 +153,7 @@ impl OverlayRecentV7 { // and commit the altered entries. fn migrate_journal(&self, source: Arc, mut batch: Batch, dest: &mut Database) -> Result<(), Error> { if let Some(val) = source.get(None, V7_LATEST_ERA_KEY).map_err(Error::Custom)? { - batch.insert(V7_LATEST_ERA_KEY.into(), val.clone().to_vec(), dest)?; + batch.insert(V7_LATEST_ERA_KEY.into(), val.clone().into_vec(), dest)?; let mut era = decode::(&val); loop { diff --git a/ethcore/src/migrations/v10.rs b/ethcore/src/migrations/v10.rs index 15abf4790..7982279cf 100644 --- a/ethcore/src/migrations/v10.rs +++ b/ethcore/src/migrations/v10.rs @@ -104,7 +104,7 @@ impl Migration for ToV10 { let mut batch = Batch::new(config, col); for (key, value) in source.iter(col).into_iter().flat_map(|inner| inner) { self.progress.tick(); - batch.insert(key.to_vec(), value.to_vec(), dest)?; + batch.insert(key.into_vec(), value.into_vec(), dest)?; } batch.commit(dest)?; diff --git a/ethcore/src/migrations/v9.rs b/ethcore/src/migrations/v9.rs index 4ca6e3a82..08f83f132 100644 --- a/ethcore/src/migrations/v9.rs +++ b/ethcore/src/migrations/v9.rs @@ -51,7 +51,6 @@ impl ToV9 { } impl Migration for ToV9 { - fn columns(&self) -> Option { Some(5) } fn version(&self) -> u32 { 9 } @@ -63,17 +62,17 @@ impl Migration for ToV9 { self.progress.tick(); match self.extract { Extract::Header => { - batch.insert(key.to_vec(), Rlp::new(&value).at(0).as_raw().to_vec(), dest)? + batch.insert(key.into_vec(), Rlp::new(&value).at(0).as_raw().to_vec(), dest)? }, Extract::Body => { let mut body = RlpStream::new_list(2); let block_rlp = Rlp::new(&value); body.append_raw(block_rlp.at(1).as_raw(), 1); body.append_raw(block_rlp.at(2).as_raw(), 1); - batch.insert(key.to_vec(), body.out(), dest)? + batch.insert(key.into_vec(), body.out(), dest)? }, Extract::All => { - batch.insert(key.to_vec(), value.to_vec(), dest)? + batch.insert(key.into_vec(), value.into_vec(), dest)? } } } diff --git a/ethcore/src/miner/stratum.rs b/ethcore/src/miner/stratum.rs index 4da5d1849..e419247f0 100644 --- a/ethcore/src/miner/stratum.rs +++ b/ethcore/src/miner/stratum.rs @@ -145,7 +145,7 @@ impl JobDispatcher for StratumJobDispatcher { ); self.with_core_void(|client, miner| { - let seal = vec![encode(&payload.mix_hash).to_vec(), encode(&payload.nonce).to_vec()]; + let seal = vec![encode(&payload.mix_hash).into_vec(), encode(&payload.nonce).into_vec()]; if let Err(e) = miner.submit_seal(&*client, payload.pow_hash, seal) { warn!(target: "stratum", "submit_seal error: {:?}", e); }; diff --git a/ethcore/src/snapshot/account.rs b/ethcore/src/snapshot/account.rs index cef32bc93..a9f2ba593 100644 --- a/ethcore/src/snapshot/account.rs +++ b/ethcore/src/snapshot/account.rs @@ -121,7 +121,7 @@ pub fn to_fat_rlps(account_hash: &H256, acc: &BasicAccount, acct_db: &AccountDB, let stream = ::std::mem::replace(&mut account_stream, RlpStream::new_list(2)); chunks.push(stream.out()); target_chunk_size = max_chunk_size; - leftover = Some(pair.to_vec()); + leftover = Some(pair.into_vec()); break; } }, diff --git a/ethcore/src/snapshot/block.rs b/ethcore/src/snapshot/block.rs index b5144b23d..75aa8e13e 100644 --- a/ethcore/src/snapshot/block.rs +++ b/ethcore/src/snapshot/block.rs @@ -190,7 +190,7 @@ mod tests { let receipts_root = b.header.receipts_root().clone(); b.header.set_transactions_root(::util::triehash::ordered_trie_root( - b.transactions.iter().map(::rlp::encode).map(|out| out.to_vec()) + b.transactions.iter().map(::rlp::encode).map(|out| out.into_vec()) )); let encoded = encode_block(&b); diff --git a/ethcore/src/snapshot/consensus/authority.rs b/ethcore/src/snapshot/consensus/authority.rs index 9cbffb62b..1a1215522 100644 --- a/ethcore/src/snapshot/consensus/authority.rs +++ b/ethcore/src/snapshot/consensus/authority.rs @@ -24,34 +24,28 @@ use super::{SnapshotComponents, Rebuilder, ChunkSink}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use blockchain::{BlockChain, BlockProvider, EpochTransition}; -use engines::{Engine, EpochVerifier}; -use env_info::EnvInfo; +use blockchain::{BlockChain, BlockProvider}; +use engines::{Engine, EpochVerifier, EpochTransition}; use ids::BlockId; use header::Header; use receipt::Receipt; use snapshot::{Error, ManifestData}; -use state_db::StateDB; use itertools::{Position, Itertools}; use rlp::{RlpStream, UntrustedRlp}; -use util::{Address, Bytes, H256, KeyValueDB, DBValue}; +use util::{Bytes, H256, KeyValueDB}; /// Snapshot creation and restoration for PoA chains. /// Chunk format: /// -/// [FLAG, [header, epoch_number, epoch data, state proof, last hashes], ...] +/// [FLAG, [header, epoch data], ...] /// - Header data at which transition occurred, -/// - epoch data (usually list of validators) -/// - state items required to check epoch data -/// - last 256 hashes before the transition; required for checking state changes. +/// - epoch data (usually list of validators and proof of change) /// /// FLAG is a bool: true for last chunk, false otherwise. /// /// The last item of the last chunk will be a list containing data for the warp target block: -/// [header, transactions, uncles, receipts, last_hashes, parent_td]. -/// If this block is not a transition block, the epoch data should be the same as that -/// for the last transition. +/// [header, transactions, uncles, receipts, parent_td]. pub struct PoaSnapshot; impl SnapshotComponents for PoaSnapshot { @@ -68,35 +62,23 @@ impl SnapshotComponents for PoaSnapshot { let mut pending_size = 0; let mut rlps = Vec::new(); - // TODO: this will become irrelevant after recent block hashes are moved into - // the state. can we optimize it out in that case? - let make_last_hashes = |parent_hash| chain.ancestry_iter(parent_hash) - .into_iter() - .flat_map(|inner| inner) - .take(255) - .collect::>(); - - for (epoch_number, transition) in chain.epoch_transitions() + for (_, transition) in chain.epoch_transitions() .take_while(|&(_, ref t)| t.block_number <= number) { + // this can happen when our starting block is non-canonical. + if transition.block_number == number && transition.block_hash != block_at { + break + } + let header = chain.block_header_data(&transition.block_hash) .ok_or(Error::BlockNotFound(transition.block_hash))?; - let last_hashes: Vec<_> = make_last_hashes(header.parent_hash()); - let entry = { - let mut entry_stream = RlpStream::new_list(5); + let mut entry_stream = RlpStream::new_list(2); entry_stream .append_raw(&header.into_inner(), 1) - .append(&epoch_number) .append(&transition.proof); - entry_stream.begin_list(transition.state_proof.len()); - for item in transition.state_proof { - entry_stream.append(&&*item); - } - - entry_stream.append_list(&last_hashes); entry_stream.out() }; @@ -121,16 +103,13 @@ impl SnapshotComponents for PoaSnapshot { .map(|d| d.total_difficulty) .ok_or(Error::BlockNotFound(block_at))?; - let last_hashes = make_last_hashes(*block.header.parent_hash()); - rlps.push({ - let mut stream = RlpStream::new_list(6); + let mut stream = RlpStream::new_list(5); stream .append(&block.header) .append_list(&block.transactions) .append_list(&block.uncles) .append(&receipts) - .append_list(&last_hashes) .append(&parent_td); stream.out() }); @@ -153,7 +132,7 @@ impl SnapshotComponents for PoaSnapshot { db: db, had_genesis: false, unverified_firsts: Vec::new(), - last_proofs: Vec::new(), + last_epochs: Vec::new(), })) } @@ -178,7 +157,7 @@ fn write_chunk(last: bool, chunk_data: &mut Vec, sink: &mut ChunkSink) -> // transition header is verifiable from the epoch data of the one prior. struct ChunkRebuilder { manifest: ManifestData, - warp_target: Option<(Header, Vec)>, + warp_target: Option
, chain: BlockChain, db: Arc, had_genesis: bool, @@ -186,52 +165,16 @@ struct ChunkRebuilder { // sorted vectors of unverified first blocks in a chunk // and epoch data from last blocks in chunks. // verification for these will be done at the end. - unverified_firsts: Vec<(u64, Header)>, - last_proofs: Vec<(u64, Header, Bytes)>, + unverified_firsts: Vec<(Header, Bytes, H256)>, + last_epochs: Vec<(Header, Box)>, } // verified data. struct Verified { - epoch_number: u64, epoch_transition: EpochTransition, header: Header, } -// make a transaction and env info. -// TODO: hardcoded 50M to match constants in client. -// would be nice to extract magic numbers, or better yet -// off-chain transaction execution, into its own module. -fn make_tx_and_env( - engine: &Engine, - addr: Address, - data: Bytes, - header: &Header, - last_hashes: Arc>, -) -> (::transaction::SignedTransaction, EnvInfo) { - use transaction::{Action, Transaction}; - - let transaction = Transaction { - nonce: engine.account_start_nonce(header.number()), - action: Action::Call(addr), - gas: 50_000_000.into(), - gas_price: 0.into(), - value: 0.into(), - data: data, - }.fake_sign(Default::default()); - - let env = EnvInfo { - number: header.number(), - author: *header.author(), - timestamp: header.timestamp(), - difficulty: *header.difficulty(), - gas_limit: 50_000_000.into(), - last_hashes: last_hashes, - gas_used: 0.into(), - }; - - (transaction, env) -} - impl ChunkRebuilder { fn verify_transition( &mut self, @@ -239,69 +182,49 @@ impl ChunkRebuilder { transition_rlp: UntrustedRlp, engine: &Engine, ) -> Result { + use engines::ConstructedVerifier; + // decode. let header: Header = transition_rlp.val_at(0)?; - let epoch_number: u64 = transition_rlp.val_at(1)?; - let epoch_data: Bytes = transition_rlp.val_at(2)?; - let state_proof: Vec = transition_rlp.at(3)? - .iter() - .map(|x| Ok(DBValue::from_slice(x.data()?))) - .collect::>()?; - let last_hashes: Vec = transition_rlp.list_at(4)?; - let last_hashes = Arc::new(last_hashes); + let epoch_data: Bytes = transition_rlp.val_at(1)?; - trace!(target: "snapshot", "verifying transition to epoch {}", epoch_number); + trace!(target: "snapshot", "verifying transition to epoch at block {}", header.number()); // check current transition against validators of last epoch. - if let Some(verifier) = last_verifier.as_ref() { - verifier.verify_heavy(&header)?; - } + let new_verifier = match engine.epoch_verifier(&header, &epoch_data) { + ConstructedVerifier::Trusted(v) => v, + ConstructedVerifier::Unconfirmed(v, finality_proof, hash) => { + match *last_verifier { + Some(ref last) => + if last.check_finality_proof(finality_proof).map_or(true, |hashes| !hashes.contains(&hash)) + { + return Err(Error::BadEpochProof(header.number()).into()); + }, + None if header.number() != 0 => { + // genesis never requires additional validation. - { - // check the provided state proof actually leads to the - // given epoch data. - let caller = |addr, data| { - use state::{check_proof, ProvedExecution}; + let idx = self.unverified_firsts + .binary_search_by_key(&header.number(), |&(ref h, _, _)| h.number()) + .unwrap_or_else(|x| x); - let (transaction, env_info) = make_tx_and_env( - engine, - addr, - data, - &header, - last_hashes.clone(), - ); - - let result = check_proof( - &state_proof, - header.state_root().clone(), - &transaction, - engine, - &env_info, - ); - - match result { - ProvedExecution::Complete(executed) => Ok(executed.output), - _ => Err("Bad state proof".into()), + let entry = (header.clone(), finality_proof.to_owned(), hash); + self.unverified_firsts.insert(idx, entry); + } + None => {} } - }; - let extracted_proof = engine.epoch_proof(&header, &caller) - .map_err(|_| Error::BadEpochProof(epoch_number))?; - - if extracted_proof != epoch_data { - return Err(Error::BadEpochProof(epoch_number).into()); + v } - } + ConstructedVerifier::Err(e) => return Err(e), + }; // create new epoch verifier. - *last_verifier = Some(engine.epoch_verifier(&header, &epoch_data)?); + *last_verifier = Some(new_verifier); Ok(Verified { - epoch_number: epoch_number, epoch_transition: EpochTransition { block_hash: header.hash(), block_number: header.number(), - state_proof: state_proof, proof: epoch_data, }, header: header, @@ -327,6 +250,10 @@ impl Rebuilder for ChunkRebuilder { num_items - 1 }; + if num_transitions == 0 && !is_last_chunk { + return Err(Error::WrongChunkFormat("Found non-last chunk without any data.".into()).into()); + } + let mut last_verifier = None; let mut last_number = None; for transition_rlp in rlp.iter().skip(1).take(num_transitions).with_position() { @@ -356,41 +283,33 @@ impl Rebuilder for ChunkRebuilder { if is_first { // make sure the genesis transition was included, // but it doesn't need verification later. - if verified.epoch_number == 0 && verified.header.number() == 0 { + if verified.header.number() == 0 { if verified.header.hash() != self.chain.genesis_hash() { return Err(Error::WrongBlockHash(0, verified.header.hash(), self.chain.genesis_hash()).into()); } self.had_genesis = true; - } else { - let idx = self.unverified_firsts - .binary_search_by_key(&verified.epoch_number, |&(a, _)| a) - .unwrap_or_else(|x| x); - - let entry = (verified.epoch_number, verified.header.clone()); - self.unverified_firsts.insert(idx, entry); } } if is_last { - let idx = self.last_proofs - .binary_search_by_key(&verified.epoch_number, |&(a, _, _)| a) + let idx = self.last_epochs + .binary_search_by_key(&verified.header.number(), |&(ref h, _)| h.number()) .unwrap_or_else(|x| x); let entry = ( - verified.epoch_number, verified.header.clone(), - verified.epoch_transition.proof.clone() + last_verifier.take().expect("last_verifier always set after verify_transition; qed"), ); - self.last_proofs.insert(idx, entry); + self.last_epochs.insert(idx, entry); } // write epoch transition into database. let mut batch = self.db.transaction(); - self.chain.insert_epoch_transition(&mut batch, verified.epoch_number, + self.chain.insert_epoch_transition(&mut batch, verified.header.number(), verified.epoch_transition); self.db.write_buffered(batch); - trace!(target: "snapshot", "Verified epoch transition for epoch {}", verified.epoch_number); + trace!(target: "snapshot", "Verified epoch transition for epoch at block {}", verified.header.number()); } if is_last_chunk { @@ -413,84 +332,57 @@ impl Rebuilder for ChunkRebuilder { } } - let last_hashes: Vec = last_rlp.list_at(4)?; - let parent_td: ::util::U256 = last_rlp.val_at(5)?; + let parent_td: ::util::U256 = last_rlp.val_at(4)?; let mut batch = self.db.transaction(); self.chain.insert_unordered_block(&mut batch, &block_data, receipts, Some(parent_td), true, false); self.db.write_buffered(batch); - self.warp_target = Some((block.header, last_hashes)); + self.warp_target = Some(block.header); } Ok(()) } - fn finalize(&mut self, db: StateDB, engine: &Engine) -> Result<(), ::error::Error> { - use state::State; - + fn finalize(&mut self, _engine: &Engine) -> Result<(), ::error::Error> { if !self.had_genesis { return Err(Error::WrongChunkFormat("No genesis transition included.".into()).into()); } - let (target_header, target_last_hashes) = match self.warp_target.take() { + let target_header = match self.warp_target.take() { Some(x) => x, None => return Err(Error::WrongChunkFormat("Warp target block not included.".into()).into()), }; - // we store the last data even for the last chunk for easier verification - // of warp target, but we don't store genesis transition data. - // other than that, there should be a one-to-one correspondence of - // chunk ends to chunk beginnings. - if self.last_proofs.len() != self.unverified_firsts.len() + 1 { - return Err(Error::WrongChunkFormat("More than one 'last' chunk".into()).into()); - } - // verify the first entries of chunks we couldn't before. - let lasts_iter = self.last_proofs.iter().map(|&(_, ref hdr, ref proof)| (hdr, &proof[..])); - let firsts_iter = self.unverified_firsts.iter().map(|&(_, ref hdr)| hdr); + // we store all last verifiers, but not all firsts. + // match each unverified first epoch with a last epoch verifier. + let mut lasts_reversed = self.last_epochs.iter().rev(); + for &(ref header, ref finality_proof, hash) in self.unverified_firsts.iter().rev() { + let mut found = false; + while let Some(&(ref last_header, ref last_verifier)) = lasts_reversed.next() { + if last_header.number() < header.number() { + if last_verifier.check_finality_proof(&finality_proof).map_or(true, |hashes| !hashes.contains(&hash)) { + return Err(Error::BadEpochProof(header.number()).into()); + } + found = true; + break; + } + } - for ((last_hdr, last_proof), first_hdr) in lasts_iter.zip(firsts_iter) { - let verifier = engine.epoch_verifier(&last_hdr, &last_proof)?; - verifier.verify_heavy(&first_hdr)?; + if !found { + return Err(Error::WrongChunkFormat("Inconsistent chunk ordering.".into()).into()); + } } - // verify that the validator set of the warp target is the same as that of the - // most recent transition. if the warp target was a transition itself, - // `last_data` will still be correct - let &(_, _, ref last_data) = self.last_proofs.last() - .expect("last_proofs known to have at least one element by the check above; qed"); + // verify that the warp target verifies correctly the + // most recent epoch. if the warp target was a transition itself, + // it's already verified and doesn't need any more verification. + let &(ref header, ref last_epoch) = self.last_epochs.last() + .expect("last_epochs known to have at least one element by the check above; qed"); - let target_last_hashes = Arc::new(target_last_hashes); - let caller = |addr, data| { - use executive::{Executive, TransactOptions}; - - let factories = ::factory::Factories::default(); - let mut state = State::from_existing( - db.boxed_clone(), - self.manifest.state_root.clone(), - engine.account_start_nonce(target_header.number()), - factories, - ).map_err(|e| format!("State root mismatch: {}", e))?; - - let (tx, env_info) = make_tx_and_env( - engine, - addr, - data, - &target_header, - target_last_hashes.clone(), - ); - - let options = TransactOptions { tracing: false, vm_tracing: false, check_nonce: false }; - Executive::new(&mut state, &env_info, engine) - .transact_virtual(&tx, options) - .map(|e| e.output) - .map_err(|e| format!("Error executing: {}", e)) - }; - - let data = engine.epoch_proof(&target_header, &caller)?; - if &data[..] != &last_data[..] { - return Err(Error::WrongChunkFormat("Warp target has different epoch data than epoch transition.".into()).into()) + if header != &target_header { + last_epoch.verify_heavy(&target_header)?; } Ok(()) diff --git a/ethcore/src/snapshot/consensus/mod.rs b/ethcore/src/snapshot/consensus/mod.rs index 0ed8c909d..3f583893b 100644 --- a/ethcore/src/snapshot/consensus/mod.rs +++ b/ethcore/src/snapshot/consensus/mod.rs @@ -93,7 +93,5 @@ pub trait Rebuilder: Send { /// /// This should apply the necessary "glue" between chunks, /// and verify against the restored state. - /// - /// The database passed contains the state for the warp target block. - fn finalize(&mut self, db: ::state_db::StateDB, engine: &Engine) -> Result<(), ::error::Error>; + fn finalize(&mut self, engine: &Engine) -> Result<(), ::error::Error>; } diff --git a/ethcore/src/snapshot/consensus/work.rs b/ethcore/src/snapshot/consensus/work.rs index ff193ad00..4975203b7 100644 --- a/ethcore/src/snapshot/consensus/work.rs +++ b/ethcore/src/snapshot/consensus/work.rs @@ -283,7 +283,7 @@ impl Rebuilder for PowRebuilder { } /// Glue together any disconnected chunks and check that the chain is complete. - fn finalize(&mut self, _: ::state_db::StateDB, _: &Engine) -> Result<(), ::error::Error> { + fn finalize(&mut self, _: &Engine) -> Result<(), ::error::Error> { let mut batch = self.db.transaction(); for (first_num, first_hash) in self.disconnected.drain(..) { @@ -299,12 +299,12 @@ impl Rebuilder for PowRebuilder { } let genesis_hash = self.chain.genesis_hash(); - self.chain.insert_epoch_transition(&mut batch, 0, ::blockchain::EpochTransition { + self.chain.insert_epoch_transition(&mut batch, 0, ::engines::EpochTransition { block_number: 0, block_hash: genesis_hash, proof: vec![], - state_proof: vec![], }); + self.db.write_buffered(batch); Ok(()) } diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index 21317b551..a15c15566 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -462,7 +462,7 @@ fn rebuild_accounts( } } - ::rlp::encode(&acc).to_vec() + ::rlp::encode(&acc).into_vec() }; *out = (hash, thin_rlp); diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index 1f2aef9f7..fd4c2cc1e 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -164,11 +164,10 @@ impl Restoration { } // check for missing code. - let db = self.state.finalize(self.manifest.block_number, self.manifest.block_hash)?; - let db = ::state_db::StateDB::new(db, 0); + self.state.finalize(self.manifest.block_number, self.manifest.block_hash)?; // connect out-of-order chunks and verify chain integrity. - self.secondary.finalize(db, engine)?; + self.secondary.finalize(engine)?; if let Some(writer) = self.writer { writer.finish(self.manifest)?; diff --git a/ethcore/src/snapshot/tests/helpers.rs b/ethcore/src/snapshot/tests/helpers.rs index cfd7af9be..6429667f5 100644 --- a/ethcore/src/snapshot/tests/helpers.rs +++ b/ethcore/src/snapshot/tests/helpers.rs @@ -26,7 +26,6 @@ use client::{BlockChainClient, Client}; use engines::Engine; use snapshot::{StateRebuilder}; use snapshot::io::{SnapshotReader, PackedWriter, PackedReader}; -use state_db::StateDB; use devtools::{RandomTempPath, GuardedTempResult}; use rand::Rng; @@ -78,7 +77,7 @@ impl StateProducer { let mut account: BasicAccount = ::rlp::decode(&*account_data); let acct_db = AccountDBMut::from_hash(db, *address_hash); fill_storage(acct_db, &mut account.storage_root, &mut self.storage_seed); - *account_data = DBValue::from_vec(::rlp::encode(&account).to_vec()); + *account_data = DBValue::from_vec(::rlp::encode(&account).into_vec()); } // sweep again to alter account trie. @@ -195,8 +194,7 @@ pub fn restore( secondary.feed(&snappy_buffer[..len], engine, &flag)?; } - let jdb = state.finalize(manifest.block_number, manifest.block_hash)?; - let state_db = StateDB::new(jdb, 0); - - secondary.finalize(state_db, engine) + trace!(target: "snapshot", "finalizing"); + state.finalize(manifest.block_number, manifest.block_hash)?; + secondary.finalize(engine) } diff --git a/ethcore/src/snapshot/tests/proof_of_authority.rs b/ethcore/src/snapshot/tests/proof_of_authority.rs index beec143cb..4428ea2ad 100644 --- a/ethcore/src/snapshot/tests/proof_of_authority.rs +++ b/ethcore/src/snapshot/tests/proof_of_authority.rs @@ -21,11 +21,9 @@ use std::sync::Arc; use std::str::FromStr; use account_provider::AccountProvider; -use client::{Client, BlockChainClient, MiningBlockChainClient}; +use client::{Client, BlockChainClient}; use ethkey::Secret; -use engines::Seal; use futures::Future; -use miner::MinerService; use native_contracts::test_contracts::ValidatorSet; use snapshot::tests::helpers as snapshot_helpers; use spec::Spec; @@ -37,7 +35,7 @@ use util::kvdb; const PASS: &'static str = ""; const TRANSITION_BLOCK_1: usize = 2; // block at which the contract becomes activated. -const TRANSITION_BLOCK_2: usize = 6; // block at which the second contract activates. +const TRANSITION_BLOCK_2: usize = 10; // block at which the second contract activates. macro_rules! secret { ($e: expr) => { Secret::from_slice(&$e.sha3()) } @@ -54,10 +52,10 @@ lazy_static! { } -/// Contract code used here: https://gist.github.com/rphmeier/2de14fd365a969e3a9e10d77eb9a1e37 +/// Contract code used here: https://gist.github.com/anonymous/2a43783647e0f0dfcc359bd6fd81d6d9 /// Account with secrets "1".sha3() is initially the validator. /// Transitions to the contract at block 2, initially same validator set. -/// Create a new Spec with BasicAuthority which uses a contract at address 5 to determine the current validators using `getValidators`. +/// Create a new Spec with AuthorityRound which uses a contract at address 5 to determine the current validators using `getValidators`. /// `native_contracts::test_contracts::ValidatorSet` provides a native wrapper for the ABi. fn spec_fixed_to_contract() -> Spec { let data = include_bytes!("test_validator_contract.json"); @@ -101,45 +99,41 @@ fn make_chain(accounts: Arc, blocks_beyond: usize, transitions: { // push a block with given number, signed by one of the signers, with given transactions. let push_block = |signers: &[Address], n, txs: Vec| { - use block::IsBlock; + use miner::MinerService; + + let idx = n as usize % signers.len(); + trace!(target: "snapshot", "Pushing block #{}, {} txs, author={}", + n, txs.len(), signers[idx]); + + client.miner().set_author(signers[idx]); + client.miner().import_external_transactions(&*client, + txs.into_iter().map(Into::into).collect()); let engine = client.engine(); - let idx = n as usize % signers.len(); engine.set_signer(accounts.clone(), signers[idx], PASS.to_owned()); + engine.step(); - trace!(target: "snapshot", "Pushing block #{}, {} txs, author={}", n, txs.len(), signers[idx]); - - let mut open_block = client.prepare_open_block(signers[idx], (5_000_000.into(), 5_000_000.into()), Vec::new()); - for tx in txs { - open_block.push_transaction(tx, None).unwrap(); - } - let block = open_block.close_and_lock(); - let seal = match engine.generate_seal(block.block()) { - Seal::Regular(seal) => seal, - _ => panic!("Unable to generate seal for dummy chain block #{}", n), - }; - let block = block.seal(&*engine, seal).unwrap(); - - client.import_sealed_block(block).unwrap(); + assert_eq!(client.chain_info().best_block_number, n); }; // execution callback for native contract: push transaction to be sealed. let nonce = RefCell::new(client.engine().account_start_nonce(0)); - let exec = |addr, data| { + + // create useless transactions vector so we don't have to dig in + // and force sealing. + let make_useless_transactions = || { let mut nonce = nonce.borrow_mut(); let transaction = Transaction { nonce: *nonce, - gas_price: 0.into(), - gas: 1_000_000.into(), - action: Action::Call(addr), - value: 0.into(), - data: data, + gas_price: 1.into(), + gas: 21_000.into(), + action: Action::Call(Address::new()), + value: 1.into(), + data: Vec::new(), }.sign(&*RICH_SECRET, client.signing_network_id()); - client.miner().import_own_transaction(&*client, transaction.into()).unwrap(); - *nonce = *nonce + 1.into(); - Ok(Vec::new()) + vec![transaction] }; let contract_1 = ValidatorSet::new(*CONTRACT_ADDR_1); @@ -156,8 +150,12 @@ fn make_chain(accounts: Arc, blocks_beyond: usize, transitions: panic!("Bad test: issued epoch change before transition to contract."); } + if (num as u64) < client.chain_info().best_block_number { + panic!("Bad test: issued epoch change before previous transition finalized."); + } + for number in client.chain_info().best_block_number + 1 .. num as u64 { - push_block(&cur_signers, number, vec![]); + push_block(&cur_signers, number, make_useless_transactions()); } let pending = if manual { @@ -167,22 +165,48 @@ fn make_chain(accounts: Arc, blocks_beyond: usize, transitions: false => &contract_1, }; - contract.set_validators(&exec, new_set.clone()).wait().unwrap(); - client.ready_transactions() - .into_iter() - .map(|x| x.transaction) - .collect() + let mut pending = Vec::new(); + { + let mut exec = |addr, data| { + let mut nonce = nonce.borrow_mut(); + let transaction = Transaction { + nonce: *nonce, + gas_price: 0.into(), + gas: 1_000_000.into(), + action: Action::Call(addr), + value: 0.into(), + data: data, + }.sign(&*RICH_SECRET, client.signing_network_id()); + + pending.push(transaction); + + *nonce = *nonce + 1.into(); + Ok(Vec::new()) + }; + + contract.set_validators(&mut exec, new_set.clone()).wait().unwrap(); + } + + pending } else { - Vec::new() + make_useless_transactions() }; + // push transition block. push_block(&cur_signers, num as u64, pending); + + // push blocks to finalize transition + for finalization_count in 1.. { + if finalization_count * 2 > cur_signers.len() { break } + push_block(&cur_signers, (num + finalization_count) as u64, make_useless_transactions()); + } + cur_signers = new_set; } // make blocks beyond. for number in (client.chain_info().best_block_number..).take(blocks_beyond) { - push_block(&cur_signers, number + 1, vec![]); + push_block(&cur_signers, number + 1, make_useless_transactions()); } } @@ -190,7 +214,7 @@ fn make_chain(accounts: Arc, blocks_beyond: usize, transitions: } #[test] -fn fixed_to_contract() { +fn fixed_to_contract_only() { let (provider, addrs) = make_accounts(&[ RICH_SECRET.clone(), secret!("foo"), @@ -204,17 +228,21 @@ fn fixed_to_contract() { assert!(provider.has_account(*RICH_ADDR).unwrap()); - let client = make_chain(provider, 1, vec![ + let client = make_chain(provider, 3, vec![ Transition::Manual(3, vec![addrs[2], addrs[3], addrs[5], addrs[7]]), - Transition::Manual(4, vec![addrs[0], addrs[1], addrs[4], addrs[6]]), + Transition::Manual(6, vec![addrs[0], addrs[1], addrs[4], addrs[6]]), ]); - assert_eq!(client.chain_info().best_block_number, 5); + // 6, 7, 8 prove finality for transition at 6. + // 3 beyond gets us to 11. + assert_eq!(client.chain_info().best_block_number, 11); let reader = snapshot_helpers::snap(&*client); let new_db = kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)); let spec = spec_fixed_to_contract(); + // ensure fresh engine's step matches. + for _ in 0..11 { spec.engine.step() } snapshot_helpers::restore(Arc::new(new_db), &*spec.engine, &**reader, &spec.genesis_block()).unwrap(); } @@ -233,17 +261,18 @@ fn fixed_to_contract_to_contract() { assert!(provider.has_account(*RICH_ADDR).unwrap()); - let client = make_chain(provider, 2, vec![ + let client = make_chain(provider, 3, vec![ Transition::Manual(3, vec![addrs[2], addrs[3], addrs[5], addrs[7]]), - Transition::Manual(4, vec![addrs[0], addrs[1], addrs[4], addrs[6]]), - Transition::Implicit(5, vec![addrs[0]]), - Transition::Manual(8, vec![addrs[2], addrs[4], addrs[6], addrs[7]]), + Transition::Manual(6, vec![addrs[0], addrs[1], addrs[4], addrs[6]]), + Transition::Implicit(10, vec![addrs[0]]), + Transition::Manual(13, vec![addrs[2], addrs[4], addrs[6], addrs[7]]), ]); - assert_eq!(client.chain_info().best_block_number, 10); + assert_eq!(client.chain_info().best_block_number, 16); let reader = snapshot_helpers::snap(&*client); let new_db = kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)); let spec = spec_fixed_to_contract(); + for _ in 0..16 { spec.engine.step() } snapshot_helpers::restore(Arc::new(new_db), &*spec.engine, &**reader, &spec.genesis_block()).unwrap(); } diff --git a/ethcore/src/snapshot/tests/proof_of_work.rs b/ethcore/src/snapshot/tests/proof_of_work.rs index e3b65aec4..e7d0a0964 100644 --- a/ethcore/src/snapshot/tests/proof_of_work.rs +++ b/ethcore/src/snapshot/tests/proof_of_work.rs @@ -23,10 +23,8 @@ use blockchain::generator::{ChainGenerator, ChainIterator, BlockFinalizer}; use blockchain::BlockChain; use snapshot::{chunk_secondary, Error as SnapshotError, Progress, SnapshotComponents}; use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter}; -use state_db::StateDB; use util::{Mutex, snappy}; -use util::journaldb::{self, Algorithm}; use util::kvdb::{self, KeyValueDB, DBTransaction}; use std::sync::Arc; @@ -83,7 +81,6 @@ fn chunk_and_restore(amount: u64) { // restore it. let new_db = Arc::new(kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0))); let new_chain = BlockChain::new(Default::default(), &genesis, new_db.clone()); - let new_state = StateDB::new(journaldb::new(new_db.clone(), Algorithm::Archive, None), 0); let mut rebuilder = SNAPSHOT_MODE.rebuilder(new_chain, new_db.clone(), &manifest).unwrap(); let reader = PackedReader::new(&snapshot_path).unwrap().unwrap(); @@ -94,7 +91,7 @@ fn chunk_and_restore(amount: u64) { rebuilder.feed(&chunk, engine.as_ref(), &flag).unwrap(); } - rebuilder.finalize(new_state, engine.as_ref()).unwrap(); + rebuilder.finalize(engine.as_ref()).unwrap(); drop(rebuilder); // and test it. diff --git a/ethcore/src/snapshot/tests/test_validator_contract.json b/ethcore/src/snapshot/tests/test_validator_contract.json index b422ebde3..e2485fe82 100644 --- a/ethcore/src/snapshot/tests/test_validator_contract.json +++ b/ethcore/src/snapshot/tests/test_validator_contract.json @@ -1,15 +1,16 @@ { "name": "TestValidatorContract", "engine": { - "basicAuthority": { + "authorityRound": { "params": { "gasLimitBoundDivisor": "0x0400", - "durationLimit": "0x0d", + "stepDuration": 1, + "startStep": 0, "validators": { "multi": { "0": { "list": ["0x7d577a597b2742b498cb5cf0c26cdcd726d39e6e"] }, "2": { "contract": "0x0000000000000000000000000000000000000005" }, - "6": { "contract": "0x0000000000000000000000000000000000000006" } + "10": { "contract": "0x0000000000000000000000000000000000000006" } } } } @@ -23,7 +24,10 @@ }, "genesis": { "seal": { - "generic": "0xc180" + "authorityRound": { + "step": "0x0", + "signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } }, "difficulty": "0x20000", "author": "0x0000000000000000000000000000000000000000", @@ -39,11 +43,11 @@ "0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }, "0000000000000000000000000000000000000005": { "balance": "1", - "constructor": "6060604052604060405190810160405280737d577a597b2742b498cb5cf0c26cdcd726d39e6e73ffffffffffffffffffffffffffffffffffffffff1681526020017382a978b3f5962a5b0957d9ee9eef472ee55b42f173ffffffffffffffffffffffffffffffffffffffff16815250600290600261007e929190610096565b50341561008757fe5b5b60006001819055505b610163565b82805482825590600052602060002090810192821561010f579160200282015b8281111561010e5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550916020019190600101906100b6565b5b50905061011c9190610120565b5090565b61016091905b8082111561015c57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101610126565b5090565b90565b61045d806101726000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063303e98e5146100675780639300c9261461008d578063b7ab4db5146100e4578063bfc708a014610159578063fd6e1b501461018f575bfe5b341561006f57fe5b6100776101c5565b6040518082815260200191505060405180910390f35b341561009557fe5b6100e26004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506101d0565b005b34156100ec57fe5b6100f46102b3565b6040518080602001828103825283818151815260200191508051906020019060200280838360008314610146575b80518252602083111561014657602082019150602081019050602083039250610122565b5050509050019250505060405180910390f35b341561016157fe5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610348565b005b341561019757fe5b6101c3600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061034c565b005b600060015490505b90565b600081600290805190602001906101e8929190610350565b50600143034090506000546000191681600019161415156102ae578060008160001916905550600160016000828254019250508190555060015481600019167f47e91f47ccfdcb578564e1af55da55c5e5d33403372fe68e4fed3dfd385764a184604051808060200182810382528381815181526020019150805190602001906020028083836000831461029b575b80518252602083111561029b57602082019150602081019050602083039250610277565b5050509050019250505060405180910390a35b5b5050565b6102bb6103da565b600280548060200260200160405190810160405280929190818152602001828054801561033d57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116102f3575b505050505090505b90565b5b50565b5b50565b8280548282559060005260206000209081019282156103c9579160200282015b828111156103c85782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610370565b5b5090506103d691906103ee565b5090565b602060405190810160405280600081525090565b61042e91905b8082111561042a57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016103f4565b5090565b905600a165627a7a723058205c9ed1e1da2b93682907ac47377a662b21a5f9d89c4b21be40b098bdb00254360029" + "constructor": "6060604052602060405190810160405280737d577a597b2742b498cb5cf0c26cdcd726d39e6e73ffffffffffffffffffffffffffffffffffffffff16815250600090600161004e92919061005c565b50341561005757fe5b610129565b8280548282559060005260206000209081019282156100d5579160200282015b828111156100d45782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019061007c565b5b5090506100e291906100e6565b5090565b61012691905b8082111561012257600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016100ec565b5090565b90565b61056f806101386000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806375286211146100675780639300c92614610079578063b7ab4db5146100d0578063c476dd4014610145578063d69f13bb146101c7575bfe5b341561006f57fe5b610077610206565b005b341561008157fe5b6100ce600480803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050610275565b005b34156100d857fe5b6100e061031f565b6040518080602001828103825283818151815260200191508051906020019060200280838360008314610132575b8051825260208311156101325760208201915060208101905060208303925061010e565b5050509050019250505060405180910390f35b341561014d57fe5b6101c5600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506103b4565b005b34156101cf57fe5b610204600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506103ba565b005b73fffffffffffffffffffffffffffffffffffffffe3373ffffffffffffffffffffffffffffffffffffffff1614151561023f5760006000fd5b600060018054905014151561027257600160009080546102609291906103bf565b5060006001816102709190610411565b505b5b565b806001908051906020019061028b92919061043d565b506001430340600019167f55252fa6eee4741b4e24a74a70e9c11fd2c2281df8d6ea13126ff845f7825c89826040518080602001828103825283818151815260200191508051906020019060200280838360008314610309575b805182526020831115610309576020820191506020810190506020830392506102e5565b5050509050019250505060405180910390a25b50565b6103276104c7565b60008054806020026020016040519081016040528092919081815260200182805480156103a957602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001906001019080831161035f575b505050505090505b90565b5b505050565b5b5050565b8280548282559060005260206000209081019282156104005760005260206000209182015b828111156103ff5782548255916001019190600101906103e4565b5b50905061040d91906104db565b5090565b81548183558181151161043857818360005260206000209182019101610437919061051e565b5b505050565b8280548282559060005260206000209081019282156104b6579160200282015b828111156104b55782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019061045d565b5b5090506104c391906104db565b5090565b602060405190810160405280600081525090565b61051b91905b8082111561051757600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016104e1565b5090565b90565b61054091905b8082111561053c576000816000905550600101610524565b5090565b905600a165627a7a7230582041ce7e5c820bc89b1a330a3233c4f3013e77433ecba368fa234adf758d87fe1d0029" }, "0000000000000000000000000000000000000006": { "balance": "1", - "constructor": "6060604052602060405190810160405280737d577a597b2742b498cb5cf0c26cdcd726d39e6e73ffffffffffffffffffffffffffffffffffffffff16815250600290600161004e929190610066565b50341561005757fe5b5b60006001819055505b610133565b8280548282559060005260206000209081019282156100df579160200282015b828111156100de5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610086565b5b5090506100ec91906100f0565b5090565b61013091905b8082111561012c57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016100f6565b5090565b90565b61045d806101426000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063303e98e5146100675780639300c9261461008d578063b7ab4db5146100e4578063bfc708a014610159578063fd6e1b501461018f575bfe5b341561006f57fe5b6100776101c5565b6040518082815260200191505060405180910390f35b341561009557fe5b6100e26004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506101d0565b005b34156100ec57fe5b6100f46102b3565b6040518080602001828103825283818151815260200191508051906020019060200280838360008314610146575b80518252602083111561014657602082019150602081019050602083039250610122565b5050509050019250505060405180910390f35b341561016157fe5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610348565b005b341561019757fe5b6101c3600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061034c565b005b600060015490505b90565b600081600290805190602001906101e8929190610350565b50600143034090506000546000191681600019161415156102ae578060008160001916905550600160016000828254019250508190555060015481600019167f47e91f47ccfdcb578564e1af55da55c5e5d33403372fe68e4fed3dfd385764a184604051808060200182810382528381815181526020019150805190602001906020028083836000831461029b575b80518252602083111561029b57602082019150602081019050602083039250610277565b5050509050019250505060405180910390a35b5b5050565b6102bb6103da565b600280548060200260200160405190810160405280929190818152602001828054801561033d57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116102f3575b505050505090505b90565b5b50565b5b50565b8280548282559060005260206000209081019282156103c9579160200282015b828111156103c85782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610370565b5b5090506103d691906103ee565b5090565b602060405190810160405280600081525090565b61042e91905b8082111561042a57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016103f4565b5090565b905600a165627a7a723058203070810251dcb89c9838d957eb3dbeef357bef0902e0245e3dc3849b6143c3960029" + "constructor": "6060604052602060405190810160405280737d577a597b2742b498cb5cf0c26cdcd726d39e6e73ffffffffffffffffffffffffffffffffffffffff16815250600090600161004e92919061005c565b50341561005757fe5b610129565b8280548282559060005260206000209081019282156100d5579160200282015b828111156100d45782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019061007c565b5b5090506100e291906100e6565b5090565b61012691905b8082111561012257600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016100ec565b5090565b90565b61056f806101386000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806375286211146100675780639300c92614610079578063b7ab4db5146100d0578063c476dd4014610145578063d69f13bb146101c7575bfe5b341561006f57fe5b610077610206565b005b341561008157fe5b6100ce600480803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050610275565b005b34156100d857fe5b6100e061031f565b6040518080602001828103825283818151815260200191508051906020019060200280838360008314610132575b8051825260208311156101325760208201915060208101905060208303925061010e565b5050509050019250505060405180910390f35b341561014d57fe5b6101c5600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506103b4565b005b34156101cf57fe5b610204600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506103ba565b005b73fffffffffffffffffffffffffffffffffffffffe3373ffffffffffffffffffffffffffffffffffffffff1614151561023f5760006000fd5b600060018054905014151561027257600160009080546102609291906103bf565b5060006001816102709190610411565b505b5b565b806001908051906020019061028b92919061043d565b506001430340600019167f55252fa6eee4741b4e24a74a70e9c11fd2c2281df8d6ea13126ff845f7825c89826040518080602001828103825283818151815260200191508051906020019060200280838360008314610309575b805182526020831115610309576020820191506020810190506020830392506102e5565b5050509050019250505060405180910390a25b50565b6103276104c7565b60008054806020026020016040519081016040528092919081815260200182805480156103a957602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001906001019080831161035f575b505050505090505b90565b5b505050565b5b5050565b8280548282559060005260206000209081019282156104005760005260206000209182015b828111156103ff5782548255916001019190600101906103e4565b5b50905061040d91906104db565b5090565b81548183558181151161043857818360005260206000209182019101610437919061051e565b5b505050565b8280548282559060005260206000209081019282156104b6579160200282015b828111156104b55782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019061045d565b5b5090506104c391906104db565b5090565b602060405190810160405280600081525090565b61051b91905b8082111561051757600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016104e1565b5090565b90565b61054091905b8082111561053c576000816000905550600101610524565b5090565b905600a165627a7a7230582041ce7e5c820bc89b1a330a3233c4f3013e77433ecba368fa234adf758d87fe1d0029" }, "0x7d577a597b2742b498cb5cf0c26cdcd726d39e6e": { "balance": "1606938044258990275541962092341162602522202993782792835301376" }, "0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1": { "balance": "1606938044258990275541962092341162602522202993782792835301376" } diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 205ba6af4..9e58f2ec0 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -257,7 +257,7 @@ impl Account { match db.get(&self.code_hash) { Some(x) => { self.code_size = Some(x.len()); - self.code_cache = Arc::new(x.to_vec()); + self.code_cache = Arc::new(x.into_vec()); Some(self.code_cache.clone()) }, _ => { @@ -476,10 +476,10 @@ mod tests { fn account_compress() { let raw = Account::new_basic(2.into(), 4.into()).rlp(); let rlp = UntrustedRlp::new(&raw); - let compact_vec = rlp.compress(RlpType::Snapshot).to_vec(); + let compact_vec = rlp.compress(RlpType::Snapshot).into_vec(); assert!(raw.len() > compact_vec.len()); let again_raw = UntrustedRlp::new(&compact_vec).decompress(RlpType::Snapshot); - assert_eq!(raw, again_raw.to_vec()); + assert_eq!(raw, again_raw.into_vec()); } #[test] diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 501601fde..a2480e3c3 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -1826,14 +1826,14 @@ mod tests { let mut state = get_temp_state(); state.require_or_from(&a, false, ||Account::new_contract(42.into(), 0.into()), |_|{}).unwrap(); state.init_code(&a, vec![1, 2, 3]).unwrap(); - assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].to_vec()))); + assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3]))); state.commit().unwrap(); - assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].to_vec()))); + assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3]))); state.drop() }; let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap(); - assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].to_vec()))); + assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3]))); } #[test] diff --git a/ethcore/src/tests/helpers.rs b/ethcore/src/tests/helpers.rs index c54933fd1..f8e412073 100644 --- a/ethcore/src/tests/helpers.rs +++ b/ethcore/src/tests/helpers.rs @@ -133,7 +133,7 @@ pub fn create_test_block_with_data(header: &Header, transactions: &[SignedTransa rlp.append(header); rlp.begin_list(transactions.len()); for t in transactions { - rlp.append_raw(&rlp::encode(t).to_vec(), 1); + rlp.append_raw(&rlp::encode(t).into_vec(), 1); } rlp.append_list(&uncles); rlp.out() @@ -193,7 +193,8 @@ pub fn generate_dummy_client_with_spec_accounts_and_data(get_test_spec: F, ac Arc::new(last_hashes.clone()), author.clone(), (3141562.into(), 31415620.into()), - vec![] + vec![], + false, ).unwrap(); b.set_difficulty(U256::from(0x20000)); rolling_timestamp += 10; diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 0df4b86b6..d244c2af1 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -475,7 +475,7 @@ mod tests { let mut uncles_rlp = RlpStream::new(); uncles_rlp.append_list(&good_uncles); let good_uncles_hash = uncles_rlp.as_raw().sha3(); - let good_transactions_root = ordered_trie_root(good_transactions.iter().map(|t| ::rlp::encode::(t).to_vec())); + let good_transactions_root = ordered_trie_root(good_transactions.iter().map(|t| ::rlp::encode::(t).into_vec())); let mut parent = good.clone(); parent.set_number(9); diff --git a/ethstore/src/account/crypto.rs b/ethstore/src/account/crypto.rs index 9d1530429..7d87b1c69 100755 --- a/ethstore/src/account/crypto.rs +++ b/ethstore/src/account/crypto.rs @@ -104,7 +104,7 @@ impl Crypto { cipher: Cipher::Aes128Ctr(Aes128Ctr { iv: iv, }), - ciphertext: (*ciphertext).to_vec(), + ciphertext: ciphertext.into_vec(), kdf: Kdf::Pbkdf2(Pbkdf2 { dklen: crypto::KEY_LENGTH as u32, salt: salt, diff --git a/evmbin/src/display/json.rs b/evmbin/src/display/json.rs index 1791640d6..38265c14c 100644 --- a/evmbin/src/display/json.rs +++ b/evmbin/src/display/json.rs @@ -122,7 +122,7 @@ impl trace::VMTracer for Informant { fn prepare_subtrace(&self, code: &[u8]) -> Self where Self: Sized { let mut vm = Informant::default(); vm.depth = self.depth + 1; - vm.code = code.to_vec(); + vm.code = code.into_vec(); vm.gas_used = self.gas_used; vm } diff --git a/ipfs/src/lib.rs b/ipfs/src/lib.rs index 104c7db19..4821ef59d 100644 --- a/ipfs/src/lib.rs +++ b/ipfs/src/lib.rs @@ -233,7 +233,7 @@ mod tests { let _ = write_chunk(&mut transport, &mut progress, b"foobar"); - assert_eq!(b"foobar".to_vec(), transport); + assert_eq!(b"foobar".into_vec(), transport); assert_eq!(6, progress); } @@ -244,7 +244,7 @@ mod tests { let _ = write_chunk(&mut transport, &mut progress, b"foobar"); - assert_eq!(b"bar".to_vec(), transport); + assert_eq!(b"bar".into_vec(), transport); assert_eq!(6, progress); } diff --git a/ipfs/src/route.rs b/ipfs/src/route.rs index fecafb264..b034c2d4c 100644 --- a/ipfs/src/route.rs +++ b/ipfs/src/route.rs @@ -79,7 +79,7 @@ impl IpfsHandler { fn block_list(&self, hash: H256) -> Result { let uncles = self.client().find_uncles(&hash).ok_or(Error::BlockNotFound)?; - Ok(Out::OctetStream(rlp::encode_list(&uncles).to_vec())) + Ok(Out::OctetStream(rlp::encode_list(&uncles).into_vec())) } /// Get transaction by hash and return as raw binary. @@ -87,7 +87,7 @@ impl IpfsHandler { let tx_id = TransactionId::Hash(hash); let tx = self.client().transaction(tx_id).ok_or(Error::TransactionNotFound)?; - Ok(Out::OctetStream(rlp::encode(&*tx).to_vec())) + Ok(Out::OctetStream(rlp::encode(&*tx).into_vec())) } /// Get state trie node by hash and return as raw binary. diff --git a/json/src/spec/authority_round.rs b/json/src/spec/authority_round.rs index ae518eebc..0fdbfbfb3 100644 --- a/json/src/spec/authority_round.rs +++ b/json/src/spec/authority_round.rs @@ -49,6 +49,9 @@ pub struct AuthorityRoundParams { /// Block from which monotonic steps start. #[serde(rename="validateStepTransition")] pub validate_step_transition: Option, + /// Whether transitions should be immediate. + #[serde(rename="immediateTransitions")] + pub immediate_transitions: Option, } /// Authority engine deserialization. @@ -92,5 +95,6 @@ mod tests { assert!(deserialized.params.registrar.is_none()); assert_eq!(deserialized.params.start_step, Some(Uint(U256::from(24)))); assert_eq!(deserialized.params.eip155_transition, Some(Uint(U256::from(0x42)))); + assert_eq!(deserialized.params.immediate_transitions, None); } } diff --git a/local-store/src/lib.rs b/local-store/src/lib.rs index e975aa43d..5077fbe01 100644 --- a/local-store/src/lib.rs +++ b/local-store/src/lib.rs @@ -121,7 +121,7 @@ impl TransactionEntry { impl From for TransactionEntry { fn from(pending: PendingTransaction) -> Self { TransactionEntry { - rlp_bytes: ::rlp::encode(&pending.transaction).to_vec(), + rlp_bytes: ::rlp::encode(&pending.transaction).into_vec(), condition: pending.condition.map(Into::into), } } diff --git a/parity/run.rs b/parity/run.rs index 35515d54f..bcb18aeeb 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -227,8 +227,7 @@ fn execute_light(cmd: RunCmd, can_restart: bool, logger: Arc) -> } // start on_demand service. - let account_start_nonce = service.client().engine().account_start_nonce(0); - let on_demand = Arc::new(::light::on_demand::OnDemand::new(cache.clone(), account_start_nonce)); + let on_demand = Arc::new(::light::on_demand::OnDemand::new(cache.clone())); // set network path. net_conf.net_config_path = Some(db_dirs.network_path().to_string_lossy().into_owned()); diff --git a/rpc/src/v1/helpers/fake_sign.rs b/rpc/src/v1/helpers/fake_sign.rs index a80afb0bb..21cb0cfe1 100644 --- a/rpc/src/v1/helpers/fake_sign.rs +++ b/rpc/src/v1/helpers/fake_sign.rs @@ -36,6 +36,6 @@ pub fn sign_call( gas: request.gas.unwrap_or(50_000_000.into()), gas_price: request.gas_price.unwrap_or_else(|| default_gas_price(&**client, &**miner)), value: request.value.unwrap_or(0.into()), - data: request.data.map_or_else(Vec::new, |d| d.to_vec()) + data: request.data.unwrap_or_default(), }.fake_sign(from)) } diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index 9ecdffe80..a0316f9cb 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -192,7 +192,7 @@ impl LightFetch { let action = req.to.map_or(Action::Create, Action::Call); let gas = req.gas.unwrap_or(U256::from(10_000_000)); // better gas amount? let value = req.value.unwrap_or_else(U256::zero); - let data = req.data.map_or_else(Vec::new, |d| d.to_vec()); + let data = req.data.unwrap_or_default(); future::done(match nonce { Some(n) => Ok(EthTransaction { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 04c74434e..499b0a15f 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -607,7 +607,7 @@ impl Eth for EthClient where let mix_hash: H256 = mix_hash.into(); trace!(target: "miner", "submit_work: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash); - let seal = vec![rlp::encode(&mix_hash).to_vec(), rlp::encode(&nonce).to_vec()]; + let seal = vec![rlp::encode(&mix_hash).into_vec(), rlp::encode(&nonce).into_vec()]; Ok(self.miner.submit_seal(&*self.client, pow_hash, seal).is_ok()) } diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index e133b3e7a..f50dd82ab 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -154,7 +154,7 @@ impl EthClient { true => BlockTransactions::Full(block.view().localized_transactions().into_iter().map(|t| Transaction::from_localized(t, eip86_transition)).collect()), _ => BlockTransactions::Hashes(block.transaction_hashes().into_iter().map(Into::into).collect()), }, - extra_data: Bytes::new(header.extra_data().to_vec()), + extra_data: Bytes::new(header.extra_data().clone()), }, extra_info: extra_info } diff --git a/rpc/src/v1/impls/personal.rs b/rpc/src/v1/impls/personal.rs index 0bb0be9a7..8028168fd 100644 --- a/rpc/src/v1/impls/personal.rs +++ b/rpc/src/v1/impls/personal.rs @@ -126,7 +126,7 @@ impl Personal for PersonalClient { .and_then(|(pending_tx, dispatcher)| { let network_id = pending_tx.network_id(); trace!(target: "miner", "send_transaction: dispatching tx: {} for network ID {:?}", - ::rlp::encode(&*pending_tx).to_vec().pretty(), network_id); + ::rlp::encode(&*pending_tx).into_vec().pretty(), network_id); dispatcher.dispatch_transaction(pending_tx).map(Into::into) }) diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index 701c57db4..3f158f1c5 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -963,7 +963,7 @@ fn rpc_eth_send_raw_transaction() { let signature = tester.accounts_provider.sign(address, None, t.hash(None)).unwrap(); let t = t.with_signature(signature, None); - let rlp = rlp::encode(&t).to_vec().to_hex(); + let rlp = rlp::encode(&t).into_vec().to_hex(); let req = r#"{ "jsonrpc": "2.0", diff --git a/rpc/src/v1/types/transaction.rs b/rpc/src/v1/types/transaction.rs index e8cd1602f..7cc109ec2 100644 --- a/rpc/src/v1/types/transaction.rs +++ b/rpc/src/v1/types/transaction.rs @@ -195,7 +195,7 @@ impl Transaction { Action::Create => Some(contract_address(scheme, &t.sender(), &t.nonce, &t.data.sha3()).into()), Action::Call(_) => None, }, - raw: ::rlp::encode(&t.signed).to_vec().into(), + raw: ::rlp::encode(&t.signed).into_vec().into(), public_key: t.recover_public().ok().map(Into::into), network_id: t.network_id(), standard_v: t.standard_v().into(), @@ -229,7 +229,7 @@ impl Transaction { Action::Create => Some(contract_address(scheme, &t.sender(), &t.nonce, &t.data.sha3()).into()), Action::Call(_) => None, }, - raw: ::rlp::encode(&t).to_vec().into(), + raw: ::rlp::encode(&t).into_vec().into(), public_key: t.public_key().map(Into::into), network_id: t.network_id(), standard_v: t.standard_v().into(), diff --git a/secret_store/src/key_storage.rs b/secret_store/src/key_storage.rs index b324dd90a..391725998 100644 --- a/secret_store/src/key_storage.rs +++ b/secret_store/src/key_storage.rs @@ -93,7 +93,7 @@ impl KeyStorage for PersistentKeyStorage { self.db.get(None, document) .map_err(Error::Database)? .ok_or(Error::DocumentNotFound) - .map(|key| key.to_vec()) + .map(|key| key.into_vec()) .and_then(|key| serde_json::from_slice::(&key).map_err(|e| Error::Database(e.to_string()))) .map(Into::into) } diff --git a/stratum/src/lib.rs b/stratum/src/lib.rs index 0042ab1e9..d87bf59a8 100644 --- a/stratum/src/lib.rs +++ b/stratum/src/lib.rs @@ -342,7 +342,7 @@ mod tests { let mut core = Core::new().expect("Tokio Core should be created with no errors"); let mut buffer = vec![0u8; 2048]; - let mut data_vec = data.as_bytes().to_vec(); + let mut data_vec = data.as_bytes().into_vec(); data_vec.extend(b"\n"); let stream = TcpStream::connect(addr, &core.handle()) @@ -353,7 +353,7 @@ mod tests { io::read(stream, &mut buffer) }) .and_then(|(_, read_buf, len)| { - future::ok(read_buf[0..len].to_vec()) + future::ok(read_buf[0..len].into_vec()) }); let result = core.run(stream).expect("Core should run with no errors"); @@ -454,7 +454,7 @@ mod tests { let mut auth_request = r#"{"jsonrpc": "2.0", "method": "mining.authorize", "params": ["miner1", ""], "id": 1}"# .as_bytes() - .to_vec(); + .into_vec(); auth_request.extend(b"\n"); let mut core = Core::new().expect("Tokio Core should be created with no errors"); @@ -487,7 +487,7 @@ mod tests { }) .and_then(|(_, read_buf, len)| { trace!(target: "stratum", "Received work from server"); - future::ok(read_buf[0..len].to_vec()) + future::ok(read_buf[0..len].into_vec()) }); let response = String::from_utf8( core.run(stream).expect("Core should run with no errors") diff --git a/sync/src/api.rs b/sync/src/api.rs index 737456167..09511ca1f 100644 --- a/sync/src/api.rs +++ b/sync/src/api.rs @@ -427,7 +427,7 @@ struct TxRelay(Arc); impl LightHandler for TxRelay { fn on_transactions(&self, ctx: &EventContext, relay: &[::ethcore::transaction::UnverifiedTransaction]) { trace!(target: "pip", "Relaying {} transactions from peer {}", relay.len(), ctx.peer()); - self.0.queue_transactions(relay.iter().map(|tx| ::rlp::encode(tx).to_vec()).collect(), ctx.peer()) + self.0.queue_transactions(relay.iter().map(|tx| ::rlp::encode(tx).into_vec()).collect(), ctx.peer()) } } diff --git a/sync/src/light_sync/response.rs b/sync/src/light_sync/response.rs index 73ce58b39..1ab504a9f 100644 --- a/sync/src/light_sync/response.rs +++ b/sync/src/light_sync/response.rs @@ -177,7 +177,7 @@ mod tests { parent_hash = Some(header.hash()); - encoded::Header::new(::rlp::encode(&header).to_vec()) + encoded::Header::new(::rlp::encode(&header).into_vec()) }).collect(); assert!(verify(&headers, &request).is_ok()); @@ -203,7 +203,7 @@ mod tests { parent_hash = Some(header.hash()); - encoded::Header::new(::rlp::encode(&header).to_vec()) + encoded::Header::new(::rlp::encode(&header).into_vec()) }).collect(); assert!(verify(&headers, &request).is_ok()); @@ -229,7 +229,7 @@ mod tests { parent_hash = Some(header.hash()); - encoded::Header::new(::rlp::encode(&header).to_vec()) + encoded::Header::new(::rlp::encode(&header).into_vec()) }).collect(); assert_eq!(verify(&headers, &request), Err(BasicError::TooManyHeaders(20, 25))); @@ -248,7 +248,7 @@ mod tests { let mut header = Header::default(); header.set_number(x); - encoded::Header::new(::rlp::encode(&header).to_vec()) + encoded::Header::new(::rlp::encode(&header).into_vec()) }).collect(); assert_eq!(verify(&headers, &request), Err(BasicError::WrongSkip(5, Some(2)))); diff --git a/util/Cargo.toml b/util/Cargo.toml index 5d5f5ab55..0af5635ab 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -16,7 +16,7 @@ time = "0.1.34" rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" } eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } rust-crypto = "0.2.34" -elastic-array = "0.8" +elastic-array = "0.9" rlp = { path = "rlp" } heapsize = "0.4" itertools = "0.5" diff --git a/util/benches/trie.rs b/util/benches/trie.rs index e02077ad4..d526b97ac 100644 --- a/util/benches/trie.rs +++ b/util/benches/trie.rs @@ -45,14 +45,14 @@ fn random_bytes(min_count: usize, diff_count: usize, seed: &mut H256) -> Vec assert!(min_count + diff_count <= 32); *seed = seed.sha3(); let r = min_count + (seed[31] as usize % (diff_count + 1)); - seed[0..r].to_vec() + seed[0..r].into_vec() } fn random_value(seed: &mut H256) -> Bytes { *seed = seed.sha3(); match seed[0] % 2 { 1 => vec![seed[31];1], - _ => seed.to_vec(), + _ => seed.into_vec(), } } diff --git a/util/rlp/Cargo.toml b/util/rlp/Cargo.toml index 6ba4aafcd..b6ca67984 100644 --- a/util/rlp/Cargo.toml +++ b/util/rlp/Cargo.toml @@ -7,7 +7,7 @@ version = "0.2.0" authors = ["Parity Technologies "] [dependencies] -elastic-array = "0.8" +elastic-array = "0.9" ethcore-bigint = { path = "../bigint" } lazy_static = "0.2" rustc-serialize = "0.3" diff --git a/util/rlp/src/compression.rs b/util/rlp/src/compression.rs index 74a8f354f..f76a3b7ab 100644 --- a/util/rlp/src/compression.rs +++ b/util/rlp/src/compression.rs @@ -105,7 +105,7 @@ fn deep_decompress(rlp: &UntrustedRlp, swapper: &InvalidRlpSwapper) -> Option rlp.at(1).ok().map_or(simple_swap(), - |r| deep_decompress(&r, swapper).map(|d| { let v = d.to_vec(); encode(&v) })), + |r| deep_decompress(&r, swapper).map(|d| { let v = d.into_vec(); encode(&v) })), // Iterate through RLP while checking if it has been compressed. _ => map_rlp(rlp, |r| deep_decompress(r, swapper)), } @@ -148,10 +148,10 @@ mod tests { fn simple_compression() { let basic_account_rlp = vec![248, 68, 4, 2, 160, 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, 160, 197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125, 178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112]; let rlp = UntrustedRlp::new(&basic_account_rlp); - let compressed = rlp.compress(RlpType::Snapshot).to_vec(); + let compressed = rlp.compress(RlpType::Snapshot).into_vec(); assert_eq!(compressed, vec![198, 4, 2, 129, 0, 129, 1]); let compressed_rlp = UntrustedRlp::new(&compressed); - assert_eq!(compressed_rlp.decompress(RlpType::Snapshot).to_vec(), basic_account_rlp); + assert_eq!(compressed_rlp.decompress(RlpType::Snapshot).into_vec(), basic_account_rlp); } #[test] @@ -159,36 +159,36 @@ mod tests { let data_basic_account_rlp = vec![184, 70, 248, 68, 4, 2, 160, 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, 160, 197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125, 178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112]; let compressed = vec![201, 129, 127, 198, 4, 2, 129, 0, 129, 1]; let compressed_rlp = UntrustedRlp::new(&compressed); - assert_eq!(compressed_rlp.decompress(RlpType::Blocks).to_vec(), data_basic_account_rlp); + assert_eq!(compressed_rlp.decompress(RlpType::Blocks).into_vec(), data_basic_account_rlp); } #[test] fn nested_list_rlp() { let nested_basic_account_rlp = vec![228, 4, 226, 2, 160, 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33]; let nested_rlp = UntrustedRlp::new(&nested_basic_account_rlp); - let compressed = nested_rlp.compress(RlpType::Blocks).to_vec(); + let compressed = nested_rlp.compress(RlpType::Blocks).into_vec(); assert_eq!(compressed, vec![197, 4, 195, 2, 129, 0]); let compressed_rlp = UntrustedRlp::new(&compressed); - assert_eq!(compressed_rlp.decompress(RlpType::Blocks).to_vec(), nested_basic_account_rlp); - let compressed = nested_rlp.compress(RlpType::Snapshot).to_vec(); + assert_eq!(compressed_rlp.decompress(RlpType::Blocks).into_vec(), nested_basic_account_rlp); + let compressed = nested_rlp.compress(RlpType::Snapshot).into_vec(); assert_eq!(compressed, vec![197, 4, 195, 2, 129, 0]); let compressed_rlp = UntrustedRlp::new(&compressed); - assert_eq!(compressed_rlp.decompress(RlpType::Snapshot).to_vec(), nested_basic_account_rlp); + assert_eq!(compressed_rlp.decompress(RlpType::Snapshot).into_vec(), nested_basic_account_rlp); } #[test] fn malformed_rlp() { let malformed = vec![248, 81, 128, 128, 128, 128, 128, 160, 12, 51, 241, 93, 69, 218, 74, 138, 79, 115, 227, 44, 216, 81, 46, 132, 85, 235, 96, 45, 252, 48, 181, 29, 75, 141, 217, 215, 86, 160, 109, 130, 160, 140, 36, 93, 200, 109, 215, 100, 241, 246, 99, 135, 92, 168, 149, 170, 114, 9, 143, 4, 93, 25, 76, 54, 176, 119, 230, 170, 154, 105, 47, 121, 10, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]; let malformed_rlp = UntrustedRlp::new(&malformed); - assert_eq!(malformed_rlp.decompress(RlpType::Blocks).to_vec(), malformed); + assert_eq!(malformed_rlp.decompress(RlpType::Blocks).into_vec(), malformed); } #[test] fn large_block() { let block = vec![249, 97, 87, 249, 2, 19, 160, 137, 152, 36, 115, 234, 67, 89, 207, 44, 42, 186, 128, 91, 242, 10, 16, 42, 193, 195, 2, 129, 60, 181, 150, 192, 178, 117, 15, 18, 100, 174, 249, 160, 29, 204, 77, 232, 222, 199, 93, 122, 171, 133, 181, 103, 182, 204, 212, 26, 211, 18, 69, 27, 148, 138, 116, 19, 240, 161, 66, 253, 64, 212, 147, 71, 148, 223, 125, 126, 5, 57, 51, 181, 204, 36, 55, 47, 135, 140, 144, 230, 45, 173, 173, 93, 66, 160, 93, 42, 52, 28, 156, 139, 242, 60, 121, 90, 117, 99, 92, 182, 196, 25, 131, 16, 155, 186, 239, 137, 33, 118, 105, 232, 230, 239, 213, 240, 207, 6, 160, 59, 72, 35, 216, 124, 37, 62, 178, 34, 97, 180, 254, 212, 103, 179, 45, 247, 168, 205, 145, 7, 157, 75, 247, 83, 230, 233, 248, 97, 132, 232, 161, 160, 122, 167, 249, 196, 203, 2, 173, 180, 106, 203, 129, 214, 232, 181, 87, 39, 60, 99, 135, 6, 40, 34, 163, 118, 140, 149, 79, 241, 238, 230, 201, 194, 185, 1, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 64, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 134, 36, 160, 31, 187, 182, 29, 131, 58, 212, 207, 131, 71, 168, 13, 131, 45, 60, 7, 132, 89, 53, 51, 233, 147, 69, 84, 67, 32, 101, 116, 104, 101, 114, 109, 105, 110, 101, 32, 45, 32, 69, 85, 49, 160, 204, 49, 229, 99, 26, 47, 30, 50, 223, 117, 111, 168, 102, 158, 12, 186, 140, 98, 193, 196, 214, 29, 13, 87, 44, 31, 216, 48, 250, 251, 148, 69, 136, 225, 206, 131, 96, 2, 39, 50, 46, 249, 95, 61, 248, 109, 1, 133, 4, 227, 178, 146, 0, 130, 82, 8, 148, 123, 45, 95, 28, 247, 139, 190, 196, 52, 39, 251, 53, 226, 79, 251, 1, 98, 34, 68, 240, 136, 18, 81, 1, 26, 180, 46, 168, 0, 128, 129, 157, 160, 31, 164, 62, 186, 38, 56, 118, 133, 24, 180, 239, 139, 254, 154, 196, 115, 8, 246, 45, 233, 227, 165, 192, 193, 7, 111, 1, 169, 2, 204, 2, 144, 160, 42, 60, 78, 200, 5, 113, 98, 65, 250, 105, 0, 164, 152, 81, 235, 154, 100, 204, 182, 141, 174, 39, 107, 127, 219, 120, 63, 221, 237, 87, 57, 9, 249, 94, 203, 52, 133, 2, 84, 11, 228, 0, 131, 44, 233, 255, 148, 137, 61, 196, 25, 119, 102, 53, 248, 253, 27, 31, 169, 147, 75, 245, 41, 174, 242, 86, 7, 128, 185, 94, 100, 194, 32, 154, 203, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 131, 110, 76, 27, 36, 34, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 138, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 248, 249, 1, 245, 160, 89, 97, 73, 3, 84, 63, 105, 163, 169, 7, 237, 254, 220, 243, 13, 27, 0, 45, 215, 39, 235, 232, 237, 22, 162, 83, 99, 164, 247, 240, 48, 66, 160, 29, 204, 77, 232, 222, 199, 93, 122, 171, 133, 181, 103, 182, 204, 212, 26, 211, 18, 69, 27, 148, 138, 116, 19, 240, 161, 66, 253, 64, 212, 147, 71, 148, 137, 61, 196, 25, 119, 102, 53, 248, 253, 27, 31, 169, 147, 75, 245, 41, 174, 242, 86, 7, 160, 243, 100, 253, 32, 58, 153, 124, 189, 215, 216, 21, 229, 230, 182, 39, 222, 135, 217, 92, 155, 164, 143, 79, 14, 178, 128, 26, 245, 152, 197, 247, 33, 160, 98, 156, 249, 227, 33, 40, 127, 226, 250, 254, 222, 21, 37, 66, 5, 23, 142, 73, 121, 64, 233, 198, 110, 212, 131, 134, 126, 38, 218, 85, 149, 212, 160, 32, 179, 60, 112, 219, 114, 185, 205, 184, 204, 31, 210, 181, 8, 109, 97, 227, 206, 41, 177, 238, 122, 205, 193, 93, 163, 176, 107, 28, 181, 63, 19, 185, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 36, 236, 76, 26, 58, 130, 131, 58, 210, 155, 131, 71, 183, 132, 130, 82, 8, 132, 89, 53, 19, 83, 160, 83, 109, 97, 114, 116, 80, 111, 111, 108, 45, 79, 76, 69, 66, 100, 120, 122, 50, 54, 106, 73, 50, 74, 65, 72, 109, 52, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 203, 86, 242, 75, 191, 176, 245, 37, 106, 66, 34, 44, 77, 161, 164, 143, 56, 229, 102, 192, 191, 114, 46, 137, 15, 59, 249, 198, 20, 64, 167, 176, 167, 146, 234, 72, 147, 122, 168, 34, 174, 210, 94, 131, 105, 110, 180, 48, 248, 10, 127, 156, 194, 83, 60, 48, 89, 126, 86, 90, 218, 235, 170, 15, 206, 23, 82, 13, 250, 255, 240, 112, 168, 137, 111, 204, 205, 125, 24, 81, 118, 165, 92, 28, 127, 50, 223, 173, 231, 234, 212, 181, 9, 113, 72, 250, 97, 126, 194, 18, 102, 51, 189, 147, 246, 2, 201, 27, 206, 15, 130, 172, 1, 206, 219, 204, 49, 211, 162, 78, 101, 26, 16, 73, 106, 70, 209, 118, 140, 59, 133, 162, 114, 14, 92, 8, 26, 83, 213, 91, 136, 207, 228, 86, 13, 208, 64, 85, 211, 143, 252, 181, 128, 77, 187, 198, 50, 91, 26, 156, 109, 233, 136, 36, 216, 142, 87, 112, 45, 166, 235, 118, 128, 191, 66, 23, 48, 32, 3, 41, 37, 103, 8, 180, 236, 77, 106, 59, 18, 77, 206, 23, 154, 143, 236, 63, 235, 52, 105, 155, 38, 207, 31, 145, 193, 98, 251, 216, 224, 213, 250, 164, 22, 21, 227, 190, 223, 74, 29, 107, 0, 103, 187, 53, 129, 204, 202, 170, 156, 19, 67, 185, 100, 252, 5, 129, 164, 58, 228, 121, 214, 27, 53, 35, 16, 238, 93, 64, 94, 4, 250, 138, 102, 22, 128, 37, 229, 104, 40, 245, 216, 107, 16, 52, 202, 54, 98, 43, 162, 245, 56, 48, 150, 41, 3, 224, 167, 171, 5, 254, 106, 199, 0, 47, 238, 162, 27, 114, 168, 111, 231, 241, 102, 79, 138, 66, 168, 38, 157, 140, 76, 56, 155, 66, 109, 253, 243, 207, 79, 88, 167, 111, 251, 135, 38, 249, 85, 167, 36, 113, 7, 243, 34, 132, 113, 117, 8, 245, 93, 79, 171, 12, 223, 157, 41, 201, 221, 129, 60, 186, 164, 123, 1, 247, 202, 28, 61, 121, 156, 214, 55, 68, 36, 205, 113, 203, 45, 173, 24, 190, 32, 42, 207, 69, 189, 209, 221, 50, 18, 77, 60, 249, 233, 101, 216, 168, 47, 16, 155, 172, 248, 90, 115, 162, 134, 95, 6, 227, 202, 46, 26, 133, 135, 65, 251, 97, 109, 181, 141, 87, 156, 59, 40, 253, 87, 116, 244, 225, 242, 133, 77, 199, 120, 210, 152, 108, 90, 137, 127, 214, 137, 250, 180, 148, 113, 71, 68, 183, 216, 166, 169, 54, 174, 235, 51, 45, 172, 47, 5, 205, 154, 71, 241, 106, 228, 222, 150, 34, 95, 68, 251, 78, 244, 111, 59, 252, 138, 106, 31, 185, 107, 123, 22, 37, 184, 249, 117, 231, 56, 224, 137, 13, 254, 50, 240, 252, 220, 74, 33, 223, 163, 97, 74, 180, 232, 189, 92, 104, 193, 59, 255, 80, 10, 146, 236, 17, 80, 90, 139, 35, 212, 153, 19, 13, 159, 7, 184, 77, 193, 43, 251, 149, 176, 147, 169, 227, 236, 74, 98, 163, 193, 180, 4, 186, 19, 29, 212, 166, 177, 114, 30, 254, 241, 141, 95, 72, 99, 104, 101, 21, 141, 181, 85, 200, 184, 190, 11, 255, 74, 39, 89, 41, 204, 187, 96, 202, 188, 191, 157, 135, 239, 166, 155, 86, 32, 228, 198, 117, 41, 31, 54, 151, 229, 214, 56, 149, 187, 177, 123, 164, 182, 232, 188, 21, 94, 2, 155, 177, 124, 94, 151, 249, 116, 78, 62, 0, 194, 76, 156, 86, 227, 11, 25, 35, 6, 175, 77, 151, 60, 44, 114, 234, 153, 124, 79, 114, 88, 36, 178, 223, 229, 61, 90, 198, 60, 237, 224, 169, 115, 22, 152, 254, 235, 17, 130, 53, 1, 235, 67, 90, 238, 52, 170, 182, 73, 182, 138, 182, 189, 130, 170, 200, 91, 14, 150, 174, 100, 63, 29, 93, 171, 150, 154, 93, 72, 34, 156, 173, 108, 74, 29, 107, 197, 130, 86, 106, 178, 138, 210, 0, 92, 11, 78, 111, 226, 120, 169, 222, 50, 18, 156, 170, 98, 206, 97, 21, 28, 112, 234, 145, 2, 216, 188, 172, 150, 183, 39, 125, 17, 146, 49, 184, 242, 2, 60, 19, 162, 180, 210, 254, 249, 182, 240, 148, 184, 118, 113, 198, 27, 115, 165, 193, 97, 232, 201, 140, 63, 200, 153, 10, 162, 170, 69, 68, 152, 199, 103, 14, 164, 228, 120, 71, 47, 196, 217, 251, 181, 26, 112, 185, 116, 184, 77, 93, 236, 160, 235, 40, 0, 162, 199, 123, 223, 37, 53, 73, 177, 69, 207, 11, 137, 67, 204, 57, 231, 50, 185, 148, 48, 30, 102, 195, 248, 40, 189, 227, 187, 95, 166, 1, 7, 30, 112, 32, 101, 38, 72, 208, 52, 67, 131, 96, 34, 192, 156, 48, 92, 231, 188, 97, 103, 97, 41, 254, 33, 72, 190, 68, 184, 85, 114, 25, 94, 65, 144, 102, 176, 150, 76, 247, 146, 9, 188, 66, 4, 144, 98, 233, 196, 166, 7, 15, 54, 148, 247, 81, 52, 253, 27, 113, 235, 255, 230, 179, 168, 140, 95, 230, 163, 86, 235, 119, 185, 152, 223, 129, 48, 169, 170, 225, 224, 154, 164, 209, 129, 232, 92, 190, 187, 38, 217, 36, 113, 250, 61, 125, 168, 25, 70, 227, 39, 142, 12, 226, 20, 134, 82, 143, 147, 211, 173, 149, 223, 58, 27, 163, 18, 252, 148, 112, 19, 101, 144, 21, 105, 34, 200, 254, 11, 254, 8, 247, 210, 142, 194, 54, 150, 34, 171, 33, 203, 79, 79, 135, 186, 51, 68, 215, 106, 100, 21, 239, 178, 68, 230, 238, 72, 4, 31, 101, 161, 29, 204, 129, 234, 66, 195, 6, 69, 77, 48, 157, 137, 236, 96, 138, 119, 86, 147, 205, 172, 242, 28, 115, 188, 254, 216, 35, 89, 33, 27, 162, 243, 58, 102, 131, 50, 23, 169, 58, 218, 111, 6, 199, 164, 171, 104, 207, 34, 111, 229, 3, 207, 124, 96, 241, 95, 105, 113, 4, 16, 48, 163, 153, 0, 96, 174, 246, 3, 154, 124, 14, 132, 237, 184, 91, 217, 201, 53, 80, 39, 31, 113, 246, 67, 132, 85, 62, 153, 187, 240, 180, 117, 162, 17, 27, 190, 72, 178, 14, 101, 173, 200, 14, 196, 225, 212, 38, 153, 165, 147, 130, 51, 134, 40, 36, 7, 234, 179, 73, 28, 224, 4, 222, 10, 61, 65, 78, 23, 98, 246, 144, 9, 16, 180, 248, 56, 214, 162, 214, 18, 50, 67, 207, 3, 77, 7, 6, 28, 43, 131, 124, 117, 124, 213, 160, 67, 1, 44, 39, 15, 28, 149, 45, 54, 127, 157, 237, 193, 132, 174, 214, 8, 164, 106, 159, 213, 27, 173, 33, 24, 31, 110, 210, 95, 140, 236, 71, 68, 207, 225, 134, 105, 25, 226, 168, 119, 172, 1, 252, 11, 231, 182, 93, 254, 211, 58, 78, 192, 168, 67, 71, 11, 160, 76, 111, 234, 138, 119, 135, 51, 226, 113, 167, 146, 103, 97, 43, 192, 133, 252, 124, 42, 190, 217, 38, 95, 95, 222, 14, 245, 192, 116, 245, 68, 114, 253, 25, 229, 221, 0, 158, 27, 163, 45, 244, 200, 0, 205, 150, 162, 76, 224, 168, 203, 79, 114, 137, 18, 206, 12, 152, 241, 159, 245, 197, 175, 146, 16, 62, 152, 112, 233, 23, 132, 151, 100, 175, 26, 83, 0, 254, 150, 230, 94, 174, 77, 39, 57, 106, 155, 69, 85, 230, 239, 202, 205, 49, 17, 47, 72, 128, 251, 42, 157, 218, 234, 213, 127, 118, 152, 74, 139, 99, 120, 217, 116, 16, 73, 79, 40, 88, 107, 38, 132, 34, 101, 225, 109, 114, 91, 66, 69, 10, 44, 191, 6, 160, 208, 104, 123, 247, 247, 49, 151, 246, 216, 228, 157, 69, 140, 155, 98, 147, 202, 12, 79, 168, 40, 210, 164, 230, 241, 107, 109, 231, 243, 187, 252, 100, 70, 41, 140, 35, 231, 115, 98, 49, 192, 102, 46, 12, 82, 162, 226, 104, 86, 169, 42, 34, 213, 76, 89, 197, 131, 10, 25, 120, 204, 115, 231, 103, 217, 164, 13, 166, 139, 141, 77, 75, 27, 21, 84, 212, 209, 189, 148, 198, 213, 96, 234, 190, 213, 40, 210, 152, 141, 4, 110, 167, 209, 226, 236, 247, 139, 119, 215, 175, 30, 49, 225, 174, 42, 195, 251, 228, 170, 246, 94, 117, 128, 34, 177, 10, 15, 126, 165, 52, 159, 249, 67, 35, 200, 86, 65, 254, 141, 198, 219, 55, 225, 240, 111, 248, 101, 29, 235, 192, 112, 225, 19, 255, 139, 129, 46, 42, 9, 8, 74, 58, 254, 191, 49, 173, 189, 32, 5, 174, 81, 223, 94, 145, 85, 40, 194, 145, 251, 88, 168, 166, 143, 39, 33, 111, 230, 115, 77, 113, 83, 100, 211, 244, 163, 201, 141, 71, 193, 106, 138, 3, 215, 134, 217, 191, 10, 177, 250, 233, 247, 127, 162, 112, 206, 150, 187, 205, 141, 211, 181, 58, 199, 11, 220, 91, 180, 169, 182, 178, 224, 159, 144, 105, 146, 29, 162, 221, 106, 190, 209, 151, 126, 98, 187, 91, 50, 91, 198, 210, 78, 189, 155, 193, 208, 178, 164, 0, 189, 145, 189, 7, 162, 88, 156, 33, 118, 176, 125, 130, 199, 108, 240, 99, 125, 119, 202, 188, 53, 17, 140, 102, 26, 30, 23, 30, 214, 203, 93, 82, 6, 67, 28, 31, 12, 166, 105, 63, 132, 69, 166, 208, 252, 140, 56, 175, 245, 17, 170, 3, 193, 26, 168, 92, 40, 131, 82, 17, 144, 128, 91, 48, 220, 16, 209, 53, 226, 4, 225, 6, 253, 141, 25, 254, 146, 41, 63, 90, 19, 6, 75, 96, 130, 156, 14, 91, 231, 207, 128, 244, 15, 135, 63, 45, 235, 51, 134, 10, 75, 252, 212, 63, 51, 131, 253, 110, 144, 239, 182, 194, 107, 45, 103, 124, 83, 154, 173, 181, 51, 60, 63, 75, 172, 103, 222, 53, 31, 73, 93, 76, 159, 184, 24, 240, 41, 97, 72, 131, 54, 113, 170, 233, 182, 86, 62, 88, 131, 206, 86, 180, 32, 143, 172, 114, 41, 233, 121, 221, 190, 192, 97, 48, 196, 185, 135, 67, 79, 190, 66, 181, 196, 246, 211, 94, 250, 228, 62, 117, 159, 141, 54, 186, 81, 143, 113, 108, 102, 252, 182, 146, 233, 20, 135, 30, 255, 237, 33, 224, 68, 8, 175, 33, 58, 49, 16, 226, 113, 54, 90, 209, 159, 211, 193, 203, 187, 186, 156, 89, 81, 127, 211, 171, 113, 92, 238, 193, 159, 11, 242, 183, 97, 67, 211, 138, 203, 35, 113, 247, 64, 205, 71, 2, 127, 208, 90, 139, 132, 148, 180, 247, 7, 119, 195, 128, 96, 221, 195, 110, 44, 53, 114, 26, 196, 226, 219, 134, 195, 190, 205, 171, 29, 137, 224, 75, 167, 188, 94, 123, 199, 64, 167, 105, 191, 52, 247, 43, 224, 181, 250, 58, 109, 25, 1, 120, 7, 223, 250, 69, 199, 83, 15, 20, 136, 90, 247, 128, 109, 169, 243, 24, 220, 215, 188, 169, 46, 31, 131, 112, 79, 132, 93, 170, 127, 238, 207, 138, 110, 201, 232, 163, 214, 77, 45, 113, 103, 179, 197, 206, 83, 148, 6, 185, 231, 174, 111, 171, 162, 147, 39, 252, 36, 132, 173, 145, 77, 43, 223, 164, 46, 136, 129, 210, 219, 221, 202, 246, 182, 95, 135, 8, 55, 229, 71, 245, 57, 131, 217, 93, 90, 179, 195, 230, 102, 169, 80, 51, 197, 6, 48, 143, 112, 121, 27, 79, 174, 47, 88, 240, 47, 10, 62, 94, 177, 78, 234, 112, 136, 65, 84, 4, 245, 190, 138, 38, 98, 108, 187, 47, 236, 65, 95, 233, 245, 47, 126, 208, 199, 74, 229, 158, 20, 238, 148, 218, 241, 233, 229, 13, 14, 206, 95, 42, 22, 65, 191, 218, 73, 116, 90, 23, 4, 166, 32, 236, 51, 107, 252, 198, 10, 163, 100, 140, 221, 174, 111, 179, 171, 183, 159, 204, 229, 104, 156, 190, 99, 142, 130, 46, 142, 31, 244, 30, 114, 69, 86, 159, 173, 185, 88, 130, 238, 12, 216, 140, 134, 15, 104, 64, 131, 106, 95, 206, 11, 1, 183, 75, 167, 43, 63, 188, 39, 144, 14, 179, 140, 47, 140, 253, 202, 192, 215, 156, 108, 18, 211, 9, 75, 108, 47, 212, 81, 24, 149, 244, 189, 60, 199, 210, 251, 22, 15, 247, 145, 136, 59, 51, 228, 31, 227, 226, 12, 199, 36, 126, 167, 153, 168, 220, 216, 56, 68, 79, 99, 88, 13, 34, 125, 123, 33, 239, 167, 121, 240, 167, 65, 1, 82, 9, 126, 165, 52, 107, 207, 11, 48, 112, 3, 150, 102, 30, 177, 250, 211, 194, 239, 204, 242, 27, 31, 118, 231, 44, 200, 178, 138, 104, 164, 131, 113, 205, 95, 88, 165, 136, 177, 7, 111, 216, 83, 186, 110, 193, 241, 164, 24, 237, 204, 95, 250, 183, 26, 100, 70, 58, 91, 190, 43, 165, 31, 136, 139, 190, 27, 67, 52, 72, 65, 120, 121, 54, 81, 27, 209, 28, 74, 51, 58, 211, 86, 46, 92, 123, 222, 10, 44, 145, 78, 90, 26, 61, 64, 143, 228, 227, 254, 73, 218, 85, 93, 218, 33, 123, 181, 195, 9, 76, 237, 41, 119, 145, 131, 106, 4, 150, 58, 7, 156, 65, 113, 108, 28, 135, 43, 21, 245, 159, 20, 163, 123, 27, 20, 58, 212, 183, 242, 82, 228, 110, 80, 53, 164, 161, 180, 244, 125, 168, 207, 81, 4, 253, 95, 101, 88, 31, 63, 25, 134, 59, 130, 0, 90, 220, 24, 200, 221, 149, 76, 225, 16, 26, 77, 179, 172, 190, 145, 199, 145, 239, 140, 106, 131, 29, 211, 187, 12, 207, 40, 205, 237, 151, 159, 18, 76, 49, 193, 137, 196, 197, 105, 181, 171, 23, 172, 208, 115, 95, 139, 136, 150, 211, 251, 132, 247, 206, 93, 70, 19, 181, 13, 205, 216, 79, 238, 229, 123, 12, 38, 24, 233, 96, 205, 223, 126, 95, 54, 15, 145, 149, 40, 41, 34, 30, 17, 1, 153, 252, 244, 214, 40, 66, 158, 71, 219, 142, 206, 216, 251, 200, 191, 75, 34, 147, 163, 27, 127, 64, 195, 187, 129, 132, 63, 224, 112, 1, 154, 28, 76, 141, 165, 195, 155, 53, 84, 189, 57, 148, 144, 98, 14, 232, 213, 179, 55, 191, 169, 203, 103, 99, 120, 159, 254, 201, 113, 51, 23, 99, 116, 246, 200, 59, 122, 13, 165, 118, 14, 230, 35, 231, 158, 48, 20, 104, 147, 121, 161, 241, 83, 109, 58, 84, 246, 251, 170, 145, 99, 179, 150, 32, 203, 93, 193, 99, 13, 86, 8, 224, 237, 61, 69, 58, 27, 79, 229, 84, 129, 145, 109, 58, 2, 230, 50, 0, 38, 189, 160, 18, 89, 158, 44, 255, 190, 108, 59, 161, 43, 49, 238, 84, 229, 223, 183, 138, 75, 130, 84, 208, 112, 183, 75, 108, 229, 254, 186, 103, 207, 244, 244, 149, 217, 71, 217, 238, 59, 98, 49, 214, 251, 83, 43, 104, 84, 0, 244, 181, 253, 235, 119, 236, 31, 36, 163, 105, 46, 52, 21, 212, 81, 170, 106, 186, 162, 63, 24, 235, 197, 184, 239, 229, 147, 105, 73, 145, 164, 214, 128, 23, 141, 50, 203, 41, 135, 32, 169, 168, 152, 137, 199, 38, 93, 226, 205, 20, 190, 208, 216, 76, 204, 133, 134, 137, 99, 89, 32, 57, 235, 138, 176, 10, 63, 159, 110, 85, 155, 164, 250, 194, 190, 58, 202, 52, 237, 95, 54, 149, 206, 144, 74, 123, 152, 231, 41, 202, 121, 248, 243, 40, 247, 161, 225, 88, 148, 188, 79, 6, 235, 43, 132, 24, 200, 229, 86, 53, 166, 123, 116, 233, 203, 23, 212, 55, 0, 195, 238, 247, 152, 247, 216, 229, 23, 93, 244, 224, 96, 37, 6, 61, 24, 107, 51, 63, 254, 187, 179, 71, 7, 45, 170, 122, 160, 223, 44, 203, 190, 142, 134, 129, 210, 67, 41, 17, 118, 139, 196, 163, 243, 54, 81, 192, 212, 129, 52, 227, 168, 113, 238, 178, 185, 158, 213, 144, 12, 198, 236, 234, 35, 179, 157, 91, 138, 46, 220, 35, 65, 82, 11, 16, 125, 96, 248, 199, 155, 100, 48, 154, 106, 187, 141, 250, 191, 130, 222, 131, 227, 14, 138, 219, 23, 23, 190, 180, 155, 147, 58, 224, 150, 39, 182, 226, 239, 3, 45, 47, 99, 255, 32, 73, 242, 233, 180, 149, 238, 45, 103, 39, 196, 231, 138, 16, 51, 224, 221, 136, 174, 205, 149, 132, 92, 83, 186, 48, 133, 204, 210, 5, 40, 57, 22, 64, 160, 4, 73, 168, 178, 229, 222, 185, 235, 109, 196, 109, 183, 150, 158, 0, 56, 16, 41, 43, 193, 31, 204, 169, 219, 50, 167, 242, 107, 206, 105, 228, 246, 59, 53, 18, 42, 19, 217, 56, 220, 59, 46, 160, 107, 200, 164, 0, 5, 213, 178, 133, 187, 142, 174, 218, 60, 252, 237, 61, 66, 146, 207, 179, 93, 234, 83, 219, 93, 55, 107, 92, 139, 101, 151, 198, 135, 246, 223, 101, 139, 44, 166, 82, 97, 233, 217, 130, 67, 22, 88, 36, 131, 80, 179, 192, 34, 206, 119, 167, 17, 65, 217, 71, 250, 52, 253, 29, 4, 156, 63, 64, 81, 6, 67, 130, 79, 0, 95, 87, 36, 43, 4, 26, 51, 250, 24, 178, 197, 41, 20, 142, 187, 180, 239, 156, 102, 113, 15, 13, 18, 90, 70, 184, 7, 250, 193, 117, 127, 60, 0, 198, 218, 128, 116, 119, 124, 126, 160, 129, 231, 68, 189, 98, 48, 43, 120, 178, 91, 54, 242, 66, 112, 55, 188, 42, 179, 94, 60, 249, 136, 81, 149, 132, 98, 209, 181, 219, 223, 31, 40, 235, 55, 5, 69, 11, 63, 192, 51, 224, 119, 107, 193, 84, 178, 191, 58, 217, 222, 183, 118, 114, 95, 45, 48, 126, 184, 10, 207, 0, 217, 59, 167, 244, 219, 9, 238, 41, 13, 127, 191, 123, 139, 9, 74, 40, 164, 194, 205, 116, 204, 185, 230, 133, 148, 215, 50, 105, 173, 220, 113, 117, 98, 233, 80, 209, 185, 211, 232, 29, 157, 12, 206, 228, 187, 26, 240, 193, 21, 15, 69, 115, 120, 66, 2, 92, 165, 103, 29, 177, 151, 154, 211, 107, 177, 89, 16, 135, 243, 135, 178, 237, 184, 110, 191, 169, 230, 243, 106, 16, 95, 128, 124, 73, 132, 107, 116, 123, 38, 0, 72, 24, 171, 8, 113, 227, 43, 136, 168, 25, 174, 100, 201, 252, 212, 119, 246, 131, 95, 78, 65, 222, 89, 192, 87, 66, 102, 58, 237, 94, 56, 138, 71, 121, 65, 49, 22, 65, 29, 183, 56, 59, 27, 16, 176, 232, 120, 22, 104, 212, 83, 32, 55, 90, 2, 37, 108, 112, 146, 113, 34, 64, 78, 65, 80, 198, 101, 190, 60, 69, 60, 230, 72, 216, 215, 225, 166, 155, 122, 140, 137, 245, 89, 77, 237, 209, 242, 67, 37, 88, 5, 117, 101, 165, 98, 84, 139, 18, 57, 118, 67, 78, 254, 178, 60, 181, 124, 144, 169, 13, 20, 233, 60, 51, 55, 1, 215, 225, 224, 42, 191, 189, 227, 246, 25, 53, 164, 27, 1, 66, 112, 36, 211, 67, 195, 172, 119, 52, 81, 244, 10, 39, 11, 219, 160, 35, 230, 225, 176, 171, 74, 254, 100, 229, 4, 64, 140, 85, 94, 85, 197, 63, 234, 173, 243, 129, 52, 220, 154, 175, 195, 223, 23, 85, 20, 171, 79, 240, 185, 10, 14, 93, 185, 93, 100, 11, 41, 39, 106, 137, 70, 122, 173, 221, 195, 73, 174, 145, 7, 85, 1, 232, 126, 67, 38, 213, 104, 164, 213, 213, 5, 23, 233, 233, 47, 222, 14, 3, 33, 180, 180, 49, 136, 73, 46, 237, 209, 47, 197, 173, 95, 131, 4, 157, 40, 217, 217, 156, 31, 81, 103, 24, 116, 208, 225, 123, 11, 122, 143, 55, 224, 125, 121, 42, 109, 151, 120, 245, 141, 176, 100, 12, 237, 222, 197, 100, 79, 16, 168, 247, 103, 223, 85, 92, 26, 17, 23, 91, 90, 249, 228, 162, 166, 164, 178, 215, 48, 203, 209, 138, 42, 42, 87, 132, 134, 120, 39, 13, 50, 77, 187, 15, 42, 82, 80, 242, 210, 141, 28, 213, 194, 241, 75, 86, 159, 120, 217, 98, 94, 100, 129, 1, 228, 157, 183, 171, 186, 164, 245, 72, 107, 119, 241, 227, 77, 109, 120, 58, 248, 36, 82, 38, 188, 50, 177, 65, 227, 192, 169, 124, 7, 137, 254, 80, 151, 200, 73, 55, 99, 30, 150, 192, 13, 106, 41, 236, 18, 6, 73, 73, 16, 239, 162, 0, 218, 201, 184, 78, 184, 137, 253, 12, 130, 241, 245, 158, 233, 159, 0, 130, 99, 50, 12, 240, 186, 207, 221, 250, 179, 115, 138, 137, 154, 182, 72, 119, 204, 16, 18, 101, 107, 27, 98, 142, 16, 143, 116, 161, 238, 232, 227, 70, 247, 124, 150, 157, 67, 114, 24, 162, 246, 158, 205, 24, 77, 79, 107, 232, 141, 103, 99, 128, 101, 40, 241, 212, 127, 90, 40, 2, 229, 105, 51, 164, 70, 216, 95, 2, 240, 54, 224, 11, 241, 201, 181, 97, 113, 49, 10, 170, 203, 10, 7, 130, 42, 236, 195, 146, 175, 222, 91, 235, 145, 13, 33, 82, 81, 187, 250, 248, 59, 250, 222, 136, 69, 192, 178, 189, 103, 176, 235, 101, 89, 133, 145, 203, 35, 138, 157, 180, 144, 6, 172, 55, 58, 147, 217, 109, 95, 81, 141, 214, 209, 245, 146, 96, 23, 130, 101, 107, 180, 188, 69, 204, 224, 195, 29, 108, 199, 70, 239, 18, 199, 143, 68, 161, 121, 110, 132, 238, 186, 97, 217, 227, 106, 86, 162, 24, 170, 155, 34, 8, 92, 154, 199, 184, 210, 214, 20, 31, 200, 22, 169, 186, 176, 26, 52, 62, 5, 251, 241, 108, 67, 153, 104, 242, 20, 28, 143, 23, 92, 191, 96, 254, 141, 235, 113, 154, 10, 219, 117, 159, 56, 31, 140, 161, 225, 247, 236, 253, 126, 160, 115, 23, 15, 175, 190, 227, 94, 149, 166, 102, 173, 251, 60, 192, 100, 70, 126, 89, 88, 154, 70, 176, 82, 212, 137, 12, 243, 203, 215, 247, 252, 91, 27, 19, 104, 229, 123, 83, 164, 166, 1, 90, 189, 251, 6, 81, 168, 28, 250, 206, 104, 62, 122, 66, 100, 183, 204, 196, 12, 57, 237, 25, 151, 165, 202, 65, 176, 124, 4, 94, 99, 250, 31, 43, 245, 160, 19, 247, 137, 120, 147, 24, 227, 192, 34, 21, 113, 168, 214, 235, 104, 140, 252, 170, 127, 90, 181, 149, 35, 160, 69, 110, 233, 71, 194, 66, 156, 225, 152, 129, 163, 168, 162, 154, 99, 172, 144, 85, 253, 238, 250, 48, 69, 99, 139, 49, 133, 200, 148, 34, 238, 235, 163, 13, 229, 232, 206, 118, 9, 132, 186, 253, 112, 251, 185, 191, 253, 155, 31, 161, 100, 249, 50, 145, 99, 243, 16, 21, 182, 137, 81, 104, 165, 96, 66, 112, 137, 68, 233, 58, 217, 65, 209, 62, 125, 164, 71, 64, 3, 44, 47, 172, 14, 211, 105, 241, 194, 50, 196, 89, 82, 26, 174, 194, 101, 119, 171, 140, 162, 141, 123, 206, 115, 85, 248, 33, 85, 228, 42, 92, 97, 100, 0, 16, 52, 27, 111, 146, 22, 223, 104, 54, 254, 70, 119, 180, 9, 126, 226, 173, 218, 140, 232, 213, 96, 232, 138, 148, 131, 144, 15, 69, 136, 43, 252, 203, 249, 20, 198, 32, 153, 17, 9, 28, 69, 183, 178, 240, 203, 31, 197, 112, 215, 34, 199, 95, 180, 116, 231, 191, 216, 12, 90, 216, 161, 227, 246, 5, 183, 26, 243, 239, 47, 193, 208, 140, 195, 151, 178, 100, 250, 38, 182, 15, 156, 211, 44, 207, 216, 110, 150, 234, 92, 160, 204, 228, 246, 38, 224, 16, 83, 166, 33, 22, 163, 174, 99, 80, 3, 23, 142, 55, 3, 253, 128, 63, 222, 111, 158, 184, 10, 60, 153, 124, 202, 53, 189, 14, 118, 45, 87, 79, 252, 20, 226, 58, 249, 197, 29, 162, 78, 211, 147, 165, 240, 7, 60, 175, 73, 90, 61, 167, 239, 68, 104, 66, 207, 208, 194, 87, 148, 158, 184, 247, 129, 7, 150, 171, 62, 157, 62, 240, 137, 36, 88, 122, 225, 83, 173, 245, 238, 245, 249, 227, 252, 152, 40, 8, 3, 150, 155, 71, 121, 187, 46, 173, 248, 107, 78, 135, 232, 20, 174, 165, 135, 5, 106, 244, 62, 79, 249, 72, 99, 252, 177, 27, 158, 223, 235, 59, 34, 141, 45, 221, 238, 31, 102, 247, 65, 170, 15, 219, 210, 232, 80, 100, 68, 171, 37, 211, 156, 83, 147, 246, 219, 89, 41, 195, 110, 252, 146, 164, 200, 63, 22, 154, 235, 157, 224, 24, 13, 102, 218, 53, 116, 235, 195, 57, 44, 157, 20, 89, 193, 102, 118, 163, 6, 24, 185, 177, 103, 106, 237, 7, 242, 206, 186, 232, 186, 164, 89, 138, 96, 207, 218, 228, 8, 77, 218, 15, 219, 168, 183, 178, 106, 155, 150, 37, 27, 139, 195, 72, 245, 64, 122, 219, 34, 125, 244, 159, 107, 23, 200, 151, 221, 249, 115, 21, 122, 60, 189, 31, 36, 127, 78, 52, 175, 187, 142, 179, 50, 53, 30, 246, 156, 89, 21, 120, 137, 129, 51, 10, 219, 176, 167, 197, 56, 128, 1, 21, 249, 225, 157, 135, 91, 248, 216, 237, 108, 143, 105, 159, 168, 97, 56, 54, 26, 181, 62, 66, 194, 192, 246, 142, 174, 157, 28, 52, 18, 33, 44, 54, 106, 28, 19, 94, 56, 49, 80, 181, 104, 237, 198, 100, 25, 119, 50, 224, 202, 71, 203, 246, 127, 108, 93, 3, 58, 61, 195, 222, 215, 50, 146, 156, 110, 216, 51, 40, 228, 9, 192, 77, 26, 58, 144, 247, 220, 122, 136, 51, 97, 227, 255, 158, 63, 76, 105, 203, 118, 96, 163, 154, 19, 163, 65, 249, 170, 225, 220, 193, 235, 177, 57, 168, 2, 14, 44, 34, 130, 107, 145, 189, 125, 158, 223, 106, 229, 0, 175, 136, 163, 176, 151, 192, 102, 36, 251, 135, 128, 146, 36, 182, 219, 135, 150, 115, 34, 164, 3, 69, 39, 128, 31, 3, 250, 103, 109, 228, 88, 77, 91, 51, 229, 228, 39, 140, 87, 33, 182, 110, 20, 127, 154, 139, 110, 252, 14, 92, 5, 39, 245, 215, 141, 132, 66, 99, 195, 210, 248, 104, 29, 72, 126, 58, 54, 254, 137, 250, 235, 51, 200, 139, 32, 61, 174, 43, 194, 99, 179, 203, 207, 53, 245, 133, 177, 124, 73, 203, 155, 38, 11, 171, 223, 12, 171, 48, 169, 129, 190, 14, 43, 247, 147, 163, 204, 5, 102, 247, 251, 92, 79, 18, 195, 208, 25, 55, 228, 229, 55, 83, 17, 96, 4, 60, 85, 10, 218, 76, 101, 24, 172, 80, 228, 108, 45, 55, 129, 87, 97, 22, 86, 102, 70, 31, 187, 191, 1, 178, 184, 253, 120, 104, 197, 84, 242, 112, 17, 245, 82, 85, 96, 40, 21, 9, 4, 45, 209, 147, 162, 110, 90, 34, 41, 194, 135, 169, 75, 169, 114, 206, 220, 166, 81, 141, 187, 64, 120, 169, 165, 23, 66, 222, 214, 18, 184, 136, 116, 199, 67, 91, 151, 67, 123, 201, 40, 171, 30, 81, 53, 172, 11, 252, 52, 200, 191, 236, 81, 63, 28, 28, 79, 197, 11, 72, 49, 4, 124, 134, 233, 232, 35, 46, 146, 22, 245, 251, 182, 162, 76, 231, 32, 196, 244, 181, 102, 124, 215, 106, 183, 214, 60, 118, 51, 84, 203, 105, 179, 56, 73, 212, 219, 228, 251, 38, 126, 206, 115, 119, 115, 151, 21, 49, 80, 168, 206, 170, 174, 215, 59, 70, 84, 59, 126, 167, 254, 115, 232, 114, 60, 182, 40, 129, 177, 240, 200, 38, 37, 198, 209, 23, 76, 170, 118, 83, 1, 131, 247, 56, 26, 57, 127, 156, 31, 144, 27, 184, 203, 148, 35, 11, 202, 85, 112, 185, 103, 107, 238, 6, 233, 105, 127, 30, 36, 5, 87, 171, 241, 3, 56, 204, 132, 15, 217, 229, 139, 21, 217, 129, 72, 249, 87, 89, 79, 96, 37, 236, 89, 92, 155, 19, 126, 84, 218, 53, 184, 26, 224, 179, 7, 109, 243, 241, 91, 4, 121, 186, 223, 116, 222, 74, 23, 153, 101, 79, 27, 149, 143, 26, 68, 95, 238, 21, 43, 211, 107, 255, 231, 205, 156, 7, 52, 151, 74, 253, 249, 109, 51, 153, 31, 163, 151, 172, 121, 248, 150, 198, 13, 118, 76, 248, 18, 210, 184, 219, 23, 234, 59, 115, 254, 81, 254, 67, 110, 53, 177, 188, 60, 180, 25, 87, 10, 150, 44, 208, 115, 144, 16, 3, 244, 119, 137, 173, 22, 158, 135, 89, 82, 86, 224, 43, 127, 108, 234, 223, 64, 224, 50, 214, 124, 246, 207, 122, 29, 99, 234, 199, 48, 125, 106, 221, 148, 40, 5, 16, 140, 234, 185, 222, 239, 214, 67, 77, 22, 165, 135, 224, 121, 236, 251, 70, 6, 123, 22, 230, 117, 208, 172, 131, 59, 53, 108, 100, 173, 136, 63, 22, 130, 83, 137, 15, 28, 82, 36, 34, 221, 235, 226, 114, 79, 126, 119, 218, 50, 130, 122, 143, 128, 240, 138, 49, 95, 254, 117, 105, 94, 76, 117, 93, 6, 189, 236, 192, 252, 227, 60, 208, 190, 216, 173, 157, 42, 240, 134, 97, 184, 215, 46, 30, 152, 214, 186, 205, 122, 64, 241, 9, 165, 113, 56, 244, 89, 27, 38, 41, 168, 30, 3, 50, 249, 121, 35, 55, 79, 10, 253, 33, 221, 231, 112, 53, 230, 15, 241, 247, 11, 202, 123, 27, 169, 254, 215, 208, 212, 184, 229, 58, 145, 142, 227, 155, 8, 98, 108, 50, 239, 238, 82, 161, 80, 228, 170, 128, 65, 71, 94, 4, 135, 27, 30, 28, 176, 66, 87, 245, 58, 0, 242, 162, 155, 1, 230, 130, 191, 161, 30, 167, 132, 37, 170, 137, 45, 70, 182, 29, 64, 230, 204, 218, 12, 26, 236, 146, 21, 130, 38, 184, 0, 185, 21, 57, 51, 227, 123, 26, 216, 87, 227, 198, 78, 106, 171, 224, 255, 223, 12, 92, 86, 191, 171, 109, 68, 29, 196, 31, 189, 44, 47, 198, 240, 63, 119, 237, 15, 4, 66, 204, 61, 54, 105, 188, 52, 38, 85, 29, 10, 181, 57, 21, 63, 27, 248, 254, 144, 201, 69, 96, 72, 176, 206, 105, 209, 182, 227, 107, 31, 34, 36, 199, 71, 50, 233, 205, 40, 110, 204, 197, 190, 202, 175, 155, 208, 26, 241, 28, 118, 239, 86, 87, 198, 167, 203, 148, 79, 69, 114, 108, 111, 178, 8, 29, 141, 229, 254, 121, 55, 99, 138, 88, 211, 25, 213, 124, 32, 248, 28, 178, 12, 184, 96, 118, 178, 219, 74, 186, 235, 22, 144, 68, 124, 152, 163, 132, 152, 125, 193, 123, 203, 54, 115, 216, 254, 245, 228, 88, 47, 119, 152, 56, 194, 120, 93, 63, 251, 138, 157, 142, 83, 235, 111, 98, 208, 67, 226, 204, 115, 172, 14, 15, 217, 122, 68, 94, 214, 215, 29, 196, 49, 82, 155, 80, 204, 30, 180, 143, 142, 231, 118, 154, 68, 4, 61, 180, 33, 86, 157, 251, 119, 49, 46, 239, 175, 251, 115, 135, 182, 34, 219, 38, 134, 237, 12, 183, 159, 71, 196, 175, 119, 134, 146, 175, 239, 200, 85, 24, 217, 227, 238, 110, 252, 34, 213, 35, 175, 138, 193, 218, 182, 239, 83, 198, 26, 3, 30, 86, 54, 168, 174, 79, 129, 135, 146, 192, 218, 114, 151, 242, 108, 220, 232, 99, 46, 215, 49, 77, 5, 233, 222, 144, 69, 82, 85, 250, 180, 112, 61, 41, 7, 70, 35, 129, 219, 1, 102, 71, 40, 17, 52, 46, 102, 92, 75, 71, 121, 235, 18, 248, 78, 23, 237, 185, 36, 1, 253, 155, 195, 206, 244, 208, 255, 183, 10, 124, 207, 30, 200, 87, 15, 2, 31, 82, 248, 77, 199, 99, 110, 49, 133, 23, 175, 42, 20, 172, 13, 61, 178, 71, 197, 1, 87, 56, 214, 83, 138, 223, 121, 216, 209, 94, 188, 153, 136, 22, 101, 223, 251, 36, 70, 159, 160, 137, 55, 158, 136, 136, 94, 201, 249, 232, 129, 31, 163, 204, 148, 185, 219, 185, 188, 250, 87, 91, 233, 206, 199, 222, 41, 173, 48, 157, 166, 37, 53, 134, 142, 204, 169, 185, 136, 17, 238, 221, 67, 31, 233, 131, 78, 85, 250, 158, 115, 59, 6, 197, 0, 29, 209, 138, 21, 65, 208, 208, 100, 2, 249, 160, 42, 114, 168, 84, 100, 83, 98, 42, 113, 93, 199, 99, 3, 23, 187, 223, 35, 173, 167, 172, 12, 250, 132, 84, 191, 41, 161, 177, 90, 245, 36, 174, 96, 92, 4, 65, 80, 221, 118, 130, 137, 210, 181, 216, 234, 6, 114, 245, 247, 11, 183, 159, 78, 227, 93, 225, 188, 56, 210, 246, 105, 24, 127, 13, 3, 223, 213, 164, 180, 246, 129, 106, 153, 92, 20, 112, 229, 65, 37, 202, 16, 204, 79, 45, 14, 159, 111, 103, 125, 63, 209, 11, 212, 23, 29, 14, 106, 187, 95, 125, 231, 159, 247, 143, 149, 128, 20, 201, 139, 220, 243, 141, 124, 26, 171, 218, 135, 196, 74, 252, 154, 52, 245, 147, 236, 196, 248, 112, 70, 142, 237, 97, 191, 75, 100, 47, 234, 68, 85, 201, 28, 130, 3, 198, 86, 253, 79, 150, 148, 144, 204, 233, 54, 3, 5, 106, 19, 90, 161, 130, 16, 147, 168, 51, 234, 73, 72, 190, 54, 204, 146, 106, 213, 51, 33, 182, 127, 68, 91, 247, 225, 121, 4, 90, 117, 154, 82, 244, 70, 88, 15, 122, 187, 153, 136, 172, 52, 21, 174, 107, 175, 69, 121, 80, 180, 17, 154, 197, 30, 205, 200, 150, 198, 136, 64, 199, 22, 175, 74, 4, 195, 49, 111, 218, 52, 213, 176, 230, 58, 138, 61, 209, 13, 2, 114, 124, 80, 26, 50, 139, 86, 36, 192, 192, 36, 71, 80, 0, 59, 30, 135, 185, 103, 130, 115, 138, 250, 126, 155, 175, 240, 84, 122, 137, 200, 171, 68, 72, 164, 79, 79, 28, 90, 84, 110, 130, 122, 133, 165, 245, 35, 124, 195, 10, 99, 78, 140, 219, 139, 219, 107, 1, 172, 39, 0, 28, 150, 91, 243, 188, 215, 147, 12, 70, 161, 15, 172, 102, 17, 146, 175, 95, 79, 20, 209, 180, 207, 154, 153, 229, 190, 251, 73, 215, 11, 113, 37, 230, 193, 192, 218, 119, 83, 16, 237, 167, 193, 157, 157, 102, 102, 203, 198, 68, 237, 252, 121, 120, 132, 126, 65, 199, 197, 59, 186, 66, 182, 38, 126, 221, 17, 96, 102, 99, 218, 185, 124, 152, 18, 240, 92, 241, 171, 178, 231, 64, 223, 228, 161, 110, 182, 217, 95, 166, 165, 113, 6, 203, 8, 254, 9, 241, 90, 157, 60, 194, 125, 210, 73, 213, 243, 16, 159, 123, 119, 162, 42, 178, 159, 91, 130, 235, 17, 142, 202, 65, 31, 213, 60, 108, 95, 53, 161, 25, 85, 114, 18, 117, 199, 73, 71, 168, 243, 188, 126, 180, 37, 10, 239, 179, 38, 227, 177, 184, 213, 193, 130, 45, 115, 2, 196, 136, 54, 99, 161, 163, 212, 189, 9, 142, 113, 251, 137, 138, 187, 11, 117, 189, 246, 30, 193, 150, 187, 60, 70, 108, 189, 10, 152, 108, 36, 102, 189, 204, 224, 8, 100, 72, 219, 66, 97, 53, 90, 23, 109, 82, 49, 94, 227, 67, 207, 146, 127, 199, 212, 174, 5, 115, 160, 81, 23, 44, 130, 49, 248, 2, 67, 94, 32, 231, 7, 238, 13, 65, 115, 85, 211, 138, 184, 26, 88, 21, 69, 115, 129, 30, 63, 79, 116, 118, 207, 139, 204, 42, 88, 114, 154, 26, 166, 116, 28, 189, 75, 201, 163, 102, 236, 156, 198, 58, 122, 99, 97, 179, 132, 66, 245, 26, 90, 49, 91, 69, 117, 71, 163, 122, 152, 220, 240, 131, 139, 80, 95, 199, 50, 34, 131, 99, 154, 8, 240, 77, 238, 85, 0, 60, 144, 102, 5, 83, 16, 174, 3, 125, 158, 231, 212, 80, 67, 109, 64, 129, 65, 152, 126, 217, 180, 3, 123, 31, 139, 40, 177, 229, 154, 149, 0, 9, 108, 240, 174, 68, 247, 2, 95, 106, 173, 104, 173, 73, 133, 174, 64, 164, 216, 90, 210, 114, 220, 105, 214, 232, 155, 157, 25, 103, 74, 72, 105, 6, 96, 3, 14, 168, 64, 0, 14, 74, 135, 241, 67, 80, 41, 107, 78, 44, 201, 206, 166, 31, 187, 72, 108, 29, 225, 109, 224, 21, 189, 198, 90, 74, 132, 170, 45, 181, 124, 167, 55, 178, 176, 245, 3, 121, 248, 88, 55, 57, 84, 168, 38, 97, 212, 185, 211, 75, 237, 191, 148, 160, 19, 135, 106, 139, 109, 230, 29, 169, 143, 40, 88, 55, 125, 152, 99, 211, 249, 146, 19, 108, 39, 87, 216, 202, 57, 193, 173, 54, 237, 94, 199, 249, 113, 60, 220, 114, 138, 147, 252, 244, 211, 29, 16, 5, 38, 145, 100, 157, 148, 247, 85, 131, 132, 234, 56, 134, 249, 247, 149, 240, 128, 102, 26, 196, 211, 204, 188, 41, 146, 59, 238, 60, 118, 144, 97, 167, 147, 181, 37, 102, 245, 87, 136, 136, 183, 194, 224, 215, 16, 26, 176, 144, 248, 243, 216, 151, 198, 208, 45, 25, 158, 102, 99, 84, 117, 57, 69, 24, 248, 8, 171, 198, 227, 0, 97, 117, 125, 39, 56, 98, 7, 78, 237, 199, 252, 17, 128, 35, 21, 191, 162, 252, 97, 165, 185, 20, 182, 71, 25, 192, 235, 193, 9, 108, 32, 162, 82, 45, 226, 247, 149, 106, 183, 197, 123, 208, 64, 32, 231, 114, 123, 249, 204, 31, 126, 229, 191, 93, 154, 255, 251, 163, 84, 109, 176, 62, 9, 91, 54, 135, 174, 214, 219, 244, 55, 159, 138, 47, 141, 95, 225, 222, 146, 81, 136, 14, 49, 71, 142, 141, 198, 178, 143, 42, 126, 67, 81, 73, 244, 110, 174, 53, 160, 244, 221, 117, 44, 13, 86, 181, 20, 163, 145, 49, 126, 196, 202, 24, 55, 167, 72, 21, 88, 64, 190, 217, 248, 29, 46, 25, 147, 233, 239, 109, 41, 178, 123, 54, 78, 205, 11, 77, 66, 172, 204, 254, 48, 206, 14, 170, 65, 25, 4, 88, 231, 174, 21, 231, 98, 191, 171, 70, 249, 226, 12, 15, 173, 103, 0, 52, 83, 81, 236, 239, 45, 4, 3, 243, 172, 42, 73, 19, 244, 141, 114, 119, 169, 73, 185, 221, 81, 46, 251, 25, 248, 147, 227, 140, 25, 133, 123, 209, 122, 68, 120, 188, 68, 131, 220, 204, 48, 59, 131, 50, 0, 63, 164, 97, 145, 194, 192, 196, 187, 250, 118, 225, 50, 121, 49, 17, 98, 221, 231, 79, 222, 91, 99, 124, 27, 226, 73, 141, 116, 188, 90, 55, 204, 111, 53, 54, 36, 225, 24, 179, 36, 97, 25, 224, 43, 204, 164, 245, 213, 62, 220, 246, 111, 166, 164, 10, 239, 90, 231, 156, 71, 192, 68, 16, 48, 152, 110, 158, 120, 170, 117, 188, 129, 88, 26, 66, 1, 172, 32, 102, 243, 220, 12, 165, 248, 190, 83, 143, 22, 45, 166, 182, 87, 198, 76, 59, 235, 90, 82, 147, 207, 219, 77, 15, 175, 33, 94, 132, 155, 247, 0, 233, 108, 219, 2, 115, 43, 239, 200, 102, 48, 22, 29, 127, 98, 33, 131, 111, 232, 27, 45, 119, 14, 138, 8, 165, 210, 165, 59, 92, 49, 87, 238, 157, 19, 109, 116, 34, 152, 203, 239, 125, 242, 148, 246, 83, 229, 231, 67, 221, 170, 75, 187, 111, 96, 105, 206, 20, 123, 222, 223, 9, 33, 251, 167, 255, 69, 65, 196, 201, 26, 44, 149, 169, 81, 133, 65, 107, 143, 168, 33, 169, 39, 12, 34, 37, 116, 244, 21, 198, 162, 120, 221, 110, 71, 169, 248, 173, 37, 178, 128, 28, 26, 113, 92, 144, 75, 42, 223, 212, 129, 210, 141, 135, 166, 193, 192, 97, 52, 222, 254, 23, 148, 9, 112, 114, 64, 84, 12, 0, 125, 189, 173, 232, 223, 134, 210, 13, 236, 70, 153, 231, 212, 20, 224, 146, 173, 139, 57, 190, 134, 118, 153, 147, 141, 236, 92, 50, 237, 88, 178, 184, 155, 140, 69, 133, 101, 211, 123, 101, 137, 130, 38, 50, 225, 155, 224, 53, 213, 65, 112, 198, 206, 81, 96, 203, 29, 141, 206, 29, 232, 124, 216, 35, 8, 62, 149, 236, 178, 118, 57, 28, 94, 86, 43, 220, 48, 108, 137, 108, 195, 130, 28, 212, 104, 37, 93, 83, 174, 52, 92, 137, 136, 245, 238, 54, 132, 123, 121, 136, 105, 15, 23, 185, 141, 208, 44, 117, 156, 169, 74, 234, 83, 135, 181, 51, 173, 98, 228, 101, 216, 166, 90, 42, 211, 115, 53, 198, 255, 53, 31, 204, 244, 146, 83, 100, 59, 103, 100, 81, 139, 131, 47, 109, 149, 157, 235, 100, 64, 188, 73, 77, 255, 230, 192, 121, 88, 233, 145, 46, 214, 145, 195, 177, 107, 1, 169, 44, 54, 69, 197, 68, 16, 16, 211, 16, 41, 134, 144, 71, 40, 46, 249, 160, 144, 31, 188, 218, 244, 180, 195, 35, 145, 40, 126, 240, 86, 250, 200, 74, 203, 70, 69, 84, 247, 148, 178, 102, 232, 217, 29, 244, 63, 41, 26, 206, 12, 208, 188, 160, 66, 96, 29, 86, 185, 152, 172, 183, 67, 182, 163, 158, 61, 102, 22, 162, 176, 127, 184, 115, 86, 214, 84, 179, 215, 43, 8, 32, 27, 18, 198, 40, 69, 143, 122, 55, 55, 223, 36, 87, 74, 116, 38, 173, 95, 4, 148, 104, 217, 54, 158, 80, 118, 68, 201, 80, 167, 172, 236, 11, 8, 3, 182, 231, 105, 248, 122, 83, 91, 190, 108, 124, 232, 144, 34, 30, 140, 1, 223, 30, 13, 33, 206, 8, 1, 116, 227, 249, 185, 192, 4, 233, 99, 7, 81, 144, 170, 102, 29, 7, 5, 87, 164, 208, 142, 13, 147, 99, 116, 47, 176, 157, 71, 76, 229, 175, 151, 190, 117, 238, 161, 140, 126, 154, 114, 180, 109, 197, 60, 160, 11, 117, 113, 139, 72, 90, 145, 223, 126, 26, 201, 46, 122, 157, 144, 164, 170, 154, 74, 54, 76, 213, 67, 33, 232, 148, 219, 175, 216, 59, 68, 148, 51, 30, 162, 24, 112, 162, 40, 8, 181, 90, 210, 95, 250, 35, 209, 11, 162, 205, 2, 241, 95, 18, 61, 11, 6, 90, 79, 128, 18, 110, 247, 101, 192, 234, 27, 38, 155, 204, 170, 160, 194, 35, 212, 120, 110, 174, 173, 19, 10, 66, 171, 122, 206, 171, 1, 209, 22, 166, 136, 66, 166, 203, 93, 90, 27, 82, 13, 158, 240, 229, 146, 152, 71, 67, 152, 107, 142, 44, 196, 232, 54, 36, 188, 124, 55, 50, 233, 162, 60, 143, 197, 182, 77, 110, 109, 87, 254, 90, 79, 17, 102, 226, 93, 222, 158, 110, 239, 210, 198, 179, 5, 50, 42, 156, 176, 5, 177, 27, 249, 68, 0, 187, 12, 115, 74, 112, 137, 39, 176, 122, 69, 69, 138, 17, 215, 146, 56, 43, 68, 4, 249, 214, 116, 40, 27, 97, 79, 13, 190, 147, 73, 27, 111, 70, 178, 119, 109, 108, 188, 243, 136, 192, 39, 30, 74, 240, 247, 103, 121, 55, 51, 207, 225, 5, 98, 186, 68, 147, 229, 160, 13, 92, 57, 193, 90, 130, 235, 169, 255, 92, 162, 111, 143, 244, 67, 83, 68, 23, 140, 96, 32, 91, 24, 238, 76, 85, 235, 104, 111, 221, 13, 159, 85, 162, 98, 242, 60, 137, 64, 25, 248, 161, 233, 176, 134, 117, 35, 128, 69, 199, 149, 178, 73, 219, 5, 27, 165, 40, 31, 28, 17, 2, 217, 119, 10, 80, 102, 140, 22, 214, 243, 96, 35, 87, 61, 225, 211, 101, 235, 249, 232, 211, 175, 52, 136, 197, 21, 125, 175, 194, 6, 252, 236, 9, 18, 139, 76, 85, 88, 173, 19, 238, 191, 220, 28, 29, 225, 9, 88, 23, 211, 214, 102, 232, 121, 143, 243, 133, 66, 152, 113, 159, 120, 114, 177, 77, 51, 44, 176, 78, 165, 41, 182, 156, 139, 101, 89, 0, 43, 60, 178, 117, 161, 19, 17, 29, 9, 71, 38, 75, 70, 176, 161, 253, 47, 35, 75, 129, 198, 163, 219, 120, 3, 49, 32, 70, 134, 81, 62, 62, 236, 194, 82, 106, 132, 113, 138, 5, 40, 178, 48, 80, 151, 204, 209, 117, 201, 208, 89, 209, 130, 50, 66, 137, 242, 219, 157, 9, 186, 112, 202, 119, 138, 43, 241, 249, 46, 200, 126, 31, 27, 3, 119, 210, 152, 232, 126, 119, 116, 239, 79, 245, 79, 189, 48, 234, 24, 193, 98, 172, 103, 103, 7, 188, 95, 183, 218, 250, 187, 230, 48, 173, 251, 206, 246, 244, 233, 56, 163, 21, 23, 155, 101, 135, 29, 94, 4, 27, 194, 130, 146, 177, 228, 245, 191, 85, 9, 243, 101, 174, 242, 230, 183, 221, 66, 169, 52, 217, 74, 73, 47, 16, 174, 199, 174, 236, 138, 59, 88, 131, 209, 190, 146, 212, 5, 126, 237, 23, 43, 112, 107, 85, 53, 245, 47, 214, 10, 165, 155, 170, 227, 242, 91, 253, 25, 151, 177, 80, 22, 69, 42, 197, 119, 193, 18, 70, 115, 36, 18, 118, 57, 93, 194, 23, 84, 154, 40, 66, 194, 238, 31, 241, 251, 215, 147, 250, 144, 65, 168, 67, 128, 213, 2, 210, 39, 193, 34, 4, 29, 111, 112, 25, 249, 169, 1, 157, 135, 246, 133, 148, 202, 202, 72, 208, 231, 115, 19, 123, 246, 9, 168, 182, 85, 181, 26, 184, 157, 236, 238, 146, 87, 141, 13, 30, 82, 23, 22, 76, 35, 123, 61, 53, 148, 248, 52, 49, 84, 72, 238, 109, 106, 69, 159, 230, 51, 229, 164, 61, 192, 192, 52, 172, 173, 121, 35, 209, 109, 154, 199, 51, 45, 255, 29, 66, 154, 251, 78, 14, 205, 6, 166, 20, 118, 225, 82, 242, 122, 89, 184, 105, 91, 232, 232, 36, 254, 8, 147, 188, 247, 201, 227, 123, 132, 66, 178, 130, 166, 246, 162, 213, 195, 204, 53, 230, 201, 219, 161, 254, 65, 134, 224, 52, 61, 92, 115, 135, 127, 130, 225, 130, 188, 60, 35, 146, 126, 246, 50, 216, 171, 206, 209, 193, 222, 29, 57, 236, 252, 61, 184, 236, 74, 180, 23, 197, 160, 46, 25, 22, 144, 114, 224, 53, 164, 147, 179, 190, 98, 200, 197, 50, 153, 163, 153, 240, 205, 73, 94, 129, 40, 225, 2, 132, 61, 241, 227, 99, 9, 206, 10, 244, 61, 16, 2, 204, 37, 103, 242, 104, 28, 132, 115, 153, 186, 27, 102, 215, 98, 254, 149, 188, 50, 52, 184, 139, 133, 54, 210, 81, 77, 215, 134, 70, 70, 56, 83, 64, 237, 5, 175, 232, 241, 64, 34, 237, 149, 117, 112, 136, 26, 240, 126, 71, 131, 27, 248, 73, 249, 150, 227, 212, 13, 141, 158, 95, 83, 46, 225, 74, 116, 112, 90, 252, 58, 102, 95, 58, 186, 138, 60, 204, 74, 0, 235, 103, 141, 117, 40, 48, 175, 208, 192, 30, 88, 253, 35, 1, 212, 172, 63, 176, 12, 149, 222, 34, 41, 71, 192, 86, 224, 88, 217, 16, 133, 235, 4, 70, 205, 25, 154, 138, 33, 243, 32, 176, 250, 65, 82, 107, 42, 184, 230, 159, 165, 30, 54, 62, 111, 235, 222, 214, 173, 232, 15, 22, 52, 10, 66, 205, 42, 11, 144, 212, 214, 45, 177, 229, 128, 5, 189, 248, 35, 169, 215, 78, 15, 149, 188, 162, 209, 253, 193, 239, 244, 183, 37, 233, 157, 190, 203, 172, 86, 163, 49, 91, 41, 166, 98, 137, 88, 31, 76, 157, 204, 185, 162, 36, 169, 111, 212, 107, 59, 47, 16, 193, 109, 235, 128, 230, 166, 239, 157, 14, 23, 13, 176, 237, 152, 255, 147, 93, 114, 117, 39, 23, 178, 75, 67, 183, 124, 38, 140, 121, 186, 74, 115, 178, 9, 197, 118, 1, 23, 222, 221, 151, 92, 64, 145, 130, 131, 245, 205, 21, 189, 155, 201, 244, 155, 239, 101, 67, 186, 249, 9, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 192, 52, 174, 242, 81, 205, 211, 61, 25, 139, 159, 177, 105, 41, 30, 42, 213, 46, 197, 53, 167, 58, 7, 239, 29, 185, 82, 211, 68, 212, 184, 107, 226, 41, 43, 224, 22, 195, 136, 195, 83, 229, 114, 175, 66, 156, 29, 234, 244, 207, 2, 130, 205, 111, 77, 101, 218, 137, 131, 12, 134, 83, 223, 104, 127, 53, 221, 160, 131, 7, 177, 14, 230, 144, 57, 252, 186, 129, 17, 232, 197, 196, 98, 209, 1, 45, 125, 38, 79, 78, 79, 205, 86, 137, 34, 148, 236, 104, 255, 148, 126, 139, 170, 152, 81, 124, 241, 99, 85, 64, 219, 190, 41, 26, 241, 189, 46, 120, 146, 174, 125, 38, 89, 232, 191, 159, 41, 60, 59, 124, 3, 83, 90, 193, 179, 178, 218, 237, 71, 118, 84, 146, 132, 171, 138, 85, 203, 68, 215, 196, 179, 144, 14, 177, 7, 131, 178, 35, 178, 60, 195, 206, 133, 204, 114, 45, 244, 85, 215, 54, 6, 195, 13, 21, 169, 53, 170, 193, 40, 111, 41, 129, 135, 1, 7, 231, 11, 30, 182, 1, 49, 39, 153, 125, 42, 194, 181, 161, 31, 225, 12, 7, 203, 136, 56, 221, 249, 243, 10, 70, 40, 7, 185, 44, 130, 246, 110, 117, 80, 156, 16, 107, 9, 208, 52, 225, 196, 107, 78, 99, 182, 163, 75, 85, 211, 230, 155, 237, 90, 188, 158, 228, 168, 219, 214, 1, 214, 10, 208, 65, 24, 6, 106, 197, 31, 24, 182, 90, 212, 193, 164, 165, 72, 252, 129, 220, 23, 60, 110, 87, 37, 248, 212, 75, 104, 132, 28, 240, 211, 62, 28, 98, 56, 14, 84, 116, 201, 72, 203, 112, 226, 194, 235, 85, 186, 124, 193, 204, 158, 88, 88, 154, 237, 87, 112, 209, 204, 251, 167, 218, 9, 3, 92, 176, 47, 83, 94, 17, 116, 73, 210, 76, 89, 65, 53, 117, 81, 135, 24, 123, 72, 228, 209, 12, 130, 113, 64, 15, 0, 129, 145, 180, 246, 137, 98, 85, 142, 28, 11, 98, 31, 212, 141, 27, 126, 36, 194, 225, 96, 107, 28, 56, 46, 129, 86, 211, 202, 198, 8, 130, 145, 168, 251, 168, 47, 190, 124, 154, 7, 24, 236, 155, 6, 216, 2, 52, 183, 14, 81, 237, 145, 106, 163, 57, 70, 110, 201, 195, 76, 225, 169, 141, 27, 123, 4, 168, 127, 46, 127, 235, 142, 233, 238, 31, 216, 199, 11, 226, 248, 73, 60, 46, 31, 130, 42, 199, 120, 19, 114, 194, 175, 145, 98, 24, 241, 112, 251, 162, 211, 147, 73, 105, 44, 119, 124, 155, 203, 208, 30, 84, 236, 50, 175, 194, 84, 2, 84, 57, 101, 137, 115, 18, 205, 178, 85, 140, 239, 187, 40, 123, 255, 215, 212, 221, 248, 8, 108, 82, 221, 132, 14, 109, 202, 131, 101, 219, 111, 5, 104, 94, 147, 8, 157, 43, 127, 65, 229, 59, 138, 201, 160, 29, 119, 166, 145, 221, 160, 237, 117, 188, 140, 19, 233, 86, 27, 112, 176, 201, 67, 209, 58, 131, 86, 64, 101, 220, 165, 73, 191, 134, 42, 233, 90, 100, 18, 227, 209, 125, 238, 13, 77, 212, 120, 177, 12, 53, 15, 253, 142, 192, 182, 156, 74, 171, 128, 12, 35, 10, 156, 182, 209, 168, 84, 192, 114, 145, 152, 124, 207, 225, 128, 108, 54, 189, 60, 250, 115, 88, 184, 129, 7, 54, 68, 99, 212, 251, 57, 193, 136, 36, 125, 173, 9, 110, 84, 241, 59, 165, 113, 22, 152, 51, 85, 215, 160, 211, 164, 74, 19, 92, 36, 28, 182, 244, 9, 168, 250, 79, 123, 164, 160, 207, 240, 29, 29, 91, 38, 31, 188, 16, 228, 118, 149, 198, 198, 123, 14, 133, 20, 110, 176, 129, 138, 94, 248, 218, 77, 108, 191, 3, 141, 69, 248, 163, 99, 44, 87, 208, 18, 202, 33, 184, 40, 2, 222, 223, 120, 144, 93, 173, 140, 217, 214, 57, 15, 78, 141, 161, 248, 165, 4, 189, 14, 213, 23, 46, 113, 141, 18, 31, 137, 224, 228, 19, 62, 168, 70, 248, 204, 171, 125, 122, 155, 19, 50, 210, 89, 69, 6, 23, 241, 173, 182, 133, 86, 219, 241, 9, 215, 247, 155, 68, 18, 22, 107, 167, 120, 118, 169, 9, 221, 231, 153, 100, 199, 129, 43, 239, 122, 102, 79, 161, 133, 75, 74, 184, 210, 30, 175, 5, 20, 8, 48, 208, 5, 219, 33, 224, 96, 252, 1, 42, 19, 38, 147, 44, 197, 172, 222, 84, 156, 79, 217, 103, 46, 60, 174, 144, 121, 208, 111, 207, 54, 16, 163, 104, 156, 10, 207, 160, 151, 193, 121, 38, 251, 43, 200, 28, 137, 109, 22, 140, 17, 13, 95, 69, 119, 61, 222, 131, 92, 105, 130, 56, 96, 236, 209, 218, 51, 172, 213, 244, 44, 64, 60, 88, 192, 199, 41, 83, 141, 237, 224, 62, 187, 134, 251, 89, 48, 18, 12, 121, 63, 28, 218, 86, 160, 86, 109, 99, 206, 2, 236, 50, 26, 239, 237, 63, 12, 102, 84, 252, 215, 145, 131, 231, 49, 212, 54, 43, 99, 224, 120, 178, 36, 106, 99, 92, 77, 4, 176, 3, 99, 0, 188, 98, 168, 58, 123, 240, 159, 102, 55, 108, 176, 198, 49, 8, 141, 220, 122, 216, 43, 55, 35, 106, 133, 53, 123, 69, 84, 167, 23, 9, 209, 194, 29, 186, 63, 184, 71, 241, 49, 33, 47, 88, 39, 65, 91, 85, 92, 198, 126, 212, 129, 102, 167, 100, 174, 89, 228, 134, 42, 212, 208, 194, 252, 67, 150, 198, 132, 209, 16, 209, 249, 44, 238, 138, 179, 128, 92, 6, 197, 10, 134, 97, 232, 147, 219, 143, 72, 209, 83, 35, 210, 182, 162, 183, 213, 125, 47, 156, 218, 18, 194, 137, 234, 117, 231, 112, 250, 48, 146, 123, 141, 174, 61, 213, 177, 251, 162, 214, 211, 122, 171, 155, 211, 117, 228, 198, 235, 155, 225, 14, 85, 57, 54, 8, 168, 75, 216, 68, 135, 19, 133, 24, 26, 138, 111, 72, 0, 250, 101, 237, 246, 137, 8, 38, 83, 123, 237, 250, 104, 106, 31, 217, 235, 103, 177, 73, 174, 208, 233, 230, 69, 77, 161, 21, 10, 223, 157, 62, 232, 133, 80, 117, 214, 254, 247, 93, 53, 45, 130, 226, 118, 216, 149, 78, 143, 25, 30, 110, 134, 48, 72, 1, 107, 197, 211, 48, 235, 82, 179, 54, 95, 171, 91, 36, 188, 53, 85, 24, 216, 236, 79, 62, 90, 52, 157, 175, 171, 127, 132, 118, 187, 200, 5, 60, 22, 6, 117, 78, 242, 169, 102, 46, 74, 185, 188, 138, 221, 79, 49, 13, 247, 196, 176, 199, 53, 220, 208, 175, 132, 8, 186, 175, 76, 125, 227, 33, 44, 193, 209, 17, 52, 110, 227, 212, 139, 93, 154, 218, 220, 57, 5, 255, 119, 252, 7, 69, 145, 109, 118, 76, 45, 48, 20, 218, 123, 26, 193, 203, 254, 58, 206, 189, 91, 87, 28, 112, 27, 204, 145, 8, 8, 203, 83, 199, 179, 70, 32, 208, 8, 44, 44, 217, 69, 93, 32, 74, 13, 105, 100, 232, 134, 89, 67, 98, 52, 242, 113, 109, 36, 244, 169, 115, 146, 186, 48, 75, 128, 102, 149, 174, 100, 5, 87, 23, 88, 161, 184, 135, 198, 80, 194, 179, 150, 4, 182, 153, 124, 63, 34, 251, 63, 73, 37, 18, 188, 143, 151, 211, 2, 11, 182, 108, 6, 109, 9, 192, 85, 67, 251, 113, 129, 185, 10, 81, 246, 134, 57, 249, 181, 39, 2, 172, 177, 69, 221, 100, 77, 234, 159, 108, 192, 187, 22, 239, 204, 26, 94, 199, 59, 193, 124, 97, 107, 238, 43, 72, 36, 172, 173, 100, 3, 161, 92, 128, 18, 51, 253, 186, 99, 120, 241, 227, 110, 163, 21, 128, 76, 0, 148, 199, 82, 165, 71, 150, 145, 226, 233, 70, 52, 185, 206, 113, 110, 186, 143, 46, 101, 113, 96, 134, 203, 115, 46, 55, 192, 157, 132, 213, 103, 74, 56, 60, 226, 172, 157, 32, 97, 223, 104, 48, 125, 83, 201, 108, 78, 237, 12, 215, 156, 61, 116, 134, 118, 63, 200, 81, 7, 47, 77, 30, 241, 4, 137, 72, 8, 91, 145, 131, 254, 195, 186, 45, 197, 110, 40, 219, 97, 152, 169, 225, 55, 192, 230, 111, 60, 241, 161, 50, 177, 243, 51, 234, 106, 27, 142, 1, 189, 193, 154, 186, 97, 14, 148, 58, 207, 191, 184, 68, 201, 243, 178, 192, 239, 119, 184, 134, 119, 241, 66, 223, 13, 66, 95, 251, 229, 94, 98, 209, 155, 193, 245, 65, 137, 119, 28, 21, 248, 157, 7, 38, 235, 152, 149, 26, 232, 137, 163, 244, 168, 119, 255, 98, 154, 244, 184, 192, 128, 41, 22, 106, 88, 67, 221, 88, 250, 13, 146, 186, 159, 222, 62, 120, 192, 209, 111, 237, 74, 128, 194, 125, 45, 48, 161, 135, 15, 178, 28, 138, 107, 200, 198, 196, 70, 193, 133, 132, 133, 166, 177, 202, 99, 13, 217, 192, 252, 46, 121, 76, 53, 138, 194, 89, 188, 116, 79, 121, 226, 110, 5, 152, 64, 100, 50, 210, 195, 168, 80, 1, 241, 155, 92, 104, 113, 111, 242, 97, 185, 175, 105, 220, 50, 208, 175, 77, 147, 100, 181, 2, 190, 96, 109, 124, 113, 30, 81, 143, 151, 17, 71, 202, 252, 10, 155, 190, 218, 183, 185, 200, 67, 199, 111, 150, 251, 13, 147, 58, 133, 186, 141, 249, 64, 223, 148, 110, 28, 236, 49, 22, 57, 17, 73, 146, 239, 146, 30, 234, 88, 167, 108, 235, 12, 88, 131, 33, 37, 202, 137, 81, 186, 89, 6, 6, 72, 210, 191, 90, 124, 235, 98, 144, 97, 245, 49, 67, 169, 106, 190, 157, 56, 227, 0, 196, 55, 177, 246, 5, 171, 178, 130, 214, 132, 191, 0, 218, 236, 129, 191, 155, 129, 241, 33, 208, 156, 254, 132, 121, 163, 189, 231, 51, 180, 21, 190, 87, 29, 5, 102, 185, 218, 136, 248, 113, 65, 209, 238, 177, 109, 248, 167, 189, 241, 181, 115, 24, 89, 95, 67, 115, 211, 244, 218, 63, 79, 148, 168, 238, 47, 110, 82, 130, 96, 55, 120, 139, 149, 120, 204, 85, 249, 232, 88, 139, 152, 111, 170, 143, 209, 129, 105, 87, 50, 12, 192, 50, 227, 191, 29, 194, 102, 243, 193, 142, 62, 49, 248, 188, 92, 11, 60, 228, 133, 100, 209, 8, 246, 85, 143, 169, 197, 81, 169, 72, 51, 102, 19, 210, 249, 185, 78, 200, 179, 42, 40, 111, 94, 84, 221, 156, 90, 2, 216, 95, 53, 92, 217, 172, 192, 97, 130, 77, 87, 163, 65, 112, 45, 250, 81, 131, 95, 4, 68, 136, 139, 240, 43, 141, 251, 195, 36, 31, 179, 197, 10, 76, 230, 247, 154, 134, 215, 76, 134, 240, 248, 151, 186, 16, 253, 99, 129, 147, 47, 55, 53, 116, 139, 65, 64, 44, 29, 168, 200, 169, 8, 118, 38, 100, 162, 124, 48, 46, 137, 246, 255, 39, 156, 70, 228, 139, 6, 35, 67, 229, 235, 18, 114, 66, 206, 217, 236, 11, 86, 119, 106, 120, 177, 150, 118, 52, 6, 204, 14, 4, 196, 40, 149, 120, 162, 11, 143, 168, 138, 248, 243, 62, 123, 15, 78, 255, 23, 100, 206, 115, 143, 144, 114, 210, 165, 115, 161, 73, 211, 146, 104, 185, 127, 166, 117, 50, 63, 25, 242, 101, 119, 219, 108, 208, 71, 204, 116, 138, 226, 175, 178, 243, 52, 238, 124, 85, 161, 173, 70, 233, 141, 108, 161, 84, 14, 226, 235, 12, 28, 16, 249, 79, 198, 120, 192, 204, 17, 138, 231, 159, 81, 25, 130, 216, 29, 246, 62, 212, 113, 237, 67, 131, 145, 221, 189, 143, 137, 244, 17, 214, 165, 13, 205, 92, 172, 241, 8, 205, 146, 131, 246, 97, 210, 91, 107, 167, 251, 32, 155, 208, 141, 74, 184, 228, 40, 237, 171, 12, 29, 152, 31, 144, 168, 66, 216, 171, 187, 23, 118, 55, 159, 194, 137, 51, 119, 14, 95, 153, 62, 186, 38, 69, 119, 144, 155, 50, 15, 54, 37, 88, 32, 225, 3, 105, 136, 254, 28, 104, 210, 231, 16, 238, 109, 37, 117, 150, 0, 253, 121, 33, 14, 83, 178, 187, 112, 57, 96, 197, 72, 0, 164, 107, 236, 45, 138, 56, 214, 34, 5, 141, 86, 227, 107, 107, 110, 121, 191, 132, 151, 203, 91, 158, 82, 180, 65, 249, 109, 94, 169, 45, 25, 99, 86, 87, 79, 140, 44, 141, 40, 166, 128, 206, 146, 244, 31, 200, 192, 125, 35, 161, 202, 241, 225, 82, 44, 114, 189, 42, 135, 50, 99, 166, 200, 107, 92, 178, 232, 4, 88, 33, 27, 122, 192, 174, 138, 147, 154, 54, 111, 75, 46, 159, 73, 34, 154, 255, 102, 16, 123, 161, 222, 172, 154, 208, 206, 23, 69, 76, 84, 152, 153, 178, 151, 12, 41, 104, 98, 214, 142, 202, 114, 183, 30, 242, 8, 237, 182, 133, 229, 57, 209, 32, 164, 139, 247, 137, 6, 42, 127, 100, 170, 141, 113, 52, 13, 52, 137, 66, 237, 43, 61, 149, 191, 124, 73, 232, 14, 109, 168, 151, 164, 237, 141, 6, 228, 197, 168, 143, 4, 171, 113, 28, 46, 228, 101, 111, 198, 205, 32, 110, 35, 49, 127, 95, 207, 11, 155, 221, 27, 85, 188, 14, 127, 211, 19, 208, 139, 67, 182, 153, 229, 29, 214, 156, 191, 29, 10, 66, 187, 194, 168, 194, 246, 234, 118, 170, 194, 82, 179, 242, 24, 58, 142, 24, 232, 103, 109, 114, 210, 10, 237, 8, 201, 66, 125, 245, 52, 129, 60, 10, 211, 199, 73, 152, 116, 175, 216, 111, 213, 141, 162, 172, 78, 204, 92, 182, 12, 158, 165, 129, 98, 54, 130, 236, 12, 47, 203, 63, 133, 20, 225, 128, 178, 150, 84, 94, 228, 236, 54, 44, 68, 65, 204, 84, 216, 7, 253, 22, 254, 225, 203, 108, 200, 59, 166, 91, 70, 119, 185, 166, 175, 76, 129, 175, 203, 58, 205, 39, 126, 15, 239, 104, 20, 95, 127, 161, 196, 28, 88, 51, 11, 232, 44, 119, 45, 25, 32, 240, 237, 147, 222, 74, 129, 161, 39, 7, 235, 65, 113, 108, 75, 194, 117, 54, 46, 48, 252, 23, 145, 253, 146, 26, 193, 71, 31, 93, 190, 129, 74, 30, 64, 22, 204, 73, 25, 56, 130, 29, 202, 84, 67, 84, 150, 164, 154, 229, 67, 49, 125, 31, 114, 44, 74, 83, 199, 26, 129, 218, 21, 91, 180, 169, 142, 104, 114, 150, 34, 97, 39, 153, 115, 240, 90, 71, 179, 198, 137, 15, 66, 82, 243, 142, 188, 61, 73, 39, 162, 29, 127, 183, 2, 204, 3, 194, 51, 47, 29, 7, 155, 6, 98, 225, 25, 98, 224, 30, 47, 152, 184, 23, 80, 115, 202, 48, 161, 23, 137, 32, 230, 210, 45, 42, 173, 117, 116, 181, 11, 250, 108, 100, 129, 45, 98, 77, 208, 215, 113, 103, 107, 140, 17, 213, 253, 202, 22, 158, 153, 224, 216, 53, 131, 125, 60, 138, 229, 199, 236, 168, 121, 174, 126, 204, 113, 113, 66, 147, 2, 58, 143, 50, 120, 123, 27, 55, 132, 118, 255, 152, 128, 137, 97, 145, 144, 164, 102, 71, 95, 59, 57, 109, 99, 172, 77, 159, 69, 81, 107, 38, 58, 81, 173, 30, 17, 123, 58, 208, 159, 212, 204, 195, 146, 48, 129, 223, 62, 74, 34, 161, 188, 185, 150, 124, 2, 175, 205, 241, 202, 161, 7, 50, 19, 78, 41, 248, 70, 9, 211, 53, 242, 147, 222, 158, 230, 133, 149, 90, 83, 177, 133, 78, 189, 246, 129, 242, 39, 93, 171, 33, 26, 131, 211, 140, 34, 230, 172, 138, 61, 193, 246, 253, 205, 210, 92, 248, 181, 219, 3, 47, 200, 24, 91, 124, 122, 15, 213, 192, 115, 177, 196, 142, 141, 121, 98, 28, 202, 32, 156, 46, 6, 34, 21, 164, 212, 186, 205, 85, 161, 61, 176, 237, 250, 33, 184, 250, 248, 154, 133, 16, 186, 207, 2, 199, 145, 74, 196, 234, 201, 66, 76, 221, 85, 66, 241, 112, 97, 15, 52, 249, 211, 90, 132, 14, 74, 167, 81, 28, 184, 221, 51, 158, 96, 161, 144, 80, 7, 154, 174, 61, 234, 66, 93, 40, 229, 187, 186, 239, 121, 90, 137, 103, 229, 48, 116, 19, 212, 231, 195, 114, 57, 28, 234, 149, 211, 73, 204, 202, 52, 71, 112, 132, 143, 103, 10, 83, 205, 185, 251, 62, 174, 243, 32, 121, 28, 252, 92, 167, 231, 119, 110, 129, 14, 233, 37, 69, 120, 15, 90, 41, 124, 169, 196, 161, 137, 0, 217, 44, 15, 93, 212, 239, 58, 181, 20, 176, 159, 162, 74, 229, 41, 99, 14, 145, 65, 31, 224, 179, 30, 132, 226, 71, 18, 132, 48, 78, 33, 247, 86, 205, 28, 197, 175, 204, 126, 44, 140, 66, 13, 112, 183, 84, 3, 143, 214, 80, 133, 126, 145, 143, 34, 77, 23, 146, 177, 165, 151, 70, 240, 223, 116, 115, 25, 212, 248, 27, 113, 47, 200, 90, 132, 56, 26, 94, 0, 76, 138, 174, 112, 47, 54, 107, 193, 149, 73, 53, 142, 218, 91, 57, 238, 46, 178, 154, 71, 19, 189, 166, 196, 94, 170, 218, 133, 118, 205, 225, 108, 153, 24, 237, 27, 111, 37, 90, 14, 100, 15, 229, 18, 128, 213, 4, 155, 143, 166, 39, 142, 206, 78, 189, 91, 166, 159, 129, 30, 7, 139, 72, 227, 164, 164, 161, 100, 94, 162, 55, 49, 248, 189, 179, 206, 146, 255, 91, 179, 82, 6, 138, 24, 141, 171, 146, 217, 50, 135, 32, 203, 177, 27, 91, 24, 204, 252, 137, 121, 90, 226, 43, 35, 226, 246, 38, 72, 212, 172, 188, 173, 69, 107, 148, 163, 88, 125, 144, 127, 44, 41, 190, 71, 0, 88, 70, 175, 189, 233, 55, 206, 220, 185, 192, 197, 165, 193, 87, 146, 249, 94, 72, 59, 57, 43, 52, 203, 194, 56, 221, 21, 130, 183, 78, 75, 154, 67, 18, 74, 151, 201, 38, 202, 108, 61, 8, 29, 98, 62, 172, 77, 155, 227, 189, 10, 116, 179, 50, 165, 152, 74, 209, 96, 200, 230, 180, 188, 191, 165, 245, 108, 36, 26, 37, 17, 167, 125, 120, 111, 236, 211, 66, 183, 1, 251, 79, 34, 26, 121, 28, 136, 33, 149, 17, 174, 43, 206, 137, 77, 10, 173, 243, 111, 73, 106, 241, 252, 70, 43, 147, 120, 40, 229, 121, 201, 69, 195, 63, 43, 87, 45, 203, 174, 214, 181, 35, 46, 226, 47, 44, 56, 123, 56, 73, 166, 252, 144, 150, 100, 73, 156, 177, 225, 105, 161, 41, 226, 162, 167, 132, 45, 62, 211, 104, 16, 89, 173, 255, 70, 194, 254, 186, 130, 50, 135, 121, 197, 147, 84, 97, 49, 107, 26, 164, 189, 151, 234, 39, 72, 117, 21, 92, 43, 119, 110, 45, 209, 172, 192, 131, 45, 2, 99, 179, 131, 248, 69, 144, 223, 23, 151, 0, 196, 64, 161, 172, 49, 56, 114, 108, 68, 134, 160, 209, 154, 30, 240, 206, 156, 140, 80, 70, 34, 218, 43, 187, 80, 209, 26, 166, 69, 4, 240, 135, 148, 68, 64, 170, 244, 134, 32, 69, 87, 50, 135, 112, 91, 71, 0, 134, 245, 80, 30, 27, 12, 234, 212, 223, 168, 27, 78, 19, 126, 77, 138, 121, 75, 51, 47, 44, 5, 253, 227, 88, 41, 226, 189, 183, 124, 184, 68, 210, 6, 171, 77, 78, 221, 154, 78, 229, 88, 147, 147, 21, 119, 13, 251, 71, 89, 237, 224, 152, 21, 88, 234, 234, 130, 74, 119, 115, 27, 8, 139, 155, 243, 195, 29, 196, 213, 5, 161, 117, 41, 246, 92, 204, 143, 186, 229, 59, 18, 76, 171, 224, 152, 224, 82, 193, 115, 208, 9, 84, 177, 130, 178, 122, 251, 216, 39, 253, 73, 199, 154, 88, 236, 215, 219, 154, 195, 11, 235, 165, 217, 212, 248, 65, 43, 0, 112, 35, 39, 18, 238, 212, 151, 187, 53, 30, 235, 202, 217, 163, 177, 80, 70, 97, 90, 98, 174, 5, 163, 246, 219, 124, 216, 253, 43, 114, 108, 69, 2, 242, 77, 85, 51, 91, 7, 226, 100, 238, 213, 183, 55, 47, 222, 65, 222, 75, 49, 102, 29, 20, 10, 103, 232, 107, 0, 27, 247, 112, 177, 121, 185, 250, 215, 18, 78, 186, 87, 112, 147, 225, 75, 236, 241, 197, 161, 123, 146, 132, 217, 240, 98, 201, 17, 53, 82, 60, 237, 232, 92, 177, 174, 1, 51, 12, 54, 226, 215, 58, 61, 186, 15, 135, 103, 195, 176, 10, 74, 110, 97, 106, 100, 112, 153, 16, 115, 248, 136, 36, 43, 245, 26, 211, 246, 143, 10, 112, 14, 176, 86, 8, 62, 93, 100, 135, 160, 125, 244, 49, 17, 192, 63, 42, 110, 36, 61, 93, 14, 16, 41, 98, 232, 84, 222, 245, 155, 24, 210, 135, 16, 84, 204, 214, 83, 67, 255, 217, 117, 85, 99, 107, 3, 247, 112, 24, 143, 221, 99, 49, 222, 12, 113, 185, 146, 231, 24, 10, 163, 80, 92, 208, 40, 35, 42, 4, 179, 164, 133, 228, 238, 37, 194, 173, 2, 132, 221, 127, 26, 108, 192, 48, 29, 100, 252, 150, 41, 204, 9, 103, 1, 14, 158, 249, 155, 88, 236, 122, 184, 21, 190, 12, 42, 239, 63, 211, 105, 218, 77, 199, 63, 86, 126, 40, 209, 229, 23, 173, 73, 180, 54, 17, 136, 94, 9, 80, 145, 207, 18, 196, 81, 163, 232, 195, 15, 97, 189, 3, 77, 171, 13, 209, 115, 43, 111, 139, 101, 26, 181, 212, 49, 27, 98, 60, 243, 94, 127, 50, 134, 131, 80, 13, 83, 89, 166, 11, 230, 42, 243, 219, 131, 143, 64, 179, 1, 44, 206, 1, 25, 71, 47, 102, 1, 174, 91, 96, 145, 66, 205, 155, 46, 175, 197, 35, 134, 19, 142, 96, 224, 80, 249, 187, 203, 133, 189, 178, 243, 148, 190, 210, 96, 235, 209, 39, 47, 228, 34, 95, 211, 22, 212, 179, 144, 17, 7, 167, 105, 181, 197, 163, 21, 92, 227, 106, 99, 97, 69, 82, 75, 81, 252, 134, 112, 88, 12, 199, 223, 255, 127, 120, 203, 252, 45, 155, 20, 111, 208, 148, 38, 62, 26, 44, 198, 171, 101, 105, 55, 59, 34, 149, 250, 144, 241, 173, 52, 152, 11, 206, 218, 250, 31, 106, 194, 66, 21, 172, 43, 23, 96, 152, 74, 41, 111, 46, 57, 67, 46, 115, 157, 120, 32, 244, 181, 120, 138, 172, 192, 72, 145, 198, 4, 153, 118, 250, 158, 115, 197, 143, 215, 34, 193, 194, 184, 38, 232, 194, 11, 238, 179, 12, 171, 247, 147, 122, 216, 224, 15, 240, 70, 64, 139, 209, 176, 39, 37, 185, 63, 97, 103, 177, 114, 120, 230, 242, 13, 34, 185, 145, 67, 129, 107, 21, 250, 38, 222, 4, 102, 72, 61, 149, 25, 82, 132, 101, 245, 189, 223, 10, 48, 15, 181, 35, 98, 9, 193, 88, 8, 9, 178, 105, 94, 34, 146, 236, 134, 168, 46, 201, 101, 93, 30, 11, 6, 30, 76, 87, 11, 46, 168, 244, 47, 150, 194, 127, 252, 157, 124, 161, 197, 169, 21, 17, 224, 26, 55, 22, 112, 96, 0, 46, 220, 143, 129, 166, 108, 155, 239, 158, 186, 125, 240, 44, 54, 141, 156, 129, 184, 216, 180, 189, 158, 14, 197, 64, 97, 152, 154, 39, 159, 106, 74, 166, 252, 70, 203, 206, 30, 218, 69, 26, 139, 113, 26, 68, 177, 99, 237, 180, 12, 66, 108, 95, 8, 136, 80, 81, 206, 131, 94, 203, 20, 229, 54, 14, 70, 50, 176, 87, 128, 171, 187, 37, 118, 77, 147, 114, 186, 163, 3, 198, 64, 85, 226, 183, 5, 182, 14, 213, 237, 27, 89, 154, 51, 218, 52, 253, 88, 56, 106, 3, 52, 10, 165, 125, 60, 174, 246, 189, 50, 27, 253, 116, 62, 247, 131, 198, 18, 119, 202, 10, 60, 233, 29, 6, 46, 39, 204, 152, 116, 182, 243, 99, 52, 230, 84, 207, 220, 58, 27, 222, 198, 85, 142, 186, 46, 182, 163, 65, 94, 109, 13, 50, 127, 209, 124, 50, 2, 55, 128, 139, 183, 23, 15, 168, 159, 36, 109, 138, 41, 12, 175, 132, 224, 65, 70, 52, 80, 2, 179, 46, 220, 218, 110, 187, 70, 230, 200, 212, 235, 95, 35, 160, 155, 161, 34, 168, 200, 173, 13, 3, 229, 241, 25, 186, 115, 182, 157, 24, 88, 100, 80, 207, 59, 128, 100, 106, 141, 146, 170, 121, 110, 112, 25, 5, 26, 101, 107, 30, 17, 72, 177, 162, 164, 54, 100, 210, 196, 191, 71, 5, 236, 4, 55, 242, 132, 64, 101, 37, 124, 222, 15, 39, 229, 111, 76, 210, 171, 236, 7, 93, 14, 216, 248, 45, 79, 218, 85, 211, 199, 250, 104, 33, 143, 222, 15, 88, 238, 164, 172, 135, 2, 101, 11, 255, 112, 8, 238, 139, 63, 190, 149, 130, 215, 130, 110, 68, 83, 56, 239, 253, 120, 96, 196, 38, 198, 153, 137, 110, 157, 87, 94, 69, 70, 176, 197, 220, 237, 73, 176, 217, 112, 186, 20, 16, 151, 251, 244, 204, 120, 42, 216, 194, 250, 127, 191, 45, 87, 138, 204, 145, 110, 119, 217, 185, 242, 50, 47, 102, 253, 107, 242, 121, 122, 204, 10, 232, 48, 214, 183, 190, 152, 249, 7, 228, 139, 181, 252, 84, 123, 199, 146, 175, 30, 152, 54, 4, 162, 26, 19, 103, 112, 216, 130, 148, 218, 40, 215, 53, 114, 87, 174, 194, 30, 148, 70, 183, 213, 103, 2, 24, 161, 173, 212, 50, 52, 10, 46, 252, 205, 46, 192, 187, 105, 16, 187, 193, 255, 182, 92, 222, 209, 193, 118, 129, 137, 218, 80, 242, 213, 89, 122, 224, 65, 158, 65, 104, 40, 15, 135, 86, 159, 63, 139, 29, 195, 230, 20, 180, 82, 142, 98, 48, 228, 204, 22, 199, 47, 96, 30, 125, 192, 222, 237, 243, 115, 222, 31, 182, 150, 172, 42, 17, 232, 108, 142, 241, 119, 143, 215, 117, 221, 37, 188, 136, 68, 166, 53, 120, 198, 16, 59, 74, 184, 175, 120, 42, 72, 102, 137, 171, 56, 141, 189, 173, 89, 128, 12, 114, 241, 189, 111, 136, 73, 132, 123, 93, 249, 199, 130, 191, 251, 1, 251, 208, 58, 108, 177, 41, 72, 20, 202, 120, 187, 38, 8, 163, 75, 63, 139, 91, 159, 26, 233, 162, 204, 152, 80, 228, 52, 96, 166, 8, 250, 206, 115, 97, 28, 220, 48, 59, 19, 66, 12, 137, 203, 7, 95, 23, 107, 3, 185, 110, 57, 39, 117, 13, 68, 70, 54, 238, 106, 230, 167, 242, 216, 208, 42, 154, 110, 41, 188, 51, 156, 153, 0, 199, 221, 58, 21, 57, 68, 24, 114, 67, 93, 90, 0, 252, 188, 145, 7, 24, 55, 189, 176, 50, 106, 154, 57, 17, 95, 223, 93, 17, 125, 163, 80, 18, 22, 229, 212, 90, 138, 222, 86, 8, 125, 63, 229, 145, 190, 200, 10, 39, 176, 9, 182, 211, 236, 122, 29, 134, 1, 186, 231, 227, 215, 194, 42, 240, 7, 196, 0, 179, 211, 150, 193, 21, 137, 84, 32, 92, 218, 185, 7, 200, 34, 179, 138, 244, 114, 167, 159, 23, 51, 124, 60, 253, 124, 75, 8, 65, 123, 59, 88, 219, 250, 242, 250, 112, 27, 222, 143, 17, 107, 48, 44, 172, 13, 223, 78, 218, 107, 93, 235, 5, 208, 23, 179, 176, 38, 213, 101, 154, 64, 132, 134, 83, 63, 77, 229, 126, 65, 142, 245, 167, 180, 96, 51, 24, 148, 105, 243, 63, 186, 163, 124, 34, 50, 179, 29, 215, 142, 5, 239, 54, 7, 196, 36, 81, 188, 247, 192, 3, 244, 124, 253, 168, 19, 233, 109, 231, 192, 175, 145, 117, 76, 63, 70, 62, 40, 182, 78, 254, 130, 186, 51, 198, 159, 107, 19, 156, 134, 103, 50, 90, 103, 74, 56, 89, 219, 199, 9, 95, 82, 84, 194, 128, 42, 20, 199, 148, 228, 7, 118, 119, 197, 45, 128, 9, 170, 208, 53, 183, 193, 219, 5, 217, 212, 134, 223, 36, 133, 92, 186, 235, 96, 221, 117, 0, 193, 177, 162, 117, 175, 70, 109, 31, 153, 192, 154, 149, 154, 14, 97, 150, 111, 227, 28, 62, 28, 87, 9, 143, 179, 167, 61, 34, 56, 49, 214, 103, 226, 6, 252, 32, 41, 67, 251, 82, 211, 79, 59, 118, 84, 13, 186, 17, 210, 208, 173, 195, 188, 134, 107, 74, 31, 134, 203, 90, 191, 112, 36, 15, 24, 25, 235, 139, 143, 62, 206, 200, 184, 140, 76, 38, 33, 145, 111, 208, 150, 137, 130, 192, 60, 198, 200, 136, 65, 8, 120, 228, 137, 230, 157, 86, 120, 28, 249, 236, 246, 108, 236, 190, 181, 14, 130, 11, 117, 191, 234, 124, 3, 114, 238, 202, 204, 12, 64, 157, 68, 242, 69, 222, 71, 38, 20, 167, 248, 156, 18, 118, 68, 41, 139, 228, 235, 148, 91, 226, 42, 148, 22, 166, 232, 244, 29, 159, 154, 36, 142, 96, 176, 49, 183, 130, 138, 26, 37, 220, 156, 202, 183, 34, 131, 245, 174, 136, 48, 154, 230, 37, 118, 121, 68, 231, 79, 63, 221, 46, 137, 160, 179, 87, 17, 218, 214, 63, 102, 102, 99, 169, 198, 113, 33, 76, 13, 61, 36, 89, 148, 49, 134, 239, 253, 12, 242, 28, 5, 21, 143, 242, 106, 146, 125, 164, 137, 207, 95, 235, 57, 211, 192, 118, 224, 242, 249, 16, 83, 56, 41, 181, 124, 108, 16, 28, 185, 71, 171, 15, 164, 118, 198, 66, 198, 194, 107, 83, 84, 163, 186, 219, 43, 221, 9, 3, 20, 103, 40, 59, 249, 24, 216, 106, 16, 99, 168, 109, 128, 169, 57, 46, 158, 81, 167, 201, 255, 62, 103, 14, 62, 238, 99, 254, 210, 106, 23, 120, 215, 2, 3, 73, 251, 237, 135, 128, 128, 206, 101, 77, 245, 27, 70, 53, 196, 81, 223, 13, 0, 204, 10, 222, 12, 164, 202, 100, 79, 25, 249, 121, 215, 148, 225, 91, 127, 75, 75, 163, 110, 205, 5, 204, 177, 254, 134, 245, 217, 178, 64, 239, 106, 55, 124, 16, 80, 124, 16, 81, 169, 61, 200, 221, 24, 221, 18, 233, 230, 164, 121, 212, 126, 79, 2, 216, 164, 249, 41, 255, 39, 98, 231, 12, 123, 13, 116, 220, 172, 166, 89, 112, 113, 250, 61, 176, 153, 84, 225, 187, 162, 79, 65, 106, 221, 173, 209, 157, 70, 33, 75, 158, 110, 152, 39, 200, 89, 91, 89, 253, 126, 84, 27, 158, 181, 101, 249, 32, 129, 198, 38, 144, 92, 64, 112, 208, 113, 60, 212, 72, 138, 49, 82, 95, 183, 174, 225, 77, 53, 121, 211, 223, 131, 161, 148, 220, 88, 131, 151, 69, 208, 240, 49, 163, 151, 121, 50, 79, 129, 137, 98, 57, 18, 33, 202, 150, 120, 255, 99, 34, 54, 85, 204, 172, 120, 77, 42, 123, 242, 129, 92, 196, 78, 101, 98, 25, 146, 73, 186, 132, 227, 246, 96, 236, 208, 63, 50, 90, 183, 134, 219, 143, 100, 54, 175, 20, 172, 107, 171, 169, 199, 50, 110, 252, 135, 93, 169, 144, 100, 236, 91, 122, 111, 40, 196, 143, 73, 177, 56, 50, 27, 21, 249, 185, 212, 182, 40, 134, 197, 187, 55, 165, 125, 48, 132, 76, 242, 184, 173, 177, 111, 150, 67, 58, 189, 122, 152, 228, 51, 241, 130, 42, 113, 112, 62, 70, 131, 4, 23, 177, 114, 212, 125, 157, 28, 8, 238, 223, 158, 211, 172, 145, 188, 65, 125, 62, 45, 220, 124, 226, 100, 34, 36, 153, 93, 76, 157, 89, 219, 60, 42, 88, 68, 158, 155, 181, 124, 242, 72, 167, 74, 56, 176, 56, 114, 203, 54, 170, 85, 155, 235, 79, 29, 201, 71, 124, 181, 127, 180, 139, 147, 47, 167, 26, 18, 67, 141, 150, 37, 197, 6, 170, 96, 68, 89, 209, 246, 182, 183, 53, 68, 239, 126, 147, 50, 210, 34, 248, 246, 109, 34, 41, 213, 229, 134, 154, 97, 241, 132, 17, 162, 180, 74, 151, 253, 150, 69, 251, 151, 63, 192, 219, 79, 253, 212, 137, 234, 196, 133, 215, 211, 147, 128, 54, 85, 93, 202, 30, 168, 167, 128, 125, 150, 188, 250, 23, 195, 249, 52, 179, 26, 207, 129, 227, 68, 78, 56, 2, 17, 86, 220, 89, 99, 19, 20, 173, 57, 203, 140, 66, 231, 27, 69, 214, 238, 201, 134, 89, 102, 254, 85, 249, 132, 115, 51, 39, 65, 184, 199, 187, 14, 44, 6, 217, 16, 227, 116, 185, 66, 201, 188, 95, 66, 178, 243, 103, 79, 144, 147, 139, 59, 123, 238, 28, 18, 202, 166, 75, 59, 246, 190, 150, 75, 73, 182, 251, 132, 15, 248, 96, 112, 253, 41, 3, 203, 44, 141, 147, 255, 69, 85, 78, 129, 60, 145, 81, 166, 224, 131, 132, 215, 210, 169, 5, 136, 178, 23, 30, 139, 153, 106, 40, 54, 139, 244, 214, 43, 132, 229, 221, 58, 81, 81, 57, 190, 168, 255, 114, 63, 122, 173, 6, 136, 110, 159, 188, 50, 188, 91, 56, 185, 99, 107, 139, 120, 176, 228, 142, 146, 209, 96, 27, 133, 77, 69, 254, 114, 99, 194, 195, 4, 80, 36, 220, 147, 252, 207, 142, 66, 65, 64, 226, 63, 85, 218, 66, 125, 108, 197, 49, 143, 59, 43, 182, 0, 253, 169, 234, 209, 57, 90, 190, 234, 14, 25, 237, 62, 155, 188, 246, 92, 78, 241, 21, 154, 242, 201, 59, 16, 147, 73, 252, 52, 13, 175, 51, 158, 248, 118, 159, 4, 186, 101, 250, 170, 10, 16, 135, 251, 224, 114, 97, 61, 25, 102, 23, 74, 58, 118, 158, 32, 74, 115, 104, 240, 131, 42, 187, 155, 134, 209, 171, 225, 85, 13, 71, 252, 156, 81, 126, 72, 110, 45, 207, 84, 113, 187, 61, 152, 107, 111, 80, 105, 35, 104, 81, 245, 68, 28, 51, 67, 212, 172, 99, 191, 248, 217, 91, 186, 232, 145, 201, 135, 56, 164, 52, 127, 137, 111, 186, 6, 164, 236, 112, 31, 232, 75, 224, 58, 209, 31, 205, 204, 46, 180, 127, 215, 44, 45, 13, 147, 165, 245, 241, 162, 178, 249, 226, 241, 113, 104, 80, 175, 59, 1, 43, 12, 25, 255, 146, 70, 208, 140, 140, 225, 122, 125, 181, 239, 73, 89, 5, 107, 9, 241, 8, 16, 223, 203, 176, 57, 33, 4, 115, 216, 80, 155, 249, 103, 241, 188, 44, 216, 37, 115, 171, 104, 154, 145, 134, 183, 58, 141, 141, 178, 123, 166, 222, 67, 68, 154, 167, 52, 235, 31, 112, 206, 223, 53, 6, 183, 5, 146, 93, 226, 30, 73, 237, 197, 140, 19, 34, 104, 116, 213, 152, 6, 75, 215, 218, 214, 66, 101, 19, 72, 244, 9, 81, 57, 43, 202, 165, 46, 36, 100, 31, 15, 218, 44, 181, 120, 172, 25, 99, 242, 188, 3, 83, 202, 190, 27, 251, 130, 200, 101, 175, 176, 105, 39, 227, 210, 240, 121, 137, 42, 27, 128, 5, 30, 234, 109, 232, 77, 59, 100, 180, 107, 5, 215, 28, 55, 228, 186, 224, 16, 156, 182, 238, 181, 59, 124, 105, 117, 32, 66, 83, 110, 109, 112, 68, 95, 77, 121, 139, 94, 176, 190, 6, 58, 109, 213, 214, 24, 253, 72, 61, 86, 209, 20, 88, 36, 146, 179, 79, 168, 66, 209, 168, 48, 253, 177, 239, 139, 166, 213, 72, 242, 160, 36, 254, 135, 57, 207, 55, 198, 205, 150, 198, 54, 140, 247, 242, 52, 106, 132, 71, 67, 233, 29, 181, 247, 189, 36, 48, 232, 111, 130, 149, 234, 243, 241, 165, 66, 221, 64, 173, 207, 0, 69, 201, 111, 209, 157, 16, 56, 217, 29, 157, 106, 232, 206, 148, 110, 71, 113, 29, 228, 195, 57, 249, 181, 71, 203, 211, 131, 64, 92, 141, 89, 58, 210, 70, 246, 227, 146, 137, 63, 41, 250, 187, 56, 160, 17, 174, 45, 28, 245, 204, 63, 18, 174, 162, 53, 208, 121, 187, 1, 121, 46, 50, 245, 207, 140, 5, 186, 237, 72, 158, 163, 44, 143, 197, 127, 34, 160, 41, 242, 108, 220, 123, 138, 205, 164, 23, 164, 18, 117, 123, 153, 22, 150, 73, 141, 43, 176, 88, 251, 198, 143, 93, 33, 20, 40, 143, 84, 197, 67, 255, 148, 57, 146, 198, 114, 33, 71, 30, 82, 192, 170, 52, 234, 239, 80, 64, 40, 102, 84, 166, 173, 142, 183, 193, 94, 230, 23, 141, 252, 243, 157, 35, 237, 118, 118, 42, 74, 1, 54, 87, 226, 144, 53, 58, 204, 32, 19, 74, 57, 167, 120, 21, 185, 51, 252, 176, 109, 2, 92, 125, 240, 132, 20, 197, 113, 129, 104, 179, 18, 64, 47, 115, 96, 209, 210, 76, 191, 39, 127, 230, 135, 242, 56, 42, 214, 109, 188, 170, 192, 204, 9, 204, 190, 58, 162, 143, 115, 247, 60, 155, 37, 146, 119, 159, 64, 247, 242, 239, 189, 181, 85, 25, 145, 123, 81, 123, 205, 83, 33, 144, 45, 196, 64, 114, 13, 18, 247, 116, 14, 202, 246, 213, 177, 225, 152, 217, 119, 24, 39, 253, 158, 222, 242, 242, 175, 77, 241, 126, 29, 93, 45, 170, 185, 71, 131, 214, 114, 43, 181, 150, 252, 39, 6, 87, 37, 134, 229, 17, 8, 15, 186, 181, 205, 161, 20, 235, 0, 12, 137, 197, 184, 41, 11, 222, 237, 139, 70, 19, 213, 30, 122, 10, 226, 173, 98, 29, 245, 52, 215, 124, 12, 134, 182, 57, 22, 177, 59, 226, 249, 248, 41, 180, 183, 47, 165, 116, 170, 152, 20, 74, 194, 122, 200, 136, 75, 176, 189, 240, 211, 88, 98, 205, 34, 105, 216, 138, 137, 72, 56, 215, 175, 140, 70, 137, 91, 54, 133, 221, 38, 226, 239, 139, 212, 80, 177, 248, 110, 195, 61, 196, 255, 7, 156, 229, 136, 198, 72, 3, 234, 106, 16, 83, 14, 210, 94, 51, 205, 43, 23, 224, 60, 41, 139, 192, 59, 25, 111, 190, 82, 39, 54, 189, 75, 126, 229, 83, 220, 32, 148, 43, 104, 248, 214, 206, 224, 215, 16, 60, 193, 15, 56, 193, 32, 170, 160, 23, 190, 102, 110, 19, 17, 72, 35, 17, 208, 211, 97, 113, 200, 24, 54, 117, 191, 45, 89, 163, 74, 198, 191, 150, 95, 253, 192, 22, 129, 130, 32, 152, 172, 103, 119, 229, 128, 56, 107, 92, 200, 44, 214, 191, 125, 210, 215, 82, 117, 251, 113, 109, 109, 226, 6, 169, 109, 74, 23, 249, 245, 34, 66, 19, 101, 185, 162, 211, 82, 34, 142, 17, 229, 51, 118, 89, 199, 214, 28, 129, 55, 42, 45, 223, 195, 53, 145, 14, 230, 108, 57, 10, 38, 30, 54, 47, 103, 228, 177, 43, 124, 215, 126, 179, 126, 224, 136, 52, 213, 200, 239, 248, 56, 200, 140, 211, 100, 66, 168, 7, 73, 198, 24, 116, 195, 168, 244, 221, 29, 96, 70, 60, 223, 74, 211, 190, 250, 31, 253, 102, 252, 5, 79, 214, 195, 57, 178, 97, 227, 185, 105, 107, 5, 36, 58, 5, 55, 206, 148, 62, 127, 7, 185, 106, 245, 3, 39, 244, 34, 213, 127, 5, 102, 234, 34, 21, 55, 212, 6, 181, 98, 25, 92, 178, 172, 22, 221, 208, 146, 54, 119, 64, 138, 248, 54, 134, 7, 72, 247, 6, 228, 125, 93, 153, 23, 141, 207, 95, 56, 117, 215, 95, 159, 159, 214, 117, 97, 43, 109, 88, 50, 163, 148, 70, 44, 108, 208, 165, 89, 202, 104, 76, 241, 196, 12, 40, 102, 154, 234, 158, 197, 135, 31, 129, 203, 135, 181, 145, 20, 117, 153, 231, 212, 228, 118, 193, 211, 167, 59, 198, 170, 28, 74, 11, 164, 211, 1, 189, 68, 202, 163, 110, 158, 216, 123, 31, 16, 30, 31, 111, 81, 108, 235, 56, 98, 114, 76, 29, 142, 234, 159, 214, 18, 38, 226, 183, 37, 36, 15, 56, 53, 141, 161, 85, 198, 76, 246, 223, 82, 137, 2, 27, 186, 111, 208, 68, 146, 181, 205, 85, 101, 70, 19, 33, 38, 254, 177, 231, 88, 176, 43, 130, 244, 94, 228, 81, 193, 13, 224, 8, 45, 35, 185, 9, 103, 112, 133, 124, 107, 172, 66, 48, 64, 33, 84, 14, 127, 69, 54, 46, 68, 14, 225, 255, 48, 107, 32, 75, 160, 60, 67, 158, 149, 12, 243, 130, 168, 250, 146, 60, 29, 121, 117, 186, 93, 171, 26, 187, 23, 130, 200, 105, 169, 14, 241, 206, 210, 146, 59, 79, 197, 56, 14, 119, 202, 166, 82, 77, 90, 96, 193, 7, 176, 83, 166, 12, 5, 99, 4, 173, 44, 162, 241, 216, 251, 218, 158, 2, 222, 159, 93, 5, 189, 82, 143, 147, 50, 220, 207, 150, 229, 93, 47, 39, 242, 159, 236, 141, 31, 209, 237, 21, 156, 8, 199, 201, 62, 55, 18, 132, 140, 65, 177, 159, 152, 137, 179, 4, 196, 88, 135, 212, 251, 156, 138, 108, 108, 84, 178, 243, 153, 151, 175, 177, 23, 163, 44, 180, 29, 98, 159, 125, 91, 169, 25, 131, 30, 65, 139, 56, 16, 177, 161, 230, 244, 121, 38, 207, 45, 64, 0, 235, 250, 149, 220, 128, 161, 118, 12, 148, 229, 107, 33, 108, 158, 197, 103, 236, 220, 167, 93, 108, 227, 34, 17, 54, 31, 131, 135, 182, 166, 130, 136, 244, 128, 130, 64, 45, 59, 203, 121, 207, 228, 46, 75, 96, 55, 66, 87, 173, 145, 207, 106, 111, 97, 224, 103, 86, 128, 36, 37, 105, 165, 77, 69, 13, 29, 220, 163, 123, 49, 209, 38, 212, 238, 25, 4, 232, 186, 232, 133, 3, 163, 79, 139, 249, 111, 69, 0, 187, 128, 212, 60, 242, 147, 148, 223, 17, 73, 194, 244, 125, 146, 191, 38, 15, 247, 52, 4, 91, 229, 37, 22, 64, 135, 77, 181, 241, 149, 80, 196, 124, 21, 200, 117, 76, 105, 121, 30, 188, 3, 65, 161, 205, 178, 242, 67, 111, 175, 58, 9, 95, 46, 201, 105, 23, 224, 249, 98, 100, 205, 255, 23, 50, 131, 30, 216, 87, 102, 59, 91, 156, 114, 45, 237, 187, 117, 192, 231, 51, 65, 183, 127, 231, 90, 69, 131, 6, 141, 83, 217, 17, 41, 150, 182, 89, 2, 191, 56, 69, 42, 120, 196, 10, 177, 255, 154, 238, 104, 210, 58, 33, 13, 163, 136, 178, 244, 61, 163, 206, 79, 81, 212, 50, 23, 56, 28, 182, 165, 29, 84, 29, 173, 150, 194, 201, 221, 239, 145, 151, 60, 119, 233, 183, 171, 240, 201, 10, 91, 26, 12, 55, 126, 52, 113, 9, 105, 150, 111, 58, 76, 222, 35, 54, 5, 36, 51, 229, 13, 222, 167, 248, 130, 166, 6, 108, 78, 44, 228, 219, 155, 216, 122, 66, 163, 52, 100, 111, 104, 166, 127, 253, 123, 15, 179, 63, 102, 161, 23, 86, 81, 41, 241, 164, 196, 71, 122, 216, 18, 22, 196, 39, 126, 223, 86, 220, 81, 90, 103, 74, 116, 226, 16, 125, 173, 210, 46, 194, 102, 224, 246, 149, 225, 35, 1, 248, 108, 64, 20, 74, 48, 89, 109, 173, 212, 114, 175, 87, 97, 217, 241, 107, 253, 67, 82, 32, 14, 1, 219, 60, 10, 73, 19, 183, 87, 110, 95, 252, 101, 56, 34, 67, 24, 180, 179, 55, 32, 247, 187, 98, 99, 235, 73, 77, 243, 29, 29, 93, 242, 60, 26, 51, 27, 102, 109, 98, 251, 98, 76, 235, 39, 89, 1, 108, 46, 238, 115, 33, 59, 45, 46, 4, 56, 141, 65, 192, 26, 110, 192, 216, 245, 71, 57, 65, 144, 246, 236, 191, 64, 159, 245, 245, 14, 36, 66, 6, 98, 18, 148, 99, 141, 82, 64, 51, 168, 215, 201, 82, 150, 68, 84, 237, 2, 185, 49, 39, 122, 245, 239, 219, 60, 142, 16, 78, 165, 59, 145, 226, 38, 19, 228, 26, 159, 176, 90, 32, 1, 163, 43, 127, 125, 232, 29, 223, 231, 232, 176, 78, 57, 34, 219, 177, 64, 17, 186, 201, 72, 51, 195, 59, 140, 226, 123, 219, 243, 10, 190, 99, 40, 236, 187, 46, 119, 180, 164, 197, 70, 134, 167, 185, 241, 187, 218, 249, 220, 62, 226, 47, 97, 251, 132, 155, 218, 32, 253, 182, 144, 98, 22, 209, 215, 16, 95, 246, 4, 58, 32, 214, 187, 1, 103, 224, 60, 163, 97, 233, 219, 15, 97, 6, 176, 177, 176, 174, 149, 111, 229, 17, 47, 10, 167, 193, 114, 2, 14, 131, 72, 117, 147, 68, 11, 217, 168, 7, 84, 89, 255, 130, 70, 149, 123, 55, 161, 5, 27, 3, 133, 147, 51, 133, 120, 139, 225, 134, 107, 121, 199, 129, 150, 117, 73, 6, 190, 67, 1, 127, 99, 203, 123, 26, 10, 131, 160, 255, 55, 205, 8, 109, 202, 165, 46, 13, 144, 141, 238, 4, 15, 30, 91, 78, 167, 56, 207, 181, 100, 89, 226, 166, 91, 6, 87, 42, 161, 18, 173, 46, 134, 84, 47, 192, 51, 192, 86, 143, 106, 143, 68, 251, 155, 48, 132, 148, 113, 151, 135, 133, 68, 135, 223, 141, 62, 40, 237, 173, 32, 255, 82, 138, 211, 98, 135, 17, 208, 76, 110, 10, 169, 109, 29, 94, 79, 56, 157, 83, 52, 181, 250, 138, 162, 188, 220, 51, 204, 209, 222, 189, 226, 142, 162, 134, 34, 176, 136, 149, 252, 25, 172, 22, 56, 41, 175, 96, 189, 47, 60, 197, 122, 228, 229, 174, 7, 187, 59, 62, 90, 104, 81, 171, 136, 40, 100, 33, 61, 107, 104, 93, 125, 99, 111, 143, 164, 107, 234, 102, 20, 82, 79, 151, 211, 159, 79, 36, 159, 15, 137, 116, 236, 128, 31, 195, 155, 61, 48, 44, 168, 114, 179, 176, 19, 154, 247, 138, 187, 48, 108, 202, 239, 31, 5, 253, 101, 72, 112, 65, 48, 8, 136, 4, 140, 125, 19, 45, 76, 151, 233, 69, 65, 39, 222, 33, 169, 153, 248, 69, 22, 63, 82, 47, 141, 89, 69, 102, 183, 148, 108, 230, 206, 254, 173, 111, 126, 205, 73, 85, 110, 8, 195, 112, 225, 241, 117, 201, 155, 66, 182, 43, 95, 192, 172, 85, 95, 200, 55, 150, 254, 183, 79, 51, 140, 194, 243, 218, 6, 207, 43, 112, 155, 165, 185, 81, 231, 61, 156, 78, 134, 159, 39, 52, 3, 54, 202, 111, 201, 137, 237, 153, 86, 65, 220, 47, 171, 44, 200, 196, 150, 157, 71, 245, 230, 122, 68, 43, 159, 42, 220, 239, 39, 59, 81, 215, 190, 128, 130, 45, 90, 180, 95, 118, 120, 37, 13, 88, 3, 66, 233, 214, 12, 132, 171, 162, 38, 115, 151, 111, 181, 74, 10, 105, 88, 147, 18, 179, 28, 209, 232, 145, 185, 92, 144, 230, 74, 12, 70, 230, 10, 109, 202, 47, 127, 142, 241, 226, 160, 99, 236, 6, 133, 69, 212, 154, 166, 91, 50, 29, 34, 28, 146, 191, 43, 169, 86, 236, 44, 39, 96, 174, 26, 12, 210, 205, 182, 94, 148, 21, 71, 7, 55, 243, 169, 236, 251, 148, 255, 130, 169, 82, 153, 21, 140, 25, 11, 83, 255, 108, 240, 128, 13, 36, 35, 182, 182, 242, 102, 57, 202, 171, 124, 196, 136, 92, 214, 60, 128, 224, 239, 59, 200, 208, 243, 143, 95, 97, 220, 171, 167, 40, 18, 63, 70, 152, 3, 129, 146, 154, 72, 146, 176, 144, 56, 0, 216, 206, 217, 145, 170, 82, 110, 208, 56, 155, 158, 133, 32, 72, 127, 55, 98, 223, 55, 57, 226, 184, 221, 143, 62, 205, 153, 184, 72, 233, 147, 245, 235, 115, 24, 146, 28, 29, 191, 188, 195, 216, 0, 79, 123, 176, 54, 74, 228, 161, 151, 255, 57, 132, 208, 222, 172, 239, 205, 243, 127, 50, 141, 9, 28, 72, 123, 85, 122, 138, 248, 107, 55, 73, 183, 2, 189, 140, 161, 129, 16, 183, 182, 207, 76, 105, 61, 159, 207, 220, 140, 223, 15, 72, 164, 232, 55, 246, 173, 204, 217, 67, 72, 116, 35, 22, 247, 217, 8, 97, 20, 37, 53, 199, 137, 14, 183, 78, 33, 179, 245, 104, 161, 143, 174, 147, 54, 58, 153, 221, 189, 50, 27, 25, 252, 142, 76, 18, 135, 116, 106, 21, 78, 71, 130, 246, 120, 35, 81, 60, 230, 156, 147, 127, 104, 209, 94, 21, 168, 51, 226, 215, 97, 176, 83, 122, 225, 117, 106, 49, 117, 171, 146, 184, 154, 203, 205, 153, 155, 84, 153, 95, 190, 76, 32, 248, 17, 43, 20, 48, 114, 56, 234, 90, 101, 59, 154, 217, 35, 15, 234, 180, 156, 178, 214, 117, 220, 215, 178, 12, 37, 247, 61, 212, 186, 28, 176, 157, 38, 125, 116, 68, 128, 229, 191, 65, 183, 125, 81, 130, 183, 131, 93, 244, 175, 42, 119, 240, 179, 174, 78, 1, 125, 226, 231, 160, 105, 14, 32, 19, 86, 170, 9, 226, 40, 148, 47, 70, 27, 37, 13, 56, 247, 89, 179, 103, 45, 105, 94, 115, 97, 185, 56, 13, 24, 135, 47, 150, 57, 56, 72, 31, 70, 31, 48, 75, 206, 216, 69, 184, 201, 237, 221, 113, 183, 214, 140, 167, 68, 69, 187, 226, 254, 182, 189, 142, 132, 1, 220, 204, 174, 248, 29, 216, 137, 194, 87, 139, 131, 224, 76, 73, 194, 165, 71, 63, 157, 208, 134, 167, 116, 14, 87, 226, 46, 76, 101, 73, 42, 99, 13, 76, 238, 140, 44, 48, 118, 246, 56, 74, 153, 113, 185, 44, 218, 130, 32, 218, 143, 177, 174, 194, 189, 188, 12, 248, 30, 201, 111, 41, 179, 117, 45, 168, 224, 254, 10, 90, 226, 81, 242, 96, 40, 61, 225, 156, 143, 248, 187, 220, 74, 237, 159, 165, 63, 246, 200, 229, 75, 103, 203, 208, 187, 92, 84, 138, 17, 36, 207, 108, 67, 138, 71, 82, 252, 122, 231, 150, 11, 109, 169, 15, 75, 46, 149, 100, 227, 59, 95, 15, 40, 246, 192, 66, 68, 36, 248, 149, 74, 54, 28, 207, 167, 237, 62, 186, 11, 49, 155, 38, 20, 117, 62, 18, 201, 9, 166, 33, 74, 232, 160, 202, 178, 77, 25, 107, 220, 210, 141, 40, 172, 79, 179, 55, 185, 100, 199, 98, 115, 207, 191, 151, 67, 174, 160, 99, 155, 76, 33, 141, 242, 154, 100, 87, 243, 208, 43, 160, 42, 126, 22, 177, 199, 150, 245, 244, 247, 186, 241, 222, 110, 37, 208, 33, 61, 184, 15, 72, 19, 103, 39, 215, 155, 210, 224, 71, 180, 11, 172, 63, 25, 19, 134, 108, 93, 35, 239, 49, 159, 42, 238, 79, 117, 86, 16, 121, 66, 93, 45, 199, 23, 187, 127, 36, 85, 208, 230, 132, 244, 81, 51, 107, 51, 72, 30, 81, 50, 238, 169, 204, 134, 134, 45, 5, 148, 235, 84, 132, 46, 226, 36, 102, 68, 51, 213, 138, 238, 72, 88, 110, 117, 31, 222, 121, 76, 130, 195, 232, 169, 252, 218, 169, 141, 41, 51, 63, 78, 122, 236, 42, 150, 182, 48, 40, 80, 44, 60, 40, 167, 42, 133, 21, 222, 175, 242, 236, 255, 53, 141, 153, 55, 223, 175, 247, 251, 102, 105, 54, 31, 47, 236, 176, 106, 191, 35, 249, 141, 170, 115, 8, 43, 117, 98, 108, 207, 43, 62, 247, 140, 37, 234, 0, 243, 31, 52, 42, 240, 226, 94, 128, 246, 249, 56, 37, 226, 92, 53, 36, 72, 144, 138, 181, 113, 54, 159, 116, 37, 26, 174, 73, 158, 179, 22, 173, 173, 76, 118, 38, 13, 255, 67, 194, 86, 90, 199, 243, 65, 3, 10, 210, 37, 198, 22, 139, 92, 210, 95, 166, 208, 227, 48, 255, 255, 78, 64, 150, 209, 86, 77, 140, 215, 139, 1, 112, 216, 14, 126, 41, 52, 81, 240, 166, 110, 246, 236, 70, 106, 95, 165, 112, 102, 214, 225, 248, 58, 57, 164, 225, 7, 167, 15, 66, 26, 243, 153, 184, 43, 67, 226, 136, 56, 251, 245, 85, 141, 129, 183, 244, 109, 227, 163, 251, 110, 135, 174, 205, 49, 67, 131, 32, 134, 231, 225, 203, 78, 160, 182, 78, 140, 213, 115, 82, 156, 130, 102, 106, 184, 123, 84, 13, 160, 185, 162, 47, 227, 197, 165, 83, 122, 68, 128, 131, 150, 125, 112, 150, 138, 8, 148, 69, 176, 172, 114, 73, 127, 86, 70, 212, 0, 157, 63, 184, 197, 6, 82, 157, 55, 154, 33, 170, 56, 181, 70, 206, 169, 92, 122, 27, 184, 159, 242, 206, 225, 177, 242, 162, 148, 117, 158, 172, 72, 76, 186, 59, 60, 8, 161, 188, 101, 31, 233, 37, 240, 69, 226, 40, 247, 105, 19, 211, 15, 90, 90, 102, 180, 61, 128, 50, 212, 248, 144, 135, 178, 49, 175, 106, 28, 225, 242, 203, 247, 6, 165, 202, 108, 36, 8, 155, 177, 240, 70, 84, 16, 250, 91, 0, 19, 54, 91, 196, 133, 73, 197, 2, 211, 143, 201, 123, 80, 142, 191, 119, 98, 18, 245, 100, 73, 93, 243, 201, 35, 54, 231, 238, 241, 5, 155, 127, 0, 254, 121, 146, 12, 127, 122, 195, 64, 99, 255, 95, 186, 185, 45, 7, 180, 159, 154, 64, 100, 182, 150, 27, 189, 63, 7, 52, 11, 159, 184, 38, 230, 77, 198, 241, 22, 194, 222, 20, 202, 53, 236, 141, 149, 64, 148, 242, 76, 79, 56, 46, 188, 118, 201, 56, 142, 141, 123, 75, 119, 211, 5, 54, 61, 145, 48, 231, 130, 81, 12, 80, 29, 248, 136, 242, 226, 149, 57, 110, 1, 184, 147, 187, 208, 86, 103, 131, 34, 214, 35, 146, 124, 252, 177, 76, 110, 156, 99, 118, 76, 153, 73, 89, 49, 37, 178, 14, 250, 151, 170, 254, 220, 59, 171, 75, 84, 164, 65, 121, 87, 122, 212, 27, 65, 94, 57, 60, 250, 249, 156, 80, 109, 238, 235, 92, 201, 39, 192, 86, 162, 30, 106, 104, 114, 182, 9, 183, 97, 95, 231, 16, 40, 87, 196, 43, 69, 29, 136, 219, 68, 42, 215, 122, 197, 109, 134, 88, 61, 55, 177, 209, 174, 109, 110, 217, 95, 201, 16, 133, 149, 147, 244, 155, 105, 39, 28, 105, 247, 251, 139, 219, 63, 176, 161, 71, 101, 63, 98, 218, 96, 33, 127, 192, 31, 69, 166, 61, 74, 143, 142, 88, 225, 134, 65, 235, 214, 145, 245, 107, 56, 238, 119, 101, 160, 247, 38, 236, 87, 124, 117, 93, 199, 107, 151, 217, 41, 30, 69, 61, 60, 228, 120, 38, 61, 202, 4, 196, 60, 107, 93, 230, 40, 247, 224, 159, 40, 66, 236, 243, 135, 202, 146, 209, 197, 56, 33, 126, 2, 150, 230, 154, 253, 35, 136, 132, 121, 244, 123, 201, 99, 100, 34, 233, 123, 210, 194, 205, 243, 251, 205, 118, 7, 211, 100, 55, 210, 42, 228, 153, 167, 251, 150, 182, 182, 23, 158, 81, 162, 157, 253, 5, 44, 163, 226, 150, 71, 84, 7, 94, 209, 240, 30, 86, 146, 182, 130, 210, 61, 179, 233, 42, 26, 151, 54, 91, 14, 155, 19, 142, 113, 38, 169, 23, 73, 254, 124, 16, 15, 81, 67, 86, 230, 56, 77, 86, 225, 157, 240, 176, 138, 0, 179, 194, 157, 235, 199, 57, 160, 108, 54, 67, 205, 162, 28, 140, 215, 230, 18, 47, 130, 185, 162, 65, 150, 58, 177, 194, 149, 41, 64, 20, 205, 76, 57, 68, 53, 128, 73, 52, 99, 239, 127, 206, 232, 68, 50, 48, 176, 235, 249, 65, 38, 39, 152, 147, 79, 184, 174, 106, 120, 67, 79, 81, 97, 56, 196, 246, 63, 10, 133, 104, 2, 134, 231, 66, 48, 202, 47, 125, 78, 73, 181, 93, 140, 185, 53, 223, 108, 194, 31, 97, 227, 137, 251, 150, 126, 82, 77, 115, 123, 6, 224, 250, 235, 144, 171, 159, 213, 113, 246, 46, 151, 87, 13, 119, 210, 206, 215, 189, 246, 27, 228, 25, 69, 4, 248, 63, 128, 9, 67, 54, 72, 217, 224, 134, 171, 137, 235, 100, 152, 160, 155, 85, 223, 5, 138, 178, 94, 25, 223, 12, 180, 199, 151, 120, 38, 4, 121, 192, 69, 126, 105, 16, 7, 22, 26, 187, 124, 6, 203, 17, 11, 231, 196, 67, 234, 38, 86, 246, 52, 16, 112, 156, 178, 231, 251, 108, 147, 239, 177, 185, 211, 79, 1, 136, 247, 203, 252, 140, 213, 247, 230, 147, 90, 110, 53, 207, 160, 70, 250, 109, 6, 44, 231, 3, 185, 25, 85, 200, 137, 200, 34, 92, 52, 151, 250, 44, 132, 111, 80, 243, 47, 234, 216, 229, 22, 231, 52, 195, 171, 132, 133, 33, 38, 232, 245, 226, 186, 146, 58, 40, 73, 163, 32, 82, 203, 121, 68, 128, 95, 107, 20, 11, 76, 242, 165, 111, 52, 144, 156, 147, 63, 100, 94, 226, 149, 56, 39, 32, 58, 34, 153, 138, 224, 4, 95, 129, 192, 92, 247, 139, 190, 177, 0, 50, 83, 231, 45, 59, 59, 13, 24, 117, 66, 5, 16, 145, 172, 84, 230, 74, 90, 94, 208, 92, 219, 54, 218, 134, 162, 251, 162, 99, 78, 191, 188, 71, 249, 101, 232, 123, 16, 123, 177, 248, 47, 254, 56, 11, 39, 62, 155, 143, 137, 174, 99, 73, 186, 53, 169, 27, 241, 40, 29, 166, 22, 41, 90, 31, 62, 28, 12, 230, 143, 15, 68, 119, 28, 126, 94, 55, 161, 151, 211, 129, 162, 206, 109, 158, 173, 85, 119, 18, 54, 107, 213, 68, 29, 99, 62, 188, 115, 105, 95, 2, 135, 83, 183, 67, 210, 255, 160, 128, 83, 141, 177, 169, 129, 223, 157, 30, 0, 68, 103, 164, 42, 103, 35, 179, 193, 54, 200, 250, 197, 233, 163, 86, 231, 73, 242, 217, 81, 48, 62, 230, 40, 173, 144, 84, 7, 199, 88, 61, 166, 38, 187, 80, 60, 136, 44, 242, 62, 224, 98, 169, 210, 116, 9, 233, 199, 224, 1, 82, 201, 179, 116, 145, 37, 75, 101, 153, 31, 55, 129, 184, 193, 179, 55, 174, 186, 144, 178, 179, 118, 148, 33, 84, 250, 164, 85, 137, 168, 250, 89, 21, 237, 153, 127, 29, 86, 131, 72, 118, 175, 255, 160, 160, 78, 202, 88, 140, 237, 161, 195, 157, 85, 15, 234, 31, 168, 47, 189, 111, 47, 243, 160, 208, 218, 128, 2, 3, 82, 214, 40, 174, 190, 92, 201, 109, 235, 231, 112, 248, 229, 169, 93, 38, 100, 47, 43, 17, 55, 160, 208, 158, 64, 96, 147, 178, 156, 194, 179, 197, 166, 34, 156, 165, 124, 160, 189, 213, 20, 144, 108, 45, 99, 202, 209, 121, 163, 23, 138, 219, 56, 251, 153, 134, 129, 8, 97, 220, 30, 228, 217, 13, 225, 75, 209, 193, 32, 9, 16, 195, 85, 27, 193, 112, 192, 21, 21, 37, 46, 24, 252, 43, 212, 110, 152, 164, 90, 125, 111, 218, 35, 67, 171, 237, 146, 80, 22, 243, 160, 105, 146, 234, 181, 180, 71, 41, 146, 102, 250, 55, 46, 175, 92, 103, 43, 197, 59, 67, 118, 181, 189, 30, 185, 114, 71, 82, 16, 177, 167, 54, 106, 253, 174, 16, 51, 123, 54, 138, 200, 171, 89, 180, 183, 101, 207, 34, 112, 59, 3, 70, 172, 251, 177, 30, 232, 31, 10, 182, 220, 90, 116, 128, 201, 9, 43, 165, 0, 240, 72, 63, 137, 152, 20, 249, 146, 189, 148, 197, 160, 236, 224, 27, 222, 150, 0, 116, 38, 147, 169, 95, 0, 248, 196, 168, 222, 48, 72, 33, 67, 78, 73, 34, 186, 173, 18, 62, 181, 23, 165, 248, 62, 244, 123, 26, 241, 223, 76, 3, 186, 242, 41, 210, 210, 237, 65, 61, 55, 58, 94, 241, 147, 119, 27, 74, 112, 249, 193, 147, 157, 20, 4, 128, 142, 54, 213, 217, 60, 47, 9, 109, 162, 197, 147, 81, 76, 167, 7, 175, 223, 128, 217, 229, 40, 157, 182, 157, 171, 75, 204, 114, 152, 7, 164, 198, 239, 88, 148, 178, 217, 122, 187, 151, 105, 66, 51, 164, 92, 78, 168, 118, 143, 117, 64, 252, 91, 214, 145, 212, 138, 131, 5, 225, 150, 184, 184, 6, 138, 153, 120, 154, 194, 161, 33, 99, 204, 177, 237, 41, 32, 157, 36, 164, 246, 212, 120, 128, 48, 82, 218, 165, 206, 206, 105, 150, 204, 206, 124, 214, 233, 139, 53, 2, 36, 13, 21, 44, 79, 163, 163, 164, 28, 181, 134, 74, 128, 3, 53, 190, 125, 115, 155, 58, 63, 198, 87, 227, 191, 172, 49, 217, 71, 178, 118, 68, 19, 105, 142, 170, 115, 32, 135, 82, 203, 62, 132, 241, 200, 132, 101, 220, 251, 229, 204, 138, 31, 106, 33, 253, 157, 217, 71, 132, 66, 165, 203, 227, 243, 231, 22, 249, 159, 131, 27, 33, 156, 16, 58, 211, 229, 167, 144, 173, 111, 0, 195, 144, 177, 116, 78, 103, 158, 13, 248, 193, 107, 210, 62, 245, 116, 118, 24, 127, 187, 225, 100, 120, 91, 10, 102, 4, 200, 220, 200, 230, 238, 51, 89, 166, 63, 147, 149, 104, 47, 62, 171, 171, 59, 23, 143, 241, 99, 30, 84, 138, 19, 223, 133, 9, 221, 142, 76, 204, 164, 189, 170, 45, 75, 123, 133, 106, 196, 83, 57, 213, 182, 237, 52, 36, 222, 231, 127, 66, 120, 60, 81, 164, 109, 202, 239, 232, 180, 138, 153, 2, 255, 32, 247, 187, 79, 240, 104, 129, 192, 138, 249, 160, 8, 121, 178, 118, 13, 166, 27, 59, 29, 190, 147, 216, 204, 246, 184, 122, 194, 184, 58, 155, 133, 170, 194, 86, 22, 250, 122, 210, 127, 128, 157, 175, 131, 19, 188, 121, 118, 158, 93, 19, 110, 23, 209, 26, 19, 197, 2, 55, 221, 229, 155, 177, 20, 89, 154, 211, 185, 72, 213, 202, 136, 238, 42, 251, 228, 224, 191, 158, 39, 162, 231, 2, 128, 188, 49, 36, 104, 158, 163, 95, 82, 92, 255, 213, 162, 147, 211, 189, 44, 190, 220, 166, 0, 102, 10, 162, 99, 13, 55, 222, 95, 172, 195, 4, 37, 44, 100, 97, 112, 244, 251, 65, 67, 114, 88, 179, 150, 13, 176, 190, 86, 221, 113, 80, 243, 68, 221, 148, 98, 24, 179, 251, 40, 158, 171, 97, 223, 158, 131, 74, 182, 28, 39, 38, 254, 13, 3, 35, 107, 161, 178, 99, 22, 87, 101, 77, 208, 8, 58, 138, 113, 13, 60, 26, 3, 89, 77, 215, 108, 69, 221, 115, 207, 213, 216, 93, 32, 85, 210, 87, 199, 212, 79, 2, 63, 85, 70, 221, 136, 237, 79, 99, 59, 92, 57, 58, 51, 217, 141, 103, 17, 219, 153, 125, 209, 188, 57, 180, 23, 146, 104, 85, 229, 209, 155, 46, 99, 89, 244, 120, 122, 124, 218, 56, 44, 25, 61, 129, 130, 228, 55, 241, 74, 32, 187, 145, 149, 209, 10, 230, 245, 20, 16, 94, 26, 128, 15, 207, 132, 34, 33, 15, 61, 105, 98, 250, 221, 91, 113, 81, 64, 11, 131, 255, 75, 225, 190, 50, 95, 170, 69, 209, 215, 178, 89, 223, 190, 175, 55, 159, 176, 99, 12, 21, 221, 201, 211, 132, 234, 58, 251, 204, 61, 85, 153, 173, 81, 11, 8, 239, 170, 130, 41, 53, 165, 199, 70, 111, 30, 79, 181, 39, 105, 105, 104, 159, 52, 124, 253, 38, 191, 242, 73, 99, 65, 106, 128, 191, 172, 116, 182, 53, 71, 143, 85, 113, 195, 169, 227, 233, 232, 50, 99, 69, 244, 53, 148, 212, 1, 204, 147, 138, 157, 119, 246, 39, 240, 9, 65, 207, 52, 81, 43, 68, 81, 155, 65, 168, 204, 178, 108, 223, 249, 218, 180, 228, 83, 136, 79, 230, 12, 138, 229, 11, 69, 2, 97, 77, 99, 174, 37, 180, 12, 83, 141, 139, 41, 108, 40, 93, 160, 232, 30, 232, 159, 126, 223, 93, 90, 45, 88, 245, 158, 141, 88, 241, 91, 120, 252, 230, 140, 200, 195, 248, 58, 98, 152, 93, 232, 127, 89, 95, 106, 173, 142, 242, 24, 115, 66, 215, 211, 201, 240, 36, 140, 223, 207, 165, 241, 180, 34, 11, 159, 155, 250, 94, 136, 164, 214, 95, 154, 30, 106, 97, 114, 217, 176, 92, 18, 198, 157, 255, 78, 82, 208, 161, 185, 45, 209, 137, 91, 97, 227, 8, 185, 59, 203, 189, 25, 50, 230, 220, 135, 167, 13, 227, 236, 142, 141, 8, 16, 173, 250, 39, 18, 9, 75, 191, 174, 189, 226, 50, 125, 158, 188, 26, 109, 99, 57, 200, 231, 153, 197, 250, 247, 224, 57, 218, 53, 34, 172, 142, 30, 196, 98, 117, 187, 203, 134, 45, 87, 207, 6, 40, 205, 151, 192, 214, 214, 139, 206, 36, 121, 162, 25, 28, 206, 229, 18, 154, 136, 107, 204, 65, 235, 122, 185, 132, 50, 165, 227, 161, 234, 187, 27, 231, 212, 27, 113, 54, 208, 235, 204, 46, 47, 85, 217, 212, 6, 5, 222, 164, 126, 75, 51, 39, 94, 145, 145, 159, 255, 29, 240, 196, 214, 43, 242, 169, 34, 138, 132, 111, 181, 251, 51, 100, 115, 156, 246, 20, 179, 242, 151, 174, 252, 146, 226, 109, 180, 228, 254, 82, 143, 136, 145, 239, 4, 163, 200, 121, 67, 9, 11, 192, 42, 211, 156, 37, 16, 169, 120, 181, 223, 204, 86, 98, 174, 15, 46, 85, 75, 156, 43, 98, 90, 90, 158, 8, 135, 228, 42, 231, 56, 201, 199, 80, 141, 242, 25, 34, 169, 190, 232, 245, 47, 73, 17, 195, 41, 168, 247, 75, 124, 125, 201, 38, 85, 69, 132, 255, 113, 31, 89, 209, 45, 8, 142, 77, 148, 109, 204, 246, 229, 34, 22, 213, 34, 255, 106, 3, 42, 161, 193, 77, 135, 204, 225, 218, 48, 3, 254, 213, 42, 199, 174, 123, 143, 86, 217, 94, 137, 239, 137, 99, 200, 251, 208, 39, 101, 154, 44, 7, 26, 125, 245, 76, 122, 201, 11, 190, 108, 134, 231, 225, 43, 8, 158, 154, 158, 37, 191, 27, 72, 150, 249, 39, 230, 240, 58, 76, 61, 59, 127, 14, 172, 38, 117, 115, 231, 148, 243, 194, 3, 213, 191, 219, 84, 101, 30, 210, 88, 191, 188, 113, 92, 66, 253, 166, 28, 146, 23, 51, 85, 65, 217, 233, 190, 248, 126, 238, 242, 244, 113, 189, 105, 192, 143, 189, 236, 37, 222, 28, 212, 33, 101, 138, 157, 203, 134, 87, 129, 74, 122, 251, 3, 202, 170, 239, 162, 148, 182, 203, 183, 157, 130, 115, 213, 90, 4, 96, 25, 196, 143, 234, 135, 14, 0, 103, 8, 178, 46, 205, 167, 74, 183, 57, 201, 148, 226, 211, 177, 145, 85, 144, 34, 66, 144, 101, 192, 93, 86, 205, 82, 35, 231, 189, 37, 56, 59, 121, 40, 108, 211, 252, 202, 71, 209, 174, 29, 171, 63, 75, 226, 253, 6, 106, 207, 195, 184, 134, 148, 172, 59, 167, 223, 138, 168, 181, 51, 85, 107, 239, 40, 201, 2, 236, 162, 34, 243, 200, 227, 21, 180, 114, 11, 33, 191, 87, 55, 119, 41, 126, 220, 86, 243, 165, 101, 67, 208, 29, 191, 16, 138, 156, 196, 200, 178, 9, 39, 202, 174, 182, 241, 166, 116, 90, 30, 185, 68, 199, 239, 177, 201, 163, 61, 195, 82, 180, 170, 34, 101, 201, 79, 150, 243, 34, 99, 197, 177, 224, 181, 203, 222, 205, 86, 60, 138, 175, 0, 84, 209, 163, 39, 233, 91, 106, 117, 23, 59, 6, 126, 120, 206, 73, 106, 245, 115, 17, 5, 19, 225, 61, 149, 216, 108, 251, 192, 196, 6, 155, 69, 58, 162, 106, 211, 167, 116, 191, 222, 187, 101, 51, 250, 76, 247, 187, 195, 40, 120, 236, 32, 86, 221, 8, 65, 202, 233, 74, 242, 25, 197, 188, 240, 41, 148, 107, 49, 198, 214, 142, 122, 186, 28, 193, 27, 2, 115, 140, 146, 126, 45, 52, 216, 53, 167, 60, 225, 147, 67, 50, 115, 24, 193, 230, 170, 141, 49, 253, 13, 251, 92, 207, 24, 157, 212, 223, 21, 158, 171, 90, 173, 218, 152, 1, 4, 74, 128, 245, 51, 167, 73, 61, 253, 20, 120, 152, 240, 195, 200, 169, 207, 207, 199, 179, 74, 115, 32, 172, 199, 119, 59, 66, 53, 124, 115, 104, 159, 26, 161, 110, 77, 238, 114, 225, 75, 25, 152, 24, 80, 84, 223, 99, 224, 99, 190, 88, 73, 235, 76, 117, 179, 228, 193, 205, 227, 61, 202, 175, 239, 231, 221, 176, 198, 240, 214, 66, 131, 123, 161, 255, 16, 184, 163, 207, 149, 32, 65, 160, 120, 224, 255, 106, 36, 131, 192, 71, 15, 168, 214, 81, 48, 126, 178, 172, 35, 174, 78, 144, 7, 159, 13, 254, 74, 177, 112, 85, 14, 86, 82, 92, 14, 214, 148, 241, 177, 165, 0, 15, 51, 162, 181, 60, 117, 39, 242, 239, 82, 227, 236, 216, 139, 193, 55, 113, 19, 133, 63, 76, 83, 4, 237, 100, 118, 87, 150, 163, 127, 176, 226, 140, 181, 2, 249, 73, 81, 192, 4, 196, 165, 197, 196, 81, 214, 193, 144, 239, 115, 210, 135, 229, 193, 131, 224, 18, 157, 211, 54, 189, 124, 73, 166, 180, 210, 23, 228, 78, 169, 106, 217, 242, 68, 86, 50, 138, 249, 136, 123, 99, 129, 144, 18, 33, 67, 117, 168, 140, 231, 225, 179, 70, 4, 209, 82, 40, 231, 4, 232, 248, 137, 234, 15, 194, 115, 71, 101, 219, 154, 36, 119, 29, 150, 31, 28, 6, 33, 251, 86, 176, 240, 192, 141, 246, 134, 158, 194, 124, 33, 173, 241, 9, 102, 21, 236, 162, 98, 17, 119, 128, 86, 87, 148, 250, 148, 219, 51, 133, 29, 252, 50, 108, 1, 22, 80, 80, 60, 104, 238, 72, 11, 179, 15, 206, 48, 189, 24, 108, 101, 203, 17, 117, 32, 196, 147, 250, 234, 49, 147, 132, 250, 105, 149, 170, 104, 192, 184, 115, 46, 248, 209, 182, 38, 60, 144, 231, 158, 96, 229, 121, 234, 12, 209, 120, 186, 192, 245, 124, 237, 19, 113, 117, 110, 163, 30, 26, 63, 49, 98, 8, 253, 24, 82, 51, 117, 64, 45, 250, 6, 74, 199, 184, 39, 122, 187, 75, 119, 101, 5, 62, 243, 82, 61, 239, 20, 65, 88, 194, 141, 218, 217, 127, 176, 235, 26, 88, 175, 75, 154, 86, 82, 111, 226, 147, 149, 229, 182, 17, 32, 95, 6, 116, 75, 7, 87, 108, 154, 94, 194, 250, 97, 106, 50, 125, 249, 29, 243, 218, 74, 218, 36, 136, 231, 41, 43, 199, 226, 225, 83, 248, 39, 115, 187, 233, 231, 28, 68, 168, 221, 37, 197, 152, 95, 128, 61, 109, 87, 87, 28, 45, 245, 191, 132, 168, 143, 181, 227, 13, 35, 22, 40, 179, 55, 230, 103, 145, 87, 61, 50, 104, 245, 173, 34, 19, 57, 22, 215, 86, 144, 0, 194, 139, 14, 235, 236, 119, 79, 186, 44, 185, 152, 190, 154, 91, 31, 132, 45, 68, 187, 97, 253, 122, 113, 4, 144, 92, 102, 7, 172, 235, 28, 36, 159, 27, 139, 245, 165, 97, 44, 80, 233, 55, 72, 221, 162, 147, 198, 151, 201, 174, 60, 186, 119, 78, 95, 141, 66, 99, 35, 32, 20, 61, 67, 71, 69, 166, 237, 165, 45, 194, 143, 44, 242, 96, 14, 54, 204, 121, 108, 115, 132, 172, 151, 47, 6, 217, 127, 202, 228, 166, 154, 94, 174, 198, 5, 62, 145, 112, 149, 165, 188, 55, 47, 13, 62, 75, 234, 208, 167, 136, 37, 209, 203, 188, 85, 72, 228, 173, 50, 51, 212, 69, 194, 112, 112, 26, 135, 27, 82, 219, 210, 93, 168, 193, 1, 167, 153, 116, 207, 12, 101, 157, 98, 8, 211, 170, 92, 200, 152, 33, 129, 81, 167, 2, 189, 245, 210, 6, 159, 83, 29, 211, 128, 148, 221, 28, 103, 45, 133, 245, 212, 39, 204, 94, 16, 92, 116, 251, 163, 18, 159, 160, 49, 38, 95, 212, 191, 235, 215, 248, 88, 202, 45, 45, 93, 244, 187, 79, 134, 75, 104, 83, 189, 31, 172, 21, 64, 217, 93, 123, 45, 161, 68, 50, 194, 147, 23, 19, 1, 37, 169, 199, 207, 140, 31, 184, 104, 81, 143, 200, 198, 14, 205, 209, 252, 228, 253, 247, 242, 132, 29, 43, 149, 212, 68, 29, 154, 221, 71, 150, 77, 169, 83, 200, 251, 152, 46, 214, 206, 245, 199, 53, 166, 12, 112, 216, 52, 135, 33, 2, 188, 75, 63, 110, 140, 42, 155, 136, 164, 175, 113, 54, 151, 16, 80, 8, 140, 220, 48, 252, 143, 70, 151, 255, 150, 253, 105, 192, 249, 80, 92, 142, 21, 76, 55, 223, 85, 224, 171, 61, 14, 81, 66, 24, 141, 70, 171, 223, 250, 200, 140, 132, 239, 151, 235, 4, 118, 218, 235, 51, 210, 0, 61, 54, 136, 131, 52, 98, 157, 243, 68, 99, 139, 159, 61, 208, 155, 124, 90, 189, 236, 37, 222, 28, 212, 33, 101, 138, 157, 203, 134, 87, 129, 74, 122, 251, 3, 202, 170, 239, 162, 148, 182, 203, 183, 157, 130, 115, 213, 90, 4, 96, 25, 196, 143, 234, 135, 14, 0, 103, 8, 178, 46, 205, 167, 74, 183, 57, 201, 148, 226, 211, 177, 145, 85, 144, 34, 66, 144, 101, 192, 93, 86, 205, 82, 35, 231, 189, 37, 56, 59, 121, 40, 108, 211, 252, 202, 71, 209, 174, 29, 171, 63, 75, 226, 253, 6, 106, 207, 195, 184, 134, 148, 172, 59, 167, 223, 138, 168, 181, 51, 85, 107, 239, 40, 201, 2, 236, 162, 34, 243, 200, 227, 21, 180, 114, 11, 33, 191, 87, 55, 119, 41, 126, 220, 86, 243, 171, 6, 126, 106, 15, 240, 10, 62, 186, 1, 93, 195, 223, 205, 122, 188, 96, 141, 116, 119, 239, 8, 101, 111, 226, 65, 153, 103, 109, 240, 238, 201, 133, 154, 97, 7, 164, 128, 8, 239, 201, 39, 153, 121, 233, 62, 104, 57, 194, 223, 107, 234, 83, 63, 117, 127, 15, 171, 177, 140, 226, 182, 166, 233, 207, 204, 175, 222, 11, 7, 78, 222, 243, 139, 61, 73, 157, 159, 146, 86, 223, 99, 13, 51, 57, 95, 141, 178, 3, 125, 3, 177, 21, 158, 43, 16, 64, 3, 35, 54, 6, 88, 72, 81, 133, 184, 179, 125, 243, 26, 144, 145, 51, 119, 72, 121, 218, 50, 190, 106, 233, 75, 190, 137, 222, 240, 124, 228, 52, 0, 69, 73, 216, 67, 65, 204, 4, 167, 173, 64, 105, 5, 164, 30, 17, 59, 1, 65, 159, 250, 254, 99, 159, 75, 170, 11, 40, 181, 130, 112, 214, 190, 10, 140, 254, 137, 249, 211, 65, 109, 159, 135, 11, 182, 194, 192, 112, 83, 73, 19, 73, 184, 58, 192, 204, 129, 60, 250, 180, 116, 136, 60, 214, 240, 155, 212, 2, 38, 34, 4, 89, 116, 98, 128, 174, 158, 113, 229, 236, 55, 95, 168, 88, 173, 231, 151, 32, 39, 127, 88, 222, 77, 27, 211, 1, 214, 34, 55, 204, 205, 186, 252, 201, 160, 99, 52, 38, 173, 187, 57, 126, 151, 1, 18, 5, 127, 67, 254, 222, 143, 200, 1, 241, 176, 10, 223, 156, 96, 61, 230, 53, 42, 22, 105, 153, 97, 225, 204, 98, 5, 67, 32, 247, 191, 186, 100, 32, 110, 216, 180, 108, 225, 54, 219, 68, 174, 71, 168, 205, 118, 38, 248, 144, 7, 160, 125, 112, 19, 125, 178, 165, 150, 239, 71, 163, 236, 204, 201, 40, 124, 125, 196, 17, 109, 238, 45, 177, 46, 107, 98, 48, 28, 191, 65, 86, 13, 133, 7, 60, 139, 16, 8, 235, 38, 185, 253, 187, 183, 207, 11, 233, 134, 246, 230, 241, 121, 110, 253, 126, 89, 29, 126, 177, 62, 51, 39, 95, 119, 123, 255, 188, 37, 244, 140, 187, 210, 55, 198, 175, 198, 218, 0, 8, 84, 103, 128, 73, 198, 0, 4, 235, 15, 193, 194, 239, 6, 56, 197, 251, 119, 135, 113, 166, 133, 243, 237, 192, 104, 180, 171, 13, 116, 144, 40, 192, 49, 119, 150, 69, 149, 23, 54, 234, 118, 49, 169, 242, 232, 80, 103, 30, 169, 52, 98, 49, 140, 255, 186, 65, 192, 224, 90, 86, 248, 173, 27, 183, 162, 183, 208, 145, 104, 210, 220, 136, 26, 227, 167, 161, 69, 73, 218, 119, 46, 126, 10, 224, 207, 60, 107, 47, 128, 194, 66, 127, 18, 104, 161, 209, 64, 0, 18, 45, 212, 82, 204, 204, 50, 98, 224, 32, 169, 240, 5, 180, 202, 189, 22, 201, 86, 250, 239, 212, 197, 56, 6, 45, 5, 24, 188, 98, 15, 75, 224, 227, 173, 61, 233, 116, 148, 98, 51, 165, 138, 170, 62, 94, 228, 187, 142, 57, 214, 181, 10, 6, 178, 122, 138, 242, 181, 54, 229, 80, 48, 48, 167, 54, 25, 245, 79, 63, 64, 72, 191, 44, 146, 70, 79, 109, 90, 32, 91, 141, 67, 251, 66, 37, 21, 155, 42, 3, 97, 61, 40, 106, 169, 225, 180, 5, 158, 116, 32, 148, 214, 27, 227, 40, 215, 227, 104, 91, 181, 203, 86, 76, 91, 0, 222, 98, 74, 178, 24, 1, 163, 217, 120, 207, 112, 153, 10, 231, 149, 147, 15, 90, 238, 106, 196, 130, 148, 98, 26, 208, 71, 47, 144, 72, 19, 23, 208, 43, 75, 38, 161, 225, 203, 133, 147, 249, 225, 233, 245, 225, 37, 222, 77, 227, 65, 12, 60, 155, 177, 76, 243, 93, 35, 168, 70, 180, 23, 148, 195, 239, 135, 63, 179, 193, 153, 73, 99, 230, 83, 220, 232, 190, 113, 86, 24, 130, 182, 79, 80, 250, 67, 144, 140, 128, 228, 110, 174, 255, 4, 37, 242, 168, 11, 2, 0, 184, 10, 140, 16, 71, 5, 82, 10, 253, 85, 168, 36, 76, 89, 222, 22, 115, 173, 206, 44, 252, 127, 242, 131, 111, 129, 79, 185, 20, 102, 38, 193, 74, 120, 182, 211, 9, 108, 225, 0, 250, 103, 67, 231, 218, 20, 11, 250, 33, 77, 157, 222, 239, 116, 253, 58, 232, 191, 196, 232, 100, 206, 56, 202, 68, 121, 33, 186, 22, 255, 114, 243, 66, 197, 25, 122, 223, 62, 11, 101, 92, 75, 36, 20, 165, 177, 66, 171, 215, 102, 109, 180, 38, 140, 26, 174, 159, 227, 113, 202, 106, 221, 58, 229, 111, 8, 248, 144, 140, 178, 225, 43, 151, 226, 211, 211, 49, 123, 98, 50, 50, 121, 68, 91, 154, 31, 106, 95, 52, 200, 208, 147, 73, 167, 95, 254, 81, 178, 41, 66, 7, 116, 143, 156, 147, 193, 60, 83, 116, 21, 105, 68, 133, 25, 39, 211, 80, 39, 0, 237, 159, 165, 230, 232, 7, 198, 140, 184, 38, 12, 210, 38, 149, 8, 36, 154, 108, 28, 100, 25, 144, 85, 86, 197, 68, 54, 175, 49, 167, 183, 4, 111, 174, 169, 125, 79, 201, 234, 129, 250, 49, 95, 233, 170, 26, 88, 76, 245, 178, 253, 34, 160, 61, 140, 30, 87, 105, 114, 35, 165, 10, 178, 35, 192, 237, 220, 249, 59, 18, 237, 162, 206, 250, 211, 218, 47, 74, 159, 162, 33, 208, 234, 96, 63, 104, 121, 36, 187, 162, 155, 7, 247, 173, 223, 10, 144, 21, 191, 60, 129, 109, 191, 65, 116, 54, 228, 29, 237, 174, 65, 145, 21, 240, 44, 63, 236, 88, 184, 28, 67, 55, 123, 9, 152, 72, 108, 108, 237, 194, 6, 42, 88, 221, 80, 109, 224, 123, 209, 53, 159, 7, 0, 49, 66, 54, 99, 36, 105, 97, 3, 7, 73, 159, 72, 142, 146, 141, 164, 150, 134, 74, 89, 192, 208, 96, 8, 3, 127, 118, 154, 48, 34, 209, 255, 145, 208, 178, 246, 209, 134, 55, 193, 124, 32, 34, 151, 212, 120, 155, 94, 137, 142, 201, 99, 196, 42, 162, 94, 109, 129, 3, 69, 73, 0, 91, 252, 83, 61, 226, 164, 137, 162, 17, 2, 83, 154, 202, 241, 189, 236, 182, 84, 162, 184, 79, 179, 52, 233, 176, 53, 151, 228, 80, 153, 220, 158, 133, 134, 160, 220, 171, 149, 170, 164, 64, 181, 27, 19, 249, 32, 77, 110, 194, 11, 18, 110, 79, 57, 198, 172, 56, 54, 217, 86, 88, 122, 150, 76, 94, 117, 149, 234, 147, 237, 22, 191, 87, 107, 204, 108, 95, 178, 38, 3, 158, 84, 85, 245, 208, 78, 59, 4, 1, 159, 0, 172, 90, 118, 165, 24, 228, 176, 56, 254, 90, 34, 4, 134, 245, 119, 34, 35, 210, 56, 140, 137, 216, 234, 218, 78, 202, 207, 205, 46, 116, 90, 200, 190, 160, 123, 213, 246, 177, 232, 114, 52, 141, 44, 223, 183, 194, 145, 57, 155, 69, 96, 68, 41, 176, 128, 233, 84, 209, 146, 5, 119, 144, 46, 204, 49, 231, 47, 249, 202, 62, 255, 213, 195, 148, 42, 216, 124, 122, 89, 131, 78, 158, 213, 218, 29, 32, 122, 56, 80, 233, 104, 42, 55, 189, 107, 194, 238, 245, 219, 88, 183, 209, 49, 211, 215, 169, 193, 248, 3, 217, 53, 165, 201, 20, 8, 208, 254, 23, 152, 88, 94, 8, 60, 214, 18, 234, 252, 251, 0, 95, 130, 207, 248, 26, 224, 84, 177, 80, 194, 83, 132, 147, 21, 166, 77, 40, 42, 220, 172, 151, 164, 190, 173, 177, 139, 255, 12, 10, 19, 62, 94, 92, 174, 4, 36, 9, 173, 249, 58, 100, 243, 221, 42, 221, 88, 19, 23, 252, 179, 226, 75, 43, 25, 8, 250, 174, 14, 39, 230, 247, 87, 97, 215, 51, 228, 46, 222, 103, 151, 200, 137, 73, 223, 202, 205, 127, 72, 132, 3, 195, 156, 97, 166, 22, 194, 236, 46, 57, 47, 49, 249, 90, 153, 15, 47, 198, 219, 110, 8, 203, 43, 140, 232, 191, 49, 44, 103, 30, 39, 168, 70, 136, 180, 23, 245, 82, 207, 240, 107, 65, 66, 74, 96, 178, 136, 191, 161, 92, 42, 225, 100, 210, 52, 229, 252, 189, 69, 110, 255, 244, 15, 21, 209, 140, 80, 203, 140, 85, 205, 8, 135, 86, 176, 166, 216, 91, 189, 196, 79, 80, 246, 106, 41, 248, 185, 195, 46, 179, 168, 109, 71, 121, 153, 143, 111, 63, 22, 69, 52, 37, 2, 155, 145, 104, 85, 43, 47, 69, 60, 65, 22, 19, 198, 104, 215, 56, 12, 184, 98, 37, 32, 199, 106, 71, 115, 176, 75, 122, 248, 39, 177, 189, 244, 72, 96, 135, 214, 77, 209, 140, 68, 180, 102, 233, 127, 212, 59, 4, 181, 231, 62, 225, 240, 62, 18, 179, 44, 59, 135, 47, 197, 182, 6, 100, 162, 56, 159, 43, 35, 209, 35, 197, 203, 143, 58, 139, 166, 13, 80, 9, 242, 49, 45, 99, 115, 238, 190, 236, 47, 250, 96, 28, 6, 119, 197, 178, 112, 171, 50, 41, 143, 171, 212, 168, 8, 51, 212, 90, 171, 75, 47, 156, 103, 80, 28, 172, 228, 49, 227, 215, 213, 62, 111, 153, 20, 112, 179, 11, 16, 60, 207, 161, 86, 116, 116, 250, 81, 74, 232, 151, 34, 165, 85, 139, 202, 161, 208, 179, 141, 201, 224, 108, 168, 30, 54, 32, 34, 4, 243, 35, 18, 47, 174, 240, 115, 229, 17, 185, 144, 180, 30, 239, 68, 235, 182, 77, 76, 207, 102, 165, 1, 200, 145, 125, 139, 253, 239, 40, 83, 255, 171, 78, 120, 109, 92, 120, 76, 120, 205, 116, 211, 161, 17, 76, 109, 126, 28, 241, 63, 183, 39, 177, 224, 192, 198, 137, 110, 225, 202, 64, 6, 239, 237, 121, 13, 35, 19, 205, 39, 43, 230, 203, 77, 184, 99, 145, 240, 37, 114, 134, 117, 17, 54, 9, 95, 193, 88, 65, 126, 39, 146, 126, 62, 114, 55, 187, 222, 121, 145, 149, 211, 121, 6, 17, 107, 175, 89, 122, 34, 44, 116, 218, 126, 187, 71, 191, 16, 228, 98, 23, 87, 77, 81, 13, 14, 38, 157, 141, 169, 233, 29, 98, 152, 8, 234, 96, 91, 77, 120, 220, 211, 46, 121, 180, 111, 168, 40, 242, 38, 236, 168, 111, 10, 85, 94, 133, 45, 74, 250, 28, 253, 107, 199, 6, 218, 55, 207, 103, 119, 97, 160, 250, 176, 135, 252, 21, 176, 224, 188, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 89, 53, 19, 83, 80, 184, 110, 48, 13, 148, 38, 57, 0, 0, 0, 0, 89, 53, 19, 83, 80, 184, 110, 48, 13, 148, 38, 57, 0, 0, 0, 0, 89, 53, 19, 83, 53, 157, 46, 228, 44, 100, 6, 157, 0, 0, 0, 0, 89, 53, 19, 83, 49, 100, 95, 92, 3, 214, 107, 168, 0, 0, 0, 0, 89, 53, 19, 83, 105, 200, 47, 192, 42, 36, 168, 23, 0, 0, 0, 0, 89, 53, 19, 83, 103, 248, 160, 44, 8, 171, 233, 143, 0, 0, 0, 0, 89, 53, 19, 83, 43, 27, 189, 16, 28, 10, 94, 76, 0, 0, 0, 0, 89, 53, 19, 68, 242, 185, 50, 196, 1, 216, 57, 65, 0, 0, 0, 0, 89, 53, 19, 139, 37, 34, 243, 88, 5, 112, 102, 11, 0, 0, 0, 0, 89, 53, 19, 83, 123, 8, 171, 64, 33, 188, 59, 16, 0, 0, 0, 0, 89, 53, 19, 163, 245, 104, 124, 68, 9, 98, 25, 235, 0, 0, 0, 0, 89, 53, 19, 139, 65, 107, 226, 4, 8, 144, 155, 158, 0, 0, 0, 0, 89, 53, 19, 234, 192, 216, 187, 232, 5, 154, 84, 215, 0, 0, 0, 0, 89, 53, 19, 191, 0, 65, 23, 88, 9, 157, 187, 194, 0, 0, 0, 0, 89, 53, 19, 68, 167, 194, 165, 224, 10, 219, 222, 27, 0, 0, 0, 0, 89, 53, 18, 125, 157, 130, 214, 120, 4, 43, 225, 191, 0, 0, 0, 0, 89, 53, 21, 136, 206, 70, 37, 64, 17, 207, 214, 132, 0, 0, 0, 0, 89, 53, 19, 234, 199, 35, 129, 64, 7, 207, 4, 156, 0, 0, 0, 0, 89, 53, 18, 125, 97, 236, 218, 12, 5, 48, 197, 88, 0, 0, 0, 0, 89, 53, 15, 12, 8, 154, 2, 16, 3, 86, 85, 126, 0, 0, 0, 0, 89, 53, 21, 208, 43, 160, 216, 240, 2, 140, 168, 206, 0, 0, 0, 0, 89, 53, 21, 136, 214, 251, 86, 200, 5, 246, 36, 108, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, 143, 72, 43, 189, 196, 235, 72, 200, 143, 170, 119, 170, 14, 207, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 177, 44, 72, 181, 35, 106, 117, 91, 162, 103, 79, 11, 78, 19, 252, 154, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 184, 42, 92, 84, 222, 230, 10, 98, 4, 230, 99, 133, 197, 27, 254, 186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 162, 126, 6, 242, 61, 40, 168, 218, 169, 143, 71, 23, 196, 156, 153, 165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 205, 239, 124, 102, 148, 144, 125, 146, 206, 3, 105, 225, 248, 47, 202, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 181, 12, 13, 236, 84, 197, 170, 108, 219, 112, 173, 238, 156, 144, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 81, 73, 188, 4, 159, 115, 0, 157, 56, 153, 159, 78, 129, 71, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 209, 66, 138, 207, 127, 187, 145, 247, 131, 145, 228, 118, 103, 112, 67, 178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 243, 190, 107, 187, 182, 254, 134, 98, 69, 119, 21, 167, 187, 240, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 193, 218, 206, 184, 36, 238, 107, 27, 165, 73, 170, 187, 47, 157, 136, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 158, 110, 146, 49, 211, 192, 184, 117, 18, 88, 103, 37, 136, 172, 79, 27, 160, 123, 142, 7, 160, 51, 68, 215, 216, 144, 248, 89, 147, 47, 63, 12, 16, 98, 29, 203, 214, 232, 245, 170, 92, 58, 10, 193, 138, 40, 201, 159, 227, 160, 120, 50, 119, 93, 239, 86, 22, 245, 98, 16, 169, 180, 14, 136, 163, 121, 187, 213, 145, 33, 8, 153, 67, 177, 91, 117, 75, 65, 71, 46, 130, 81, 192]; let block_rlp = UntrustedRlp::new(&block); - let compressed = block_rlp.compress(RlpType::Blocks).to_vec(); + let compressed = block_rlp.compress(RlpType::Blocks).into_vec(); let compressed_rlp = UntrustedRlp::new(&compressed); - assert_eq!(compressed_rlp.decompress(RlpType::Blocks).to_vec(), block); + assert_eq!(compressed_rlp.decompress(RlpType::Blocks).into_vec(), block); } } diff --git a/util/rlp/src/lib.rs b/util/rlp/src/lib.rs index af7d84c00..e7e20b17d 100644 --- a/util/rlp/src/lib.rs +++ b/util/rlp/src/lib.rs @@ -98,7 +98,7 @@ pub fn decode_list(bytes: &[u8]) -> Vec where T: Decodable { /// /// fn main () { /// let animal = "cat"; -/// let out = rlp::encode(&animal).to_vec(); +/// let out = rlp::encode(&animal).into_vec(); /// assert_eq!(out, vec![0x83, b'c', b'a', b't']); /// } /// ``` diff --git a/util/rlp/src/stream.rs b/util/rlp/src/stream.rs index 8c20c0a46..000b6e15b 100644 --- a/util/rlp/src/stream.rs +++ b/util/rlp/src/stream.rs @@ -264,8 +264,8 @@ impl RlpStream { /// panic! if stream is not finished. pub fn out(self) -> Vec { match self.is_finished() { - //true => self.encoder.out().to_vec(), - true => self.buffer.to_vec(), + //true => self.encoder.out().into_vec(), + true => self.buffer.into_vec(), false => panic!() } } diff --git a/util/src/journaldb/overlayrecentdb.rs b/util/src/journaldb/overlayrecentdb.rs index 93eec118d..915e64d05 100644 --- a/util/src/journaldb/overlayrecentdb.rs +++ b/util/src/journaldb/overlayrecentdb.rs @@ -242,8 +242,8 @@ impl JournalDB for OverlayRecentDB { fn state(&self, key: &H256) -> Option { let journal_overlay = self.journal_overlay.read(); let key = to_short_key(key); - journal_overlay.backing_overlay.get(&key).map(|v| v.to_vec()) - .or_else(|| journal_overlay.pending_overlay.get(&key).map(|d| d.clone().to_vec())) + journal_overlay.backing_overlay.get(&key).map(|v| v.into_vec()) + .or_else(|| journal_overlay.pending_overlay.get(&key).map(|d| d.clone().into_vec())) .or_else(|| self.backing.get_by_prefix(self.column, &key[0..DB_PREFIX_LEN]).map(|b| b.into_vec())) } @@ -288,7 +288,7 @@ impl JournalDB for OverlayRecentDB { batch.put_vec(self.column, &k.drain(), r.out()); if journal_overlay.latest_era.map_or(true, |e| now > e) { trace!(target: "journaldb", "Set latest era to {}", now); - batch.put_vec(self.column, &LATEST_ERA_KEY, encode(&now).to_vec()); + batch.put_vec(self.column, &LATEST_ERA_KEY, encode(&now).into_vec()); journal_overlay.latest_era = Some(now); } diff --git a/util/src/kvdb.rs b/util/src/kvdb.rs index 6ea1bc542..d1cf67218 100644 --- a/util/src/kvdb.rs +++ b/util/src/kvdb.rs @@ -216,7 +216,7 @@ impl KeyValueDB for InMemory { Some(map) => map.iter() .find(|&(ref k ,_)| k.starts_with(prefix)) - .map(|(_, v)| (&**v).to_vec().into_boxed_slice()) + .map(|(_, v)| v.to_vec().into_boxed_slice()) } } @@ -227,7 +227,7 @@ impl KeyValueDB for InMemory { match op { DBOp::Insert { col, key, value } => { if let Some(mut col) = columns.get_mut(&col) { - col.insert(key.to_vec(), value); + col.insert(key.into_vec(), value); } }, DBOp::InsertCompressed { col, key, value } => { @@ -235,7 +235,7 @@ impl KeyValueDB for InMemory { let compressed = UntrustedRlp::new(&value).compress(RlpType::Blocks); let mut value = DBValue::new(); value.append_slice(&compressed); - col.insert(key.to_vec(), value); + col.insert(key.into_vec(), value); } }, DBOp::Delete { col, key } => { @@ -253,7 +253,7 @@ impl KeyValueDB for InMemory { Some(map) => Box::new( // TODO: worth optimizing at all? map.clone() .into_iter() - .map(|(k, v)| (k.into_boxed_slice(), v.to_vec().into_boxed_slice())) + .map(|(k, v)| (k.into_boxed_slice(), v.into_vec().into_boxed_slice())) ), None => Box::new(None.into_iter()), } @@ -267,7 +267,7 @@ impl KeyValueDB for InMemory { map.clone() .into_iter() .skip_while(move |&(ref k, _)| !k.starts_with(prefix)) - .map(|(k, v)| (k.into_boxed_slice(), v.to_vec().into_boxed_slice())) + .map(|(k, v)| (k.into_boxed_slice(), v.into_vec().into_boxed_slice())) ), None => Box::new(None.into_iter()), } diff --git a/util/src/migration/mod.rs b/util/src/migration/mod.rs index 93a98f1dc..3e6b898ff 100644 --- a/util/src/migration/mod.rs +++ b/util/src/migration/mod.rs @@ -163,7 +163,7 @@ impl Migration for T { }; for (key, value) in iter { - if let Some((key, value)) = self.simple_migrate(key.to_vec(), value.to_vec()) { + if let Some((key, value)) = self.simple_migrate(key.into_vec(), value.into_vec()) { batch.insert(key, value, dest)?; } } diff --git a/util/src/migration/tests.rs b/util/src/migration/tests.rs index a246f65c8..585bb5f36 100644 --- a/util/src/migration/tests.rs +++ b/util/src/migration/tests.rs @@ -95,7 +95,7 @@ impl Migration for AddsColumn { let mut batch = Batch::new(config, col); for (key, value) in source.iter(col).into_iter().flat_map(|inner| inner) { - batch.insert(key.to_vec(), value.to_vec(), dest)?; + batch.insert(key.into_vec(), value.into_vec(), dest)?; } diff --git a/util/src/trie/fatdb.rs b/util/src/trie/fatdb.rs index a1d54037d..f10e6d4bf 100644 --- a/util/src/trie/fatdb.rs +++ b/util/src/trie/fatdb.rs @@ -95,7 +95,7 @@ impl<'db> Iterator for FatDBIterator<'db> { .map(|res| res.map(|(hash, value)| { let aux_hash = hash.sha3(); - (self.trie.db().get(&aux_hash).expect("Missing fatdb hash").to_vec(), value) + (self.trie.db().get(&aux_hash).expect("Missing fatdb hash").into_vec(), value) }) ) } diff --git a/util/src/trie/standardmap.rs b/util/src/trie/standardmap.rs index 39f28eaef..f839f4f2e 100644 --- a/util/src/trie/standardmap.rs +++ b/util/src/trie/standardmap.rs @@ -111,7 +111,7 @@ impl StandardMap { let v = match self.value_mode { ValueMode::Mirror => k.clone(), ValueMode::Random => Self::random_value(seed), - ValueMode::Index => encode(&index).to_vec(), + ValueMode::Index => encode(&index).into_vec(), }; d.push((k, v)) } diff --git a/util/src/trie/triedb.rs b/util/src/trie/triedb.rs index 5c3052323..5da304167 100644 --- a/util/src/trie/triedb.rs +++ b/util/src/trie/triedb.rs @@ -378,7 +378,7 @@ fn iterator() { } let t = TrieDB::new(&memdb, &root).unwrap(); - assert_eq!(d.iter().map(|i| i.clone().to_vec()).collect::>(), t.iter().unwrap().map(|x| x.unwrap().0).collect::>()); + assert_eq!(d.iter().map(|i| i.clone().into_vec()).collect::>(), t.iter().unwrap().map(|x| x.unwrap().0).collect::>()); assert_eq!(d, t.iter().unwrap().map(|x| x.unwrap().1).collect::>()); } diff --git a/util/src/trie/triedbmut.rs b/util/src/trie/triedbmut.rs index 2c2e556c5..6c770a9d5 100644 --- a/util/src/trie/triedbmut.rs +++ b/util/src/trie/triedbmut.rs @@ -1026,14 +1026,14 @@ mod tests { let mut memdb = MemoryDB::new(); let mut root = H256::new(); let mut t1 = TrieDBMut::new(&mut memdb, &mut root); - t1.insert(&[0x01, 0x23], &big_value.to_vec()).unwrap(); - t1.insert(&[0x01, 0x34], &big_value.to_vec()).unwrap(); + t1.insert(&[0x01, 0x23], big_value).unwrap(); + t1.insert(&[0x01, 0x34], big_value).unwrap(); let mut memdb2 = MemoryDB::new(); let mut root2 = H256::new(); let mut t2 = TrieDBMut::new(&mut memdb2, &mut root2); - t2.insert(&[0x01], &big_value.to_vec()).unwrap(); - t2.insert(&[0x01, 0x23], &big_value.to_vec()).unwrap(); - t2.insert(&[0x01, 0x34], &big_value.to_vec()).unwrap(); + t2.insert(&[0x01], big_value).unwrap(); + t2.insert(&[0x01, 0x23], big_value).unwrap(); + t2.insert(&[0x01, 0x34], big_value).unwrap(); t2.remove(&[0x01]).unwrap(); } diff --git a/util/src/triehash.rs b/util/src/triehash.rs index 772f3f475..ca1974e7b 100644 --- a/util/src/triehash.rs +++ b/util/src/triehash.rs @@ -48,7 +48,7 @@ pub fn ordered_trie_root(input: I) -> H256 // optimize it later .into_iter() .enumerate() - .map(|(i, vec)| (rlp::encode(&i).to_vec(), vec)) + .map(|(i, vec)| (rlp::encode(&i).into_vec(), vec)) .collect::>() // then move them to a vector .into_iter()