Fix lots of typos.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! An implementation of "reduced tree" LMD GHOST fork choice.
|
||||
//!
|
||||
//! This algorithm was concieved at IC3 Cornell, 2019.
|
||||
//! This algorithm was conceived at IC3 Cornell, 2019.
|
||||
//!
|
||||
//! This implementation is incomplete and has known bugs. Do not use in production.
|
||||
use super::{LmdGhost, Result as SuperResult};
|
||||
@@ -147,7 +147,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Removes `current_hash` and all decendants, except `subtree_hash` and all nodes
|
||||
/// Removes `current_hash` and all descendants, except `subtree_hash` and all nodes
|
||||
/// which have `subtree_hash` as an ancestor.
|
||||
///
|
||||
/// In effect, prunes the tree so that only decendants of `subtree_hash` exist.
|
||||
|
||||
@@ -34,7 +34,7 @@ pub struct OperationPool<T: EthSpec + Default> {
|
||||
/// Map from deposit index to deposit data.
|
||||
// NOTE: We assume that there is only one deposit per index
|
||||
// because the Eth1 data is updated (at most) once per epoch,
|
||||
// and the spec doesn't seem to accomodate for re-orgs on a time-frame
|
||||
// and the spec doesn't seem to accommodate for re-orgs on a time-frame
|
||||
// longer than an epoch
|
||||
deposits: RwLock<BTreeMap<u64, Deposit>>,
|
||||
/// Map from two attestation IDs to a slashing for those IDs.
|
||||
|
||||
@@ -48,7 +48,7 @@ pub fn bench_epoch_processing_n_validators(c: &mut Criterion, validator_count: u
|
||||
"The state should have an attestation for each committee."
|
||||
);
|
||||
|
||||
// Assert that we will run the first arm of process_rewards_and_penalities
|
||||
// Assert that we will run the first arm of process_rewards_and_penalties
|
||||
let epochs_since_finality = state.next_epoch(&spec) - state.finalized_epoch;
|
||||
assert_eq!(
|
||||
epochs_since_finality, 4,
|
||||
|
||||
@@ -247,7 +247,7 @@ pub enum IndexedAttestationInvalid {
|
||||
MaxIndicesExceed(u64, usize),
|
||||
/// The validator indices were not in increasing order.
|
||||
///
|
||||
/// The error occured between the given `index` and `index + 1`
|
||||
/// The error occurred between the given `index` and `index + 1`
|
||||
BadValidatorIndicesOrdering(usize),
|
||||
/// The validator index is unknown. One cannot slash one who does not exist.
|
||||
UnknownValidator(u64),
|
||||
@@ -413,7 +413,7 @@ pub enum TransferInvalid {
|
||||
/// The `transfer.from` validator has been activated and is not withdrawable.
|
||||
///
|
||||
/// (from_validator)
|
||||
FromValidatorIneligableForTransfer(u64),
|
||||
FromValidatorIneligibleForTransfer(u64),
|
||||
/// The validators withdrawal credentials do not match `transfer.pubkey`.
|
||||
///
|
||||
/// (state_credentials, transfer_pubkey_credentials)
|
||||
|
||||
@@ -114,7 +114,7 @@ fn verify_transfer_parametric<T: EthSpec>(
|
||||
|| sender_validator.activation_eligibility_epoch == spec.far_future_epoch
|
||||
|| sender_validator.is_withdrawable_at(epoch)
|
||||
|| total_amount + spec.max_effective_balance <= sender_balance,
|
||||
Invalid::FromValidatorIneligableForTransfer(transfer.sender)
|
||||
Invalid::FromValidatorIneligibleForTransfer(transfer.sender)
|
||||
);
|
||||
|
||||
// Ensure the withdrawal credentials generated from the sender's pubkey match those stored in
|
||||
|
||||
@@ -47,7 +47,7 @@ pub fn per_epoch_processing<T: EthSpec>(
|
||||
// Crosslinks.
|
||||
let winning_root_for_shards = process_crosslinks(state, spec)?;
|
||||
|
||||
// Rewards and Penalities.
|
||||
// Rewards and Penalties.
|
||||
process_rewards_and_penalties(
|
||||
state,
|
||||
&mut validator_statuses,
|
||||
|
||||
@@ -12,7 +12,7 @@ pub fn process_slashings<T: EthSpec>(
|
||||
|
||||
let total_at_start = state.get_slashed_balance(current_epoch + 1)?;
|
||||
let total_at_end = state.get_slashed_balance(current_epoch)?;
|
||||
let total_penalities = total_at_end - total_at_start;
|
||||
let total_penalties = total_at_end - total_at_start;
|
||||
|
||||
for (index, validator) in state.validator_registry.iter().enumerate() {
|
||||
let should_penalize = current_epoch.as_usize() + T::LatestSlashedExitLength::to_usize() / 2
|
||||
@@ -22,7 +22,7 @@ pub fn process_slashings<T: EthSpec>(
|
||||
let effective_balance = state.get_effective_balance(index, spec)?;
|
||||
|
||||
let penalty = std::cmp::max(
|
||||
effective_balance * std::cmp::min(total_penalities * 3, current_total_balance)
|
||||
effective_balance * std::cmp::min(total_penalties * 3, current_total_balance)
|
||||
/ current_total_balance,
|
||||
effective_balance / spec.min_slashing_penalty_quotient,
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ use super::Error;
|
||||
use itertools::{Either, Itertools};
|
||||
use types::*;
|
||||
|
||||
/// Peforms a validator registry update, if required.
|
||||
/// Performs a validator registry update, if required.
|
||||
///
|
||||
/// Spec v0.6.3
|
||||
pub fn process_registry_updates<T: EthSpec>(
|
||||
|
||||
@@ -150,7 +150,7 @@ pub struct TotalBalances {
|
||||
/// some `BeaconState`.
|
||||
#[derive(Clone)]
|
||||
pub struct ValidatorStatuses {
|
||||
/// Information about each individual validator from the state's validator registy.
|
||||
/// Information about each individual validator from the state's validator registry.
|
||||
pub statuses: Vec<ValidatorStatus>,
|
||||
/// Summed balances for various sets of validators.
|
||||
pub total_balances: TotalBalances,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! The `Slot` and `Epoch` types are defined as newtypes over u64 to enforce type-safety between
|
||||
//! The `Slot` and `Epoch` types are defined as new types over u64 to enforce type-safety between
|
||||
//! the two types.
|
||||
//!
|
||||
//! `Slot` and `Epoch` have implementations which permit conversion, comparison and math operations
|
||||
|
||||
@@ -34,7 +34,7 @@ impl TestingDepositBuilder {
|
||||
///
|
||||
/// - `pubkey` to the signing pubkey.
|
||||
/// - `withdrawal_credentials` to the signing pubkey.
|
||||
/// - `proof_of_possesssion`
|
||||
/// - `proof_of_possession`
|
||||
pub fn sign(&mut self, keypair: &Keypair, epoch: Epoch, fork: &Fork, spec: &ChainSpec) {
|
||||
let withdrawal_credentials = Hash256::from_slice(
|
||||
&get_withdrawal_credentials(&keypair.pk, spec.bls_withdrawal_prefix_byte)[..],
|
||||
|
||||
@@ -6,7 +6,7 @@ impl TestRandom for SecretKey {
|
||||
let mut key_bytes = vec![0; 48];
|
||||
rng.fill_bytes(&mut key_bytes);
|
||||
/*
|
||||
* An `unreachable!` is used here as there's no reason why you cannot constuct a key from a
|
||||
* An `unreachable!` is used here as there's no reason why you cannot construct a key from a
|
||||
* fixed-length byte slice. Also, this should only be used during testing so a panic is
|
||||
* acceptable.
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ impl AggregateSignature {
|
||||
/// Instantiate a new AggregateSignature.
|
||||
///
|
||||
/// is_empty is false
|
||||
/// AggregateSiganture is point at infinity
|
||||
/// AggregateSignature is point at infinity
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
aggregate_signature: RawAggregateSignature::new(),
|
||||
@@ -87,7 +87,7 @@ impl AggregateSignature {
|
||||
.verify_multiple(&msg[..], domain, &aggregate_public_keys[..])
|
||||
}
|
||||
|
||||
/// Return AggregateSiganture as bytes
|
||||
/// Return AggregateSignature as bytes
|
||||
pub fn as_bytes(&self) -> Vec<u8> {
|
||||
if self.is_empty {
|
||||
return vec![0; BLS_AGG_SIG_BYTE_SIZE];
|
||||
@@ -95,7 +95,7 @@ impl AggregateSignature {
|
||||
self.aggregate_signature.as_bytes()
|
||||
}
|
||||
|
||||
/// Convert bytes to AggregateSiganture
|
||||
/// Convert bytes to AggregateSignature
|
||||
pub fn from_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {
|
||||
for byte in bytes {
|
||||
if *byte != 0 {
|
||||
@@ -114,7 +114,7 @@ impl AggregateSignature {
|
||||
Ok(Self::empty_signature())
|
||||
}
|
||||
|
||||
/// Returns if the AggregateSiganture `is_empty`
|
||||
/// Returns if the AggregateSignature `is_empty`
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.is_empty
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ pub struct BTreeOverlay {
|
||||
}
|
||||
|
||||
impl BTreeOverlay {
|
||||
/// Instantiates a new instance for `item`, where it's first chunk is `inital_offset` and has
|
||||
/// Instantiates a new instance for `item`, where it's first chunk is `initial_offset` and has
|
||||
/// the specified `depth`.
|
||||
pub fn new<T>(item: &T, initial_offset: usize, depth: usize) -> Self
|
||||
where
|
||||
|
||||
@@ -201,7 +201,7 @@ pub fn update_tree_hash_cache<T: CachedTreeHash>(
|
||||
|
||||
cache.chunk_index = new.end;
|
||||
}
|
||||
// The list has been lengthened and this is a new item that was prevously a
|
||||
// The list has been lengthened and this is a new item that was previously a
|
||||
// padding item.
|
||||
//
|
||||
// Splice the tree for the new item over the padding chunk.
|
||||
@@ -268,7 +268,7 @@ pub fn update_tree_hash_cache<T: CachedTreeHash>(
|
||||
// This leaf was padding in both lists, there's nothing to do.
|
||||
(LeafNode::Padding, LeafNode::Padding) => (),
|
||||
// As we are looping through the larger of the lists of leaf nodes, it should
|
||||
// be impossible for either leaf to be non-existant.
|
||||
// be impossible for either leaf to be non-existent.
|
||||
(LeafNode::DoesNotExist, LeafNode::DoesNotExist) => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ impl TreeHashCache {
|
||||
}
|
||||
|
||||
/// Instantiate a new cache from the pre-built `bytes` where each `self.chunk_modified` will be
|
||||
/// set to `intitial_modified_state`.
|
||||
/// set to `initial_modified_state`.
|
||||
///
|
||||
/// Note: `bytes.len()` must be a multiple of 32
|
||||
pub fn from_bytes(
|
||||
|
||||
@@ -29,7 +29,7 @@ impl<'a, T> Iterator for Split<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Splits a slice into chunks of size n. All postive n values are applicable,
|
||||
/// Splits a slice into chunks of size n. All positive n values are applicable,
|
||||
/// hence the honey_badger prefix.
|
||||
///
|
||||
/// Returns an iterator over the original list.
|
||||
|
||||
@@ -213,7 +213,7 @@ return rawbytes[current_index+4:current_index+4+bytes_length], new_index
|
||||
|
||||
#### List
|
||||
|
||||
Deserailize each object in the list.
|
||||
Deserialize each object in the list.
|
||||
1. Get the length of the serialized list.
|
||||
2. Loop through deseralizing each item in the list until you reach the
|
||||
entire length of the list.
|
||||
@@ -437,7 +437,7 @@ let decoded: Result<(Vec<usize>, usize), DecodeError> = decode_ssz_list( &encode
|
||||
|
||||
Deserializes the "length" value in the serialized bytes from the index. The
|
||||
length of bytes is given (usually 4 stated in the reference implementation) and
|
||||
is often the value appended to the list infront of the actual serialized
|
||||
is often the value appended to the list in front of the actual serialized
|
||||
object.
|
||||
|
||||
| Parameter | Description |
|
||||
|
||||
@@ -535,7 +535,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn awkward_fixed_lenth_portion() {
|
||||
fn awkward_fixed_length_portion() {
|
||||
assert_eq!(
|
||||
<Vec<Vec<u16>>>::from_ssz_bytes(&[10, 0, 0, 0, 10, 0, 0, 0, 0, 0]),
|
||||
Err(DecodeError::InvalidByteLength {
|
||||
|
||||
@@ -47,7 +47,7 @@ pub fn merkleize_standard(bytes: &[u8]) -> Vec<u8> {
|
||||
|
||||
j -= HASHSIZE;
|
||||
let hash = match o.get(i..i + MERKLE_HASH_CHUNK) {
|
||||
// All bytes are available, hash as ususal.
|
||||
// All bytes are available, hash as usual.
|
||||
Some(slice) => hash(slice),
|
||||
// Unable to get all the bytes.
|
||||
None => {
|
||||
|
||||
@@ -27,7 +27,7 @@ fn get_hashable_named_field_idents<'a>(struct_data: &'a syn::DataStruct) -> Vec<
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns true if some field has an attribute declaring it should not be hashedd.
|
||||
/// Returns true if some field has an attribute declaring it should not be hashed.
|
||||
///
|
||||
/// The field attribute is: `#[tree_hash(skip_hashing)]`
|
||||
fn should_skip_hashing(field: &syn::Field) -> bool {
|
||||
|
||||
@@ -59,7 +59,7 @@ pub fn update_validator_set(
|
||||
for (i, v) in validators.iter_mut().enumerate() {
|
||||
match v.status {
|
||||
/*
|
||||
* Validator is pending activiation.
|
||||
* Validator is pending activation.
|
||||
*/
|
||||
ValidatorStatus::PendingActivation => {
|
||||
let new_total_changed = total_changed
|
||||
|
||||
Reference in New Issue
Block a user