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

feat: update signature location in tx #608

Closed
Closed
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
27 changes: 16 additions & 11 deletions crates/ef-testing/src/evm_sequencer/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::constants::KAKAROT_ADDRESS;
use super::types::felt::FeltSequencer;
use bytes::BytesMut;
use reth_primitives::{Address, Bytes, TransactionSigned};
use reth_primitives::{Address, Bytes, TransactionSigned, TxType};
use revm_primitives::U256;
use starknet::core::{
types::{BroadcastedInvokeTransaction, FieldElement},
Expand Down Expand Up @@ -78,16 +78,8 @@ pub fn to_broadcasted_starknet_transaction(
let nonce = FieldElement::from(transaction.nonce());
let starknet_address = compute_starknet_address(&evm_address);

#[allow(unused_mut)]
let mut bytes = BytesMut::new();
#[cfg(feature = "v0")]
{
transaction.encode_enveloped(&mut bytes);
}
#[cfg(feature = "v1")]
{
transaction.transaction.encode_without_signature(&mut bytes);
}
transaction.transaction.encode_without_signature(&mut bytes);

let mut calldata = bytes_to_felt_vec(&bytes.to_vec().into());

Expand Down Expand Up @@ -119,7 +111,20 @@ pub fn to_broadcasted_starknet_transaction(
};
execute_calldata.append(&mut calldata);

let signature = vec![];
let signature = transaction.signature();
let [r_low, r_high] = split_u256(signature.r);
let [s_low, s_high] = split_u256(signature.s);
let v = match transaction.transaction.tx_type() {
TxType::Legacy => signature.odd_y_parity as u64,
_ => signature.v(transaction.chain_id()),
};
let signature = vec![
FieldElement::from(r_low),
FieldElement::from(r_high),
FieldElement::from(s_low),
FieldElement::from(s_high),
FieldElement::from(v),
];

let request = BroadcastedInvokeTransaction {
max_fee: FieldElement::from(0u8),
Expand Down
Loading