Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ lint-smart-contracts:

.PHONY: audit-rs
audit-rs:
$(CARGO) audit --ignore RUSTSEC-2024-0437 --ignore RUSTSEC-2025-0022 --ignore RUSTSEC-2025-0055 --ignore RUSTSEC-2026-0001 --ignore RUSTSEC-2026-0007 --ignore RUSTSEC-2026-0049 --ignore RUSTSEC-2026-0068 --ignore RUSTSEC-2026-0067
$(CARGO) audit --ignore RUSTSEC-2024-0437 --ignore RUSTSEC-2025-0022 --ignore RUSTSEC-2025-0055 --ignore RUSTSEC-2026-0001 --ignore RUSTSEC-2026-0007 --ignore RUSTSEC-2026-0049 --ignore RUSTSEC-2026-0068 --ignore RUSTSEC-2026-0067 --ignore RUSTSEC-2026-0098 --ignore RUSTSEC-2026-0099

.PHONY: audit
audit: audit-rs
Expand Down
2 changes: 2 additions & 0 deletions execution_engine_testing/test_support/src/chainspec_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl ChainspecConfig {
locked_funds_period,
unbonding_delay,
round_seigniorage_rate,
enable_addressable_entity,
minimum_delegation_rate,
..
} = core_config;
Expand All @@ -146,6 +147,7 @@ impl ChainspecConfig {
.with_unbonding_delay(*unbonding_delay)
.with_genesis_timestamp_millis(DEFAULT_GENESIS_TIMESTAMP_MILLIS)
.with_storage_costs(*storage_costs)
.with_enable_addressable_entity(*enable_addressable_entity)
.with_minimum_delegation_rate(*minimum_delegation_rate)
.build();

Expand Down
1 change: 1 addition & 0 deletions execution_engine_testing/tests/src/test/regression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ mod regression_20220224;
mod regression_20220303;
mod regression_20220727;
mod regression_20240105;
mod regression_20250812;
mod slow_input;
pub(crate) mod test_utils;
mod transforms_must_be_ordered;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use casper_engine_test_support::{
ChainspecConfig, ExecuteRequestBuilder, LmdbWasmTestBuilder, DEFAULT_ACCOUNTS,
DEFAULT_ACCOUNT_ADDR, DEFAULT_PROTOCOL_VERSION,
};
use casper_types::RuntimeArgs;

const DO_NOTHING_CONTRACT: &str = "do_nothing_stored.wasm";

#[ignore]
#[test]
fn should_correctly_install_and_add_contract_version_with_ae_turned_on() {
let chainspec = ChainspecConfig::default().with_enable_addressable_entity(true);
let genesis_request = chainspec
.create_genesis_request(DEFAULT_ACCOUNTS.to_vec(), DEFAULT_PROTOCOL_VERSION)
.expect("must create genesis request");

let mut builder = LmdbWasmTestBuilder::new_temporary_with_config(chainspec);
builder.run_genesis(genesis_request).commit();

let install_request_1 = ExecuteRequestBuilder::standard(
*DEFAULT_ACCOUNT_ADDR,
DO_NOTHING_CONTRACT,
RuntimeArgs::default(),
)
.build();

let install_request_2 = ExecuteRequestBuilder::standard(
*DEFAULT_ACCOUNT_ADDR,
DO_NOTHING_CONTRACT,
RuntimeArgs::default(),
)
.build();

builder.exec(install_request_1).expect_success().commit();
builder.exec(install_request_2).expect_success().commit();
}
2 changes: 1 addition & 1 deletion node/src/components/consensus/consensus_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub(crate) enum ProtocolOutcome<C: Context> {
CreatedGossipMessage(SerializedMessage),
CreatedTargetedMessage(SerializedMessage, NodeId),
CreatedMessageToRandomPeer(SerializedMessage),
CreatedRequestToRandomPeer(SerializedMessage),
CreatedRequestToRandomValidator(SerializedMessage),
ScheduleTimer(Timestamp, TimerId),
QueueAction(ActionId),
/// Request transactions for a new block, providing the necessary context.
Expand Down
6 changes: 4 additions & 2 deletions node/src/components/consensus/era_supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,13 @@ impl EraSupervisor {
}
.ignore()
}
ProtocolOutcome::CreatedRequestToRandomPeer(payload) => {
ProtocolOutcome::CreatedRequestToRandomValidator(payload) => {
let message = ConsensusRequestMessage { era_id, payload };

async move {
let peers = effect_builder.get_fully_connected_peers(1).await;
let peers = effect_builder
.get_fully_connected_validators(1, era_id)
.await;
if let Some(to) = peers.into_iter().next() {
effect_builder.enqueue_message(to, message.into()).await;
}
Expand Down
4 changes: 2 additions & 2 deletions node/src/components/consensus/protocols/zug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ impl<C: Context + 'static> Zug<C> {
.choose(rng)
.unwrap_or(self.current_round);
let payload = self.create_sync_request(rng, first_validator_idx, round_id);
let mut outcomes = vec![ProtocolOutcome::CreatedRequestToRandomPeer(
let mut outcomes = vec![ProtocolOutcome::CreatedRequestToRandomValidator(
SerializedMessage::from_message(&payload),
)];
// Periodically sync the state with a random peer.
Expand Down Expand Up @@ -1515,7 +1515,7 @@ impl<C: Context + 'static> Zug<C> {
| ProtocolOutcome::CreatedGossipMessage(_)
| ProtocolOutcome::CreatedTargetedMessage(_, _)
| ProtocolOutcome::CreatedMessageToRandomPeer(_)
| ProtocolOutcome::CreatedRequestToRandomPeer(_)
| ProtocolOutcome::CreatedRequestToRandomValidator(_)
| ProtocolOutcome::ScheduleTimer(_, _)
| ProtocolOutcome::QueueAction(_)
| ProtocolOutcome::CreateNewBlock(_, _)
Expand Down
2 changes: 1 addition & 1 deletion node/src/components/consensus/protocols/zug/des_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl From<ProtocolOutcome<TestContext>> for ZugMessage {
ProtocolOutcome::CreatedMessageToRandomPeer(msg) => {
ZugMessage::MessageToRandomPeer(msg)
}
ProtocolOutcome::CreatedRequestToRandomPeer(request) => {
ProtocolOutcome::CreatedRequestToRandomValidator(request) => {
ZugMessage::RequestToRandomPeer(request)
}
ProtocolOutcome::ScheduleTimer(timestamp, timer_id) => {
Expand Down
7 changes: 4 additions & 3 deletions node/src/components/consensus/protocols/zug/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,16 @@ fn remove_proposal(
}
}

/// Removes all `CreatedRequestToRandomPeer`s from `outcomes` and returns the deserialized messages.
/// Removes all `CreatedRequestToRandomValidator`s from `outcomes` and returns the deserialized
/// messages.
fn remove_requests_to_random(
outcomes: &mut ProtocolOutcomes<ClContext>,
) -> Vec<SyncRequest<ClContext>> {
let mut result = Vec::new();
let expected_instance_id = ClContext::hash(INSTANCE_ID_DATA);
outcomes.retain(|outcome| {
let msg: SyncRequest<ClContext> = match outcome {
ProtocolOutcome::CreatedRequestToRandomPeer(msg) => msg.deserialize_expect(),
ProtocolOutcome::CreatedRequestToRandomValidator(msg) => msg.deserialize_expect(),
_ => return true,
};
assert_eq!(msg.instance_id, expected_instance_id);
Expand Down Expand Up @@ -892,7 +893,7 @@ fn zug_handles_sync_request() {
for _ in 0..2 {
let mut outcomes = zug2.handle_timer(timestamp, timestamp, TIMER_ID_SYNC_PEER, &mut rng);
let msg = loop {
if let ProtocolOutcome::CreatedRequestToRandomPeer(payload) =
if let ProtocolOutcome::CreatedRequestToRandomValidator(payload) =
outcomes.pop().expect("expected request to random peer")
{
break payload;
Expand Down
23 changes: 23 additions & 0 deletions node/src/components/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,22 @@ where
.choose_multiple(rng, count)
}

pub(crate) fn fully_connected_validators_random(
&self,
rng: &mut NodeRng,
count: usize,
era_id: EraId,
) -> Vec<NodeId> {
let is_validator_in_era =
|era: EraId, peer_id: &NodeId| self.outgoing_limiter.is_validator_in_era(era, peer_id);
self.connection_symmetries
.iter()
.filter(|(_, sym)| matches!(sym, ConnectionSymmetry::Symmetric { .. }))
.map(|(node_id, _)| *node_id)
.filter(|node_id| is_validator_in_era(era_id, node_id))
.choose_multiple(rng, count)
}

pub(crate) fn has_sufficient_fully_connected_peers(&self) -> bool {
self.connection_symmetries
.iter()
Expand Down Expand Up @@ -1222,6 +1238,13 @@ where
NetworkInfoRequest::FullyConnectedPeers { count, responder } => responder
.respond(self.fully_connected_peers_random(rng, count))
.ignore(),
NetworkInfoRequest::FullyConnectedValidators {
count,
era_id,
responder,
} => responder
.respond(self.fully_connected_validators_random(rng, count, era_id))
.ignore(),
NetworkInfoRequest::Insight { responder } => responder
.respond(NetworkInsights::collect_from_component(self))
.ignore(),
Expand Down
16 changes: 16 additions & 0 deletions node/src/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,22 @@ impl<REv> EffectBuilder<REv> {
.await
}

/// Gets up to `count` fully-connected network validators in random order.
pub async fn get_fully_connected_validators(self, count: usize, era_id: EraId) -> Vec<NodeId>
where
REv: From<NetworkInfoRequest>,
{
self.make_request(
|responder| NetworkInfoRequest::FullyConnectedValidators {
count,
era_id,
responder,
},
QueueKind::NetworkInfo,
)
.await
}

/// Announces which transactions have expired.
pub(crate) async fn announce_expired_transactions(self, hashes: Vec<TransactionHash>)
where
Expand Down
19 changes: 19 additions & 0 deletions node/src/effect/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ pub(crate) enum NetworkInfoRequest {
/// Responder to be called with the peers.
responder: Responder<Vec<NodeId>>,
},
/// Get up to `count` fully-connected validators in random order.
FullyConnectedValidators {
count: usize,
/// era_id in which the filtered peer needs to be a validator.
era_id: EraId,
/// Responder to be called with the peers.
responder: Responder<Vec<NodeId>>,
},
/// Get detailed insights into the nodes networking.
Insight {
responder: Responder<NetworkInsights>,
Expand All @@ -227,6 +235,17 @@ impl Display for NetworkInfoRequest {
} => {
write!(formatter, "get up to {} fully connected peers", count)
}
NetworkInfoRequest::FullyConnectedValidators {
count,
era_id,
responder: _,
} => {
write!(
formatter,
"get up to {} fully connected validators in era {}",
count, era_id
)
}
NetworkInfoRequest::Insight { responder: _ } => {
formatter.write_str("get networking insights")
}
Expand Down
4 changes: 3 additions & 1 deletion node/src/reactor/main_reactor/tests/gas_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ async fn run_gas_price_scenario(gas_price_scenario: GasPriceScenario) {
let max_gas_price: u8 = 3;

let mut transaction_config = TransactionV1Config::default();
transaction_config.native_mint_lane.max_transaction_count = 1;
transaction_config
.native_mint_lane
.set_max_transaction_count(1);

let spec_override = match gas_price_scenario {
GasPriceScenario::SlotUtilization => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl TestScenario {
.transaction_config
.transaction_v1_config
.get_lane_by_id(lane_id)
.map(|el| el.max_transaction_gas_limit)
.map(|el| el.max_transaction_gas_limit())
}

pub(crate) fn get_block_height(&self) -> u64 {
Expand Down
18 changes: 9 additions & 9 deletions node/src/reactor/main_reactor/tests/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5551,10 +5551,10 @@ async fn run_sizing_scenario(sizing_scenario: SizingScenario) {
let largest_lane = wasm_lanes
.iter()
.max_by(|left, right| {
left.max_transaction_length
.cmp(&right.max_transaction_length)
left.max_transaction_length()
.cmp(&right.max_transaction_length())
})
.map(|definition| definition.id)
.map(|definition| definition.id())
.expect("must have lane id for largest lane");

let (payment_2, session_2) = match sizing_scenario {
Expand Down Expand Up @@ -5706,17 +5706,17 @@ async fn should_assign_deploy_to_largest_lane_by_payment_amount_only_in_payment_
.clone();

wasm_lanes.sort_by(|a, b| {
a.max_transaction_gas_limit
.cmp(&b.max_transaction_gas_limit)
a.max_transaction_gas_limit()
.cmp(&b.max_transaction_gas_limit())
});

let (smallest_lane_id, smallest_gas_limt, smallest_size_limit_for_deploy) = wasm_lanes
.first()
.map(|lane_def| {
(
lane_def.id,
lane_def.max_transaction_gas_limit,
lane_def.max_transaction_length,
lane_def.id(),
lane_def.max_transaction_gas_limit(),
lane_def.max_transaction_length(),
)
})
.expect("must have at least one lane");
Expand Down Expand Up @@ -5764,7 +5764,7 @@ async fn should_assign_deploy_to_largest_lane_by_payment_amount_only_in_payment_

let (largest_lane_id, largest_gas_limt) = wasm_lanes
.last()
.map(|lane_def| (lane_def.id, lane_def.max_transaction_gas_limit))
.map(|lane_def| (lane_def.id(), lane_def.max_transaction_gas_limit()))
.expect("must have at least one lane");

assert_ne!(largest_lane_id, smallest_lane_id);
Expand Down
16 changes: 2 additions & 14 deletions node/src/types/transaction/meta_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,20 +475,8 @@ mod proptests {
fn construction_roundtrip(transaction in legal_transaction_arb()) {
let mut transaction_config = TransactionConfig::default();
transaction_config.transaction_v1_config.set_wasm_lanes(vec![
TransactionLaneDefinition {
id: 3,
max_transaction_length: u64::MAX/2,
max_transaction_args_length: 10000,
max_transaction_gas_limit: u64::MAX/2,
max_transaction_count: 10,
},
TransactionLaneDefinition {
id: 4,
max_transaction_length: u64::MAX,
max_transaction_args_length: 10000,
max_transaction_gas_limit: u64::MAX,
max_transaction_count: 10,
},
TransactionLaneDefinition::new(3, u64::MAX / 2, 10000, u64::MAX / 2, 10),
TransactionLaneDefinition::new(4, u64::MAX, 10000, u64::MAX, 10),
]);
let maybe_transaction = MetaTransaction::from_transaction(&transaction, PricingHandling::PaymentLimited, &transaction_config);
prop_assert!(maybe_transaction.is_ok(), "{:?}", maybe_transaction);
Expand Down
Loading
Loading