diff --git a/crates/rooch-executor/src/actor/executor.rs b/crates/rooch-executor/src/actor/executor.rs index 7853cd1021..f76e341abc 100644 --- a/crates/rooch-executor/src/actor/executor.rs +++ b/crates/rooch-executor/src/actor/executor.rs @@ -41,6 +41,7 @@ use rooch_types::framework::ethereum::EthereumModule; use rooch_types::framework::transaction_validator::TransactionValidator; use rooch_types::framework::{system_post_execute_functions, system_pre_execute_functions}; use rooch_types::multichain_id::RoochMultiChainID; +use rooch_types::transaction::authenticator::AUTH_PAYLOAD_SIZE; use rooch_types::transaction::{ AuthenticatorInfo, L1Block, L1BlockWithBody, L1Transaction, RoochTransaction, RoochTransactionData, @@ -365,18 +366,22 @@ impl ExecutorActor { Ok(vm_result) } - pub fn convert_to_verified_tx( + pub fn convert_to_verified_tx_for_dry_run( &self, tx_data: RoochTransactionData, ) -> Result { let root = self.root.clone(); + // The dry run supports unsigned transactions, but when calculating the transaction size, + // the length of the signature part needs to be included. + let tx_size = tx_data.tx_size() + AUTH_PAYLOAD_SIZE; + let mut tx_ctx = TxContext::new( tx_data.sender.into(), tx_data.sequence_number, tx_data.max_gas_amount, tx_data.tx_hash(), - tx_data.tx_size(), + tx_size, ); let tx_metadata = TxMeta::new_from_move_action(&tx_data.action); @@ -544,7 +549,7 @@ impl Handler for ExecutorActor { msg: ConvertL2TransactionData, _ctx: &mut ActorContext, ) -> Result { - self.convert_to_verified_tx(msg.tx_data) + self.convert_to_verified_tx_for_dry_run(msg.tx_data) } } diff --git a/crates/rooch-types/src/transaction/authenticator.rs b/crates/rooch-types/src/transaction/authenticator.rs index aa26dcf4aa..76ce65993a 100644 --- a/crates/rooch-types/src/transaction/authenticator.rs +++ b/crates/rooch-types/src/transaction/authenticator.rs @@ -30,6 +30,9 @@ use crate::{ use super::RoochTransactionData; +// The size of the signature data. +pub const AUTH_PAYLOAD_SIZE: u64 = 219; + /// A `Authenticator` is an abstraction of a account authenticator. /// It is a part of `AccountAbstraction` diff --git a/crates/rooch/src/tx_runner.rs b/crates/rooch/src/tx_runner.rs index 50bc67e320..86480092a2 100644 --- a/crates/rooch/src/tx_runner.rs +++ b/crates/rooch/src/tx_runner.rs @@ -22,6 +22,7 @@ use moveos_types::move_std::option::MoveOption; use moveos_types::moveos_std::gas_schedule::GasScheduleConfig; use moveos_types::moveos_std::object::ObjectMeta; use moveos_types::moveos_std::tx_context::TxContext; +use moveos_types::moveos_std::tx_meta::TxMeta; use moveos_types::transaction::{ MoveAction, RawTransactionOutput, VMErrorInfo, VerifiedMoveAction, VerifiedMoveOSTransaction, }; @@ -34,6 +35,7 @@ use rooch_rpc_client::{Client, ClientResolver}; use rooch_types::address::{BitcoinAddress, MultiChainAddress}; use rooch_types::framework::auth_validator::{BuiltinAuthValidator, TxValidateResult}; use rooch_types::framework::system_pre_execute_functions; +use rooch_types::transaction::authenticator::AUTH_PAYLOAD_SIZE; use rooch_types::transaction::RoochTransactionData; use std::rc::Rc; use std::str::FromStr; @@ -55,7 +57,12 @@ pub fn execute_tx_locally( GasScheduleConfig::CLI_DEFAULT_MAX_GAS_AMOUNT, true, ); - gas_meter.charge_io_write(tx.tx_size()).unwrap(); + + // The dry run supports unsigned transactions, but when calculating the transaction size, + // the length of the signature part needs to be included. + let tx_size = tx.tx_size() + AUTH_PAYLOAD_SIZE; + + gas_meter.charge_io_write(tx_size).unwrap(); let mut moveos_session = MoveOSSession::new( move_mv.inner(), @@ -235,6 +242,9 @@ fn convert_to_verified_tx( tx_data.tx_size(), ); + let tx_metadata = TxMeta::new_from_move_action(&tx_data.action); + tx_ctx.add(tx_metadata).unwrap(); + let mut bitcoin_address = BitcoinAddress::from_str("18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX")?; let user_multi_chain_address: MultiChainAddress = tx_data.sender.into();