Skip to content

feature(collator): append cumulative statistics after new master block #768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions collator/src/collator/do_collate/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl PhaseState for ExecuteState {}
impl Phase<ExecuteState> {
pub fn execute_special_transactions(&mut self) -> Result<()> {
let new_messages = self.extra.executor.create_special_transactions(
&self.state.mc_data.config,
&self.state.mc_data_stuff.current.config,
&mut self.state.collation_data,
)?;
self.extra.messages_reader.add_new_messages(new_messages);
Expand All @@ -33,7 +33,7 @@ impl Phase<ExecuteState> {

pub fn execute_tick_transactions(&mut self) -> Result<()> {
let new_messages = self.extra.executor.create_ticktock_transactions(
&self.state.mc_data.config,
&self.state.mc_data_stuff.current.config,
TickTock::Tick,
&mut self.state.collation_data,
)?;
Expand All @@ -43,7 +43,7 @@ impl Phase<ExecuteState> {

pub fn execute_tock_transactions(&mut self) -> Result<()> {
let new_messages = self.extra.executor.create_ticktock_transactions(
&self.state.mc_data.config,
&self.state.mc_data_stuff.current.config,
TickTock::Tock,
&mut self.state.collation_data,
)?;
Expand Down
62 changes: 40 additions & 22 deletions collator/src/collator/do_collate/finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ use crate::queue_adapter::MessageQueueAdapter;
use crate::tracing_targets;
use crate::types::processed_upto::{ProcessedUptoInfoExtension, ProcessedUptoInfoStuff};
use crate::types::{
BlockCandidate, CollationSessionInfo, CollatorConfig, McData, ShardDescriptionExt,
ShardHashesExt,
BlockCandidate, CollationSessionInfo, CollatorConfig, McData, McDataStuff,
ShardDescriptionShortExt, ShardHashesExt,
};
use crate::utils::block::detect_top_processed_to_anchor;

Expand Down Expand Up @@ -92,7 +92,8 @@ impl Phase<FinalizeState> {
} else {
let mut top_other_updated_shard_blocks_ids: Vec<BlockId> = self
.state
.mc_data
.mc_data_stuff
.current
.shards
.iter()
.filter(|(shard, descr)| {
Expand All @@ -101,7 +102,7 @@ impl Phase<FinalizeState> {
.map(|(shard_ident, descr)| descr.get_block_id(*shard_ident))
.collect();

top_other_updated_shard_blocks_ids.push(self.state.mc_data.block_id);
top_other_updated_shard_blocks_ids.push(self.state.mc_data_stuff.current.block_id);

top_other_updated_shard_blocks_ids
};
Expand Down Expand Up @@ -288,15 +289,15 @@ impl Phase<FinalizeState> {
let mut public_libraries = executor.executor_params().libraries.clone();

let is_masterchain = shard.is_masterchain();
let config_address = &self.state.mc_data.config.address;
let config_address = &self.state.mc_data_stuff.current.config.address;

// Compute a masterchain block seqno which will reference this block.
let ref_by_mc_seqno = if is_masterchain {
// The block itself for the masterchain
collation_data.block_id_short.seqno
} else {
// And the next masterchain block for shards
self.state.mc_data.block_id.seqno + 1
self.state.mc_data_stuff.current.block_id.seqno + 1
};

let mut processed_accounts_res = Ok(Default::default());
Expand Down Expand Up @@ -357,15 +358,15 @@ impl Phase<FinalizeState> {
&processed_accounts.shard_accounts,
&in_msgs,
&out_msgs,
&self.state.mc_data.config,
&self.state.mc_data_stuff.current.config,
)?;

// Validate value flow with simple rules.
if collator_config.check_value_flow {
Self::check_value_flow(
&value_flow,
&self.state.collation_data,
&self.state.mc_data.config,
&self.state.mc_data_stuff.current.config,
&self.state.prev_shard_data,
&in_msgs,
&out_msgs,
Expand Down Expand Up @@ -412,7 +413,10 @@ impl Phase<FinalizeState> {
(Some(extra), None)
} else {
build_mc_state_extra_elapsed = Duration::ZERO;
(None, Some(self.state.mc_data.make_block_ref()))
(
None,
Some(self.state.mc_data_stuff.current.make_block_ref()),
)
};

// HACK: make every 3-d block incorrect on debug if env variable defined
Expand All @@ -438,7 +442,7 @@ impl Phase<FinalizeState> {
gen_validator_list_hash_short: collation_session.collators().short_hash,
gen_catchain_seqno: collation_session.seqno(),
min_ref_mc_seqno: self.state.collation_data.min_ref_mc_seqno,
prev_key_block_seqno: self.state.mc_data.prev_key_block_seqno,
prev_key_block_seqno: self.state.mc_data_stuff.current.prev_key_block_seqno,
master_ref: master_ref.as_ref().map(Lazy::new).transpose()?,
..Default::default()
};
Expand All @@ -452,7 +456,12 @@ impl Phase<FinalizeState> {
// info.want_split = false;
// info.want_merge = false;

let bc_global_version = self.state.mc_data.config.get_global_version()?;
let bc_global_version = self
.state
.mc_data_stuff
.current
.config
.get_global_version()?;
if bc_global_version
.capabilities
.contains(GlobalCapability::CapReportVersion)
Expand Down Expand Up @@ -500,7 +509,8 @@ impl Phase<FinalizeState> {
// because mempool will not produce more anchors
let max_consensus_lag_rounds = self
.state
.mc_data
.mc_data_stuff
.current
.config
.get_consensus_config()?
.max_consensus_lag_rounds as u64;
Expand All @@ -525,7 +535,7 @@ impl Phase<FinalizeState> {

// build new state
let mut new_observable_state = Box::new(ShardStateUnsplit {
global_id: self.state.mc_data.global_id,
global_id: self.state.mc_data_stuff.current.global_id,
shard_ident: new_block_info.shard,
seqno: new_block_info.seqno,
vert_seqno: 0,
Expand Down Expand Up @@ -629,7 +639,7 @@ impl Phase<FinalizeState> {

// construct block
let block = Block {
global_id: self.state.mc_data.global_id,
global_id: self.state.mc_data_stuff.current.global_id,
info: Lazy::new(&new_block_info)?,
value_flow: Lazy::new(&value_flow)?,
state_update: Lazy::new(&state_update)?,
Expand Down Expand Up @@ -702,7 +712,7 @@ impl Phase<FinalizeState> {

let processed_to_anchor_id = processed_upto.get_min_externals_processed_to()?.0;

let new_mc_data = match mc_state_extra {
let mc_data_stuff = match mc_state_extra {
None => None,
Some(extra) => {
let prev_key_block_seqno = if extra.after_key_block {
Expand All @@ -720,7 +730,7 @@ impl Phase<FinalizeState> {
processed_to_anchor_id,
);

Some(Arc::new(McData {
let current_mc_data = Arc::new(McData {
global_id: new_block.as_ref().global_id,
block_id: *new_block.id(),

Expand All @@ -744,7 +754,15 @@ impl Phase<FinalizeState> {
.collation_data
.mc_shards_processed_to_by_partitions
.clone(),
}))
prev_mc_block_id: Some(self.state.mc_data_stuff.current.block_id),
});

let mc_data_stuff = McDataStuff {
current: current_mc_data,
previous: Some(self.state.mc_data_stuff.current.clone()),
};

Some(mc_data_stuff)
}
};

Expand All @@ -771,9 +789,9 @@ impl Phase<FinalizeState> {
value_flow,
created_by: self.state.collation_data.created_by,
queue_diff_aug: queue_diff.build(&new_block_id),
consensus_info: new_mc_data.as_ref().map_or_else(
|| self.state.mc_data.consensus_info,
|mcd| mcd.consensus_info,
consensus_info: mc_data_stuff.as_ref().map_or_else(
|| self.state.mc_data_stuff.current.consensus_info,
|mcd| mcd.current.consensus_info,
),
processed_upto,
});
Expand All @@ -797,11 +815,11 @@ impl Phase<FinalizeState> {
FinalizeBlockResult {
collation_data: self.state.collation_data,
block_candidate,
mc_data: new_mc_data,
mc_data_stuff,
old_mc_data_stuff: self.state.mc_data_stuff,
new_state_root,
new_observable_state,
finalize_wu_total,
old_mc_data: self.state.mc_data,
collation_config: self.state.collation_config,
},
self.extra.execute_result,
Expand Down
Loading