Store versioned transactions in the ledger, disabled by default (#19139)

* Add support for versioned transactions, but disable by default

* merge conflicts

* trent's feedback

* bump Cargo.lock

* Fix transaction error encoding

* Rename legacy_transaction method

* cargo clippy

* Clean up casts, int arithmetic, and unused methods

* Check for duplicates in sanitized message conversion

* fix clippy

* fix new test

* Fix bpf conditional compilation for message module
This commit is contained in:
Justin Starry
2021-08-17 15:17:56 -07:00
committed by GitHub
parent 098e2b2de3
commit c50b01cb60
47 changed files with 2373 additions and 1049 deletions

View File

@ -42,6 +42,7 @@ enum TransactionErrorType {
CLUSTER_MAINTENANCE = 15;
ACCOUNT_BORROW_OUTSTANDING_TX = 16;
WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 17;
UNSUPPORTED_VERSION = 18;
}
message InstructionError {

View File

@ -548,6 +548,8 @@ impl TryFrom<tx_by_addr::TransactionError> for TransactionError {
14 => TransactionError::SanitizeFailure,
15 => TransactionError::ClusterMaintenance,
16 => TransactionError::AccountBorrowOutstanding,
17 => TransactionError::WouldExceedMaxBlockCostLimit,
18 => TransactionError::UnsupportedVersion,
_ => return Err("Invalid TransactionError"),
})
}
@ -609,6 +611,9 @@ impl From<TransactionError> for tx_by_addr::TransactionError {
TransactionError::WouldExceedMaxBlockCostLimit => {
tx_by_addr::TransactionErrorType::WouldExceedMaxBlockCostLimit
}
TransactionError::UnsupportedVersion => {
tx_by_addr::TransactionErrorType::UnsupportedVersion
}
} as i32,
instruction_error: match transaction_error {
TransactionError::InstructionError(index, ref instruction_error) => {
@ -884,6 +889,14 @@ mod test {
#[test]
fn test_transaction_error_encode() {
let transaction_error = TransactionError::AccountBorrowOutstanding;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();
assert_eq!(
transaction_error,
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error = TransactionError::AccountInUse;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();
@ -908,6 +921,14 @@ mod test {
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error = TransactionError::AlreadyProcessed;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();
assert_eq!(
transaction_error,
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error = TransactionError::BlockhashNotFound;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();
@ -932,14 +953,6 @@ mod test {
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error = TransactionError::AlreadyProcessed;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();
assert_eq!(
transaction_error,
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error = TransactionError::InsufficientFundsForFee;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();
@ -1004,6 +1017,22 @@ mod test {
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error = TransactionError::WouldExceedMaxBlockCostLimit;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();
assert_eq!(
transaction_error,
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error = TransactionError::UnsupportedVersion;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();
assert_eq!(
transaction_error,
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error =
TransactionError::InstructionError(10, InstructionError::AccountAlreadyInitialized);
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =