Skip to content

Commit

Permalink
fix v
Browse files Browse the repository at this point in the history
  • Loading branch information
JayT106 committed Jun 20, 2024
1 parent 714420c commit fe6ab26
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions core/lib/eth_signer/src/g_kms_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ impl EthereumSigner for GKMSSigner {
.await
.map_err(|e| SignerError::SigningFailed(e.to_string()))?;

let adjust_v = signature.v + raw_tx.chain_id * 2 + 35;
let should_adjust_v = matches!(tx.transaction_type.map(|t| t.as_u64()), Some(0) | None);

let mut adjusted_v: u64 = 0;
if should_adjust_v {
adjusted_v = signature.v + raw_tx.chain_id * 2 + 35;
} else {
adjusted_v = signature.v;
}

let r_h256 = H256::from_slice(signature.r.as_byte_slice());
let s_h256 = H256::from_slice(signature.s.as_byte_slice());

Expand All @@ -129,16 +137,19 @@ impl EthereumSigner for GKMSSigner {
);

let web3_sig = Signature {
v: adjust_v,
v: adjusted_v,
r: r_h256,
s: s_h256,
};

tracing::info!(
"KMS sign_transaction web3_sig v: {}, r: {}, s: {}",
"KMS sign_transaction web3_sig v: {}, r: {}, s: {}, sig v: {}, chain_id: {}, tx_type: {:?} ",
web3_sig.v,
web3_sig.r.to_string(),
web3_sig.s.to_string()
web3_sig.s.to_string(),
signature.v,
raw_tx.chain_id,
tx.transaction_type,
);

let signed = tx.encode_pub(raw_tx.chain_id, Some(&web3_sig));
Expand Down

0 comments on commit fe6ab26

Please sign in to comment.