From 411b6c6e542548811752441299df858128809064 Mon Sep 17 00:00:00 2001 From: steelgeek091 Date: Wed, 5 Feb 2025 14:10:14 +0800 Subject: [PATCH] rename the converter function and add some comments --- crates/rooch-executor/src/actor/executor.rs | 10 +++++++--- crates/rooch/src/tx_runner.rs | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/rooch-executor/src/actor/executor.rs b/crates/rooch-executor/src/actor/executor.rs index 4e235510be..f76e341abc 100644 --- a/crates/rooch-executor/src/actor/executor.rs +++ b/crates/rooch-executor/src/actor/executor.rs @@ -366,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() + AUTH_PAYLOAD_SIZE, + tx_size, ); let tx_metadata = TxMeta::new_from_move_action(&tx_data.action); @@ -545,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/src/tx_runner.rs b/crates/rooch/src/tx_runner.rs index 41eab2c08e..86480092a2 100644 --- a/crates/rooch/src/tx_runner.rs +++ b/crates/rooch/src/tx_runner.rs @@ -57,9 +57,12 @@ pub fn execute_tx_locally( GasScheduleConfig::CLI_DEFAULT_MAX_GAS_AMOUNT, true, ); - gas_meter - .charge_io_write(tx.tx_size() + AUTH_PAYLOAD_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(),