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

Open
wants to merge 1 commit into
base: feat-2.0
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions 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 Down Expand Up @@ -152,7 +152,7 @@ pub(super) fn new_proposed_block_with_cited_signatures(
INSTALL_UPGRADE_LANE_ID,
install_upgrade.into_iter().collect(),
);
ret.insert(LARGE_WASM_LANE_ID, standard.into_iter().collect());
ret.insert(3, standard.into_iter().collect());
ret
};
let block_payload = BlockPayload::new(transactions, vec![], cited_signatures, true, 1u8);
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
12 changes: 7 additions & 5 deletions node/src/components/transaction_buffer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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,
TransactionConfig, TransactionLanesDefinition, TransactionV1Config,
DEFAULT_LARGE_TRANSACTION_GAS_LIMIT,
};

use super::*;
Expand All @@ -17,6 +17,7 @@ use crate::{
utils,
};

const LARGE_WASM_LANE_ID: u8 = 3;
const ERA_ONE: EraId = EraId::new(1u64);
const GAS_PRICE_TOLERANCE: u8 = 1;
const DEFAULT_MINIMUM_GAS_PRICE: u8 = 1;
Expand Down Expand Up @@ -1121,10 +1122,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])
TransactionLanesDefinition::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![
TransactionLanesDefinition::try_from(large_lane).unwrap()
]);

let transaction_config = TransactionConfig {
transaction_v1_config,
Expand Down
2 changes: 1 addition & 1 deletion node/src/reactor/main_reactor/tests/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ 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;

use casper_types::{bytesrepr::Bytes, execution::ExecutionResultV1};

const LARGE_WASM_LANE_ID: u8 = 3;
static ALICE_SECRET_KEY: Lazy<Arc<SecretKey>> = Lazy::new(|| {
Arc::new(SecretKey::ed25519_from_bytes([0xAA; SecretKey::ED25519_LENGTH]).unwrap())
});
Expand Down
7 changes: 3 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,13 +247,12 @@ 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 super::*;
use std::collections::HashSet;

const LARGE_WASM_LANE_ID: u8 = 3;
impl AppendableBlock {
pub(crate) fn transaction_hashes(&self) -> HashSet<TransactionHash> {
self.transactions.keys().copied().collect()
Expand Down
Loading
Loading