Skip to content

Commit

Permalink
fix starcoin-executor errors (#4239)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg authored Oct 17, 2024
1 parent 671994d commit 72552bc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion executor/src/block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Default for BlockExecutedData {
}
}

pub fn block_execute<S: ChainStateReader + ChainStateWriter>(
pub fn block_execute<S: ChainStateReader + ChainStateWriter + Sync>(
chain_state: &S,
txns: Vec<Transaction>,
block_gas_limit: u64,
Expand Down
13 changes: 7 additions & 6 deletions executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ use starcoin_vm_runtime::{metrics::VMMetrics, starcoin_vm::StarcoinVM, VMExecuto
use starcoin_vm_types::{
identifier::Identifier,
language_storage::{ModuleId, TypeTag},
{state_view::StateView, vm_status::VMStatus},
vm_status::VMStatus,
StateView,
};

pub fn execute_transactions<S: StateView>(
pub fn execute_transactions<S: StateView + Sync>(
chain_state: &S,
txns: Vec<Transaction>,
metrics: Option<VMMetrics>,
Expand All @@ -20,7 +21,7 @@ pub fn execute_transactions<S: StateView>(

/// Execute a block transactions with gas_limit,
/// if gas is used up when executing some txn, only return the outputs of previous succeed txns.
pub fn execute_block_transactions<S: StateView>(
pub fn execute_block_transactions<S: StateView + Sync>(
chain_state: &S,
txns: Vec<Transaction>,
block_gas_limit: u64,
Expand All @@ -29,7 +30,7 @@ pub fn execute_block_transactions<S: StateView>(
do_execute_block_transactions(chain_state, txns, Some(block_gas_limit), metrics)
}

fn do_execute_block_transactions<S: StateView>(
fn do_execute_block_transactions<S: StateView + Sync>(
chain_state: &S,
txns: Vec<Transaction>,
block_gas_limit: Option<u64>,
Expand All @@ -46,7 +47,7 @@ pub fn validate_transaction<S: StateView>(
txn: SignedUserTransaction,
metrics: Option<VMMetrics>,
) -> Option<VMStatus> {
let mut vm = StarcoinVM::new(metrics);
let mut vm = StarcoinVM::new(metrics, chain_state);
vm.verify_transaction(chain_state, txn)
}

Expand All @@ -58,6 +59,6 @@ pub fn execute_readonly_function<S: StateView>(
args: Vec<Vec<u8>>,
metrics: Option<VMMetrics>,
) -> Result<Vec<Vec<u8>>, VMStatus> {
let mut vm = StarcoinVM::new(metrics);
let mut vm = StarcoinVM::new(metrics, chain_state);
vm.execute_readonly_function(chain_state, module, function_name, type_params, args)
}
2 changes: 1 addition & 1 deletion state/statedb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ use starcoin_vm_types::state_store::state_key::inner::StateKeyInner;
use starcoin_vm_types::state_store::state_storage_usage::StateStorageUsage;
use starcoin_vm_types::state_store::state_value::StateValue;
use starcoin_vm_types::state_store::table::TableInfo;
use starcoin_vm_types::state_store::TStateView;
use starcoin_vm_types::state_store::{state_key::StateKey, table::TableHandle};
use starcoin_vm_types::state_store::{StateView, TStateView};
use std::collections::HashSet;
use std::convert::TryInto;
use std::sync::Arc;
Expand Down
7 changes: 2 additions & 5 deletions vm/compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ pub fn check_module_compat(pre_code: &[u8], new_code: &[u8]) -> VMResult<bool> {

let old = Module::new(&pre_module);
let new = Module::new(&new_module);
if Compatibility::new(true, true, false)
.check(&old, &new)
.is_err()
{
if Compatibility::new(true, false).check(&old, &new).is_err() {
Ok(false)
} else {
Ok(true)
Expand All @@ -227,7 +224,7 @@ pub fn check_compiled_module_compat(
let old = Module::new(pre);
let new = Module::new(new);

Compatibility::new(true, true, false).check(&old, &new)
Compatibility::new(true, false).check(&old, &new)
}

/// Load bytecode file, return the bytecode bytes, and whether it's script.
Expand Down
1 change: 1 addition & 0 deletions vm/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ pub mod serde_helper;
pub mod sign_message;
pub mod sips;
pub mod state_store;
pub use state_store::StateView;
pub mod time;
pub mod token;
#[cfg(test)]
Expand Down

0 comments on commit 72552bc

Please sign in to comment.