Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f744932
1, add benchmark for testing vm2 transaction execution
jackzhhuang Oct 20, 2025
17a0b49
add benchmark code
jackzhhuang Oct 22, 2025
9a94ccf
Update test
sanlee42 Oct 22, 2025
09b00bc
use 2000 receiver
jackzhhuang Oct 22, 2025
df4ee52
use 1280000 as max sender
jackzhhuang Oct 22, 2025
ceabaf8
add more 128 G as default max memory size
jackzhhuang Oct 22, 2025
be6965f
watch the tranaction
jackzhhuang Oct 24, 2025
a1f2920
fix fmt
jackzhhuang Oct 24, 2025
42462b7
add draw svg
jackzhhuang Nov 7, 2025
e5954a9
update cargo.lock
jackzhhuang Nov 7, 2025
19b0b3b
add get balance2
jackzhhuang Nov 7, 2025
25fdca4
1, update rpc schema
jackzhhuang Nov 7, 2025
95a8ae1
fix fmt and the advice from the coderabbit
jackzhhuang Nov 10, 2025
850b7dc
add bench code
jackzhhuang Nov 10, 2025
65115e1
fix fmt
jackzhhuang Nov 11, 2025
b0829ee
fix query balance2
jackzhhuang Nov 21, 2025
4b708ad
update Cargo.lock
jackzhhuang Nov 25, 2025
8b29ac3
1, add benchmark for testing vm2 transaction execution
jackzhhuang Oct 20, 2025
cb2be65
add benchmark code
jackzhhuang Oct 22, 2025
899567c
Update test
sanlee42 Oct 22, 2025
2484459
use 2000 receiver
jackzhhuang Oct 22, 2025
9ae0965
add more 128 G as default max memory size
jackzhhuang Oct 22, 2025
2fd837d
watch the tranaction
jackzhhuang Oct 24, 2025
c4a6748
watch the tranaction
jackzhhuang Oct 24, 2025
629aa50
fix fmt
jackzhhuang Oct 24, 2025
8e0bfd2
add draw svg
jackzhhuang Nov 7, 2025
3fc47c4
update cargo.lock
jackzhhuang Nov 7, 2025
0d55222
add get balance2
jackzhhuang Nov 7, 2025
ec72123
1, update rpc schema
jackzhhuang Nov 7, 2025
fe813e1
fix fmt and the advice from the coderabbit
jackzhhuang Nov 10, 2025
4fa3d7d
add bench code
jackzhhuang Nov 10, 2025
dd8c66e
fix fmt
jackzhhuang Nov 11, 2025
dfe4132
fix query balance2
jackzhhuang Nov 21, 2025
47803f0
rebase dual-verse-dag
jackzhhuang Nov 27, 2025
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
Prev Previous commit
Next Next commit
fix fmt
  • Loading branch information
jackzhhuang committed Nov 27, 2025
commit a1f2920174061d6447d7ab7676869ec18e4dc278
2 changes: 1 addition & 1 deletion cmd/tx-factory/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,4 @@ fn main() {

handle.join().unwrap();
info!("txfactory: stop now");
}
}
2 changes: 1 addition & 1 deletion config/src/txpool_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use starcoin_system::get_free_mem_size;
use std::sync::Arc;

pub const DEFAULT_MEM_SIZE: u64 = 1 * 1024 * 1024 * 1024; // 1G
pub const DEFAULT_MEM_SIZE: u64 = 1 * 1024 * 1024 * 1024; // 1G

#[derive(Default, Clone, Debug, Eq, PartialEq, Deserialize, Serialize, Parser)]
#[serde(deny_unknown_fields)]
Expand Down
2 changes: 1 addition & 1 deletion kube/manifest/starcoin-halley.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
starcoin/node-pool: seed-pool
containers:
- name: starcoin
image: starcoin/starcoin:sha-6a5e4e8
image: starcoin/starcoin:sha-718e01a
imagePullPolicy: Always
command:
- bash
Expand Down
136 changes: 101 additions & 35 deletions sync/tests/full_build_and_execute_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{collections::HashMap, env::temp_dir, sync::Arc};

use anyhow::{bail, format_err, Ok, Result};
use chrono::Local;
use futures::channel::mpsc;
use starcoin_chain_api::message::{ChainRequest, ChainResponse};
use starcoin_chain_service::ChainReaderService;
Expand All @@ -10,17 +11,22 @@ use starcoin_config::{
use starcoin_crypto::HashValue;
use starcoin_dag::blockdag::BlockDAG;
use starcoin_executor::VMMetrics;
use starcoin_genesis::Genesis;
use starcoin_logger::{
prelude::{error, info, LevelFilter},
LoggerHandle,
};
use starcoin_genesis::Genesis;
use starcoin_service_registry::{ActorService, EventHandler, RegistryAsyncService, ServiceContext, ServiceFactory, ServiceRef};
use starcoin_service_registry::{
ActorService, EventHandler, RegistryAsyncService, ServiceContext, ServiceFactory, ServiceRef,
};
use starcoin_storage::{BlockStore, Storage, Storage2, Store};
use starcoin_transaction_builder::vm2::build_batch_transfer_txn as build_batch_transfer_txn2;
use starcoin_txpool::TxStatus;
use starcoin_types::{
block::BlockHeader, genesis_config::ChainId, multi_transaction::MultiSignedUserTransaction, system_events::{NewDagBlock, NewDagBlockFromPeer, NewHeadBlock},
block::BlockHeader,
genesis_config::ChainId,
multi_transaction::MultiSignedUserTransaction,
system_events::{NewDagBlock, NewDagBlockFromPeer, NewHeadBlock},
};
use starcoin_vm2_account_api::{
message::{AccountRequest, AccountResponse},
Expand All @@ -30,11 +36,12 @@ use starcoin_vm2_account_service::AccountService as AccountService2;
use starcoin_vm2_statedb::ChainStateDB;
use starcoin_vm2_types::{account_config::G_STC_TOKEN_CODE, transaction::SignedUserTransaction};
use starcoin_vm2_vm_runtime::starcoin_vm::StarcoinVM;
use starcoin_vm2_vm_types::{account_address::AccountAddress, state_view::StateReaderExt, transaction, PeerId};
use test_helper::run_node_with_all_service;
use chrono::Local;
use starcoin_vm2_vm_types::{
account_address::AccountAddress, state_view::StateReaderExt, transaction, PeerId,
};
use std::fs::OpenOptions;
use std::io::{self, Write};
use test_helper::run_node_with_all_service;

async fn create_account(
accoun_number: u32,
Expand Down Expand Up @@ -150,7 +157,12 @@ async fn get_current_header(
Ok(current_header)
}

async fn get_balance(address: AccountAddress, storage1: Arc<Storage>, storage2: Arc<Storage2>, header_id: HashValue) -> Result<u128> {
async fn get_balance(
address: AccountAddress,
storage1: Arc<Storage>,
storage2: Arc<Storage2>,
header_id: HashValue,
) -> Result<u128> {
let multi_state = storage1.get_vm_multi_state(header_id)?;
let statedb2 = ChainStateDB::new(storage2.clone(), Some(multi_state.state_root2()));
let balance = statedb2.get_balance_by_type(address, G_STC_TOKEN_CODE.clone().try_into()?)?;
Expand Down Expand Up @@ -211,15 +223,26 @@ fn test_full_build_and_execute_in_custom_network() -> Result<()> {
loop {
// generate_block.notify(DeterminedDagBlock)?;
let current_header = get_current_header(chain_reader_service.clone()).await?;
let default_account_balance = match get_balance(default_account.address, storage1.clone(), storage2.clone(), current_header.id()).await {
let default_account_balance = match get_balance(
default_account.address,
storage1.clone(),
storage2.clone(),
current_header.id(),
)
.await
{
std::result::Result::Ok(balance) => balance,
Err(e) => {
info!("get balance error: {} and waiting for the token initialization", e);
info!(
"get balance error: {} and waiting for the token initialization",
e
);
tokio::time::sleep(tokio::time::Duration::from_millis(3000)).await;
continue;
}
};
if default_account_balance > account_count as u128 * initial_balance + initial_gas_fee { // get enough token to pay for gas
if default_account_balance > account_count as u128 * initial_balance + initial_gas_fee {
// get enough token to pay for gas
break;
}
tokio::time::sleep(tokio::time::Duration::from_millis(3000)).await;
Expand Down Expand Up @@ -317,23 +340,37 @@ fn test_full_build_and_execute_in_custom_network() -> Result<()> {
}

enum TransactionExecutionResult {
Added(String),
Rejected(String),
Culled(String),
Executed(String),
ExecutedNotInMain(String),
Other(String),
Added(String),
Rejected(String),
Culled(String),
Executed(String),
ExecutedNotInMain(String),
Other(String),
}

impl std::fmt::Debug for TransactionExecutionResult {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TransactionExecutionResult::Added(op_time) => write!(f, "TransactionExecutionResult::Added({})", op_time),
TransactionExecutionResult::Rejected(op_time) => write!(f, "TransactionExecutionResult::Rejected({})", op_time),
TransactionExecutionResult::Culled(op_time) => write!(f, "TransactionExecutionResult::Culled({})", op_time),
TransactionExecutionResult::Executed(op_time) => write!(f, "TransactionExecutionResult::Executed({})", op_time),
TransactionExecutionResult::ExecutedNotInMain(op_time) => write!(f, "TransactionExecutionResult::ExecutedNotInMain({})", op_time),
TransactionExecutionResult::Other(op_time) => write!(f, "TransactionExecutionResult::Other({})", op_time),
TransactionExecutionResult::Added(op_time) => {
write!(f, "TransactionExecutionResult::Added({})", op_time)
}
TransactionExecutionResult::Rejected(op_time) => {
write!(f, "TransactionExecutionResult::Rejected({})", op_time)
}
TransactionExecutionResult::Culled(op_time) => {
write!(f, "TransactionExecutionResult::Culled({})", op_time)
}
TransactionExecutionResult::Executed(op_time) => {
write!(f, "TransactionExecutionResult::Executed({})", op_time)
}
TransactionExecutionResult::ExecutedNotInMain(op_time) => write!(
f,
"TransactionExecutionResult::ExecutedNotInMain({})",
op_time
),
TransactionExecutionResult::Other(op_time) => {
write!(f, "TransactionExecutionResult::Other({})", op_time)
}
}
}
}
Expand All @@ -356,18 +393,28 @@ impl ObserverService {
}

fn update_transaction_status(&mut self, new_header: HashValue) -> Result<()> {
let block = self.storage1.get_block_by_hash(new_header)?.ok_or_else(|| format_err!("block not found: {:?}", new_header))?;
let block = self
.storage1
.get_block_by_hash(new_header)?
.ok_or_else(|| format_err!("block not found: {:?}", new_header))?;
let now = Local::now().format("%Y-%m-%d %H:%M:%S%.3f").to_string();
for transaction in block.body.transactions2 {
self.transaction_data.entry(transaction.id()).or_insert_with(Vec::new).push(TransactionExecutionResult::Executed(now.clone()));
self.transaction_data
.entry(transaction.id())
.or_insert_with(Vec::new)
.push(TransactionExecutionResult::Executed(now.clone()));
}
Ok(())
}

fn dump_results(&mut self) -> Result<()> {
let mut file = OpenOptions::new().write(true).create(true).truncate(true).open("/Users/jack/Documents/code/rust/flexidag/starcoin-jack/main/starcoin/sync/transaction_results.txt")?;
for (transaction, results) in &self.transaction_data {
writeln!(file, "transaction id: {}, results: {:?}", *transaction, results)?;
writeln!(
file,
"transaction id: {}, results: {:?}",
*transaction, results
)?;
}
Ok(())
}
Expand All @@ -376,13 +423,12 @@ impl ObserverService {
impl ServiceFactory<Self> for ObserverService {
fn create(ctx: &mut ServiceContext<Self>) -> Result<Self> {
let genesis = ctx.get_shared::<Genesis>()?;
let storage1 = ctx.get_shared::<Arc<Storage>>()?;
let storage1 = ctx.get_shared::<Arc<Storage>>()?;
let dag = ctx.get_shared::<BlockDAG>()?;
Self::new(genesis.block().id(), dag, storage1)
}
}


impl ActorService for ObserverService {
fn started(&mut self, ctx: &mut ServiceContext<Self>) -> Result<()> {
// ctx.subscribe::<NewHeadBlock>();
Expand All @@ -406,7 +452,7 @@ impl ActorService for ObserverService {
// impl EventHandler<Self, NewHeadBlock> for ObserverService {
// fn handle_event(&mut self, msg: NewHeadBlock, ctx: &mut ServiceContext<Self>) {
// }
// }
// }

impl EventHandler<Self, NewDagBlock> for ObserverService {
fn handle_event(&mut self, msg: NewDagBlock, ctx: &mut ServiceContext<Self>) {
Expand All @@ -415,7 +461,7 @@ impl EventHandler<Self, NewDagBlock> for ObserverService {
Err(e) => error!("failed to update transactions status for: {:?}", e),
}
}
}
}

impl EventHandler<Self, NewDagBlockFromPeer> for ObserverService {
fn handle_event(&mut self, msg: NewDagBlockFromPeer, ctx: &mut ServiceContext<Self>) {
Expand All @@ -424,18 +470,38 @@ impl EventHandler<Self, NewDagBlockFromPeer> for ObserverService {
Err(e) => error!("failed to update transactions status for: {:?}", e),
}
}
}
}

impl EventHandler<Self, Arc<[(HashValue, TxStatus)]>> for ObserverService {
fn handle_event(&mut self, msg: Arc<[(HashValue, TxStatus)]>, ctx: &mut ServiceContext<Self>) {
let now = Local::now().format("%Y-%m-%d %H:%M:%S%.3f").to_string();
for transaction_event in msg.as_ref() {
match transaction_event.1 {
starcoin_types::transaction::TxStatus::Added => self.transaction_data.entry(transaction_event.0).or_insert_with(Vec::new).push(TransactionExecutionResult::Added(now.clone())),
starcoin_types::transaction::TxStatus::Rejected => self.transaction_data.entry(transaction_event.0).or_insert_with(Vec::new).push(TransactionExecutionResult::Rejected(now.clone())),
starcoin_types::transaction::TxStatus::Culled => self.transaction_data.entry(transaction_event.0).or_insert_with(Vec::new).push(TransactionExecutionResult::Culled(now.clone())),
_ => self.transaction_data.entry(transaction_event.0).or_insert_with(Vec::new).push(TransactionExecutionResult::Other(format!("{}({})", transaction_event.1, now.clone()))),
starcoin_types::transaction::TxStatus::Added => self
.transaction_data
.entry(transaction_event.0)
.or_insert_with(Vec::new)
.push(TransactionExecutionResult::Added(now.clone())),
starcoin_types::transaction::TxStatus::Rejected => self
.transaction_data
.entry(transaction_event.0)
.or_insert_with(Vec::new)
.push(TransactionExecutionResult::Rejected(now.clone())),
starcoin_types::transaction::TxStatus::Culled => self
.transaction_data
.entry(transaction_event.0)
.or_insert_with(Vec::new)
.push(TransactionExecutionResult::Culled(now.clone())),
_ => self
.transaction_data
.entry(transaction_event.0)
.or_insert_with(Vec::new)
.push(TransactionExecutionResult::Other(format!(
"{}({})",
transaction_event.1,
now.clone()
))),
}
}
}
}
}
5 changes: 4 additions & 1 deletion vm2/vm-runtime/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ pub fn error_split(code: u64) -> (u64, u64) {

pub fn convert_prologue_runtime_error(error: VMError) -> Result<(), VMStatus> {
let status = error.into_vm_status();
info!("jacktest: convert_prologue_runtime_error status: {}", status);
info!(
"jacktest: convert_prologue_runtime_error status: {}",
status
);
Err(match status {
VMStatus::Executed => VMStatus::Executed,
VMStatus::MoveAbort(location, code) => {
Expand Down
5 changes: 4 additions & 1 deletion vm2/vm-runtime/src/starcoin_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,10 @@ impl StarcoinVM {

let traversal_storage = TraversalStorage::new();
// Run prologue by genesis account
info!("StarcoinVM::run_prologue | jacktest: 2, txn_gas_price: {}, txn_max_gas_amount: {}", txn_gas_price, txn_max_gas_amount);
info!(
"StarcoinVM::run_prologue | jacktest: 2, txn_gas_price: {}, txn_max_gas_amount: {}",
txn_gas_price, txn_max_gas_amount
);
session
.execute_function_bypass_visibility(
&account_config::G_TRANSACTION_VALIDATION_MODULE,
Expand Down
5 changes: 4 additions & 1 deletion vm2/vm-runtime/src/verifier/transaction_arg_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,10 @@ fn validate_and_construct(
// function calls. We know the feature is active when more structs then just strings are
// allowed.
let are_struct_constructors_enabled = allowed_structs.len() > 1;
info!("jacktest: are_struct_constructors_enabled: {}", are_struct_constructors_enabled);
info!(
"jacktest: are_struct_constructors_enabled: {}",
are_struct_constructors_enabled
);
if are_struct_constructors_enabled {
PartialVMError::new(StatusCode::ABORTED)
.with_sub_status(1)
Expand Down