Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/feat-2.0' into feat-2.0-tc-tra…
Browse files Browse the repository at this point in the history
…nsfer

# Conflicts:
#	execution_engine/src/engine_state/mod.rs
#	execution_engine_testing/test_support/src/wasm_test_builder.rs
  • Loading branch information
EdHastingsCasperAssociation committed Feb 16, 2024
2 parents 6c29c74 + a483a0e commit 6e11a31
Show file tree
Hide file tree
Showing 27 changed files with 107 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ steps:
environment:
SCCACHE_S3_PUBLIC: true
commands:
- make check-std-features
- make check-testing-features
- make test CARGO_FLAGS=--release
- make test-contracts CARGO_FLAGS=--release
- cachepot --show-stats
Expand All @@ -48,6 +50,8 @@ steps:
- name: cargo-test-push
<<: *buildenv
commands:
- make check-std-features
- make check-testing-features
- make test CARGO_FLAGS=--release
- make test-contracts CARGO_FLAGS=--release
- cachepot --show-stats
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ check-std-features:
cd smart_contracts/contract && $(CARGO) check --all-targets --no-default-features --features=std
cd smart_contracts/contract && $(CARGO) check --all-targets --features=std

.PHONY: check-testing-features
check-testing-features:
cd types && $(CARGO) check --all-targets --no-default-features --features=testing
cd types && $(CARGO) check --all-targets --features=testing

.PHONY: check-format
check-format:
$(CARGO_PINNED_NIGHTLY) fmt --all -- --check
Expand Down Expand Up @@ -158,18 +163,15 @@ check-rs: \
lint \
audit \
check-std-features \
check-testing-features \
test-rs \
test-rs-no-default-features \
test-contracts-rs

.PHONY: check
check: \
check-format \
doc \
lint \
audit \
test \
test-contracts
check-rs \
test-as

.PHONY: clean
clean:
Expand Down
2 changes: 0 additions & 2 deletions execution_engine/src/engine_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ where
/// contracts, sets up the genesis accounts, and sets up the auction state based on that. At
/// the end of the process, [`SystemEntityRegistry`] is persisted under the special global
/// state space [`Key::SystemEntityRegistry`].
///
/// Returns a [`GenesisResult`].
pub fn commit_genesis(&self, request: GenesisRequest) -> GenesisResult {
self.state.genesis(request)
}
Expand Down
2 changes: 2 additions & 0 deletions types/src/access_rights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use core::fmt::{self, Display, Formatter};
use bitflags::bitflags;
#[cfg(feature = "datasize")]
use datasize::DataSize;
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
Expand Down Expand Up @@ -124,6 +125,7 @@ impl<'de> Deserialize<'de> for AccessRights {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<AccessRights> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> AccessRights {
let mut result = AccessRights::NONE;
Expand Down
2 changes: 2 additions & 0 deletions types/src/account/account_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use core::{
};
#[cfg(feature = "datasize")]
use datasize::DataSize;
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
Expand Down Expand Up @@ -205,6 +206,7 @@ impl AsRef<[u8]> for AccountHash {
#[derive(Debug)]
pub struct TryFromSliceForAccountHashError(());

#[cfg(any(feature = "testing", test))]
impl Distribution<AccountHash> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> AccountHash {
AccountHash::new(rng.gen())
Expand Down
15 changes: 4 additions & 11 deletions types/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ mod json_compatibility;
mod rewarded_signatures;
mod rewards;
mod signed_block_header;

#[cfg(any(feature = "testing", test))]
mod test_block_builder {
pub mod test_block_v1_builder;
pub mod test_block_v2_builder;
}
#[cfg(any(all(feature = "std", feature = "testing"), test))]
mod test_block_builder;

use alloc::{boxed::Box, vec::Vec};
use core::fmt::{self, Display, Formatter};
Expand Down Expand Up @@ -50,11 +46,8 @@ pub use json_compatibility::JsonBlockWithSignatures;
pub use rewarded_signatures::{RewardedSignatures, SingleBlockRewardedSignatures};
pub use rewards::Rewards;
pub use signed_block_header::{SignedBlockHeader, SignedBlockHeaderValidationError};
#[cfg(any(feature = "testing", test))]
pub use test_block_builder::{
test_block_v1_builder::TestBlockV1Builder,
test_block_v2_builder::TestBlockV2Builder as TestBlockBuilder,
};
#[cfg(any(all(feature = "std", feature = "testing"), test))]
pub use test_block_builder::{TestBlockBuilder, TestBlockV1Builder};

#[cfg(feature = "json-schema")]
static BLOCK: Lazy<Block> = Lazy::new(|| BlockV2::example().into());
Expand Down
5 changes: 5 additions & 0 deletions types/src/block/test_block_builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod test_block_v1_builder;
mod test_block_v2_builder;

pub use test_block_v1_builder::TestBlockV1Builder;
pub use test_block_v2_builder::TestBlockV2Builder as TestBlockBuilder;
1 change: 0 additions & 1 deletion types/src/chainspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub use fee_handling::FeeHandling;
pub use genesis_config::{GenesisConfig, GenesisConfigBuilder};
#[cfg(any(feature = "testing", test))]
pub use genesis_config::{DEFAULT_AUCTION_DELAY, DEFAULT_FEE_HANDLING, DEFAULT_REFUND_HANDLING};

pub use global_state_update::{GlobalStateUpdate, GlobalStateUpdateConfig, GlobalStateUpdateError};
pub use highway_config::HighwayConfig;
pub use network_config::NetworkConfig;
Expand Down
7 changes: 6 additions & 1 deletion types/src/chainspec/accounts_config/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#[cfg(feature = "datasize")]
use datasize::DataSize;
use num_traits::Zero;
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{Deserialize, Serialize};

#[cfg(any(feature = "testing", test))]
use crate::SecretKey;
use crate::{
account::AccountHash,
bytesrepr,
bytesrepr::{FromBytes, ToBytes, U8_SERIALIZED_LENGTH},
system::auction::DelegationRate,
Motes, PublicKey, SecretKey,
Motes, PublicKey,
};

const TAG_LENGTH: usize = U8_SERIALIZED_LENGTH;
Expand Down Expand Up @@ -80,6 +83,7 @@ impl GenesisValidator {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<GenesisValidator> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> GenesisValidator {
let bonded_amount = Motes::new(rng.gen());
Expand Down Expand Up @@ -375,6 +379,7 @@ impl GenesisAccount {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<GenesisAccount> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> GenesisAccount {
let mut bytes = [0u8; 32];
Expand Down
3 changes: 3 additions & 0 deletions types/src/chainspec/genesis_config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[cfg(any(feature = "testing", test))]
use std::iter;

use num_rational::Ratio;
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
Expand Down Expand Up @@ -167,6 +169,7 @@ impl GenesisConfig {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<GenesisConfig> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> GenesisConfig {
let count = rng.gen_range(1..10);
Expand Down
7 changes: 6 additions & 1 deletion types/src/chainspec/vm_config/auction_costs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! Costs of the auction system contract.
#[cfg(feature = "datasize")]
use datasize::DataSize;
use rand::{distributions::Standard, prelude::*, Rng};
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{Deserialize, Serialize};

use crate::bytesrepr::{self, FromBytes, ToBytes};
Expand Down Expand Up @@ -203,6 +207,7 @@ impl FromBytes for AuctionCosts {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<AuctionCosts> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> AuctionCosts {
AuctionCosts {
Expand Down
5 changes: 4 additions & 1 deletion types/src/chainspec/vm_config/chainspec_registry.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! The registry of chainspec hash digests.
use std::{collections::BTreeMap, convert::TryFrom};

#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use std::{collections::BTreeMap, convert::TryFrom};

use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -130,6 +132,7 @@ impl CLTyped for ChainspecRegistry {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<ChainspecRegistry> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> ChainspecRegistry {
ChainspecRegistry {
Expand Down
7 changes: 6 additions & 1 deletion types/src/chainspec/vm_config/handle_payment_costs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! Costs of the `handle_payment` system contract.
#[cfg(feature = "datasize")]
use datasize::DataSize;
use rand::{distributions::Standard, prelude::*, Rng};
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{Deserialize, Serialize};

use crate::bytesrepr::{self, FromBytes, ToBytes};
Expand Down Expand Up @@ -80,6 +84,7 @@ impl FromBytes for HandlePaymentCosts {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<HandlePaymentCosts> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> HandlePaymentCosts {
HandlePaymentCosts {
Expand Down
1 change: 1 addition & 0 deletions types/src/chainspec/vm_config/host_function_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ impl FromBytes for HostFunctionCosts {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<HostFunctionCosts> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> HostFunctionCosts {
HostFunctionCosts {
Expand Down
7 changes: 6 additions & 1 deletion types/src/chainspec/vm_config/message_limits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#[cfg(feature = "datasize")]
use datasize::DataSize;
use rand::{distributions::Standard, prelude::*, Rng};
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{Deserialize, Serialize};

use crate::bytesrepr::{self, FromBytes, ToBytes};
Expand Down Expand Up @@ -80,6 +84,7 @@ impl FromBytes for MessageLimits {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<MessageLimits> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> MessageLimits {
MessageLimits {
Expand Down
7 changes: 6 additions & 1 deletion types/src/chainspec/vm_config/mint_costs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! Costs of the mint system contract.
#[cfg(feature = "datasize")]
use datasize::DataSize;
use rand::{distributions::Standard, prelude::*, Rng};
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{Deserialize, Serialize};

use crate::bytesrepr::{self, FromBytes, ToBytes};
Expand Down Expand Up @@ -127,6 +131,7 @@ impl FromBytes for MintCosts {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<MintCosts> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> MintCosts {
MintCosts {
Expand Down
9 changes: 8 additions & 1 deletion types/src/chainspec/vm_config/opcode_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
use datasize::DataSize;
use derive_more::Add;
use num_traits::Zero;
use rand::{distributions::Standard, prelude::*, Rng};
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{Deserialize, Serialize};

use crate::bytesrepr::{self, FromBytes, ToBytes};
Expand Down Expand Up @@ -96,6 +100,7 @@ impl Default for BrTableCost {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<BrTableCost> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> BrTableCost {
BrTableCost {
Expand Down Expand Up @@ -321,6 +326,7 @@ impl FromBytes for ControlFlowCosts {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<ControlFlowCosts> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> ControlFlowCosts {
ControlFlowCosts {
Expand Down Expand Up @@ -457,6 +463,7 @@ impl Default for OpcodeCosts {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<OpcodeCosts> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> OpcodeCosts {
OpcodeCosts {
Expand Down
7 changes: 6 additions & 1 deletion types/src/chainspec/vm_config/standard_payment_costs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! Costs of the standard payment system contract.
#[cfg(feature = "datasize")]
use datasize::DataSize;
use rand::{distributions::Standard, prelude::*, Rng};
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{Deserialize, Serialize};

use crate::bytesrepr::{self, FromBytes, ToBytes};
Expand Down Expand Up @@ -45,6 +49,7 @@ impl FromBytes for StandardPaymentCosts {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<StandardPaymentCosts> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> StandardPaymentCosts {
StandardPaymentCosts { pay: rng.gen() }
Expand Down
7 changes: 6 additions & 1 deletion types/src/chainspec/vm_config/storage_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
use datasize::DataSize;
use derive_more::Add;
use num_traits::Zero;
use rand::{distributions::Standard, prelude::*, Rng};
#[cfg(any(feature = "testing", test))]
use rand::{
distributions::{Distribution, Standard},
Rng,
};
use serde::{Deserialize, Serialize};

use crate::{
Expand Down Expand Up @@ -49,6 +53,7 @@ impl Default for StorageCosts {
}
}

#[cfg(any(feature = "testing", test))]
impl Distribution<StorageCosts> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> StorageCosts {
StorageCosts {
Expand Down
Loading

0 comments on commit 6e11a31

Please sign in to comment.