Remove blockhash from fee calculation (#20641)

This commit is contained in:
Jack May
2021-10-13 13:10:58 -07:00
committed by GitHub
parent 149d224557
commit da45be366a
21 changed files with 53 additions and 119 deletions

View File

@ -1961,12 +1961,11 @@ impl JsonRpcRequestProcessor {
fn get_fee_for_message(
&self,
blockhash: &Hash,
message: &SanitizedMessage,
commitment: Option<CommitmentConfig>,
) -> Result<RpcResponse<Option<u64>>> {
let bank = self.bank(commitment);
let fee = bank.get_fee_for_message(blockhash, message);
let fee = bank.get_fee_for_message(message);
Ok(new_response(&bank, fee))
}
}
@ -3124,7 +3123,6 @@ pub mod rpc_full {
fn get_fee_for_message(
&self,
meta: Self::Metadata,
blockhash: String,
data: String,
commitment: Option<CommitmentConfig>,
) -> Result<RpcResponse<Option<u64>>>;
@ -3640,20 +3638,17 @@ pub mod rpc_full {
fn get_fee_for_message(
&self,
meta: Self::Metadata,
blockhash: String,
data: String,
commitment: Option<CommitmentConfig>,
) -> Result<RpcResponse<Option<u64>>> {
debug!("get_fee_for_message rpc request received");
let blockhash = Hash::from_str(&blockhash)
.map_err(|e| Error::invalid_params(format!("{:?}", e)))?;
let (_, message) =
decode_and_deserialize::<Message>(data, UiTransactionEncoding::Base64)?;
SanitizedMessage::try_from(message)
.map_err(|err| {
Error::invalid_params(format!("invalid transaction message: {}", err))
})
.and_then(|message| meta.get_fee_for_message(&blockhash, &message, commitment))
.and_then(|message| meta.get_fee_for_message(&message, commitment))
}
}
}

View File

@ -112,7 +112,9 @@ impl TransactionStatusService {
bank.get_fee_calculator(transaction.message().recent_blockhash())
})
.expect("FeeCalculator must exist");
let fee = transaction.message().calculate_fee(&fee_calculator);
let fee = transaction
.message()
.calculate_fee(fee_calculator.lamports_per_signature);
let tx_account_locks =
transaction.get_account_locks(bank.demote_program_write_locks());