From c2756cb7ae00b4cabd2d4c5bf6c0809949649463 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Mon, 1 Jul 2024 13:09:57 -0500 Subject: [PATCH 1/4] init svm-conformance crate --- Cargo.lock | 4 ++++ Cargo.toml | 2 ++ svm-conformance/Cargo.toml | 16 ++++++++++++++++ svm-conformance/src/lib.rs | 1 + 4 files changed, 23 insertions(+) create mode 100644 svm-conformance/Cargo.toml create mode 100644 svm-conformance/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index b787b8c7ade600..1f2ef75ab0a3ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7509,6 +7509,10 @@ dependencies = [ "solana-vote", ] +[[package]] +name = "solana-svm-conformance" +version = "2.1.0" + [[package]] name = "solana-system-program" version = "2.1.0" diff --git a/Cargo.toml b/Cargo.toml index 594ab8b7aa8768..195ea0c3680fa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,6 +110,7 @@ members = [ "storage-proto", "streamer", "svm", + "svm-conformance", "test-validator", "thin-client", "tokens", @@ -395,6 +396,7 @@ solana-storage-bigtable = { path = "storage-bigtable", version = "=2.1.0" } solana-storage-proto = { path = "storage-proto", version = "=2.1.0" } solana-streamer = { path = "streamer", version = "=2.1.0" } solana-svm = { path = "svm", version = "=2.1.0" } +solana-svm-conformance = { path = "svm-conformance", version = "=2.1.0" } solana-system-program = { path = "programs/system", version = "=2.1.0" } solana-test-validator = { path = "test-validator", version = "=2.1.0" } solana-thin-client = { path = "thin-client", version = "=2.1.0" } diff --git a/svm-conformance/Cargo.toml b/svm-conformance/Cargo.toml new file mode 100644 index 00000000000000..f879c7d0d06191 --- /dev/null +++ b/svm-conformance/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "solana-svm-conformance" +description = "Solana SVM conformance" +documentation = "https://docs.rs/solana-svm-conformance" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } +publish = false + +[dependencies] + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/svm-conformance/src/lib.rs b/svm-conformance/src/lib.rs new file mode 100644 index 00000000000000..8b137891791fe9 --- /dev/null +++ b/svm-conformance/src/lib.rs @@ -0,0 +1 @@ + From 90ad44ac0406a249e6ef35658e1b3903dd82eb39 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Mon, 1 Jul 2024 13:13:51 -0500 Subject: [PATCH 2/4] svm-conformance: add protos --- Cargo.lock | 5 ++ svm-conformance/Cargo.toml | 5 ++ svm-conformance/build.rs | 15 ++++ svm-conformance/proto/context.proto | 68 ++++++++++++++++ svm-conformance/proto/invoke.proto | 65 ++++++++++++++++ svm-conformance/proto/sysvar.proto | 32 ++++++++ svm-conformance/proto/txn.proto | 115 ++++++++++++++++++++++++++++ svm-conformance/src/lib.rs | 4 +- 8 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 svm-conformance/build.rs create mode 100644 svm-conformance/proto/context.proto create mode 100644 svm-conformance/proto/invoke.proto create mode 100644 svm-conformance/proto/sysvar.proto create mode 100644 svm-conformance/proto/txn.proto diff --git a/Cargo.lock b/Cargo.lock index 1f2ef75ab0a3ca..d379a38a5030b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7512,6 +7512,11 @@ dependencies = [ [[package]] name = "solana-svm-conformance" version = "2.1.0" +dependencies = [ + "prost", + "prost-build", + "prost-types", +] [[package]] name = "solana-system-program" diff --git a/svm-conformance/Cargo.toml b/svm-conformance/Cargo.toml index f879c7d0d06191..0c7acab11e50bd 100644 --- a/svm-conformance/Cargo.toml +++ b/svm-conformance/Cargo.toml @@ -11,6 +11,11 @@ edition = { workspace = true } publish = false [dependencies] +prost = { workspace = true } +prost-types = { workspace = true } + +[build-dependencies] +prost-build = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/svm-conformance/build.rs b/svm-conformance/build.rs new file mode 100644 index 00000000000000..b3fb66548a03b5 --- /dev/null +++ b/svm-conformance/build.rs @@ -0,0 +1,15 @@ +fn main() { + let proto_base_path = std::path::PathBuf::from("proto"); + let protos = ["context.proto", "invoke.proto", "sysvar.proto", "txn.proto"]; + let protos_path: Vec<_> = protos + .iter() + .map(|name| proto_base_path.join(name)) + .collect(); + + protos_path + .iter() + .for_each(|proto| println!("cargo:rerun-if-changed={}", proto.display())); + + prost_build::compile_protos(protos_path.as_ref(), &[proto_base_path]) + .expect("Failed to compile protobuf files"); +} diff --git a/svm-conformance/proto/context.proto b/svm-conformance/proto/context.proto new file mode 100644 index 00000000000000..cd196a3bcfc843 --- /dev/null +++ b/svm-conformance/proto/context.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package org.solana.sealevel.v1; + +import "sysvar.proto"; + +// A set of feature flags. +message FeatureSet { + // Every item in this list marks an enabled feature. The value of + // each item is the first 8 bytes of the feature ID as a little- + // endian integer. + repeated fixed64 features = 1; +} + +// A seed address. This is not a PDA. +message SeedAddress { + // The seed address base. (32 bytes) + bytes base = 1; + + // The seed path (<= 32 bytes) + bytes seed = 2; + + // The seed address owner. (32 bytes) + bytes owner = 3; +} + +// The complete state of an account excluding its public key. +message AcctState { + // The account address. (32 bytes) + bytes address = 1; + + uint64 lamports = 2; + + // Account data is limited to 10 MiB on Solana mainnet as of 2024-Feb. + bytes data = 3; + + bool executable = 4; + + // The rent epoch is deprecated on Solana mainnet as of 2024-Feb. + // If ommitted, implies a value of UINT64_MAX. + uint64 rent_epoch = 5; + + // Address of the program that owns this account. (32 bytes) + bytes owner = 6; + + // The account address, but derived as a seed address. Overrides + // `address` if present. + // TODO: This is a solfuzz specific extension and is not compliant + // with the org.solana.sealevel.v1 API. + SeedAddress seed_addr = 7; +} + +// EpochContext includes context scoped to an epoch. +// On "real" ledgers, it is created during the epoch boundary. +message EpochContext { + FeatureSet features = 1; +} + + +// SlotContext includes context scoped to a block. +// On "real" ledgers, it is created during the slot boundary. +message SlotContext { + repeated bytes recent_block_hashes = 1; + // public key for the leader + bytes leader = 2; + // Slot number + fixed64 slot = 3; + SysvarCache sysvar_cache = 4; +} \ No newline at end of file diff --git a/svm-conformance/proto/invoke.proto b/svm-conformance/proto/invoke.proto new file mode 100644 index 00000000000000..63d0d31985f188 --- /dev/null +++ b/svm-conformance/proto/invoke.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; +package org.solana.sealevel.v1; + +import "context.proto"; +import "txn.proto"; + +message InstrAcct { + // Selects an account in an external list + uint32 index = 1; + bool is_writable = 2; + bool is_signer = 3; +} + +// The execution context of a program invocation (aka instruction). +// Contains all required information to independently replay an instruction. +// Also includes partial transaction context. +message InstrContext { + // The address of the program invoked. (32 bytes) + bytes program_id = 1; + + // Account state accessed by the instruction. This may include + // indirect accesses like sysvars. + repeated AcctState accounts = 3; + + // Account access list for this instruction (refers to above accounts list) + repeated InstrAcct instr_accounts = 4; + + // The input data passed to program execution. + bytes data = 5; + + uint64 cu_avail = 6; + + TxnContext txn_context = 7; + SlotContext slot_context = 8; + EpochContext epoch_context = 9; +} + +// The results of executing an InstrContext. +message InstrEffects { + // result is zero if the instruction executed succesfully. + // Otherwise, a non-zero error code. Error codes are not relevant to + // consensus. + int32 result = 1; + + // Some error cases additionally have a custom error code. Unlike + // the expected_result, this is stable across clients. + uint32 custom_err = 2; + + // Copies of accounts that were changed. May be in an arbitrary + // order. The pubkey of each account is unique in this list. Each + // account address modified here must also be in the + // InstrContext. + repeated AcctState modified_accounts = 3; + + uint64 cu_avail = 4; + + // Instruction return data. + bytes return_data = 5; +} + +// An instruction processing test fixture. +message InstrFixture { + InstrContext input = 1; + InstrEffects output = 2; +} \ No newline at end of file diff --git a/svm-conformance/proto/sysvar.proto b/svm-conformance/proto/sysvar.proto new file mode 100644 index 00000000000000..a0139b61622104 --- /dev/null +++ b/svm-conformance/proto/sysvar.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package org.solana.sealevel.v1; + +// The clock account data +message Clock { + uint64 slot = 1; + uint64 epoch_start_timestamp = 2; + uint64 epoch = 3; + uint64 leader_schedule_epoch = 4; + uint64 unix_timestamp = 5; +} + +// The data for the Rent account +message Rent { + uint64 lamports_per_byte_year = 1; + double exemption_threshold = 2; + uint64 burn_percent = 3; +} + +// The recent slot hash vector contents +message SlotHash { + uint64 slot = 1; + bytes hash = 2; +} + +// The sysvar cache for a transaction execution +message SysvarCache { + Clock clock = 1; + Rent rent = 2; + // Slot hashes sysvar: SysvarS1otHashes111111111111111111111111111 + repeated SlotHash slot_hash = 3; +} \ No newline at end of file diff --git a/svm-conformance/proto/txn.proto b/svm-conformance/proto/txn.proto new file mode 100644 index 00000000000000..b71e524fc80926 --- /dev/null +++ b/svm-conformance/proto/txn.proto @@ -0,0 +1,115 @@ +syntax = "proto3"; +package org.solana.sealevel.v1; + +import "context.proto"; + +// Message header contains the counts of required readonly and signatures +message MessageHeader { + uint32 num_required_signatures = 1; + uint32 num_readonly_signed_accounts = 2; + uint32 num_readonly_unsigned_accounts = 3; +} + + +// The instruction a transaction executes +message CompiledInstruction { + // Index into the message pubkey array + uint32 program_id_index = 1; + // Indexes into the message pubkey array + repeated uint32 accounts = 2; + bytes data = 3; +} + +// List of address table lookups used to load additional accounts for a transaction +message MessageAddressTableLookup { + bytes account_key = 1; + repeated uint32 writable_indexes = 2; + repeated uint32 readonly_indexes = 3; +} + +// Addresses loaded with on-chain lookup tables +message LoadedAddresses { + repeated bytes writable = 1; + repeated bytes readonly = 2; +} + +// Message contains the transaction data +message TransactionMessage { + // Whether this is a legacy message or not + bool is_legacy = 1; + + MessageHeader header = 2; + // Vector of pubkeys + repeated bytes account_keys = 3; + // Data associated with the accounts referred above. Not all accounts need to be here. + repeated AcctState account_shared_data = 4; + // The block hash contains 32-bytes + bytes recent_blockhash = 5; + // The instructions this transaction executes + repeated CompiledInstruction instructions = 6; + + // Not available in legacy message + repeated MessageAddressTableLookup address_table_lookups = 7; + // Not available in legacy messages + LoadedAddresses loaded_addresses = 8; +} + +// A valid verified transaction +message SanitizedTransaction { + // The transaction information + TransactionMessage message = 1; + // The message hash + bytes message_hash = 2; + // Is this a voting transaction? + bool is_simple_vote_tx = 3; + // The signatures needed in the transaction + repeated bytes signatures = 4; +} + +// This Transaction context be used to fuzz either `load_execute_and_commit_transactions`, +// `load_and_execute_transactions` in `bank.rs` or `load_and_execute_sanitized_transactions` +// in `svm/transaction_processor.rs` +message TxnContext { + // The transaction data + SanitizedTransaction tx = 1; + // The maximum age allowed for this transaction + uint64 max_age = 2; + // The limit of bytes allowed for this transaction to load + uint64 log_messages_byte_limit = 3; + + EpochContext epoch_ctx = 4; + SlotContext slot_ctx = 5; +} + +// The resulting state of an account after a transaction +message ResultingState { + AcctState state = 1; + uint64 transaction_rent = 2; + RentDebits rent_debit = 3; +} + +// The rent state for an account after a transaction +message RentDebits { + uint64 rent_collected = 1; + uint64 post_balance = 2; +} + +// The execution results for a transaction +message TxnResult { + // Whether this transaction was executed + bool executed = 1; + // The state of each account after the transaction + repeated ResultingState states = 2; + uint64 rent = 3; + + // If an executed transaction has no error + bool is_ok = 4; + // The transaction status (error code) + uint32 status = 5; + // The return data from this transaction, if any + bytes return_data = 6; + // Number of executed compute units + uint64 executed_units = 7; + // The change in accounts data len for this transaction + uint64 accounts_data_len_delta = 8; +} \ No newline at end of file diff --git a/svm-conformance/src/lib.rs b/svm-conformance/src/lib.rs index 8b137891791fe9..937880c131d7ce 100644 --- a/svm-conformance/src/lib.rs +++ b/svm-conformance/src/lib.rs @@ -1 +1,3 @@ - +pub mod proto { + include!(concat!(env!("OUT_DIR"), "/org.solana.sealevel.v1.rs")); +} From f26eea6a07854bc170c141242054f7fb50b235b5 Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Mon, 1 Jul 2024 13:21:35 -0500 Subject: [PATCH 3/4] svm: use svm-conformance for tests --- Cargo.lock | 3 +-- programs/sbf/Cargo.lock | 1 - svm/Cargo.toml | 3 +-- svm/build.rs | 14 -------------- svm/tests/conformance.rs | 7 ++----- 5 files changed, 4 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d379a38a5030b0..c71bd32fbab642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7486,8 +7486,6 @@ dependencies = [ "log", "percentage", "prost", - "prost-build", - "prost-types", "rand 0.8.5", "rustc_version 0.4.0", "serde", @@ -7504,6 +7502,7 @@ dependencies = [ "solana-program-runtime", "solana-sdk", "solana-svm", + "solana-svm-conformance", "solana-system-program", "solana-type-overrides", "solana-vote", diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index b0699636deb78c..8a192d1b538512 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -6284,7 +6284,6 @@ dependencies = [ "itertools 0.12.1", "log", "percentage", - "prost-build", "rustc_version", "serde", "serde_derive", diff --git a/svm/Cargo.toml b/svm/Cargo.toml index 2c1d910ec0a783..1416cbec9be11c 100644 --- a/svm/Cargo.toml +++ b/svm/Cargo.toml @@ -37,7 +37,6 @@ bincode = { workspace = true } lazy_static = { workspace = true } libsecp256k1 = { workspace = true } prost = { workspace = true } -prost-types = { workspace = true } rand = { workspace = true } solana-bpf-loader-program = { workspace = true } solana-compute-budget-program = { workspace = true } @@ -45,12 +44,12 @@ solana-logger = { workspace = true } solana-sdk = { workspace = true, features = ["dev-context-only-utils"] } # See order-crates-for-publishing.py for using this unusual `path = "."` solana-svm = { path = ".", features = ["dev-context-only-utils"] } +solana-svm-conformance = { workspace = true } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] -prost-build = { workspace = true } rustc_version = { workspace = true } [features] diff --git a/svm/build.rs b/svm/build.rs index 178c7d70b66c6a..e17ca70cb4718b 100644 --- a/svm/build.rs +++ b/svm/build.rs @@ -19,18 +19,4 @@ fn main() { println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION"); } } - - let proto_base_path = std::path::PathBuf::from("proto"); - let protos = ["context.proto", "invoke.proto", "sysvar.proto", "txn.proto"]; - let protos_path: Vec<_> = protos - .iter() - .map(|name| proto_base_path.join(name)) - .collect(); - - protos_path - .iter() - .for_each(|proto| println!("cargo:rerun-if-changed={}", proto.display())); - - prost_build::compile_protos(protos_path.as_ref(), &[proto_base_path]) - .expect("Failed to compile protobuf files"); } diff --git a/svm/tests/conformance.rs b/svm/tests/conformance.rs index 865cf325cb2596..ad98dd8cb3708a 100644 --- a/svm/tests/conformance.rs +++ b/svm/tests/conformance.rs @@ -1,7 +1,6 @@ use { crate::{ mock_bank::{MockBankCallback, MockForkGraph}, - proto::{InstrEffects, InstrFixture}, transaction_builder::SanitizedTransactionBuilder, }, lazy_static::lazy_static, @@ -43,6 +42,7 @@ use { TransactionProcessingEnvironment, }, }, + solana_svm_conformance::proto::{InstrEffects, InstrFixture}, std::{ collections::{HashMap, HashSet}, env, @@ -55,9 +55,6 @@ use { }, }; -mod proto { - include!(concat!(env!("OUT_DIR"), "/org.solana.sealevel.v1.rs")); -} mod mock_bank; mod transaction_builder; @@ -151,7 +148,7 @@ fn run_from_folder(base_dir: &PathBuf, run_as_instr: &HashSet) { let mut buffer = Vec::new(); file.read_to_end(&mut buffer).expect("Failed to read file"); - let fixture = proto::InstrFixture::decode(buffer.as_slice()).unwrap(); + let fixture = InstrFixture::decode(buffer.as_slice()).unwrap(); let execute_as_instr = run_as_instr.contains(&filename); run_fixture(fixture, filename, execute_as_instr); } From 194c8e454f82cc21f1a403c31880b2a06ed99bbc Mon Sep 17 00:00:00 2001 From: Joe Caulfield Date: Mon, 1 Jul 2024 13:27:36 -0500 Subject: [PATCH 4/4] svm: drop protos --- svm/proto/context.proto | 68 ------------------------ svm/proto/invoke.proto | 65 ----------------------- svm/proto/sysvar.proto | 32 ----------- svm/proto/txn.proto | 115 ---------------------------------------- 4 files changed, 280 deletions(-) delete mode 100644 svm/proto/context.proto delete mode 100644 svm/proto/invoke.proto delete mode 100644 svm/proto/sysvar.proto delete mode 100644 svm/proto/txn.proto diff --git a/svm/proto/context.proto b/svm/proto/context.proto deleted file mode 100644 index cd196a3bcfc843..00000000000000 --- a/svm/proto/context.proto +++ /dev/null @@ -1,68 +0,0 @@ -syntax = "proto3"; -package org.solana.sealevel.v1; - -import "sysvar.proto"; - -// A set of feature flags. -message FeatureSet { - // Every item in this list marks an enabled feature. The value of - // each item is the first 8 bytes of the feature ID as a little- - // endian integer. - repeated fixed64 features = 1; -} - -// A seed address. This is not a PDA. -message SeedAddress { - // The seed address base. (32 bytes) - bytes base = 1; - - // The seed path (<= 32 bytes) - bytes seed = 2; - - // The seed address owner. (32 bytes) - bytes owner = 3; -} - -// The complete state of an account excluding its public key. -message AcctState { - // The account address. (32 bytes) - bytes address = 1; - - uint64 lamports = 2; - - // Account data is limited to 10 MiB on Solana mainnet as of 2024-Feb. - bytes data = 3; - - bool executable = 4; - - // The rent epoch is deprecated on Solana mainnet as of 2024-Feb. - // If ommitted, implies a value of UINT64_MAX. - uint64 rent_epoch = 5; - - // Address of the program that owns this account. (32 bytes) - bytes owner = 6; - - // The account address, but derived as a seed address. Overrides - // `address` if present. - // TODO: This is a solfuzz specific extension and is not compliant - // with the org.solana.sealevel.v1 API. - SeedAddress seed_addr = 7; -} - -// EpochContext includes context scoped to an epoch. -// On "real" ledgers, it is created during the epoch boundary. -message EpochContext { - FeatureSet features = 1; -} - - -// SlotContext includes context scoped to a block. -// On "real" ledgers, it is created during the slot boundary. -message SlotContext { - repeated bytes recent_block_hashes = 1; - // public key for the leader - bytes leader = 2; - // Slot number - fixed64 slot = 3; - SysvarCache sysvar_cache = 4; -} \ No newline at end of file diff --git a/svm/proto/invoke.proto b/svm/proto/invoke.proto deleted file mode 100644 index 63d0d31985f188..00000000000000 --- a/svm/proto/invoke.proto +++ /dev/null @@ -1,65 +0,0 @@ -syntax = "proto3"; -package org.solana.sealevel.v1; - -import "context.proto"; -import "txn.proto"; - -message InstrAcct { - // Selects an account in an external list - uint32 index = 1; - bool is_writable = 2; - bool is_signer = 3; -} - -// The execution context of a program invocation (aka instruction). -// Contains all required information to independently replay an instruction. -// Also includes partial transaction context. -message InstrContext { - // The address of the program invoked. (32 bytes) - bytes program_id = 1; - - // Account state accessed by the instruction. This may include - // indirect accesses like sysvars. - repeated AcctState accounts = 3; - - // Account access list for this instruction (refers to above accounts list) - repeated InstrAcct instr_accounts = 4; - - // The input data passed to program execution. - bytes data = 5; - - uint64 cu_avail = 6; - - TxnContext txn_context = 7; - SlotContext slot_context = 8; - EpochContext epoch_context = 9; -} - -// The results of executing an InstrContext. -message InstrEffects { - // result is zero if the instruction executed succesfully. - // Otherwise, a non-zero error code. Error codes are not relevant to - // consensus. - int32 result = 1; - - // Some error cases additionally have a custom error code. Unlike - // the expected_result, this is stable across clients. - uint32 custom_err = 2; - - // Copies of accounts that were changed. May be in an arbitrary - // order. The pubkey of each account is unique in this list. Each - // account address modified here must also be in the - // InstrContext. - repeated AcctState modified_accounts = 3; - - uint64 cu_avail = 4; - - // Instruction return data. - bytes return_data = 5; -} - -// An instruction processing test fixture. -message InstrFixture { - InstrContext input = 1; - InstrEffects output = 2; -} \ No newline at end of file diff --git a/svm/proto/sysvar.proto b/svm/proto/sysvar.proto deleted file mode 100644 index a0139b61622104..00000000000000 --- a/svm/proto/sysvar.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto3"; -package org.solana.sealevel.v1; - -// The clock account data -message Clock { - uint64 slot = 1; - uint64 epoch_start_timestamp = 2; - uint64 epoch = 3; - uint64 leader_schedule_epoch = 4; - uint64 unix_timestamp = 5; -} - -// The data for the Rent account -message Rent { - uint64 lamports_per_byte_year = 1; - double exemption_threshold = 2; - uint64 burn_percent = 3; -} - -// The recent slot hash vector contents -message SlotHash { - uint64 slot = 1; - bytes hash = 2; -} - -// The sysvar cache for a transaction execution -message SysvarCache { - Clock clock = 1; - Rent rent = 2; - // Slot hashes sysvar: SysvarS1otHashes111111111111111111111111111 - repeated SlotHash slot_hash = 3; -} \ No newline at end of file diff --git a/svm/proto/txn.proto b/svm/proto/txn.proto deleted file mode 100644 index b71e524fc80926..00000000000000 --- a/svm/proto/txn.proto +++ /dev/null @@ -1,115 +0,0 @@ -syntax = "proto3"; -package org.solana.sealevel.v1; - -import "context.proto"; - -// Message header contains the counts of required readonly and signatures -message MessageHeader { - uint32 num_required_signatures = 1; - uint32 num_readonly_signed_accounts = 2; - uint32 num_readonly_unsigned_accounts = 3; -} - - -// The instruction a transaction executes -message CompiledInstruction { - // Index into the message pubkey array - uint32 program_id_index = 1; - // Indexes into the message pubkey array - repeated uint32 accounts = 2; - bytes data = 3; -} - -// List of address table lookups used to load additional accounts for a transaction -message MessageAddressTableLookup { - bytes account_key = 1; - repeated uint32 writable_indexes = 2; - repeated uint32 readonly_indexes = 3; -} - -// Addresses loaded with on-chain lookup tables -message LoadedAddresses { - repeated bytes writable = 1; - repeated bytes readonly = 2; -} - -// Message contains the transaction data -message TransactionMessage { - // Whether this is a legacy message or not - bool is_legacy = 1; - - MessageHeader header = 2; - // Vector of pubkeys - repeated bytes account_keys = 3; - // Data associated with the accounts referred above. Not all accounts need to be here. - repeated AcctState account_shared_data = 4; - // The block hash contains 32-bytes - bytes recent_blockhash = 5; - // The instructions this transaction executes - repeated CompiledInstruction instructions = 6; - - // Not available in legacy message - repeated MessageAddressTableLookup address_table_lookups = 7; - // Not available in legacy messages - LoadedAddresses loaded_addresses = 8; -} - -// A valid verified transaction -message SanitizedTransaction { - // The transaction information - TransactionMessage message = 1; - // The message hash - bytes message_hash = 2; - // Is this a voting transaction? - bool is_simple_vote_tx = 3; - // The signatures needed in the transaction - repeated bytes signatures = 4; -} - -// This Transaction context be used to fuzz either `load_execute_and_commit_transactions`, -// `load_and_execute_transactions` in `bank.rs` or `load_and_execute_sanitized_transactions` -// in `svm/transaction_processor.rs` -message TxnContext { - // The transaction data - SanitizedTransaction tx = 1; - // The maximum age allowed for this transaction - uint64 max_age = 2; - // The limit of bytes allowed for this transaction to load - uint64 log_messages_byte_limit = 3; - - EpochContext epoch_ctx = 4; - SlotContext slot_ctx = 5; -} - -// The resulting state of an account after a transaction -message ResultingState { - AcctState state = 1; - uint64 transaction_rent = 2; - RentDebits rent_debit = 3; -} - -// The rent state for an account after a transaction -message RentDebits { - uint64 rent_collected = 1; - uint64 post_balance = 2; -} - -// The execution results for a transaction -message TxnResult { - // Whether this transaction was executed - bool executed = 1; - // The state of each account after the transaction - repeated ResultingState states = 2; - uint64 rent = 3; - - // If an executed transaction has no error - bool is_ok = 4; - // The transaction status (error code) - uint32 status = 5; - // The return data from this transaction, if any - bytes return_data = 6; - // Number of executed compute units - uint64 executed_units = 7; - // The change in accounts data len for this transaction - uint64 accounts_data_len_delta = 8; -} \ No newline at end of file