Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/empty-block-collation'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed May 1, 2024
2 parents 4e243b6 + 83ab987 commit 1a50d92
Show file tree
Hide file tree
Showing 45 changed files with 3,123 additions and 1,173 deletions.
39 changes: 21 additions & 18 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ crc = "3.0.1"
dashmap = "5.4"
ed25519 = "2.0"
everscale-crypto = { version = "0.2", features = ["tl-proto", "serde"] }
everscale-types = "0.1.0-rc.6"
everscale-types = { version = "0.1.0-rc.6", features = ["tycho"] }
exponential-backoff = "1"
fdlimit = "0.3.0"
futures-util = "0.3"
Expand Down Expand Up @@ -99,7 +99,8 @@ tycho-util = { path = "./util" }
# NOTE: use crates.io dependency when it is released
# https://github.com/sagebind/castaway/issues/18
castaway = { git = "https://github.com/sagebind/castaway.git" }
everscale-types = { git = "https://github.com/broxus/everscale-types.git" }
#everscale-types = { git = "https://github.com/broxus/everscale-types.git", branch = "tycho" }
everscale-types = { path = "../everscale-types" }

[workspace.lints.rust]
future_incompatible = "warn"
Expand Down
3 changes: 3 additions & 0 deletions block-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ tycho-util = { workspace = true }
[dev-dependencies]
rand = { workspace = true }

[features]
test = []

[lints]
workspace = true
33 changes: 33 additions & 0 deletions block-util/src/block/block_stuff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,39 @@ pub struct BlockStuff {
}

impl BlockStuff {
#[cfg(any(test, feature = "test"))]
pub fn new_empty(shard: ShardIdent, seqno: u32) -> Self {
use everscale_types::merkle::MerkleUpdate;

let block_info = BlockInfo {
shard,
seqno,
..Default::default()
};

let block = Block {
global_id: 0,
info: Lazy::new(&BlockInfo::default()).unwrap(),
value_flow: Lazy::new(&ValueFlow::default()).unwrap(),
state_update: Lazy::new(&MerkleUpdate::default()).unwrap(),
out_msg_queue_updates: None,
extra: Lazy::new(&BlockExtra::default()).unwrap(),
};

let cell = CellBuilder::build_from(&block).unwrap();
let root_hash = *cell.repr_hash();
let file_hash = sha2::Sha256::digest(Boc::encode(&cell)).into();

let block_id = BlockId {
shard: block_info.shard,
seqno: block_info.seqno,
root_hash,
file_hash,
};

Self::with_block(block_id, block)
}

pub fn with_block(id: BlockId, block: Block) -> Self {
Self {
inner: Arc::new(Inner { id, block }),
Expand Down
24 changes: 24 additions & 0 deletions block-util/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use anyhow::Result;

use everscale_types::{dict::Dict, models::BlockchainConfig};

pub trait BlockchainConfigExt {
/// Check that config is valid.
fn validate_params(
&self,
relax_par0: bool,
mandatory_params: Option<Dict<u32, ()>>,
) -> Result<bool>;
}

impl BlockchainConfigExt for BlockchainConfig {
fn validate_params(
&self,
_relax_par0: bool,
_mandatory_params: Option<Dict<u32, ()>>,
) -> Result<bool> {
//TODO: refer to https://github.com/everx-labs/ever-block/blob/master/src/config_params.rs#L452
//STUB: currently should not be invoked in prototype
todo!()
}
}
1 change: 1 addition & 0 deletions block-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod archive;
pub mod block;
pub mod config;
pub mod state;
14 changes: 1 addition & 13 deletions cli/src/tools/gen_zerostate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,21 +343,9 @@ fn make_shard_state(global_id: i32, shard_ident: ShardIdent, now: u32) -> ShardS
ShardStateUnsplit {
global_id,
shard_ident,
seqno: 0,
vert_seqno: 0,
gen_utime: now,
gen_lt: 0,
min_ref_mc_seqno: u32::MAX,
out_msg_queue_info: Default::default(),
before_split: false,
accounts: Lazy::new(&Default::default()).unwrap(),
overload_history: 0,
underload_history: 0,
total_balance: CurrencyCollection::ZERO,
total_validator_fees: CurrencyCollection::ZERO,
libraries: Dict::new(),
master_ref: None,
custom: None,
..Default::default()
}
}

Expand Down
13 changes: 13 additions & 0 deletions collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ license.workspace = true
# crates.io deps
anyhow = { workspace = true }
async-trait = { workspace = true }
bytesize = { workspace = true }
futures-util = { workspace = true }
rand = { workspace = true }
sha2 = { workspace = true }
tl-proto = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt", "signal"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
Expand All @@ -29,9 +32,19 @@ tycho-network = { workspace = true }
tycho-storage = { workspace = true }
tycho-util = { workspace = true }
tycho-block-util = { workspace = true }
log = "0.4.21"

[dev-dependencies]
tempfile = { workspace = true }
tokio = { version = "1", features = ["rt-multi-thread"] }
tracing-test = { workspace = true }
tycho-block-util = { workspace = true, features = ["test"] }
tycho-core = { workspace = true, features = ["test"] }
tycho-storage = { workspace = true, features = ["test"] }
tycho-util = { workspace = true, features = ["test"] }

[features]
test = []

[lints]
workspace = true
Loading

0 comments on commit 1a50d92

Please sign in to comment.