refactor cost calculation (#21062)
* - cache calculated transaction cost to allow sharing; - atomic cost tracking op; - only lock accounts for transactions eligible for current block; - moved qos service and stats reporting to its own model; - add cost_weight default to neutral (as 1), vote has zero weight; Co-authored-by: Tyera Eulberg <teulberg@gmail.com> * Update core/src/qos_service.rs Co-authored-by: Tyera Eulberg <teulberg@gmail.com> * Update core/src/qos_service.rs Co-authored-by: Tyera Eulberg <teulberg@gmail.com> Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
This commit is contained in:
@@ -44,6 +44,7 @@ enum TransactionErrorType {
|
||||
WOULD_EXCEED_MAX_BLOCK_COST_LIMIT = 17;
|
||||
UNSUPPORTED_VERSION = 18;
|
||||
INVALID_WRITABLE_ACCOUNT = 19;
|
||||
WOULD_EXCEED_MAX_ACCOUNT_COST_LIMIT = 20;
|
||||
}
|
||||
|
||||
message InstructionError {
|
||||
|
@@ -553,6 +553,7 @@ impl TryFrom<tx_by_addr::TransactionError> for TransactionError {
|
||||
17 => TransactionError::WouldExceedMaxBlockCostLimit,
|
||||
18 => TransactionError::UnsupportedVersion,
|
||||
19 => TransactionError::InvalidWritableAccount,
|
||||
20 => TransactionError::WouldExceedMaxAccountCostLimit,
|
||||
_ => return Err("Invalid TransactionError"),
|
||||
})
|
||||
}
|
||||
@@ -620,6 +621,9 @@ impl From<TransactionError> for tx_by_addr::TransactionError {
|
||||
TransactionError::InvalidWritableAccount => {
|
||||
tx_by_addr::TransactionErrorType::InvalidWritableAccount
|
||||
}
|
||||
TransactionError::WouldExceedMaxAccountCostLimit => {
|
||||
tx_by_addr::TransactionErrorType::WouldExceedMaxAccountCostLimit
|
||||
}
|
||||
} as i32,
|
||||
instruction_error: match transaction_error {
|
||||
TransactionError::InstructionError(index, ref instruction_error) => {
|
||||
@@ -1031,6 +1035,14 @@ mod test {
|
||||
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();
|
||||
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();
|
||||
|
Reference in New Issue
Block a user