Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): calculate tx signature hash using packed bytes #760

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/rpc-server/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,8 @@ async fn submit_l2transaction(
Some(_) => tx_hash,
None => {
let mut hasher = new_blake2b();
hasher.update(tx.signature().as_slice());
let sig: Bytes = tx.signature().unpack();
hasher.update(&sig);
let mut hash = [0u8; 32];
hasher.finalize(&mut hash);
H256::from(hash)
Expand Down
6 changes: 4 additions & 2 deletions crates/tests/src/tests/rpc_server/submit_l2transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use gw_common::{
H256,
};
use gw_types::{
bytes::Bytes,
packed::{Fee, RawL2Transaction, SUDTArgs, SUDTTransfer, Script},
prelude::Pack,
prelude::{Pack, Unpack},
U256,
};

Expand Down Expand Up @@ -147,7 +148,8 @@ async fn test_in_queue_query_with_signature_hash() {
mem_pool_state.store(snap.into());
let signature_hash = {
let mut hasher = new_blake2b();
hasher.update(deploy_tx.signature().as_slice());
let sig: Bytes = deploy_tx.signature().unpack();
hasher.update(&sig);
let mut hash = [0u8; 32];
hasher.finalize(&mut hash);
H256::from(hash)
Expand Down