Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed the way transaction lanes are calculated if the transaction h… #5024

Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion node/src/components/block_validator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use casper_types::{
BlockSignatures, BlockSignaturesV2, Chainspec, ChainspecRawBytes, Deploy, ExecutableDeployItem,
FinalitySignatureV2, RuntimeArgs, SecretKey, TestBlockBuilder, TimeDiff, Transaction,
TransactionHash, TransactionId, TransactionV1, TransactionV1Config, AUCTION_LANE_ID,
INSTALL_UPGRADE_LANE_ID, LARGE_WASM_LANE_ID, MINT_LANE_ID, U512,
INSTALL_UPGRADE_LANE_ID, MINT_LANE_ID, U512,
};

use crate::{
Expand All @@ -19,6 +19,7 @@ use crate::{
},
effect::requests::StorageRequest,
reactor::{EventQueueHandle, QueueKind, Scheduler},
testing::LARGE_WASM_LANE_ID,
types::{BlockPayload, ValidatorMatrix},
utils::{self, Loadable},
};
Expand Down
30 changes: 20 additions & 10 deletions node/src/components/transaction_acceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl TransactionAcceptor {
block_header: Box<BlockHeader>,
) -> Effects<Event> {
let session = match &event_metadata.meta_transaction {
MetaTransaction::Deploy(deploy) => deploy.session(),
MetaTransaction::Deploy(meta_deploy) => meta_deploy.session(),
MetaTransaction::V1(txn) => {
error!(%txn, "should only handle deploys in verify_deploy_session");
return self.reject_transaction(
Expand Down Expand Up @@ -510,9 +510,10 @@ impl TransactionAcceptor {
}

let next_step = match &event_metadata.meta_transaction {
MetaTransaction::Deploy(deploy) => {
MetaTransaction::Deploy(meta_deploy) => {
let deploy_hash = meta_deploy.deploy().hash();
error!(
%deploy,
%deploy_hash,
"should only handle version 1 transactions in verify_transaction_v1_body"
);
return self.reject_transaction(
Expand Down Expand Up @@ -594,12 +595,20 @@ impl TransactionAcceptor {
};

let maybe_entry_point_name = match &event_metadata.meta_transaction {
MetaTransaction::Deploy(deploy) if is_payment => {
Some(deploy.payment().entry_point_name().to_string())
}
MetaTransaction::Deploy(deploy) => {
Some(deploy.session().entry_point_name().to_string())
}
MetaTransaction::Deploy(meta_deploy) if is_payment => Some(
meta_deploy
.deploy()
.payment()
.entry_point_name()
.to_string(),
),
MetaTransaction::Deploy(meta_deploy) => Some(
meta_deploy
.deploy()
.session()
.entry_point_name()
.to_string(),
),
MetaTransaction::V1(_) if is_payment => {
error!("should not fetch a contract to validate payment logic for transaction v1s");
None
Expand Down Expand Up @@ -764,7 +773,8 @@ impl TransactionAcceptor {
event_metadata: Box<EventMetadata>,
) -> Effects<Event> {
let is_valid = match &event_metadata.meta_transaction {
MetaTransaction::Deploy(deploy) => deploy
MetaTransaction::Deploy(meta_deploy) => meta_deploy
.deploy()
.is_valid()
.map_err(|err| Error::InvalidTransaction(err.into())),
MetaTransaction::V1(txn) => txn
Expand Down
1 change: 0 additions & 1 deletion node/src/components/transaction_acceptor/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,6 @@ async fn run_transaction_acceptor_without_timeout(
} else {
chainspec
};

chainspec.core_config.administrators = iter::once(PublicKey::from(&admin)).collect();

let chainspec = Arc::new(chainspec);
Expand Down
19 changes: 10 additions & 9 deletions node/src/components/transaction_buffer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ use std::iter;
use prometheus::Registry;
use rand::{seq::SliceRandom, Rng};

use casper_types::{
testing::TestRng, Deploy, EraId, SecretKey, TestBlockBuilder, TimeDiff, Transaction,
TransactionConfig, TransactionLimitsDefinition, TransactionV1Config,
DEFAULT_LARGE_TRANSACTION_GAS_LIMIT, LARGE_WASM_LANE_ID,
};

use super::*;
use crate::{
effect::announcements::TransactionBufferAnnouncement::{self, TransactionsExpired},
reactor::{EventQueueHandle, QueueKind, Scheduler},
testing::LARGE_WASM_LANE_ID,
types::{transaction::transaction_v1_builder::TransactionV1Builder, FinalizedBlock},
utils,
};
use casper_types::{
testing::TestRng, Deploy, EraId, SecretKey, TestBlockBuilder, TimeDiff, Transaction,
TransactionConfig, TransactionLaneDefinition, TransactionV1Config,
DEFAULT_LARGE_TRANSACTION_GAS_LIMIT,
};

const ERA_ONE: EraId = EraId::new(1u64);
const GAS_PRICE_TOLERANCE: u8 = 1;
Expand Down Expand Up @@ -1121,10 +1121,11 @@ fn make_test_chainspec(max_standard_count: u64, max_mint_count: u64) -> Arc<Chai
];
let mut transaction_v1_config = TransactionV1Config::default();
transaction_v1_config.native_mint_lane =
TransactionLimitsDefinition::try_from(vec![0, 1024, 1024, 65_000_000_000, max_mint_count])
TransactionLaneDefinition::try_from(vec![0, 1024, 1024, 65_000_000_000, max_mint_count])
.unwrap();
transaction_v1_config.wasm_lanes =
vec![TransactionLimitsDefinition::try_from(large_lane).unwrap()];
transaction_v1_config.set_wasm_lanes(vec![
TransactionLaneDefinition::try_from(large_lane).unwrap()
]);

let transaction_config = TransactionConfig {
transaction_v1_config,
Expand Down
3 changes: 1 addition & 2 deletions node/src/reactor/main_reactor/tests/transactions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::types::MetaTransaction;
use crate::{testing::LARGE_WASM_LANE_ID, types::MetaTransaction};
use casper_execution_engine::engine_state::MAX_PAYMENT_AMOUNT;
use casper_storage::data_access_layer::{
AddressableEntityRequest, BalanceIdentifier, ProofHandling, QueryRequest, QueryResult,
Expand All @@ -10,7 +10,6 @@ use casper_types::{
runtime_args,
system::mint::{ARG_AMOUNT, ARG_TARGET},
AddressableEntity, Digest, EntityAddr, ExecutionInfo, TransactionRuntimeParams,
LARGE_WASM_LANE_ID,
};
use once_cell::sync::Lazy;

Expand Down
2 changes: 2 additions & 0 deletions node/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const TEST_PORT_RANGE: Range<u16> = 60001..60998;
/// Random offset + stride for port generation.
const TEST_PORT_STRIDE: u16 = 29;

pub(crate) const LARGE_WASM_LANE_ID: u8 = 3;

macro_rules! map {
() => { std::collections::BTreeMap::new() };
( $first_key:expr => $first_value:expr $( , $key:expr => $value:expr )* $(,)? ) => {{
Expand Down
8 changes: 4 additions & 4 deletions node/src/types/appendable_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl AppendableBlock {
for lane_id in self
.transaction_config
.transaction_v1_config
.wasm_lanes
.wasm_lanes()
.iter()
.map(|lane| lane.id())
{
Expand Down Expand Up @@ -247,9 +247,9 @@ impl Display for AppendableBlock {

#[cfg(test)]
mod tests {
use casper_types::{
testing::TestRng, SingleBlockRewardedSignatures, TimeDiff, LARGE_WASM_LANE_ID,
};
use casper_types::{testing::TestRng, SingleBlockRewardedSignatures, TimeDiff};

use crate::testing::LARGE_WASM_LANE_ID;

use super::*;
use std::collections::HashSet;
Expand Down
Loading
Loading