Skip to content

Commit

Permalink
feat(collator): use tycho-executor
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Feb 12, 2025
1 parent ec56ab8 commit ed3ffa9
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 238 deletions.
37 changes: 18 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ weedb = "0.4.1"
zstd-safe = "7.2"
zstd-sys = "2.0"

# TODO: RIIR
ton_executor = { git = "https://github.com/broxus/ton-labs-executor.git", rev = "de566312176aa524d4afc26a04c931f97079b77f" }
tycho-vm = { git = "https://github.com/broxus/tycho-vm.git" }
tycho-executor = { git = "https://github.com/broxus/tycho-vm.git", rev = "40d3962ccc5892da6ced5aef360bf705dda5171f" }
tycho-vm = { git = "https://github.com/broxus/tycho-vm.git", rev = "40d3962ccc5892da6ced5aef360bf705dda5171f" }

# local deps
tycho-block-util = { path = "./block-util", version = "0.2.3" }
Expand All @@ -133,7 +132,7 @@ tycho-storage = { path = "./storage", version = "0.2.3" }
tycho-util = { path = "./util", version = "0.2.3" }

[patch.crates-io]
everscale-types = { git = "https://github.com/broxus/everscale-types.git", rev = "adada6e6539abd798dbbc5a7fc1d17cc31fa7eff" }
everscale-types = { git = "https://github.com/broxus/everscale-types.git", rev = "f0d46607c19c9657b90360b4bc5c229a56540ffa" }

[workspace.lints.rust]
future_incompatible = "warn"
Expand Down
2 changes: 0 additions & 2 deletions cli/src/cmd/tools/gen_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ impl WalletBuilder {
last_trans_lt: 0,
balance: self.balance.into(),
state: AccountState::Active(state_init),
init_code_hash: None,
};

account.storage_stat.used = compute_storage_used(&account)?;
Expand Down Expand Up @@ -332,7 +331,6 @@ impl MultisigBuilder {
last_trans_lt: 0,
balance: self.balance.into(),
state: AccountState::Active(state_init),
init_code_hash: None,
};

account.storage_stat.used = compute_storage_used(&account)?;
Expand Down
5 changes: 0 additions & 5 deletions cli/src/cmd/tools/gen_zerostate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,6 @@ impl ZerostateConfig {
split_merge_at: None,
fees_collected: CurrencyCollection::ZERO,
funds_created: CurrencyCollection::ZERO,
copyleft_rewards: Dict::new(),
proof_chain: None,
}));
}

Expand Down Expand Up @@ -446,7 +444,6 @@ impl ZerostateConfig {
last_key_block: None,
block_create_stats: None,
global_balance: state.total_balance.clone(),
copyleft_rewards: Dict::new(),
})?);

Ok(state)
Expand Down Expand Up @@ -852,7 +849,6 @@ fn build_config_account(
data: Some(data),
libraries: Dict::new(),
}),
init_code_hash: None,
};

account.storage_stat.used = compute_storage_used(&account)?;
Expand Down Expand Up @@ -887,7 +883,6 @@ fn build_elector_code(address: &HashBytes, balance: Tokens) -> Result<Account> {
data: Some(data),
libraries: Dict::new(),
}),
init_code_hash: None,
};

account.storage_stat.used = compute_storage_used(&account)?;
Expand Down
5 changes: 0 additions & 5 deletions cli/src/util/jrpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ where
last_trans_lt: <_>::load_from(s)?,
balance: <_>::load_from(s)?,
state: <_>::load_from(s)?,
init_code_hash: if s.is_data_empty() {
None
} else {
Some(<_>::load_from(s)?)
},
}))
}

Expand Down
3 changes: 0 additions & 3 deletions cli/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ pub fn compute_storage_used(account: &Account) -> Result<StorageUsed> {
storage.store_u64(account.last_trans_lt)?;
account.balance.store_into(&mut storage, cx)?;
account.state.store_into(&mut storage, cx)?;
if account.init_code_hash.is_some() {
account.init_code_hash.store_into(&mut storage, cx)?;
}
storage.build_ext(cx)?
};

Expand Down
4 changes: 2 additions & 2 deletions collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ thiserror = { workspace = true }
tl-proto = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "signal"] }
tokio-util = { workspace = true }
ton_executor = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
trait-variant = { workspace = true }
Expand All @@ -45,9 +44,10 @@ trait-variant = { workspace = true }
tycho-block-util = { workspace = true }
tycho-consensus = { workspace = true }
tycho-core = { workspace = true }
tycho-executor = { workspace = true }
tycho-network = { workspace = true }
tycho-storage = { workspace = true }
tycho-util = { workspace = true }
tycho-util = { workspace = true, features = ["bc"] }
tycho-vm = { workspace = true }

[dev-dependencies]
Expand Down
38 changes: 21 additions & 17 deletions collator/src/collator/do_collate/execution_wrapper.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use std::sync::Arc;

use anyhow::{bail, Result};
use anyhow::{bail, Context, Result};
use everscale_types::cell::{CellBuilder, CellSlice, HashBytes};
use everscale_types::models::{
BaseMessage, BlockchainConfig, CurrencyCollection, ImportFees, InMsg, InMsgExternal,
InMsgFinal, IntAddr, IntMsgInfo, IntermediateAddr, Lazy, MsgEnvelope, MsgInfo, OutMsg,
OutMsgDequeueImmediate, OutMsgExternal, OutMsgImmediate, OutMsgNew, ShardIdent, TickTock,
Transaction,
};
use ton_executor::ExecutedTransaction;
use tycho_block_util::queue::QueueKey;

use crate::collator::execution_manager::MessagesExecutor;
use crate::collator::types::{
BlockCollationData, ParsedMessage, PreparedInMsg, PreparedOutMsg, SpecialOrigin,
BlockCollationData, ExecutedTransaction, ParsedMessage, PreparedInMsg, PreparedOutMsg,
SpecialOrigin,
};
use crate::internal_queue::types::EnqueuedMessage;
use crate::tracing_targets;
Expand Down Expand Up @@ -159,7 +159,9 @@ impl ExecutorWrapper {
.executor
.execute_ordinary_transaction(account_stuff, in_message)?;

let executor_output = executed.result?;
let executor_output = executed
.result
.context("special transactions can't be skipped")?;

self.process_transaction(executor_output, Some(executed.in_message), collation_data)
}
Expand Down Expand Up @@ -196,29 +198,32 @@ impl ExecutorWrapper {
fn create_ticktock_transaction(
&mut self,
account_id: &HashBytes,
tick_tock: TickTock,
kind: TickTock,
collation_data: &mut BlockCollationData,
) -> Result<Vec<Arc<EnqueuedMessage>>> {
tracing::trace!(
target: tracing_targets::COLLATOR,
account_addr = %account_id,
kind = ?tick_tock,
?kind,
"create_ticktock_transaction",
);

let Some(account_stuff) =
self.executor
.take_account_stuff_if(account_id, |stuff| match tick_tock {
.take_account_stuff_if(account_id, |stuff| match kind {
TickTock::Tick => stuff.special.tick,
TickTock::Tock => stuff.special.tock,
})?
else {
return Ok(vec![]);
return Ok(Vec::new());
};

let executor_output = self
let Some(executor_output) = self
.executor
.execute_ticktock_transaction(account_stuff, tick_tock)?;
.execute_ticktock_transaction(account_stuff, kind)?
else {
return Ok(Vec::new());
};

self.process_transaction(executor_output, None, collation_data)
}
Expand Down Expand Up @@ -250,10 +255,9 @@ fn new_transaction(

let mut out_messages = vec![];

for out_msg_cell in executed.out_msgs.values() {
let out_msg_cell = out_msg_cell?;
let out_msg_hash = *out_msg_cell.repr_hash();
let out_msg_info = out_msg_cell.parse::<MsgInfo>()?;
for out_msg_cell in executed.out_msgs {
let out_msg_hash = *out_msg_cell.inner().repr_hash();
let out_msg_info = out_msg_cell.inner().parse::<MsgInfo>()?;

tracing::trace!(
target: tracing_targets::COLLATOR,
Expand All @@ -279,7 +283,7 @@ fn new_transaction(
IntermediateAddr::FULL_SRC_SAME_WORKCHAIN
},
fwd_fee_remaining: *fwd_fee,
message: Lazy::from_raw(out_msg_cell.clone()),
message: out_msg_cell.clone(),
})?,
transaction: executed.transaction.clone(),
});
Expand All @@ -295,15 +299,15 @@ fn new_transaction(
out_messages.push(Box::new(ParsedMessage {
info: out_msg_info,
dst_in_current_shard,
cell: out_msg_cell,
cell: out_msg_cell.into_inner(),
special_origin: None,
block_seqno: Some(collation_data.block_id_short.seqno),
from_same_shard: Some(true),
}));
}
MsgInfo::ExtOut(_) => {
let out_msg = OutMsg::External(OutMsgExternal {
out_msg: Lazy::from_raw(out_msg_cell),
out_msg: out_msg_cell,
transaction: executed.transaction.clone(),
});

Expand Down
4 changes: 1 addition & 3 deletions collator/src/collator/do_collate/finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl Phase<FinalizeState> {
let executor = self.extra.executor;

// update shard accounts tree and prepare accounts blocks
let mut global_libraries = executor.executor_params().state_libs.clone();
let mut global_libraries = executor.executor_params().libraries.clone();

let is_masterchain = shard.is_masterchain();
let config_address = &self.state.mc_data.config.address;
Expand Down Expand Up @@ -537,7 +537,6 @@ impl Phase<FinalizeState> {
.as_ref()
.map(Lazy::new)
.transpose()?,
copyleft_msgs: Default::default(),
config: if mc_state_extra.after_key_block {
Some(mc_state_extra.config.clone())
} else {
Expand Down Expand Up @@ -990,7 +989,6 @@ impl Phase<FinalizeState> {
last_key_block,
block_create_stats,
global_balance,
copyleft_rewards: Default::default(),
};

Ok((mc_state_extra, min_ref_mc_seqno))
Expand Down
Loading

0 comments on commit ed3ffa9

Please sign in to comment.