port counting vote CUs to block cost (#22477)

This commit is contained in:
Tao Zhu
2022-01-12 23:27:19 -06:00
committed by Tao Zhu
parent cddab635ff
commit 9c9f2dd5bd
13 changed files with 239 additions and 148 deletions

View File

@ -52,6 +52,7 @@ enum TransactionErrorType {
INVALID_ADDRESS_LOOKUP_TABLE_DATA = 25;
INVALID_ADDRESS_LOOKUP_TABLE_INDEX = 26;
INVALID_RENT_PAYING_ACCOUNT = 27;
WOULD_EXCEED_MAX_VOTE_COST_LIMIT = 28;
}
message InstructionError {

View File

@ -727,6 +727,7 @@ impl TryFrom<tx_by_addr::TransactionError> for TransactionError {
25 => TransactionError::InvalidAddressLookupTableData,
26 => TransactionError::InvalidAddressLookupTableIndex,
27 => TransactionError::InvalidRentPayingAccount,
28 => TransactionError::WouldExceedMaxVoteCostLimit,
_ => return Err("Invalid TransactionError"),
})
}
@ -815,10 +816,12 @@ impl From<TransactionError> for tx_by_addr::TransactionError {
TransactionError::InvalidAddressLookupTableIndex => {
tx_by_addr::TransactionErrorType::InvalidAddressLookupTableIndex
}
TransactionError::InvalidRentPayingAccount => {
tx_by_addr::TransactionErrorType::InvalidRentPayingAccount
}
TransactionError::WouldExceedMaxVoteCostLimit => {
tx_by_addr::TransactionErrorType::WouldExceedMaxVoteCostLimit
}
} as i32,
instruction_error: match transaction_error {
TransactionError::InstructionError(index, ref instruction_error) => {
@ -1233,6 +1236,14 @@ mod test {
tx_by_addr_transaction_error.try_into().unwrap()
);
let transaction_error = TransactionError::WouldExceedMaxVoteCostLimit;
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::WouldExceedMaxAccountCostLimit;
let tx_by_addr_transaction_error: tx_by_addr::TransactionError =
transaction_error.clone().into();