Skip to content

Commit

Permalink
Advance test-vectors commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Dec 3, 2024
1 parent 54a254f commit 27f1ff9
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 129 deletions.
7 changes: 6 additions & 1 deletion svm-conformance/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
fn main() {
let proto_base_path = std::path::PathBuf::from("proto");
let protos = ["context.proto", "invoke.proto", "sysvar.proto", "txn.proto"];
let protos = [
"context.proto",
"invoke.proto",
"metadata.proto",
"txn.proto",
];
let protos_path: Vec<_> = protos
.iter()
.map(|name| proto_base_path.join(name))
Expand Down
11 changes: 2 additions & 9 deletions svm-conformance/proto/context.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
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
Expand Down Expand Up @@ -55,14 +53,9 @@ 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;
}
fixed64 slot = 1;
}
10 changes: 5 additions & 5 deletions svm-conformance/proto/invoke.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";
package org.solana.sealevel.v1;

import "context.proto";
import "txn.proto";
import "metadata.proto";

message InstrAcct {
// Selects an account in an external list
Expand Down Expand Up @@ -30,7 +30,6 @@ message InstrContext {

uint64 cu_avail = 6;

TxnContext txn_context = 7;
SlotContext slot_context = 8;
EpochContext epoch_context = 9;
}
Expand Down Expand Up @@ -60,6 +59,7 @@ message InstrEffects {

// An instruction processing test fixture.
message InstrFixture {
InstrContext input = 1;
InstrEffects output = 2;
}
FixtureMetadata metadata = 1;
InstrContext input = 2;
InstrEffects output = 3;
}
7 changes: 7 additions & 0 deletions svm-conformance/proto/metadata.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";
package org.solana.sealevel.v1;

// FixtureMetadata includes the metadata for the fixture
message FixtureMetadata {
string fn_entrypoint = 1;
}
32 changes: 0 additions & 32 deletions svm-conformance/proto/sysvar.proto

This file was deleted.

75 changes: 47 additions & 28 deletions svm-conformance/proto/txn.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package org.solana.sealevel.v1;

import "context.proto";
import "metadata.proto";

// Message header contains the counts of required readonly and signatures
message MessageHeader {
Expand All @@ -10,7 +11,6 @@ message MessageHeader {
uint32 num_readonly_unsigned_accounts = 3;
}


// The instruction a transaction executes
message CompiledInstruction {
// Index into the message pubkey array
Expand All @@ -27,31 +27,27 @@ message MessageAddressTableLookup {
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

// Recent blockhash provided in message
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
Expand All @@ -72,44 +68,67 @@ message SanitizedTransaction {
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;

// Up to 300 (actually 301) most recent blockhashes (ordered from oldest to newest)
repeated bytes blockhash_queue = 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;
repeated AcctState acct_states = 1;
repeated RentDebits rent_debits = 2;
uint64 transaction_rent = 3;
}

// The rent state for an account after a transaction
message RentDebits {
uint64 rent_collected = 1;
uint64 post_balance = 2;
bytes pubkey = 1;
int64 rent_collected = 2;
}

message FeeDetails {
uint64 transaction_fee = 1;
uint64 prioritization_fee = 2;
}

// The execution results for a transaction
message TxnResult {
// Whether this transaction was executed
bool executed = 1;
// Whether there was a sanitization error
bool sanitization_error = 2;
// The state of each account after the transaction
repeated ResultingState states = 2;
uint64 rent = 3;
ResultingState resulting_state = 3;
uint64 rent = 4;

// If an executed transaction has no error
bool is_ok = 4;
bool is_ok = 5;
// The transaction status (error code)
uint32 status = 5;
uint32 status = 6;
// The instruction error, if any
uint32 instruction_error = 7;
// The instruction error index, if any
uint32 instruction_error_index = 8;
// Custom error, if any
uint32 custom_error = 9;


// The return data from this transaction, if any
bytes return_data = 6;
bytes return_data = 10;
// Number of executed compute units
uint64 executed_units = 7;
// The change in accounts data len for this transaction
uint64 accounts_data_len_delta = 8;
}
uint64 executed_units = 11;
// The collected fees in this transaction
FeeDetails fee_details = 12;
}

// Txn fixtures
message TxnFixture {
FixtureMetadata metadata = 1;
// Context
TxnContext input = 2;
// Effects
TxnResult output = 3;
}
5 changes: 5 additions & 0 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,11 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
.assign_program(program_id, Arc::new(builtin));
debug!("Added program {} under {:?}", name, program_id);
}

#[cfg(feature = "dev-context-only-utils")]
pub fn writable_sysvar_cache(&self) -> &RwLock<SysvarCache> {
&self.sysvar_cache
}
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit 27f1ff9

Please sign in to comment.