feat: convert hash field to OnceLock<TxHash> on TransactionSigned (#12596)

Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
This commit is contained in:
Steven
2024-11-21 16:40:29 -06:00
committed by GitHub
parent 6f6fb005ab
commit 4442b5d6fa
29 changed files with 127 additions and 87 deletions

View File

@ -725,7 +725,10 @@ mod tests {
provider.transaction_sender(0), Ok(Some(sender))
if sender == block.body.transactions[0].recover_signer().unwrap()
);
assert_matches!(provider.transaction_id(block.body.transactions[0].hash), Ok(Some(0)));
assert_matches!(
provider.transaction_id(block.body.transactions[0].hash()),
Ok(Some(0))
);
}
{
@ -743,7 +746,7 @@ mod tests {
Ok(_)
);
assert_matches!(provider.transaction_sender(0), Ok(None));
assert_matches!(provider.transaction_id(block.body.transactions[0].hash), Ok(None));
assert_matches!(provider.transaction_id(block.body.transactions[0].hash()), Ok(None));
}
}

View File

@ -551,7 +551,7 @@ impl<TX: DbTx + 'static, N: NodeTypes> DatabaseProvider<TX, N> {
.map(|tx| match transaction_kind {
TransactionVariant::NoHash => TransactionSigned {
// Caller explicitly asked for no hash, so we don't calculate it
hash: B256::ZERO,
hash: Default::default(),
signature: tx.signature,
transaction: tx.transaction,
},
@ -1500,7 +1500,7 @@ impl<TX: DbTx + 'static, N: NodeTypes<ChainSpec: EthereumHardforks>> Transaction
fn transaction_by_hash(&self, hash: TxHash) -> ProviderResult<Option<TransactionSigned>> {
if let Some(id) = self.transaction_id(hash)? {
Ok(self.transaction_by_id_no_hash(id)?.map(|tx| TransactionSigned {
hash,
hash: hash.into(),
signature: tx.signature,
transaction: tx.transaction,
}))
@ -1518,7 +1518,7 @@ impl<TX: DbTx + 'static, N: NodeTypes<ChainSpec: EthereumHardforks>> Transaction
if let Some(transaction_id) = self.transaction_id(tx_hash)? {
if let Some(tx) = self.transaction_by_id_no_hash(transaction_id)? {
let transaction = TransactionSigned {
hash: tx_hash,
hash: tx_hash.into(),
signature: tx.signature,
transaction: tx.transaction,
};

View File

@ -89,7 +89,7 @@ pub(crate) static TEST_BLOCK: LazyLock<SealedBlock> = LazyLock::new(|| SealedBlo
),
body: BlockBody {
transactions: vec![TransactionSigned {
hash: hex!("3541dd1d17e76adeb25dcf2b0a9b60a1669219502e58dcf26a2beafbfb550397").into(),
hash: b256!("3541dd1d17e76adeb25dcf2b0a9b60a1669219502e58dcf26a2beafbfb550397").into(),
signature: Signature::new(
U256::from_str(
"51983300959770368863831494747186777928121405155922056726144551509338672451120",