From 00ec5a7902554af877d071d3cf06da1d00344ae5 Mon Sep 17 00:00:00 2001 From: Marc Brinkmann Date: Tue, 16 Mar 2021 16:02:34 +0100 Subject: [PATCH 01/28] Use correct type deserializaing/serializing block proposer state --- node/src/components/block_proposer.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/node/src/components/block_proposer.rs b/node/src/components/block_proposer.rs index 1a2ff717e8..93ddbfcb6c 100644 --- a/node/src/components/block_proposer.rs +++ b/node/src/components/block_proposer.rs @@ -97,17 +97,12 @@ impl BlockProposer { debug!(%next_finalized_block, "creating block proposer"); // load the state from storage or use a fresh instance if loading fails. let state_key = deploy_sets::create_storage_key(chainspec); - let cloned_state_key = state_key.clone(); - let effects = async move { - effect_builder - .load_state(cloned_state_key.into()) - .await - .unwrap_or_default() - } - .event(move |sets| Event::Loaded { - sets, - next_finalized_block, - }); + let effects = effect_builder + .load_state::(state_key.clone().into()) + .event(move |sets| Event::Loaded { + sets, + next_finalized_block, + }); let block_proposer = BlockProposer { state: BlockProposerState::Initializing { @@ -262,7 +257,10 @@ impl BlockProposerReady { // After pruning, we store a state snapshot. let mut effects = effect_builder - .save_state(self.state_key.clone().into(), self.sets.clone()) + .save_state::( + self.state_key.clone().into(), + self.sets.clone(), + ) .ignore(); // Re-trigger timer after `PRUNE_INTERVAL`. From e0639f7ef17901d538cd2383b045f1f7b5cbf54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Papierski?= Date: Tue, 16 Mar 2021 17:02:02 +0100 Subject: [PATCH 02/28] EE-1203: Regression test for delegation amount. --- .../src/test/system_contracts/auction/bids.rs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/execution_engine_testing/tests/src/test/system_contracts/auction/bids.rs b/execution_engine_testing/tests/src/test/system_contracts/auction/bids.rs index e540971790..2e3170575c 100644 --- a/execution_engine_testing/tests/src/test/system_contracts/auction/bids.rs +++ b/execution_engine_testing/tests/src/test/system_contracts/auction/bids.rs @@ -2883,3 +2883,41 @@ fn should_reset_delegators_stake_after_slashing() { // Validator 1 total delegated stake is set to 0 assert_eq!(validator_1_delegator_stakes_3, U512::zero()); } + +#[should_panic(expected = "InvalidDelegatedAmount")] +#[ignore] +#[test] +fn should_validate_genesis_delegators_bond_amount() { + let accounts = { + let mut tmp: Vec = DEFAULT_ACCOUNTS.clone(); + let account_1 = GenesisAccount::account( + *ACCOUNT_1_PK, + Motes::new(ACCOUNT_1_BALANCE.into()), + Some(GenesisValidator::new(Motes::new(ACCOUNT_1_BOND.into()), 80)), + ); + let account_2 = GenesisAccount::account( + *ACCOUNT_2_PK, + Motes::new(ACCOUNT_2_BALANCE.into()), + Some(GenesisValidator::new( + Motes::new(ACCOUNT_2_BOND.into()), + DelegationRate::zero(), + )), + ); + let delegator_1 = GenesisAccount::delegator( + *ACCOUNT_1_PK, + *DELEGATOR_1, + Motes::new(DELEGATOR_1_BALANCE.into()), + Motes::new(U512::zero()), + ); + tmp.push(account_1); + tmp.push(account_2); + tmp.push(delegator_1); + tmp + }; + + let run_genesis_request = utils::create_run_genesis_request(accounts); + + let mut builder = InMemoryWasmTestBuilder::default(); + + builder.run_genesis(&run_genesis_request); +} From f13d53dc5cf171abb1bad85e64e0da44cc5e11dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Papierski?= Date: Tue, 16 Mar 2021 17:09:06 +0100 Subject: [PATCH 03/28] EE-1203: Add validation around delegated amount. --- execution_engine/src/core/engine_state/genesis.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/execution_engine/src/core/engine_state/genesis.rs b/execution_engine/src/core/engine_state/genesis.rs index 1fc793e222..8b0c94f154 100644 --- a/execution_engine/src/core/engine_state/genesis.rs +++ b/execution_engine/src/core/engine_state/genesis.rs @@ -693,6 +693,9 @@ pub enum GenesisError { InvalidBondAmount { public_key: PublicKey, }, + InvalidDelegatedAmount { + public_key: PublicKey, + }, } pub(crate) struct GenesisInstaller @@ -879,7 +882,15 @@ where let genesis_delegators: Vec<_> = self.exec_config.get_bonded_delegators().collect(); // Make sure all delegators have corresponding genesis validator entries - for (&validator_public_key, &delegator_public_key, ..) in &genesis_delegators { + for (&validator_public_key, &delegator_public_key, _balance, delegated_amount) in + &genesis_delegators + { + if delegated_amount.is_zero() { + return Err(GenesisError::InvalidDelegatedAmount { + public_key: delegator_public_key, + }); + } + if genesis_validators .iter() .find(|genesis_validator| genesis_validator.public_key() == validator_public_key) From e6efe1c40da32c15227a3d830b52edad5cc6859c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 12:18:55 +0100 Subject: [PATCH 04/28] NDRS-1028: Handle known linear chain blocks in validator reactor. --- node/src/components/linear_chain.rs | 18 +++++++++++++++--- node/src/reactor/joiner.rs | 2 +- node/src/reactor/validator.rs | 11 +++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/node/src/components/linear_chain.rs b/node/src/components/linear_chain.rs index 0fcbb17fda..813e3b76bc 100644 --- a/node/src/components/linear_chain.rs +++ b/node/src/components/linear_chain.rs @@ -47,12 +47,17 @@ pub enum Event { #[from] Request(LinearChainRequest), /// New linear chain block has been produced. - LinearChainBlock { + NewLinearChainBlock { /// The block. block: Box, /// The deploys' execution results. execution_results: HashMap, }, + /// Linear chain block we already know but we may refinalize it when syncing protocol state. + KnownLinearChainBlock { + /// The block. + block: Box, + }, /// Finality signature received. /// Not necessarily _new_ finality signature. FinalitySignatureReceived(Box), @@ -76,7 +81,7 @@ impl Display for Event { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Event::Request(req) => write!(f, "linear chain request: {}", req), - Event::LinearChainBlock { block, .. } => { + Event::NewLinearChainBlock { block, .. } => { write!(f, "linear chain new block: {}", block.hash()) } Event::FinalitySignatureReceived(fs) => write!( @@ -107,6 +112,9 @@ impl Display for Event { fs.era_id, fs.public_key ) } + Event::KnownLinearChainBlock { block } => { + write!(f, "linear chain known block: {}", block.hash()) + } } } } @@ -349,7 +357,7 @@ where } } .ignore(), - Event::LinearChainBlock { + Event::NewLinearChainBlock { block, execution_results, } => { @@ -558,6 +566,10 @@ where // TODO: Disconnect from the sender. Effects::new() } + Event::KnownLinearChainBlock { block } => { + self.latest_block = Some(*block); + Effects::new() + } } } } diff --git a/node/src/reactor/joiner.rs b/node/src/reactor/joiner.rs index 89a4880f8d..cb5c1d4d79 100644 --- a/node/src/reactor/joiner.rs +++ b/node/src/reactor/joiner.rs @@ -776,7 +776,7 @@ impl reactor::Reactor for Reactor { let block_hash = *block.hash(); // send to linear chain - let reactor_event = Event::LinearChain(linear_chain::Event::LinearChainBlock { + let reactor_event = Event::LinearChain(linear_chain::Event::NewLinearChainBlock { block: Box::new(block), execution_results: execution_results .iter() diff --git a/node/src/reactor/validator.rs b/node/src/reactor/validator.rs index d730f11688..a38512d101 100644 --- a/node/src/reactor/validator.rs +++ b/node/src/reactor/validator.rs @@ -874,9 +874,12 @@ impl reactor::Reactor for Reactor { effects.extend(self.dispatch_event(effect_builder, rng, reactor_event)); effects } - ConsensusAnnouncement::Handled(_) => { - debug!("Ignoring `Handled` announcement in `validator` reactor."); - Effects::new() + ConsensusAnnouncement::Handled(linear_chain_block) => { + let event = + Event::LinearChain(linear_chain::Event::KnownLinearChainBlock { + block: linear_chain_block, + }); + self.dispatch_event(effect_builder, rng, event) } ConsensusAnnouncement::Fault { era_id, @@ -906,7 +909,7 @@ impl reactor::Reactor for Reactor { let block_hash = *block.hash(); // send to linear chain - let reactor_event = Event::LinearChain(linear_chain::Event::LinearChainBlock { + let reactor_event = Event::LinearChain(linear_chain::Event::NewLinearChainBlock { block: Box::new(block), execution_results: execution_results .iter() From caf7ebcb023ab85910df9bf7ef0e7afa13975cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 12:20:15 +0100 Subject: [PATCH 05/28] NDRS-1028: Improve received finality signature check. --- node/src/components/linear_chain.rs | 43 +++++++++++++++++++++++------ node/src/reactor/joiner.rs | 3 +- node/src/reactor/validator.rs | 2 +- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/node/src/components/linear_chain.rs b/node/src/components/linear_chain.rs index 813e3b76bc..b01d957dc5 100644 --- a/node/src/components/linear_chain.rs +++ b/node/src/components/linear_chain.rs @@ -12,7 +12,7 @@ use itertools::Itertools; use prometheus::{IntGauge, Registry}; use tracing::{debug, error, info, warn}; -use casper_types::{ExecutionResult, ProtocolVersion, PublicKey, SemVer}; +use casper_types::{ExecutionResult, ProtocolVersion, PublicKey}; use super::{consensus::EraId, Component}; use crate::{ @@ -26,7 +26,8 @@ use crate::{ }, protocol::Message, types::{ - Block, BlockByHeight, BlockHash, BlockSignatures, DeployHash, FinalitySignature, Timestamp, + Block, BlockByHeight, BlockHash, BlockSignatures, Chainspec, DeployHash, FinalitySignature, + Timestamp, }, unregister_metric, NodeRng, }; @@ -183,7 +184,10 @@ pub(crate) struct LinearChain { /// Finality signatures to be inserted in a block once it is available. pending_finality_signatures: HashMap>, signature_cache: SignatureCache, - + /// Current protocol version of the network. + protocol_version: ProtocolVersion, + auction_delay: u64, + unbonding_delay: u64, #[data_size(skip)] metrics: LinearChainMetrics, @@ -191,12 +195,20 @@ pub(crate) struct LinearChain { } impl LinearChain { - pub fn new(registry: &Registry) -> Result { + pub fn new(registry: &Registry, chainspec: &Chainspec) -> Result { let metrics = LinearChainMetrics::new(registry)?; + let protocol_version = ProtocolVersion::from_parts( + chainspec.protocol_config.version.major as u32, + chainspec.protocol_config.version.minor as u32, + chainspec.protocol_config.version.patch as u32, + ); Ok(LinearChain { latest_block: None, pending_finality_signatures: HashMap::new(), signature_cache: SignatureCache::new(), + protocol_version, + auction_delay: chainspec.core_config.auction_delay, + unbonding_delay: chainspec.core_config.unbonding_delay, metrics, _marker: PhantomData, }) @@ -415,10 +427,21 @@ where era_id, .. } = *fs; - if let Err(err) = fs.verify() { - warn!(%block_hash, %public_key, %err, "received invalid finality signature"); + if let Some(last_block) = self.latest_block.as_ref() { + let last_block_era = last_block.header().era_id(); + let lowest_acceptable_era_id = + last_block_era + self.auction_delay - self.unbonding_delay; + let highest_acceptable_era_id = last_block_era + self.auction_delay; + if era_id < lowest_acceptable_era_id || era_id > highest_acceptable_era_id { + warn!( + ?era_id, + ?public_key, + ?block_hash, + "received finality signature for not bonded era." + ); return Effects::new(); } + } if self.has_finality_signature(&fs) { debug!(block_hash=%fs.block_hash, public_key=%fs.public_key, "finality signature already pending"); @@ -429,6 +452,10 @@ where "finality signature is already known"); return Effects::new(); } + if let Err(err) = fs.verify() { + warn!(%block_hash, %public_key, %err, "received invalid finality signature"); + return Effects::new(); + } self.add_pending_finality_signature(*fs.clone()); match self.signature_cache.get(&block_hash, era_id) { None => effect_builder @@ -482,13 +509,11 @@ where Some(block) => { let latest_header = block.header(); let state_root_hash = latest_header.state_root_hash(); - // TODO: Use protocol version that is valid for the block's height. - let protocol_version = ProtocolVersion::new(SemVer::V1_0_0); effect_builder .is_bonded_in_future_era( *state_root_hash, fs.era_id, - protocol_version, + self.protocol_version, fs.public_key, ) .map(|res| { diff --git a/node/src/reactor/joiner.rs b/node/src/reactor/joiner.rs index cb5c1d4d79..10d262a08f 100644 --- a/node/src/reactor/joiner.rs +++ b/node/src/reactor/joiner.rs @@ -502,7 +502,8 @@ impl reactor::Reactor for Reactor { registry.clone(), ); - let linear_chain = linear_chain::LinearChain::new(®istry)?; + let linear_chain = + linear_chain::LinearChain::new(®istry, &chainspec_loader.chainspec())?; let validator_weights: BTreeMap = chainspec_loader .chainspec() diff --git a/node/src/reactor/validator.rs b/node/src/reactor/validator.rs index a38512d101..e7a42f1f07 100644 --- a/node/src/reactor/validator.rs +++ b/node/src/reactor/validator.rs @@ -473,7 +473,7 @@ impl reactor::Reactor for Reactor { ) .with_parent_map(latest_block); let proto_block_validator = BlockValidator::new(Arc::clone(&chainspec_loader.chainspec())); - let linear_chain = LinearChain::new(registry)?; + let linear_chain = LinearChain::new(registry, &chainspec_loader.chainspec())?; effects.extend(reactor::wrap_effects(Event::Network, network_effects)); effects.extend(reactor::wrap_effects( From 3080b41c1940990c3310e128c19caee32f975548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 13:36:45 +0100 Subject: [PATCH 06/28] NDRS-1028: Cargo fmt. --- node/src/components/linear_chain.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/src/components/linear_chain.rs b/node/src/components/linear_chain.rs index b01d957dc5..819788b51c 100644 --- a/node/src/components/linear_chain.rs +++ b/node/src/components/linear_chain.rs @@ -439,8 +439,8 @@ where ?block_hash, "received finality signature for not bonded era." ); - return Effects::new(); - } + return Effects::new(); + } } if self.has_finality_signature(&fs) { debug!(block_hash=%fs.block_hash, public_key=%fs.public_key, From 79fd62ce20ff326f5e8ca6ccb278a013cb73b977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 15:17:28 +0100 Subject: [PATCH 07/28] NDRS-1028: Address review comments. --- node/src/components/linear_chain.rs | 25 +++++++++++++++---------- node/src/reactor/validator.rs | 7 +++---- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/node/src/components/linear_chain.rs b/node/src/components/linear_chain.rs index 819788b51c..9a0607f6a9 100644 --- a/node/src/components/linear_chain.rs +++ b/node/src/components/linear_chain.rs @@ -55,10 +55,7 @@ pub enum Event { execution_results: HashMap, }, /// Linear chain block we already know but we may refinalize it when syncing protocol state. - KnownLinearChainBlock { - /// The block. - block: Box, - }, + KnownLinearChainBlock(Box), /// Finality signature received. /// Not necessarily _new_ finality signature. FinalitySignatureReceived(Box), @@ -113,7 +110,7 @@ impl Display for Event { fs.era_id, fs.public_key ) } - Event::KnownLinearChainBlock { block } => { + Event::KnownLinearChainBlock(block) => { write!(f, "linear chain known block: {}", block.hash()) } } @@ -427,11 +424,19 @@ where era_id, .. } = *fs; - if let Some(last_block) = self.latest_block.as_ref() { - let last_block_era = last_block.header().era_id(); + if let Some(latest_block) = self.latest_block.as_ref() { + // If it's a switch block it has already forgotten its own era's validators, + // unbonded some old validators, and determined new ones. In that case, we + // should add 1 to last_block_era. + let current_era = latest_block.header().era_id() + + if latest_block.header().is_switch_block() { + 1 + } else { + 0 + }; let lowest_acceptable_era_id = - last_block_era + self.auction_delay - self.unbonding_delay; - let highest_acceptable_era_id = last_block_era + self.auction_delay; + current_era + self.auction_delay - self.unbonding_delay; + let highest_acceptable_era_id = current_era + self.auction_delay; if era_id < lowest_acceptable_era_id || era_id > highest_acceptable_era_id { warn!( ?era_id, @@ -591,7 +596,7 @@ where // TODO: Disconnect from the sender. Effects::new() } - Event::KnownLinearChainBlock { block } => { + Event::KnownLinearChainBlock(block) => { self.latest_block = Some(*block); Effects::new() } diff --git a/node/src/reactor/validator.rs b/node/src/reactor/validator.rs index e7a42f1f07..367827fd0d 100644 --- a/node/src/reactor/validator.rs +++ b/node/src/reactor/validator.rs @@ -875,10 +875,9 @@ impl reactor::Reactor for Reactor { effects } ConsensusAnnouncement::Handled(linear_chain_block) => { - let event = - Event::LinearChain(linear_chain::Event::KnownLinearChainBlock { - block: linear_chain_block, - }); + let event = Event::LinearChain(linear_chain::Event::KnownLinearChainBlock( + linear_chain_block, + )); self.dispatch_event(effect_builder, rng, event) } ConsensusAnnouncement::Fault { From 12188a53338ee48323263d7c80f5dcc5c790a88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 19:46:33 +0100 Subject: [PATCH 08/28] NDRS-1028: Gossip only signature created by local node. --- node/src/components/linear_chain.rs | 115 +++++++++++++++++++--------- node/src/reactor/validator.rs | 4 +- 2 files changed, 82 insertions(+), 37 deletions(-) diff --git a/node/src/components/linear_chain.rs b/node/src/components/linear_chain.rs index 9a0607f6a9..c7aacc6d24 100644 --- a/node/src/components/linear_chain.rs +++ b/node/src/components/linear_chain.rs @@ -36,12 +36,6 @@ use crate::{ /// waiting for their block. const MAX_PENDING_FINALITY_SIGNATURES_PER_VALIDATOR: usize = 1000; -impl From> for Event { - fn from(fs: Box) -> Self { - Event::FinalitySignatureReceived(fs) - } -} - #[derive(Debug, From)] pub enum Event { /// A linear chain request issued by another node in the network. @@ -58,7 +52,7 @@ pub enum Event { KnownLinearChainBlock(Box), /// Finality signature received. /// Not necessarily _new_ finality signature. - FinalitySignatureReceived(Box), + FinalitySignatureReceived(Box, bool), /// The result of putting a block to storage. PutBlockResult { /// The block. @@ -82,10 +76,10 @@ impl Display for Event { Event::NewLinearChainBlock { block, .. } => { write!(f, "linear chain new block: {}", block.hash()) } - Event::FinalitySignatureReceived(fs) => write!( + Event::FinalitySignatureReceived(fs, gossiped) => write!( f, - "linear-chain new finality signature for block: {}, from: {}", - fs.block_hash, fs.public_key, + "linear-chain new finality signature for block: {}, from: {}, external: {}", + fs.block_hash, fs.public_key, gossiped ), Event::PutBlockResult { .. } => write!(f, "linear-chain put-block result"), Event::GetStoredFinalitySignaturesResult(finality_signature, maybe_signatures) => { @@ -174,12 +168,37 @@ impl SignatureCache { } } +#[derive(DataSize, Debug)] +enum Signature { + Local(Box), + External(Box), +} + +impl Signature { + fn to_inner(&self) -> &Box { + match self { + Signature::Local(fs) => fs, + Signature::External(fs) => fs, + } + } + + fn take(self) -> Box { + match self { + Signature::Local(fs) | Signature::External(fs) => fs, + } + } + + fn is_local(&self) -> bool { + matches!(self, Signature::Local(_)) + } +} + #[derive(DataSize, Debug)] pub(crate) struct LinearChain { /// The most recently added block. latest_block: Option, /// Finality signatures to be inserted in a block once it is available. - pending_finality_signatures: HashMap>, + pending_finality_signatures: HashMap>, signature_cache: SignatureCache, /// Current protocol version of the network. protocol_version: ProtocolVersion, @@ -249,27 +268,40 @@ impl LinearChain { let pending_sigs = self .pending_finality_signatures .values_mut() - .filter_map(|sigs| sigs.remove(&block_hash).map(Box::new)) - .filter(|fs| !known_signatures.proofs.contains_key(&fs.public_key)) + .filter_map(|sigs| sigs.remove(&block_hash)) + .filter(|signature| { + !known_signatures + .proofs + .contains_key(&signature.to_inner().public_key) + }) .collect_vec(); self.remove_empty_entries(); // Add new signatures and send the updated block to storage. - for fs in pending_sigs { - if fs.era_id != block_era { + for signature in pending_sigs { + if signature.to_inner().era_id != block_era { // finality signature was created with era id that doesn't match block's era. // TODO: disconnect from the sender. continue; } - known_signatures.insert_proof(fs.public_key, fs.signature); - let message = Message::FinalitySignature(fs.clone()); - effects.extend(effect_builder.broadcast_message(message).ignore()); - effects.extend(effect_builder.announce_finality_signature(fs).ignore()); + known_signatures.insert_proof( + signature.to_inner().public_key, + signature.to_inner().signature, + ); + if signature.is_local() { + let message = Message::FinalitySignature(signature.to_inner().clone()); + effects.extend(effect_builder.broadcast_message(message).ignore()); + } + effects.extend( + effect_builder + .announce_finality_signature(signature.take()) + .ignore(), + ); } (known_signatures, effects) } /// Adds finality signature to the collection of pending finality signatures. - fn add_pending_finality_signature(&mut self, fs: FinalitySignature) { + fn add_pending_finality_signature(&mut self, fs: FinalitySignature, gossiped: bool) { let FinalitySignature { block_hash, public_key, @@ -288,12 +320,18 @@ impl LinearChain { ); return; } + + let signature = if gossiped { + Signature::External(Box::new(fs)) + } else { + Signature::Local(Box::new(fs)) + }; // Add the pending signature. - let _ = sigs.insert(block_hash, fs); + let _ = sigs.insert(block_hash, signature); } /// Removes finality signature from the pending collection. - fn remove_from_pending_fs(&mut self, fs: &FinalitySignature) { + fn remove_from_pending_fs(&mut self, fs: &FinalitySignature) -> Option { let FinalitySignature { block_hash, era_id: _era_id, @@ -301,10 +339,14 @@ impl LinearChain { public_key, } = fs; debug!(%block_hash, %public_key, "removing finality signature from pending collection"); - if let Some(validator_sigs) = self.pending_finality_signatures.get_mut(public_key) { - validator_sigs.remove(&block_hash); - } + let maybe_sig = + if let Some(validator_sigs) = self.pending_finality_signatures.get_mut(public_key) { + validator_sigs.remove(&block_hash) + } else { + None + }; self.remove_empty_entries(); + maybe_sig } } @@ -412,12 +454,12 @@ where effects.extend( effect_builder .handle_linear_chain_block(*block.clone()) - .map_some(move |fs| Event::FinalitySignatureReceived(Box::new(fs))), + .map_some(move |fs| Event::FinalitySignatureReceived(Box::new(fs), true)), ); effects.extend(effect_builder.announce_block_added(block).ignore()); effects } - Event::FinalitySignatureReceived(fs) => { + Event::FinalitySignatureReceived(fs, gossiped) => { let FinalitySignature { block_hash, public_key, @@ -461,7 +503,7 @@ where warn!(%block_hash, %public_key, %err, "received invalid finality signature"); return Effects::new(); } - self.add_pending_finality_signature(*fs.clone()); + self.add_pending_finality_signature(*fs.clone(), gossiped); match self.signature_cache.get(&block_hash, era_id) { None => effect_builder .get_signatures_from_storage(block_hash) @@ -553,19 +595,20 @@ where self.remove_from_pending_fs(&*fs); Effects::new() } else { - let message = Message::FinalitySignature(fs.clone()); - let mut effects = effect_builder.broadcast_message(message).ignore(); - effects.extend( - effect_builder - .announce_finality_signature(fs.clone()) - .ignore(), - ); + let mut effects = effect_builder + .announce_finality_signature(fs.clone()) + .ignore(); + if let Some(signature) = self.remove_from_pending_fs(&*fs) { + if signature.is_local() { + let message = Message::FinalitySignature(fs.clone()); + effects.extend(effect_builder.broadcast_message(message).ignore()); + } + }; signatures.insert_proof(fs.public_key, fs.signature); // Cache the results in case we receive the same finality signature before we // manage to store it in the database. self.signature_cache.insert(*signatures.clone()); debug!(hash=%signatures.block_hash, "storing finality signatures"); - self.remove_from_pending_fs(&*fs); effects.extend( effect_builder .put_signatures_to_storage(*signatures) diff --git a/node/src/reactor/validator.rs b/node/src/reactor/validator.rs index 367827fd0d..581ec57070 100644 --- a/node/src/reactor/validator.rs +++ b/node/src/reactor/validator.rs @@ -788,7 +788,9 @@ impl reactor::Reactor for Reactor { return Effects::new(); } }, - Message::FinalitySignature(fs) => Event::LinearChain(fs.into()), + Message::FinalitySignature(fs) => { + Event::LinearChain(linear_chain::Event::FinalitySignatureReceived(fs, true)) + } }; self.dispatch_event(effect_builder, rng, reactor_event) } From 54b78edee0d55daa60598611aa9048769311f7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 19:58:55 +0100 Subject: [PATCH 09/28] NDRS-1028: Prevent from underflows. --- node/src/components/linear_chain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/components/linear_chain.rs b/node/src/components/linear_chain.rs index c7aacc6d24..7acc0a4479 100644 --- a/node/src/components/linear_chain.rs +++ b/node/src/components/linear_chain.rs @@ -477,7 +477,7 @@ where 0 }; let lowest_acceptable_era_id = - current_era + self.auction_delay - self.unbonding_delay; + (current_era + self.auction_delay).saturating_sub(self.unbonding_delay); let highest_acceptable_era_id = current_era + self.auction_delay; if era_id < lowest_acceptable_era_id || era_id > highest_acceptable_era_id { warn!( From 0494b9d29d1d3f64d124281b7e7eca45b557d471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 20:15:50 +0100 Subject: [PATCH 10/28] NDRS-1028: Our own signatures are NOT gossiped. --- node/src/components/linear_chain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/components/linear_chain.rs b/node/src/components/linear_chain.rs index 7acc0a4479..43bfca081c 100644 --- a/node/src/components/linear_chain.rs +++ b/node/src/components/linear_chain.rs @@ -454,7 +454,7 @@ where effects.extend( effect_builder .handle_linear_chain_block(*block.clone()) - .map_some(move |fs| Event::FinalitySignatureReceived(Box::new(fs), true)), + .map_some(move |fs| Event::FinalitySignatureReceived(Box::new(fs), false)), ); effects.extend(effect_builder.announce_block_added(block).ignore()); effects From 50c5b6cf4f5f8914ca0e5772a94a66a68a7998c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 20:37:59 +0100 Subject: [PATCH 11/28] NDRS-1028: Clippy. --- node/src/components/linear_chain.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/src/components/linear_chain.rs b/node/src/components/linear_chain.rs index 43bfca081c..a152cff122 100644 --- a/node/src/components/linear_chain.rs +++ b/node/src/components/linear_chain.rs @@ -175,7 +175,7 @@ enum Signature { } impl Signature { - fn to_inner(&self) -> &Box { + fn to_inner(&self) -> &FinalitySignature { match self { Signature::Local(fs) => fs, Signature::External(fs) => fs, @@ -288,7 +288,7 @@ impl LinearChain { signature.to_inner().signature, ); if signature.is_local() { - let message = Message::FinalitySignature(signature.to_inner().clone()); + let message = Message::FinalitySignature(Box::new(signature.to_inner().clone())); effects.extend(effect_builder.broadcast_message(message).ignore()); } effects.extend( From 5f401137e0acf9c7b03fe4246585efccf4a7110f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kami=C5=84ski?= Date: Thu, 18 Mar 2021 17:34:48 +0100 Subject: [PATCH 12/28] Only hard-reset blocks with old protocol versions --- node/src/components/fetcher/tests.rs | 2 ++ node/src/components/gossiper/tests.rs | 3 ++- node/src/components/storage.rs | 11 +++++++++-- node/src/components/storage/tests.rs | 17 +++++++++++++---- node/src/reactor/initializer.rs | 6 +++++- node/src/reactor/initializer2.rs | 3 ++- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/node/src/components/fetcher/tests.rs b/node/src/components/fetcher/tests.rs index f3c8d41780..5bed6fd49b 100644 --- a/node/src/components/fetcher/tests.rs +++ b/node/src/components/fetcher/tests.rs @@ -5,6 +5,7 @@ use std::sync::{Arc, Mutex}; use casper_node_macros::reactor; use futures::FutureExt; +use semver::Version; use tempfile::TempDir; use thiserror::Error; use tokio::time; @@ -73,6 +74,7 @@ reactor!(Reactor { storage = Storage( &WithDir::new(cfg.temp_dir.path(), cfg.storage_config), chainspec_loader.hard_reset_to_start_of_era(), + Version::new(1, 0, 0), ); deploy_acceptor = infallible DeployAcceptor(cfg.deploy_acceptor_config, &*chainspec_loader.chainspec()); deploy_fetcher = Fetcher::("deploy", cfg.fetcher_config, registry); diff --git a/node/src/components/gossiper/tests.rs b/node/src/components/gossiper/tests.rs index d62decd022..41544d088d 100644 --- a/node/src/components/gossiper/tests.rs +++ b/node/src/components/gossiper/tests.rs @@ -9,6 +9,7 @@ use derive_more::From; use prometheus::Registry; use rand::Rng; use reactor::ReactorEvent; +use semver::Version; use serde::Serialize; use tempfile::TempDir; use thiserror::Error; @@ -161,7 +162,7 @@ impl reactor::Reactor for Reactor { let (storage_config, storage_tempdir) = storage::Config::default_for_tests(); let storage_withdir = WithDir::new(storage_tempdir.path(), storage_config); - let storage = Storage::new(&storage_withdir, None).unwrap(); + let storage = Storage::new(&storage_withdir, None, Version::new(1, 0, 0)).unwrap(); let contract_runtime_config = contract_runtime::Config::default(); let contract_runtime = diff --git a/node/src/components/storage.rs b/node/src/components/storage.rs index 9ac2a200bf..05f960c4a0 100644 --- a/node/src/components/storage.rs +++ b/node/src/components/storage.rs @@ -54,6 +54,7 @@ use derive_more::From; use lmdb::{ Cursor, Database, DatabaseFlags, Environment, EnvironmentFlags, Transaction, WriteFlags, }; +use semver::Version; use serde::{Deserialize, Serialize}; use static_assertions::const_assert; #[cfg(test)] @@ -80,7 +81,7 @@ use crate::{ NodeRng, }; use casper_execution_engine::shared::newtypes::Blake2bHash; -use casper_types::{ExecutionResult, Transfer, Transform}; +use casper_types::{ExecutionResult, ProtocolVersion, Transfer, Transform}; use lmdb_ext::{LmdbExtError, TransactionExt, WriteTransactionExt}; /// Filename for the LMDB database created by the Storage component. @@ -242,6 +243,7 @@ impl Storage { pub(crate) fn new( cfg: &WithDir, hard_reset_to_start_of_era: Option, + version: Version, ) -> Result { let config = cfg.value(); @@ -289,10 +291,15 @@ impl Storage { // Note: `iter_start` has an undocumented panic if called on an empty database. We rely on // the iterator being at the start when created. + let protocol_version = ProtocolVersion::from_parts( + version.major as u32, + version.minor as u32, + version.patch as u32, + ); for (raw_key, raw_val) in cursor.iter() { let block: BlockHeader = lmdb_ext::deserialize(raw_val)?; if let Some(invalid_era) = hard_reset_to_start_of_era { - if block.era_id() >= invalid_era { + if block.era_id() >= invalid_era && block.protocol_version() < protocol_version { continue; } } diff --git a/node/src/components/storage/tests.rs b/node/src/components/storage/tests.rs index 4b333545e6..241fa63dc8 100644 --- a/node/src/components/storage/tests.rs +++ b/node/src/components/storage/tests.rs @@ -3,6 +3,7 @@ use std::{borrow::Cow, collections::HashMap}; use rand::{prelude::SliceRandom, Rng}; +use semver::Version; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use smallvec::smallvec; @@ -42,8 +43,12 @@ fn new_config(harness: &ComponentHarness) -> Config { /// Panics if setting up the storage fixture fails. fn storage_fixture(harness: &ComponentHarness) -> Storage { let cfg = new_config(harness); - Storage::new(&WithDir::new(harness.tmp.path(), cfg), None) - .expect("could not create storage component fixture") + Storage::new( + &WithDir::new(harness.tmp.path(), cfg), + None, + Version::new(1, 0, 0), + ) + .expect("could not create storage component fixture") } /// Storage component test fixture. @@ -58,8 +63,12 @@ fn storage_fixture_with_hard_reset( reset_era_id: EraId, ) -> Storage { let cfg = new_config(harness); - Storage::new(&WithDir::new(harness.tmp.path(), cfg), Some(reset_era_id)) - .expect("could not create storage component fixture") + Storage::new( + &WithDir::new(harness.tmp.path(), cfg), + Some(reset_era_id), + Version::new(1, 1, 0), + ) + .expect("could not create storage component fixture") } /// Creates a random block with a specific block height. diff --git a/node/src/reactor/initializer.rs b/node/src/reactor/initializer.rs index dcc98fb9db..e1d76d9b8d 100644 --- a/node/src/reactor/initializer.rs +++ b/node/src/reactor/initializer.rs @@ -175,7 +175,11 @@ impl Reactor { let hard_reset_to_start_of_era = chainspec_loader.hard_reset_to_start_of_era(); let storage_config = config.map_ref(|cfg| cfg.storage.clone()); - let storage = Storage::new(&storage_config, hard_reset_to_start_of_era)?; + let storage = Storage::new( + &storage_config, + hard_reset_to_start_of_era, + chainspec_loader.chainspec().protocol_config.version.clone(), + )?; let contract_runtime = ContractRuntime::new(storage_config, &config.value().contract_runtime, registry)?; diff --git a/node/src/reactor/initializer2.rs b/node/src/reactor/initializer2.rs index f6fea8e622..12dd464f38 100644 --- a/node/src/reactor/initializer2.rs +++ b/node/src/reactor/initializer2.rs @@ -12,7 +12,8 @@ reactor!(Initializer { chainspec_loader = has_effects ChainspecLoader(cfg.dir(), effect_builder); storage = Storage( &cfg.map_ref(|cfg| cfg.storage.clone()), - chainspec_loader.hard_reset_to_start_of_era() + chainspec_loader.hard_reset_to_start_of_era(), + chainspec_loader.chainspec().protocol_config.version.clone(), ); contract_runtime = ContractRuntime(cfg.map_ref(|cfg| cfg.storage.clone()), &cfg.value().contract_runtime, registry); } From cfad09e04b5cc7db6a1bf44e6624b4b491c234b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kami=C5=84ski?= Date: Thu, 18 Mar 2021 18:15:30 +0100 Subject: [PATCH 13/28] Add a comment --- node/src/components/storage.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node/src/components/storage.rs b/node/src/components/storage.rs index 05f960c4a0..90efc77d92 100644 --- a/node/src/components/storage.rs +++ b/node/src/components/storage.rs @@ -299,6 +299,9 @@ impl Storage { for (raw_key, raw_val) in cursor.iter() { let block: BlockHeader = lmdb_ext::deserialize(raw_val)?; if let Some(invalid_era) = hard_reset_to_start_of_era { + // Don't index blocks that are in to-be-upgraded eras, but have obsolete protocol + // versions - they were most likely created before the upgrade and should be + // reverted. if block.era_id() >= invalid_era && block.protocol_version() < protocol_version { continue; } From 017c3e37cee1892cd89a0ef1939b82c6f0adc01e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kami=C5=84ski?= Date: Thu, 18 Mar 2021 18:23:58 +0100 Subject: [PATCH 14/28] Remove the orphaned blocks --- node/src/components/storage.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/src/components/storage.rs b/node/src/components/storage.rs index 90efc77d92..cc9b01625d 100644 --- a/node/src/components/storage.rs +++ b/node/src/components/storage.rs @@ -286,8 +286,8 @@ impl Storage { info!("reindexing block store"); let mut block_height_index = BTreeMap::new(); let mut switch_block_era_id_index = BTreeMap::new(); - let block_txn = env.begin_ro_txn()?; - let mut cursor = block_txn.open_ro_cursor(block_header_db)?; + let mut block_txn = env.begin_rw_txn()?; + let mut cursor = block_txn.open_rw_cursor(block_header_db)?; // Note: `iter_start` has an undocumented panic if called on an empty database. We rely on // the iterator being at the start when created. @@ -299,11 +299,11 @@ impl Storage { for (raw_key, raw_val) in cursor.iter() { let block: BlockHeader = lmdb_ext::deserialize(raw_val)?; if let Some(invalid_era) = hard_reset_to_start_of_era { - // Don't index blocks that are in to-be-upgraded eras, but have obsolete protocol + // Remove blocks that are in to-be-upgraded eras, but have obsolete protocol // versions - they were most likely created before the upgrade and should be // reverted. if block.era_id() >= invalid_era && block.protocol_version() < protocol_version { - continue; + cursor.del(Default::default())?; } } // We use the opportunity for a small integrity check. From b24b8129640b865771313f4c2f217891da24757d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kami=C5=84ski?= Date: Thu, 18 Mar 2021 18:25:15 +0100 Subject: [PATCH 15/28] Restore the continue; statement --- node/src/components/storage.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/src/components/storage.rs b/node/src/components/storage.rs index cc9b01625d..3e3e1bcfa1 100644 --- a/node/src/components/storage.rs +++ b/node/src/components/storage.rs @@ -304,6 +304,7 @@ impl Storage { // reverted. if block.era_id() >= invalid_era && block.protocol_version() < protocol_version { cursor.del(Default::default())?; + continue; } } // We use the opportunity for a small integrity check. From de12b733673547491a9ccb9e0982e2f41c86b5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kami=C5=84ski?= Date: Thu, 18 Mar 2021 18:41:47 +0100 Subject: [PATCH 16/28] Specify WriteFlags explicitly --- node/src/components/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/components/storage.rs b/node/src/components/storage.rs index 3e3e1bcfa1..9b31273f7e 100644 --- a/node/src/components/storage.rs +++ b/node/src/components/storage.rs @@ -303,7 +303,7 @@ impl Storage { // versions - they were most likely created before the upgrade and should be // reverted. if block.era_id() >= invalid_era && block.protocol_version() < protocol_version { - cursor.del(Default::default())?; + cursor.del(WriteFlags::empty())?; continue; } } From b6f154b8da7655a1abff53d96df4766908680e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kami=C5=84ski?= Date: Thu, 18 Mar 2021 18:55:35 +0100 Subject: [PATCH 17/28] Commit the transaction instead of dropping --- node/src/components/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/components/storage.rs b/node/src/components/storage.rs index 9b31273f7e..cc2fd1f2bc 100644 --- a/node/src/components/storage.rs +++ b/node/src/components/storage.rs @@ -321,7 +321,7 @@ impl Storage { } info!("block store reindexing complete"); drop(cursor); - drop(block_txn); + block_txn.commit()?; // Check the integrity of the block body database. check_block_body_db(&env, &block_body_db)?; From f5e4ba4f43ed9f4fc08643e17b8c18fe81b1e0a4 Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Thu, 18 Mar 2021 18:42:54 +0000 Subject: [PATCH 18/28] NO-TICKET: avoid exiting if overwriting execution results with different ones --- node/src/components/storage.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/node/src/components/storage.rs b/node/src/components/storage.rs index 9ac2a200bf..66919de9b4 100644 --- a/node/src/components/storage.rs +++ b/node/src/components/storage.rs @@ -59,7 +59,7 @@ use static_assertions::const_assert; #[cfg(test)] use tempfile::TempDir; use thiserror::Error; -use tracing::{error, info}; +use tracing::{debug, error, info}; use super::Component; #[cfg(test)] @@ -153,14 +153,6 @@ pub enum Error { /// Second block hash encountered at `era_id`. second: BlockHash, }, - /// Attempted to store a duplicate execution result. - #[error("duplicate execution result for deploy {deploy_hash} in block {block_hash}")] - DuplicateExecutionResult { - /// The deploy for which the result should be stored. - deploy_hash: DeployHash, - /// The block providing the context for the deploy's execution result. - block_hash: BlockHash, - }, /// LMDB error while operating. #[error("internal database error: {0}")] InternalStorage(#[from] LmdbExtError), @@ -530,17 +522,13 @@ impl Storage { .get_deploy_metadata(&mut txn, &deploy_hash)? .unwrap_or_default(); - // If we have a previous execution result, we enforce that it is the same. + // If we have a previous execution result, we can continue if it is the same. if let Some(prev) = metadata.execution_results.get(&block_hash) { - if prev != &execution_result { - return Err(Error::DuplicateExecutionResult { - deploy_hash, - block_hash: *block_hash, - }); + if prev == &execution_result { + continue; + } else { + debug!(%deploy_hash, %block_hash, "different execution result"); } - - // We can now skip adding, as the result is the same. - continue; } if let ExecutionResult::Success { effect, .. } = execution_result.clone() { From 8c9dde4ef7e86b8543b3dfa3bc976d32542e389c Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Thu, 18 Mar 2021 20:30:19 +0000 Subject: [PATCH 19/28] NO-TICKET: update storage test --- node/src/components/storage/tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/node/src/components/storage/tests.rs b/node/src/components/storage/tests.rs index 4b333545e6..856124b015 100644 --- a/node/src/components/storage/tests.rs +++ b/node/src/components/storage/tests.rs @@ -616,7 +616,6 @@ fn store_random_execution_results() { } #[test] -#[should_panic(expected = "duplicate execution result")] fn store_execution_results_twice_for_same_block_deploy_pair() { let mut harness = ComponentHarness::default(); let mut storage = storage_fixture(&harness); From e4c6ccef89cf398310aeb8f273642d8621490131 Mon Sep 17 00:00:00 2001 From: Henry Till Date: Thu, 18 Mar 2021 16:31:25 -0400 Subject: [PATCH 20/28] EE-1204: add activate-bid client contract --- Cargo.lock | 8 +++++++ .../src/test/system_contracts/auction/bids.rs | 10 ++++---- .../contracts/client/activate-bid/Cargo.toml | 19 +++++++++++++++ .../contracts/client/activate-bid/src/main.rs | 24 +++++++++++++++++++ 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 smart_contracts/contracts/client/activate-bid/Cargo.toml create mode 100644 smart_contracts/contracts/client/activate-bid/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 3d1f3c9ac6..0e63867c57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,6 +10,14 @@ dependencies = [ "regex", ] +[[package]] +name = "activate-bid" +version = "0.1.0" +dependencies = [ + "casper-contract", + "casper-types", +] + [[package]] name = "add-bid" version = "0.1.0" diff --git a/execution_engine_testing/tests/src/test/system_contracts/auction/bids.rs b/execution_engine_testing/tests/src/test/system_contracts/auction/bids.rs index 2e3170575c..f03c083e36 100644 --- a/execution_engine_testing/tests/src/test/system_contracts/auction/bids.rs +++ b/execution_engine_testing/tests/src/test/system_contracts/auction/bids.rs @@ -33,7 +33,7 @@ use casper_types::{ auction::{ self, Bids, DelegationRate, EraId, EraValidators, UnbondingPurses, ValidatorWeights, ARG_AMOUNT, ARG_DELEGATION_RATE, ARG_DELEGATOR, ARG_PUBLIC_KEY, ARG_VALIDATOR, - ARG_VALIDATOR_PUBLIC_KEY, ERA_ID_KEY, INITIAL_ERA_ID, METHOD_ACTIVATE_BID, + ERA_ID_KEY, INITIAL_ERA_ID, }, }, PublicKey, RuntimeArgs, SecretKey, U512, @@ -42,6 +42,7 @@ use casper_types::{ const ARG_TARGET: &str = "target"; const CONTRACT_TRANSFER_TO_ACCOUNT: &str = "transfer_to_account_u512.wasm"; +const CONTRACT_ACTIVATE_BID: &str = "activate_bid.wasm"; const CONTRACT_ADD_BID: &str = "add_bid.wasm"; const CONTRACT_WITHDRAW_BID: &str = "withdraw_bid.wasm"; const CONTRACT_DELEGATE: &str = "delegate.wasm"; @@ -1751,11 +1752,10 @@ fn should_undelegate_delegators_when_validator_fully_unbonds() { #[test] fn should_handle_evictions() { let activate_bid = |builder: &mut InMemoryWasmTestBuilder, validator_public_key: PublicKey| { - let auction = builder.get_auction_contract_hash(); - let run_request = ExecuteRequestBuilder::contract_call_by_hash( + const ARG_VALIDATOR_PUBLIC_KEY: &str = "validator_public_key"; + let run_request = ExecuteRequestBuilder::standard( AccountHash::from(&validator_public_key), - auction, - METHOD_ACTIVATE_BID, + CONTRACT_ACTIVATE_BID, runtime_args! { ARG_VALIDATOR_PUBLIC_KEY => validator_public_key, }, diff --git a/smart_contracts/contracts/client/activate-bid/Cargo.toml b/smart_contracts/contracts/client/activate-bid/Cargo.toml new file mode 100644 index 0000000000..f580a83e07 --- /dev/null +++ b/smart_contracts/contracts/client/activate-bid/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "activate-bid" +version = "0.1.0" +authors = ["Henry Till "] +edition = "2018" + +[[bin]] +name = "activate_bid" +path = "src/main.rs" +bench = false +doctest = false +test = false + +[features] +std = ["casper-contract/std", "casper-types/std"] + +[dependencies] +casper-contract = { path = "../../../contract" } +casper-types = { path = "../../../../types" } diff --git a/smart_contracts/contracts/client/activate-bid/src/main.rs b/smart_contracts/contracts/client/activate-bid/src/main.rs new file mode 100644 index 0000000000..54adc08ee4 --- /dev/null +++ b/smart_contracts/contracts/client/activate-bid/src/main.rs @@ -0,0 +1,24 @@ +#![no_std] +#![no_main] + +extern crate alloc; + +use casper_contract::contract_api::{runtime, system}; +use casper_types::{runtime_args, system::auction, PublicKey, RuntimeArgs}; + +const ARG_VALIDATOR_PUBLIC_KEY: &str = "validator_public_key"; + +fn activate_bid(public_key: PublicKey) { + let contract_hash = system::get_auction(); + let args = runtime_args! { + auction::ARG_VALIDATOR_PUBLIC_KEY => public_key, + }; + runtime::call_contract::<()>(contract_hash, auction::METHOD_ACTIVATE_BID, args); +} + +// Accepts a public key. Issues an activate-bid bid to the auction contract. +#[no_mangle] +pub extern "C" fn call() { + let public_key: PublicKey = runtime::get_named_arg(ARG_VALIDATOR_PUBLIC_KEY); + activate_bid(public_key); +} From c83df2d12b647f5ed425aa7b381b075e03f5c4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Tue, 16 Mar 2021 17:52:26 +0100 Subject: [PATCH 21/28] HWY-271: Log synchronizer queue size. --- .../components/consensus/protocols/highway.rs | 21 ++++++++- .../protocols/highway/synchronizer.rs | 45 ++++++++++++++++++- .../protocols/highway/synchronizer/tests.rs | 3 +- .../consensus/protocols/highway/tests.rs | 7 ++- 4 files changed, 70 insertions(+), 6 deletions(-) diff --git a/node/src/components/consensus/protocols/highway.rs b/node/src/components/consensus/protocols/highway.rs index 142635b51f..c9d7564a9d 100644 --- a/node/src/components/consensus/protocols/highway.rs +++ b/node/src/components/consensus/protocols/highway.rs @@ -51,6 +51,8 @@ const TIMER_ID_VERTEX_WITH_FUTURE_TIMESTAMP: TimerId = TimerId(1); const TIMER_ID_PURGE_VERTICES: TimerId = TimerId(2); /// The timer for logging inactive validators. const TIMER_ID_LOG_PARTICIPATION: TimerId = TimerId(3); +/// The timer for logging synchronizer queue size. +const TIMER_ID_SYNCHRONIZER_QUEUE: TimerId = TimerId(4); /// The action of adding a vertex from the `vertices_to_be_added` queue. const ACTION_ID_VERTEX: ActionId = ActionId(0); @@ -154,6 +156,10 @@ impl HighwayProtocol { now + TimeDiff::from(60_000), TIMER_ID_LOG_PARTICIPATION, ), + ProtocolOutcome::ScheduleTimer( + now + TimeDiff::from(5_000), + TIMER_ID_SYNCHRONIZER_QUEUE, + ), ]; // If there's a chance that we start after the era is finished… @@ -183,7 +189,7 @@ impl HighwayProtocol { finality_detector: FinalityDetector::new(ftt), highway: Highway::new(instance_id, validators, params), round_success_meter, - synchronizer: Synchronizer::new(config.pending_vertex_timeout), + synchronizer: Synchronizer::new(config.pending_vertex_timeout, instance_id), evidence_only: false, }); (hw_proto, outcomes) @@ -607,6 +613,15 @@ where vec![] } } + TIMER_ID_SYNCHRONIZER_QUEUE => { + self.synchronizer.log_len(); + if !self.finalized_switch_block() { + let next_timer = Timestamp::now() + TimeDiff::from(5_000); + vec![ProtocolOutcome::ScheduleTimer(next_timer, timer_id)] + } else { + vec![] + } + } _ => unreachable!("unexpected timer ID"), } } @@ -761,6 +776,10 @@ where now + TimeDiff::from(60_000), TIMER_ID_LOG_PARTICIPATION, ), + ProtocolOutcome::ScheduleTimer( + now + TimeDiff::from(5_000), + TIMER_ID_SYNCHRONIZER_QUEUE, + ), ]; if self.highway.is_active() { diff --git a/node/src/components/consensus/protocols/highway/synchronizer.rs b/node/src/components/consensus/protocols/highway/synchronizer.rs index 1331138ca8..c47be743a4 100644 --- a/node/src/components/consensus/protocols/highway/synchronizer.rs +++ b/node/src/components/consensus/protocols/highway/synchronizer.rs @@ -6,6 +6,7 @@ use std::{ use datasize::DataSize; use itertools::Itertools; +use tracing::debug; use crate::{ components::consensus::{ @@ -77,6 +78,11 @@ impl PendingVertices { self.0.retain(|pvv, _| pvv.inner().is_evidence()); } + /// Returns number of unique vertices pending in the queue. + pub(crate) fn len(&self) -> u64 { + self.0.len() as u64 + } + fn is_empty(&self) -> bool { self.0.is_empty() } @@ -151,16 +157,22 @@ where vertices_to_be_added: PendingVertices, /// The duration for which incoming vertices with missing dependencies are kept in a queue. pending_vertex_timeout: TimeDiff, + /// Instance ID of an era for which this synchronizer is constructed for. + era_id: C::InstanceId, + /// Boolean flag indicating whether we're synchronizing current era. + pub(crate) current_era: bool, } impl Synchronizer { /// Creates a new synchronizer with the specified timeout for pending vertices. - pub(crate) fn new(pending_vertex_timeout: TimeDiff) -> Self { + pub(crate) fn new(pending_vertex_timeout: TimeDiff, era_id: C::InstanceId) -> Self { Synchronizer { vertex_deps: BTreeMap::new(), vertices_to_be_added_later: BTreeMap::new(), vertices_to_be_added: Default::default(), pending_vertex_timeout, + era_id, + current_era: true, } } @@ -172,6 +184,35 @@ impl Synchronizer { Self::remove_expired(&mut self.vertex_deps, oldest); } + // Returns number of elements in the `verties_to_be_added_later` queue. + // Every pending vertex is counted once, even if it has multiple senders. + fn vertices_to_be_added_later_len(&self) -> u64 { + self.vertices_to_be_added_later + .iter() + .map(|(_, pv)| pv.len()) + .sum() + } + + // Returns number of elements in `vertex_deps` queue. + fn vertex_deps_len(&self) -> u64 { + self.vertex_deps.iter().map(|(_, pv)| pv.len()).sum() + } + + // Returns number of elements in `vertices_to_be_added` queue. + fn vertices_to_be_added_len(&self) -> u64 { + self.vertices_to_be_added.len() + } + + pub(crate) fn log_len(&self) { + debug!( + era_id = ?self.era_id, + vertices_to_be_added_later = self.vertices_to_be_added_later_len(), + vertex_deps = self.vertex_deps_len(), + vertices_to_be_added = self.vertices_to_be_added_len(), + "synchronizer queue lengths" + ); + } + /// Store a (pre-validated) vertex which will be added later. This creates a timer to be sent /// to the reactor. The vertex be added using `Self::add_vertices` when that timer goes off. pub(crate) fn store_vertex_for_addition_later( @@ -278,7 +319,7 @@ impl Synchronizer { } /// Adds a vertex with a known missing dependency to the queue. - pub(crate) fn add_missing_dependency(&mut self, dep: Dependency, pv: PendingVertex) { + fn add_missing_dependency(&mut self, dep: Dependency, pv: PendingVertex) { self.vertex_deps.entry(dep).or_default().push(pv) } diff --git a/node/src/components/consensus/protocols/highway/synchronizer/tests.rs b/node/src/components/consensus/protocols/highway/synchronizer/tests.rs index eec9820483..eab502239e 100644 --- a/node/src/components/consensus/protocols/highway/synchronizer/tests.rs +++ b/node/src/components/consensus/protocols/highway/synchronizer/tests.rs @@ -39,7 +39,8 @@ fn purge_vertices() { let peer0 = NodeId(0); // Create a synchronizer with a 0x20 ms timeout, and a Highway instance. - let mut sync = Synchronizer::::new(0x20.into()); + let mut sync = + Synchronizer::::new(0x20.into(), TEST_INSTANCE_ID); let mut highway = Highway::::new(TEST_INSTANCE_ID, test_validators(), params); // At time 0x20, we receive c2, b0 and b1 — the latter ahead of their timestamp. diff --git a/node/src/components/consensus/protocols/highway/tests.rs b/node/src/components/consensus/protocols/highway/tests.rs index 1686f6e989..8c74250e15 100644 --- a/node/src/components/consensus/protocols/highway/tests.rs +++ b/node/src/components/consensus/protocols/highway/tests.rs @@ -86,9 +86,12 @@ where 0, start_timestamp, ); - // We expect only the vertex purge timer and participation log timer outcomes. + // We expect for messages: + // * log participation timer, + // * log synchronizer queue length timer, + // * purge synchronizer queue timer, // If there are more, the tests might need to handle them. - assert_eq!(2, outcomes.len()); + assert_eq!(3, outcomes.len()); hw_proto } From c7612f9a12434a80a6816f53e05b1dce0a01a2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Fri, 19 Mar 2021 10:50:04 +0100 Subject: [PATCH 22/28] HWY-271: Cargo fmt. --- .../consensus/protocols/highway/synchronizer/tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/src/components/consensus/protocols/highway/synchronizer/tests.rs b/node/src/components/consensus/protocols/highway/synchronizer/tests.rs index eab502239e..6040c182cd 100644 --- a/node/src/components/consensus/protocols/highway/synchronizer/tests.rs +++ b/node/src/components/consensus/protocols/highway/synchronizer/tests.rs @@ -39,8 +39,7 @@ fn purge_vertices() { let peer0 = NodeId(0); // Create a synchronizer with a 0x20 ms timeout, and a Highway instance. - let mut sync = - Synchronizer::::new(0x20.into(), TEST_INSTANCE_ID); + let mut sync = Synchronizer::::new(0x20.into(), TEST_INSTANCE_ID); let mut highway = Highway::::new(TEST_INSTANCE_ID, test_validators(), params); // At time 0x20, we receive c2, b0 and b1 — the latter ahead of their timestamp. From 654371651337c932a694cc4de79d0a7da2868b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Thu, 18 Mar 2021 14:38:00 +0100 Subject: [PATCH 23/28] HWY-272: Log oldest seen panorama when syncing. --- .../consensus/highway_core/highway/vertex.rs | 8 ++++++ .../consensus/highway_core/validators.rs | 19 ++++++++++++++ .../components/consensus/protocols/highway.rs | 7 +++++- .../protocols/highway/synchronizer.rs | 25 +++++++++++++++++-- .../protocols/highway/synchronizer/tests.rs | 3 ++- 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/node/src/components/consensus/highway_core/highway/vertex.rs b/node/src/components/consensus/highway_core/highway/vertex.rs index 3efd9d464e..f8c4fa25fe 100644 --- a/node/src/components/consensus/highway_core/highway/vertex.rs +++ b/node/src/components/consensus/highway_core/highway/vertex.rs @@ -80,6 +80,14 @@ impl Vertex { } } + /// Returns the seq number of this vertex (if it is a unit). + pub(crate) fn unit_seq_number(&self) -> Option { + match self { + Vertex::Unit(swunit) => Some(swunit.wire_unit().seq_number), + _ => None, + } + } + /// Returns whether this is evidence, as opposed to other types of vertices. pub(crate) fn is_evidence(&self) -> bool { matches!(self, Vertex::Evidence(_)) diff --git a/node/src/components/consensus/highway_core/validators.rs b/node/src/components/consensus/highway_core/validators.rs index 0644466eec..f3e3cf9fce 100644 --- a/node/src/components/consensus/highway_core/validators.rs +++ b/node/src/components/consensus/highway_core/validators.rs @@ -142,6 +142,25 @@ impl fmt::Display for Validators { #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, AsRef, From, Hash)] pub(crate) struct ValidatorMap(Vec); +impl fmt::Display for ValidatorMap> +where + T: fmt::Display, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let view = self + .0 + .iter() + .map(|maybe_el| match maybe_el { + None => "N".to_string(), + Some(el) => format!("{}", el), + }) + .collect::>() + .join(", "); + write!(f, "OldestSeen({})", view)?; + Ok(()) + } +} + impl DataSize for ValidatorMap where T: DataSize, diff --git a/node/src/components/consensus/protocols/highway.rs b/node/src/components/consensus/protocols/highway.rs index c9d7564a9d..d919787017 100644 --- a/node/src/components/consensus/protocols/highway.rs +++ b/node/src/components/consensus/protocols/highway.rs @@ -87,6 +87,7 @@ impl HighwayProtocol { seed: u64, now: Timestamp, ) -> (Box>, ProtocolOutcomes) { + let validators_count = validator_stakes.len(); let sum_stakes: U512 = validator_stakes.iter().map(|(_, stake)| *stake).sum(); assert!( !sum_stakes.is_zero(), @@ -189,7 +190,11 @@ impl HighwayProtocol { finality_detector: FinalityDetector::new(ftt), highway: Highway::new(instance_id, validators, params), round_success_meter, - synchronizer: Synchronizer::new(config.pending_vertex_timeout, instance_id), + synchronizer: Synchronizer::new( + config.pending_vertex_timeout, + validators_count, + instance_id, + ), evidence_only: false, }); (hw_proto, outcomes) diff --git a/node/src/components/consensus/protocols/highway/synchronizer.rs b/node/src/components/consensus/protocols/highway/synchronizer.rs index c47be743a4..571a1e58c1 100644 --- a/node/src/components/consensus/protocols/highway/synchronizer.rs +++ b/node/src/components/consensus/protocols/highway/synchronizer.rs @@ -11,7 +11,10 @@ use tracing::debug; use crate::{ components::consensus::{ consensus_protocol::ProtocolOutcome, - highway_core::highway::{Dependency, Highway, PreValidatedVertex, Vertex}, + highway_core::{ + highway::{Dependency, Highway, PreValidatedVertex, Vertex}, + validators::ValidatorMap, + }, traits::{Context, NodeIdT}, }, types::{TimeDiff, Timestamp}, @@ -159,18 +162,26 @@ where pending_vertex_timeout: TimeDiff, /// Instance ID of an era for which this synchronizer is constructed for. era_id: C::InstanceId, + oldest_seen_panorama: ValidatorMap>, /// Boolean flag indicating whether we're synchronizing current era. pub(crate) current_era: bool, } impl Synchronizer { /// Creates a new synchronizer with the specified timeout for pending vertices. - pub(crate) fn new(pending_vertex_timeout: TimeDiff, era_id: C::InstanceId) -> Self { + pub(crate) fn new( + pending_vertex_timeout: TimeDiff, + validator_len: usize, + era_id: C::InstanceId, + ) -> Self { Synchronizer { vertex_deps: BTreeMap::new(), vertices_to_be_added_later: BTreeMap::new(), vertices_to_be_added: Default::default(), pending_vertex_timeout, + oldest_seen_panorama: ValidatorMap::from( + iter::repeat(None).take(validator_len).collect_vec(), + ), era_id, current_era: true, } @@ -211,6 +222,7 @@ impl Synchronizer { vertices_to_be_added = self.vertices_to_be_added_len(), "synchronizer queue lengths" ); + debug!(oldest_panorama=%self.oldest_seen_panorama, "oldest seen unit per validator"); } /// Store a (pre-validated) vertex which will be added later. This creates a timer to be sent @@ -264,10 +276,19 @@ impl Synchronizer { pvv: PreValidatedVertex, now: Timestamp, ) -> ProtocolOutcomes { + self.update_last_seen(&pvv); let pv = PendingVertex::new(sender, pvv, now); self.schedule_add_vertices(iter::once(pv)) } + fn update_last_seen(&mut self, pvv: &PreValidatedVertex) { + let v = pvv.inner(); + if let (Some(v_id), Some(seq_num)) = (v.creator(), v.unit_seq_number()) { + let prev_seq_num = self.oldest_seen_panorama[v_id].unwrap_or(u64::MAX); + self.oldest_seen_panorama[v_id] = Some(prev_seq_num.min(seq_num)); + } + } + /// Moves all vertices whose known missing dependency is now satisfied into the /// `vertices_to_be_added` queue. pub(crate) fn remove_satisfied_deps(&mut self, highway: &Highway) -> ProtocolOutcomes { diff --git a/node/src/components/consensus/protocols/highway/synchronizer/tests.rs b/node/src/components/consensus/protocols/highway/synchronizer/tests.rs index 6040c182cd..422d1bb495 100644 --- a/node/src/components/consensus/protocols/highway/synchronizer/tests.rs +++ b/node/src/components/consensus/protocols/highway/synchronizer/tests.rs @@ -39,7 +39,8 @@ fn purge_vertices() { let peer0 = NodeId(0); // Create a synchronizer with a 0x20 ms timeout, and a Highway instance. - let mut sync = Synchronizer::::new(0x20.into(), TEST_INSTANCE_ID); + let mut sync = + Synchronizer::::new(0x20.into(), WEIGHTS.len(), TEST_INSTANCE_ID); let mut highway = Highway::::new(TEST_INSTANCE_ID, test_validators(), params); // At time 0x20, we receive c2, b0 and b1 — the latter ahead of their timestamp. From 0a9a01fb6570e0dbd21236720e8faa2c30a529c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20G=C3=B3rski?= Date: Fri, 19 Mar 2021 12:17:38 +0100 Subject: [PATCH 24/28] HWY-272: Address review comments. --- .../consensus/protocols/highway/synchronizer.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/node/src/components/consensus/protocols/highway/synchronizer.rs b/node/src/components/consensus/protocols/highway/synchronizer.rs index 571a1e58c1..5025ac9668 100644 --- a/node/src/components/consensus/protocols/highway/synchronizer.rs +++ b/node/src/components/consensus/protocols/highway/synchronizer.rs @@ -162,6 +162,8 @@ where pending_vertex_timeout: TimeDiff, /// Instance ID of an era for which this synchronizer is constructed for. era_id: C::InstanceId, + /// Keeps track of the lowest/oldest seen unit per validator when syncing. + /// Used only for logging. oldest_seen_panorama: ValidatorMap>, /// Boolean flag indicating whether we're synchronizing current era. pub(crate) current_era: bool, @@ -222,7 +224,16 @@ impl Synchronizer { vertices_to_be_added = self.vertices_to_be_added_len(), "synchronizer queue lengths" ); - debug!(oldest_panorama=%self.oldest_seen_panorama, "oldest seen unit per validator"); + // All units seen have seq_number == 0. + let all_lowest = self + .oldest_seen_panorama + .iter() + .all(|entry| entry.map(|seq_num| seq_num == 0).unwrap_or(false)); + if all_lowest { + debug!("all seen units while synchronization with seq_num=0"); + } else { + debug!(oldest_panorama=%self.oldest_seen_panorama, "oldest seen unit per validator"); + } } /// Store a (pre-validated) vertex which will be added later. This creates a timer to be sent From 769d002b01848b7965a63d4a7aa43e87a8b20344 Mon Sep 17 00:00:00 2001 From: Joe Sacher <321623+sacherjj@users.noreply.github.com> Date: Fri, 19 Mar 2021 10:56:19 -0400 Subject: [PATCH 25/28] Update @casper/contract to casper-contract. --- smart_contracts/contract_as/README.md | 6 +++--- smart_contracts/contract_as/package-lock.json | 2 +- smart_contracts/contract_as/package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/smart_contracts/contract_as/README.md b/smart_contracts/contract_as/README.md index 417f6f9ff0..93ec608bab 100644 --- a/smart_contracts/contract_as/README.md +++ b/smart_contracts/contract_as/README.md @@ -1,4 +1,4 @@ -# @casper/contract +# casper-contract This package allows a distributed app developer to create smart contracts for the open source [Casper](https://github.com/CasperLabs/casper-node) project using [AssemblyScript](https://www.npmjs.com/package/assemblyscript). @@ -19,7 +19,7 @@ Then install assembly script and this package in the project directory. ``` npm install --save-dev assemblyscript@0.9.1 -npm install --save @casper/contract +npm install --save casper-contract ``` ## Usage @@ -73,7 +73,7 @@ You can use the following sample snippet which demonstrates a very simple smart ```typescript //@ts-nocheck -import {Error, ErrorCode} from "@casper/contract/error"; +import {Error, ErrorCode} from "casper-contract/error"; // simplest possible feedback loop export function call(): void { diff --git a/smart_contracts/contract_as/package-lock.json b/smart_contracts/contract_as/package-lock.json index d171257b7c..eea3eef720 100644 --- a/smart_contracts/contract_as/package-lock.json +++ b/smart_contracts/contract_as/package-lock.json @@ -1,5 +1,5 @@ { - "name": "@casper/contract", + "name": "casper-contract", "version": "0.9.3", "lockfileVersion": 1, "requires": true, diff --git a/smart_contracts/contract_as/package.json b/smart_contracts/contract_as/package.json index ec2fe5bcae..023d4cfd64 100644 --- a/smart_contracts/contract_as/package.json +++ b/smart_contracts/contract_as/package.json @@ -1,5 +1,5 @@ { - "name": "@casper/contract", + "name": "casper-contract", "version": "0.9.3", "description": "Library for developing Casper smart contracts.", "main": "index.js", From 7358c918492d084de9892270233f0ab2df56aa08 Mon Sep 17 00:00:00 2001 From: Joe Sacher <321623+sacherjj@users.noreply.github.com> Date: Fri, 19 Mar 2021 14:09:38 -0400 Subject: [PATCH 26/28] Bump version to 0.9.4 --- Cargo.lock | 63 +++++++++---------- client/Cargo.toml | 8 +-- execution_engine/Cargo.toml | 4 +- execution_engine/src/lib.rs | 2 +- .../cargo_casper/Cargo.toml | 2 +- .../cargo_casper/src/common.rs | 4 +- .../cargo_casper/src/tests_package.rs | 2 +- .../test_support/Cargo.toml | 8 +-- .../test_support/src/lib.rs | 2 +- node/Cargo.toml | 8 +-- node/src/lib.rs | 2 +- node_macros/Cargo.toml | 2 +- node_macros/src/lib.rs | 2 +- smart_contracts/contract/Cargo.toml | 4 +- smart_contracts/contract/src/lib.rs | 2 +- smart_contracts/contract_as/package-lock.json | 2 +- smart_contracts/contract_as/package.json | 2 +- types/Cargo.toml | 2 +- types/src/lib.rs | 2 +- 19 files changed, 61 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e63867c57..a281eee266 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -642,7 +642,7 @@ checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" [[package]] name = "cargo-casper" -version = "0.9.3" +version = "0.9.4" dependencies = [ "assert_cmd", "clap", @@ -654,7 +654,7 @@ dependencies = [ [[package]] name = "casper-client" -version = "0.9.3" +version = "0.9.4" dependencies = [ "anyhow", "base64 0.13.0", @@ -684,7 +684,7 @@ dependencies = [ [[package]] name = "casper-contract" -version = "0.9.3" +version = "0.9.4" dependencies = [ "casper-types", "hex_fmt", @@ -695,7 +695,7 @@ dependencies = [ [[package]] name = "casper-engine-test-support" -version = "0.9.3" +version = "0.9.4" dependencies = [ "casper-contract", "casper-execution-engine", @@ -736,7 +736,7 @@ dependencies = [ [[package]] name = "casper-execution-engine" -version = "0.9.3" +version = "0.9.4" dependencies = [ "anyhow", "assert_matches", @@ -780,7 +780,7 @@ dependencies = [ [[package]] name = "casper-node" -version = "0.9.3" +version = "0.9.4" dependencies = [ "ansi_term 0.12.1", "anyhow", @@ -875,7 +875,7 @@ dependencies = [ [[package]] name = "casper-node-macros" -version = "0.9.3" +version = "0.9.4" dependencies = [ "Inflector", "indexmap", @@ -886,7 +886,7 @@ dependencies = [ [[package]] name = "casper-types" -version = "0.9.3" +version = "0.9.4" dependencies = [ "base16", "base64 0.13.0", @@ -2802,9 +2802,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b07a082330a35e43f63177cc01689da34fbffa0105e1246cf0311472cac73a" +checksum = "538c092e5586f4cdd7dd8078c4a79220e3e168880218124dcbce860f0ea938c6" [[package]] name = "libp2p" @@ -3700,15 +3700,15 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.32" +version = "0.10.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" +checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577" dependencies = [ "bitflags 1.2.1", "cfg-if 1.0.0", "foreign-types", - "lazy_static", "libc", + "once_cell", "openssl-sys", ] @@ -3729,9 +3729,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.60" +version = "0.9.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" +checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" dependencies = [ "autocfg", "cc", @@ -4525,14 +4525,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.3" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] @@ -4547,9 +4546,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "remove-associated-key" @@ -4855,9 +4854,9 @@ dependencies = [ [[package]] name = "serde-big-array" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f791855a30ea300749cd42f29761707665a2166c8550be67adbfeb78c62195" +checksum = "18b20e7752957bbe9661cff4e0bb04d183d0948cdab2ea58cdb9df36a61dfe62" dependencies = [ "serde", "serde_derive", @@ -5192,9 +5191,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd9bc7ccc2688b3344c2f48b9b546648b25ce0b20fc717ee7fa7981a8ca9717" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" dependencies = [ "proc-macro2", "quote", @@ -5642,9 +5641,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41768be5b9f3489491825f56f01f25290aa1d3e7cc97e182d4d34360493ba6fa" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" dependencies = [ "proc-macro2", "quote", @@ -5693,9 +5692,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ab8966ac3ca27126141f7999361cc97dd6fb4b71da04c02044fa9045d98bb96" +checksum = "705096c6f83bf68ea5d357a6aa01829ddbdac531b357b45abeca842938085baa" dependencies = [ "ansi_term 0.12.1", "chrono", @@ -5879,9 +5878,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "ucd-trie" @@ -6077,9 +6076,9 @@ dependencies = [ [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "void" diff --git a/client/Cargo.toml b/client/Cargo.toml index 7a7e5543fd..3b4d9f9a05 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "casper-client" -version = "0.9.3" +version = "0.9.4" authors = ["Marc Brinkmann ", "Fraser Hutchison "] edition = "2018" description = "A client for interacting with the Casper network" @@ -22,9 +22,9 @@ doc = false [dependencies] base64 = "0.13.0" -casper-execution-engine = { version = "0.9.3", path = "../execution_engine" } -casper-node = { version = "0.9.3", path = "../node" } -casper-types = { version = "0.9.3", path = "../types", features = ["std"] } +casper-execution-engine = { version = "0.9.4", path = "../execution_engine" } +casper-node = { version = "0.9.4", path = "../node" } +casper-types = { version = "0.9.4", path = "../types", features = ["std"] } clap = "2.33.1" futures = "0.3.5" hex = { version = "0.4.2", features = ["serde"] } diff --git a/execution_engine/Cargo.toml b/execution_engine/Cargo.toml index bbc2c55670..3193386257 100644 --- a/execution_engine/Cargo.toml +++ b/execution_engine/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "casper-execution-engine" -version = "0.9.3" # when updating, also update 'html_root_url' in lib.rs +version = "0.9.4" # when updating, also update 'html_root_url' in lib.rs authors = ["Henry Till ", "Ed Hastings "] edition = "2018" description = "CasperLabs execution engine crates." @@ -15,7 +15,7 @@ anyhow = "1.0.33" base16 = "0.2.1" bincode = "1.3.1" blake2 = "0.9.0" -casper-types = { version = "0.9.3", path = "../types", features = ["std", "gens"] } +casper-types = { version = "0.9.4", path = "../types", features = ["std", "gens"] } chrono = "0.4.10" datasize = "0.2.4" hex = "0.4.2" diff --git a/execution_engine/src/lib.rs b/execution_engine/src/lib.rs index e7ccc9c3e3..13a6398217 100644 --- a/execution_engine/src/lib.rs +++ b/execution_engine/src/lib.rs @@ -1,6 +1,6 @@ //! The engine which executes smart contracts on the Casper network. -#![doc(html_root_url = "https://docs.rs/casper-execution-engine/0.9.3")] +#![doc(html_root_url = "https://docs.rs/casper-execution-engine/0.9.4")] #![doc( html_favicon_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Favicon_RGB_50px.png", html_logo_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Symbol_RGB.png", diff --git a/execution_engine_testing/cargo_casper/Cargo.toml b/execution_engine_testing/cargo_casper/Cargo.toml index 27b2ae7ae0..894bfbf56e 100644 --- a/execution_engine_testing/cargo_casper/Cargo.toml +++ b/execution_engine_testing/cargo_casper/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-casper" -version = "0.9.3" +version = "0.9.4" authors = ["Fraser Hutchison "] edition = "2018" description = "Command line tool for creating a Wasm smart contract and tests for use on the Casper network." diff --git a/execution_engine_testing/cargo_casper/src/common.rs b/execution_engine_testing/cargo_casper/src/common.rs index e03e059b8e..6c47238390 100644 --- a/execution_engine_testing/cargo_casper/src/common.rs +++ b/execution_engine_testing/cargo_casper/src/common.rs @@ -12,9 +12,9 @@ use once_cell::sync::Lazy; use crate::{dependency::Dependency, ARGS, FAILURE_EXIT_CODE}; pub static CL_CONTRACT: Lazy = - Lazy::new(|| Dependency::new("casper-contract", "0.9.3", "smart_contracts/contract")); + Lazy::new(|| Dependency::new("casper-contract", "0.9.4", "smart_contracts/contract")); pub static CL_TYPES: Lazy = - Lazy::new(|| Dependency::new("casper-types", "0.9.3", "types")); + Lazy::new(|| Dependency::new("casper-types", "0.9.4", "types")); pub fn print_error_and_exit(msg: &str) -> ! { e_red!("error"); diff --git a/execution_engine_testing/cargo_casper/src/tests_package.rs b/execution_engine_testing/cargo_casper/src/tests_package.rs index 110d28163a..91df99b39b 100644 --- a/execution_engine_testing/cargo_casper/src/tests_package.rs +++ b/execution_engine_testing/cargo_casper/src/tests_package.rs @@ -114,7 +114,7 @@ static INTEGRATION_TESTS_RS: Lazy = Lazy::new(|| { static ENGINE_TEST_SUPPORT: Lazy = Lazy::new(|| { Dependency::new( "casper-engine-test-support", - "0.9.3", + "0.9.4", "execution_engine_testing/test_support", ) }); diff --git a/execution_engine_testing/test_support/Cargo.toml b/execution_engine_testing/test_support/Cargo.toml index fb6ce2ede1..566d10bc78 100644 --- a/execution_engine_testing/test_support/Cargo.toml +++ b/execution_engine_testing/test_support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "casper-engine-test-support" -version = "0.9.3" # when updating, also update 'html_root_url' in lib.rs +version = "0.9.4" # when updating, also update 'html_root_url' in lib.rs authors = ["Fraser Hutchison "] edition = "2018" description = "Library to support testing of Wasm smart contracts for use on the Casper network." @@ -11,9 +11,9 @@ repository = "https://github.com/CasperLabs/casper-node/tree/master/execution_en license-file = "../../LICENSE" [dependencies] -casper-contract = { version = "0.9.3", path = "../../smart_contracts/contract", features = ["std"] } -casper-execution-engine = { version = "0.9.3", path = "../../execution_engine", features = ["gens"] } -casper-types = { version = "0.9.3", path = "../../types", features = ["std"] } +casper-contract = { version = "0.9.4", path = "../../smart_contracts/contract", features = ["std"] } +casper-execution-engine = { version = "0.9.4", path = "../../execution_engine", features = ["gens"] } +casper-types = { version = "0.9.4", path = "../../types", features = ["std"] } lmdb = "0.8.0" log = "0.4.8" num-rational = "0.3.0" diff --git a/execution_engine_testing/test_support/src/lib.rs b/execution_engine_testing/test_support/src/lib.rs index c1e67f95e0..01e5ba7401 100644 --- a/execution_engine_testing/test_support/src/lib.rs +++ b/execution_engine_testing/test_support/src/lib.rs @@ -56,7 +56,7 @@ //! assert_eq!(expected_value, returned_value); //! ``` -#![doc(html_root_url = "https://docs.rs/casper-engine-test-support/0.9.3")] +#![doc(html_root_url = "https://docs.rs/casper-engine-test-support/0.9.4")] #![doc( html_favicon_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Favicon_RGB_50px.png", html_logo_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Symbol_RGB.png", diff --git a/node/Cargo.toml b/node/Cargo.toml index 5cc9027e03..bc8e0fb107 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "casper-node" -version = "0.9.3" # when updating, also update 'html_root_url' in lib.rs +version = "0.9.4" # when updating, also update 'html_root_url' in lib.rs authors = ["Marc Brinkmann ", "Fraser Hutchison "] edition = "2018" description = "The Casper blockchain node" @@ -19,9 +19,9 @@ base16 = "0.2.1" base64 = "0.13.0" bincode = "1.3.1" blake2 = { version = "0.9.0", default-features = false } -casper-execution-engine = { version = "0.9.3", path = "../execution_engine" } -casper-node-macros = { version = "0.9.3", path = "../node_macros" } -casper-types = { version = "0.9.3", path = "../types", features = ["std", "gens"] } +casper-execution-engine = { version = "0.9.4", path = "../execution_engine" } +casper-node-macros = { version = "0.9.4", path = "../node_macros" } +casper-types = { version = "0.9.4", path = "../types", features = ["std", "gens"] } chrono = "0.4.10" datasize = { version = "0.2.9", features = ["detailed", "fake_clock-types", "futures-types", "smallvec-types", "tokio-types"] } derive_more = "0.99.7" diff --git a/node/src/lib.rs b/node/src/lib.rs index e51da16853..3ff402830a 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -8,7 +8,7 @@ //! While the [`main`](fn.main.html) function is the central entrypoint for the node application, //! its core event loop is found inside the [reactor](reactor/index.html). -#![doc(html_root_url = "https://docs.rs/casper-node/0.9.3")] +#![doc(html_root_url = "https://docs.rs/casper-node/0.9.4")] #![doc( html_favicon_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Favicon_RGB_50px.png", html_logo_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Symbol_RGB.png", diff --git a/node_macros/Cargo.toml b/node_macros/Cargo.toml index c58db21303..feb728c0cc 100644 --- a/node_macros/Cargo.toml +++ b/node_macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "casper-node-macros" -version = "0.9.3" +version = "0.9.4" authors = ["Marc Brinkmann "] edition = "2018" description = "A macro to create reactor implementations for the casper-node." diff --git a/node_macros/src/lib.rs b/node_macros/src/lib.rs index 9e3ae2caa6..6bf14be908 100644 --- a/node_macros/src/lib.rs +++ b/node_macros/src/lib.rs @@ -1,6 +1,6 @@ //! Generates reactors with routing from concise definitions. See `README.md` for details. -#![doc(html_root_url = "https://docs.rs/casper-node-macros/0.9.3")] +#![doc(html_root_url = "https://docs.rs/casper-node-macros/0.9.4")] #![doc( html_favicon_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Favicon_RGB_50px.png", html_logo_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Symbol_RGB.png", diff --git a/smart_contracts/contract/Cargo.toml b/smart_contracts/contract/Cargo.toml index ed2b735b86..8cee051ae0 100644 --- a/smart_contracts/contract/Cargo.toml +++ b/smart_contracts/contract/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "casper-contract" -version = "0.9.3" # when updating, also update 'html_root_url' in lib.rs +version = "0.9.4" # when updating, also update 'html_root_url' in lib.rs authors = ["Michael Birch ", "Mateusz Górski "] edition = "2018" description = "Library for developing Casper smart contracts." @@ -11,7 +11,7 @@ repository = "https://github.com/CasperLabs/casper-node/tree/master/smart_contra license-file = "../../LICENSE" [dependencies] -casper-types = { version = "0.9.3", path = "../../types" } +casper-types = { version = "0.9.4", path = "../../types" } hex_fmt = "0.3.0" thiserror = "1.0.18" version-sync = { version = "0.9", optional = true } diff --git a/smart_contracts/contract/src/lib.rs b/smart_contracts/contract/src/lib.rs index a9cdccec78..61d930a5cf 100644 --- a/smart_contracts/contract/src/lib.rs +++ b/smart_contracts/contract/src/lib.rs @@ -53,7 +53,7 @@ not(feature = "std"), feature(alloc_error_handler, core_intrinsics, lang_items) )] -#![doc(html_root_url = "https://docs.rs/casper-contract/0.9.3")] +#![doc(html_root_url = "https://docs.rs/casper-contract/0.9.4")] #![doc( html_favicon_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Favicon_RGB_50px.png", html_logo_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Symbol_RGB.png", diff --git a/smart_contracts/contract_as/package-lock.json b/smart_contracts/contract_as/package-lock.json index eea3eef720..66a32e2c6a 100644 --- a/smart_contracts/contract_as/package-lock.json +++ b/smart_contracts/contract_as/package-lock.json @@ -1,6 +1,6 @@ { "name": "casper-contract", - "version": "0.9.3", + "version": "0.9.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/smart_contracts/contract_as/package.json b/smart_contracts/contract_as/package.json index 023d4cfd64..e5085ec10e 100644 --- a/smart_contracts/contract_as/package.json +++ b/smart_contracts/contract_as/package.json @@ -1,6 +1,6 @@ { "name": "casper-contract", - "version": "0.9.3", + "version": "0.9.4", "description": "Library for developing Casper smart contracts.", "main": "index.js", "ascMain": "assembly/index.ts", diff --git a/types/Cargo.toml b/types/Cargo.toml index 58e6a505ae..634d45be82 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "casper-types" -version = "0.9.3" # when updating, also update 'html_root_url' in lib.rs +version = "0.9.4" # when updating, also update 'html_root_url' in lib.rs authors = ["Fraser Hutchison "] edition = "2018" description = "Types used to allow creation of Wasm contracts and tests for use on the Casper network." diff --git a/types/src/lib.rs b/types/src/lib.rs index 097e9c9936..1696b108c9 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -10,7 +10,7 @@ not(feature = "no-unstable-features"), feature(min_specialization, try_reserve) )] -#![doc(html_root_url = "https://docs.rs/casper-types/0.9.3")] +#![doc(html_root_url = "https://docs.rs/casper-types/0.9.4")] #![doc( html_favicon_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Favicon_RGB_50px.png", html_logo_url = "https://raw.githubusercontent.com/CasperLabs/casper-node/master/images/CasperLabs_Logo_Symbol_RGB.png", From aaf531fa2f78a33bf528e28c34e7bbd6c169622f Mon Sep 17 00:00:00 2001 From: TomVasile <43349666+TomVasile@users.noreply.github.com> Date: Fri, 19 Mar 2021 21:13:32 +0000 Subject: [PATCH 27/28] on-tag:new apt repo --- .drone.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.drone.yml b/.drone.yml index 651f34242b..513ad18e5f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -391,6 +391,30 @@ steps: CL_VAULT_HOST: from_secret: vault_host +- name: publish-repo-prod + image: casperlabs/aptly:latest + failure: ignore + environment: + AWS_SECRET_ACCESS_KEY: + from_secret: aptly_prod_secret_key + AWS_ACCESS_KEY_ID: + from_secret: aptly_prod_key_id + settings: + repo_name: + from_secret: aptly_prod_repo + region: + from_secret: aptly_prod_region + gpg_key: + from_secret: aptly_prod_gpg_key + gpg_pass: + from_secret: aptly_prod_gpg_pass + distribution_id: + from_secret: aptly_prod_dist_id + acl: 'public-read' + prefix: 'releases' + deb_path: './target/debian' + deb_name: '*.deb' + - name: build-upgrade-package image: casperlabs/node-build-u1804 commands: From a5dfcaf6f0ada641609b04ea5e29e3f02ac77876 Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Fri, 19 Mar 2021 23:39:03 +0000 Subject: [PATCH 28/28] NO-TICKET: fix issue for deploy validation in deploy acceptor --- node/src/components/deploy_acceptor.rs | 17 ++++++++--------- node/src/utils.rs | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/node/src/components/deploy_acceptor.rs b/node/src/components/deploy_acceptor.rs index ea1481cc89..e474aef25d 100644 --- a/node/src/components/deploy_acceptor.rs +++ b/node/src/components/deploy_acceptor.rs @@ -106,27 +106,26 @@ impl DeployAcceptor { let account_key = deploy.header().account().to_account_hash().into(); - // skip account verification if deploy not received from client or node is configured to - // not verify accounts - if !source.from_peer() || !self.verify_accounts { + // Verify account if deploy received from client and node is configured to do so. + if source.from_client() && self.verify_accounts { return effect_builder - .immediately() - .event(move |_| Event::AccountVerificationResult { + .is_verified_account(account_key) + .event(move |verified| Event::AccountVerificationResult { deploy, source, account_key, - verified: Some(true), + verified, maybe_responder, }); } effect_builder - .is_verified_account(account_key) - .event(move |verified| Event::AccountVerificationResult { + .immediately() + .event(move |_| Event::AccountVerificationResult { deploy, source, account_key, - verified, + verified: Some(true), maybe_responder, }) } diff --git a/node/src/utils.rs b/node/src/utils.rs index f30101fddd..b1f1f8d0bd 100644 --- a/node/src/utils.rs +++ b/node/src/utils.rs @@ -297,8 +297,8 @@ pub enum Source { } impl Source { - pub(crate) fn from_peer(&self) -> bool { - matches!(self, Source::Peer(_)) + pub(crate) fn from_client(&self) -> bool { + matches!(self, Source::Client) } }