Skip to content

Commit

Permalink
Merge branch 'master' into secp256r1-precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRigel authored Nov 6, 2024
2 parents b44c02f + 22443e7 commit 8629123
Show file tree
Hide file tree
Showing 29 changed files with 1,122 additions and 777 deletions.
63 changes: 60 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ members = [
"sdk/hash",
"sdk/inflation",
"sdk/instruction",
"sdk/keypair",
"sdk/macro",
"sdk/msg",
"sdk/native-token",
Expand All @@ -130,6 +131,7 @@ members = [
"sdk/package-metadata-macro",
"sdk/packet",
"sdk/precompile-error",
"sdk/presigner",
"sdk/program",
"sdk/program-entrypoint",
"sdk/program-error",
Expand All @@ -140,10 +142,13 @@ members = [
"sdk/rent",
"sdk/sanitize",
"sdk/secp256r1",
"sdk/seed-derivable",
"sdk/seed-phrase",
"sdk/serde-varint",
"sdk/serialize-utils",
"sdk/sha256-hasher",
"sdk/signature",
"sdk/signer",
"sdk/slot-hashes",
"sdk/slot-history",
"sdk/stable-layout",
Expand Down Expand Up @@ -360,6 +365,7 @@ quinn = "0.11.4"
quinn-proto = "0.11.7"
quote = "1.0"
rand = "0.8.5"
rand0-7 = { package = "rand", version = "0.7" }
rand_chacha = "0.3.1"
rayon = "1.10.0"
reed-solomon-erasure = "6.0.0"
Expand Down Expand Up @@ -448,6 +454,7 @@ solana-hash = { path = "sdk/hash", version = "=2.2.0", default-features = false
solana-inflation = { path = "sdk/inflation", version = "=2.2.0" }
solana-inline-spl = { path = "inline-spl", version = "=2.2.0" }
solana-instruction = { path = "sdk/instruction", version = "=2.2.0", default-features = false }
solana-keypair = { path = "sdk/keypair", version = "=2.2.0" }
solana-last-restart-slot = { path = "sdk/last-restart-slot", version = "=2.2.0" }
solana-lattice-hash = { path = "lattice-hash", version = "=2.2.0" }
solana-ledger = { path = "ledger", version = "=2.2.0" }
Expand All @@ -471,6 +478,7 @@ solana-perf = { path = "perf", version = "=2.2.0" }
solana-poh = { path = "poh", version = "=2.2.0" }
solana-poseidon = { path = "poseidon", version = "=2.2.0" }
solana-precompile-error = { path = "sdk/precompile-error", version = "=2.2.0" }
solana-presigner = { path = "sdk/presigner", version = "=2.2.0" }
solana-program = { path = "sdk/program", version = "=2.2.0", default-features = false }
solana-program-error = { path = "sdk/program-error", version = "=2.2.0" }
solana-program-memory = { path = "sdk/program-memory", version = "=2.2.0" }
Expand All @@ -487,10 +495,13 @@ solana-rent = { path = "sdk/rent", version = "=2.2.0", default-features = false
solana-reward-info = { path = "sdk/reward-info", version = "=2.2.0" }
solana-secp256r1-program = { path = "sdk/secp256r1", version = "=2.2.0", default-features = false }
solana-sanitize = { path = "sdk/sanitize", version = "=2.2.0" }
solana-seed-derivable = { path = "sdk/seed-derivable", version = "=2.2.0" }
solana-seed-phrase = { path = "sdk/seed-phrase", version = "=2.2.0" }
solana-serde-varint = { path = "sdk/serde-varint", version = "=2.2.0" }
solana-serialize-utils = { path = "sdk/serialize-utils", version = "=2.2.0" }
solana-sha256-hasher = { path = "sdk/sha256-hasher", version = "=2.2.0" }
solana-signature = { path = "sdk/signature", version = "=2.2.0", default-features = false }
solana-signer = { path = "sdk/signer", version = "=2.2.0" }
solana-slot-hashes = { path = "sdk/slot-hashes", version = "=2.2.0" }
solana-slot-history = { path = "sdk/slot-history", version = "=2.2.0" }
solana-time-utils = { path = "sdk/time-utils", version = "=2.2.0" }
Expand Down
28 changes: 17 additions & 11 deletions core/src/banking_stage/consume_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,12 @@ mod tests {
..
} = create_slow_genesis_config(10_000);
let (bank, bank_forks) = Bank::new_no_wallclock_throttle_for_tests(&genesis_config);
let bank = Arc::new(Bank::new_from_parent(bank, &Pubkey::new_unique(), 1));
// Warp to next epoch for MaxAge tests.
let bank = Arc::new(Bank::new_from_parent(
bank.clone(),
&Pubkey::new_unique(),
bank.get_epoch_info().slots_in_epoch,
));

let ledger_path = get_tmp_ledger_path_auto_delete!();
let blockstore = Blockstore::open(ledger_path.path())
Expand Down Expand Up @@ -889,7 +894,7 @@ mod tests {
let bid = TransactionBatchId::new(0);
let id = TransactionId::new(0);
let max_age = MaxAge {
epoch_invalidation_slot: bank.slot(),
sanitized_epoch: bank.epoch(),
alt_invalidation_slot: bank.slot(),
};
let work = ConsumeWork {
Expand Down Expand Up @@ -938,7 +943,7 @@ mod tests {
let bid = TransactionBatchId::new(0);
let id = TransactionId::new(0);
let max_age = MaxAge {
epoch_invalidation_slot: bank.slot(),
sanitized_epoch: bank.epoch(),
alt_invalidation_slot: bank.slot(),
};
let work = ConsumeWork {
Expand Down Expand Up @@ -988,7 +993,7 @@ mod tests {
let id1 = TransactionId::new(1);
let id2 = TransactionId::new(0);
let max_age = MaxAge {
epoch_invalidation_slot: bank.slot(),
sanitized_epoch: bank.epoch(),
alt_invalidation_slot: bank.slot(),
};
consume_sender
Expand Down Expand Up @@ -1049,7 +1054,7 @@ mod tests {
let id1 = TransactionId::new(1);
let id2 = TransactionId::new(0);
let max_age = MaxAge {
epoch_invalidation_slot: bank.slot(),
sanitized_epoch: bank.epoch(),
alt_invalidation_slot: bank.slot(),
};
consume_sender
Expand Down Expand Up @@ -1103,6 +1108,7 @@ mod tests {
.unwrap()
.set_bank_for_test(bank.clone());
assert!(bank.slot() > 0);
assert!(bank.epoch() > 0);

// No conflicts between transactions. Test 6 cases.
// 1. Epoch expiration, before slot => still succeeds due to resanitizing
Expand Down Expand Up @@ -1187,27 +1193,27 @@ mod tests {
transactions: txs,
max_ages: vec![
MaxAge {
epoch_invalidation_slot: bank.slot() - 1,
sanitized_epoch: bank.epoch() - 1,
alt_invalidation_slot: Slot::MAX,
},
MaxAge {
epoch_invalidation_slot: bank.slot(),
sanitized_epoch: bank.epoch(),
alt_invalidation_slot: Slot::MAX,
},
MaxAge {
epoch_invalidation_slot: bank.slot() + 1,
sanitized_epoch: bank.epoch() + 1,
alt_invalidation_slot: Slot::MAX,
},
MaxAge {
epoch_invalidation_slot: u64::MAX,
sanitized_epoch: bank.epoch(),
alt_invalidation_slot: bank.slot() - 1,
},
MaxAge {
epoch_invalidation_slot: u64::MAX,
sanitized_epoch: bank.epoch(),
alt_invalidation_slot: bank.slot(),
},
MaxAge {
epoch_invalidation_slot: u64::MAX,
sanitized_epoch: bank.epoch(),
alt_invalidation_slot: bank.slot() + 1,
},
],
Expand Down
4 changes: 2 additions & 2 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ impl Consumer {
let pre_results = txs.iter().zip(max_ages).map(|(tx, max_age)| {
// If the transaction was sanitized before this bank's epoch,
// additional checks are necessary.
if bank.slot() > max_age.epoch_invalidation_slot {
// Reserved key set may have cahnged, so we must verify that
if bank.epoch() != max_age.sanitized_epoch {
// Reserved key set may have changed, so we must verify that
// no writable keys are reserved.
bank.check_reserved_keys(tx)?;
}
Expand Down
14 changes: 12 additions & 2 deletions core/src/banking_stage/scheduler_messages.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use {
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_sdk::{clock::Slot, transaction::SanitizedTransaction},
solana_sdk::{
clock::{Epoch, Slot},
transaction::SanitizedTransaction,
},
std::fmt::Display,
};

Expand Down Expand Up @@ -38,10 +41,17 @@ impl Display for TransactionId {

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct MaxAge {
pub epoch_invalidation_slot: Slot,
pub sanitized_epoch: Epoch,
pub alt_invalidation_slot: Slot,
}

impl MaxAge {
pub const MAX: Self = Self {
sanitized_epoch: Epoch::MAX,
alt_invalidation_slot: Slot::MAX,
};
}

/// Message: [Scheduler -> Worker]
/// Transactions to be consumed (i.e. executed, recorded, and committed)
pub struct ConsumeWork {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ mod tests {
crossbeam_channel::{unbounded, Receiver},
itertools::Itertools,
solana_sdk::{
clock::Slot, compute_budget::ComputeBudgetInstruction, hash::Hash, message::Message,
packet::Packet, pubkey::Pubkey, signature::Keypair, signer::Signer, system_instruction,
compute_budget::ComputeBudgetInstruction, hash::Hash, message::Message, packet::Packet,
pubkey::Pubkey, signature::Keypair, signer::Signer, system_instruction,
transaction::Transaction,
},
std::{borrow::Borrow, sync::Arc},
Expand Down Expand Up @@ -709,10 +709,7 @@ mod tests {
);
let transaction_ttl = SanitizedTransactionTTL {
transaction,
max_age: MaxAge {
epoch_invalidation_slot: Slot::MAX,
alt_invalidation_slot: Slot::MAX,
},
max_age: MaxAge::MAX,
};
const TEST_TRANSACTION_COST: u64 = 5000;
container.insert_new_transaction(
Expand Down
Loading

0 comments on commit 8629123

Please sign in to comment.