Skip to content

Commit

Permalink
Merge branch 'master' into rmasl-fix-lazy-pages-fuzzer-wasmi-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteNacked authored Nov 22, 2024
2 parents 6cb7ff0 + a0d5e3a commit 5edf3a1
Show file tree
Hide file tree
Showing 64 changed files with 2,177 additions and 1,620 deletions.
96 changes: 93 additions & 3 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ directories = "5.0.1" # utils/key-finder
num-traits = { version = "0.2", default-features = false } # gear-core
glob = "0.3.1" # cargo-gbuild
smallvec = "1.13.2" # utils/node-wrapper
fs4 = "0.11.1" # utils/gear-wasmer-cache
bytes = "1.8.0" # utils/gear-wasmer-cache
loom = "0.7.2" # utils/gear-wasmer-cache

[profile.dev.package.corosensei]
opt-level = 3
Expand Down
35 changes: 1 addition & 34 deletions ethexe/cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
config,
params::{NetworkParams, PrometheusParams, RpcParams},
};
use anyhow::{anyhow, bail, Result};
use anyhow::{anyhow, bail};
use clap::{Parser, Subcommand};
use ethexe_ethereum::Ethereum;
use ethexe_signer::Address;
Expand Down Expand Up @@ -145,7 +145,6 @@ pub enum ExtraCommands {
ClearKeys,
InsertKey(InsertKeyArgs),
Sign(SigningArgs),
UpdateValidators(UpdateValidatorsArgs),
UploadCode(UploadCodeArgs),
CreateProgram(CreateProgramArgs),
}
Expand All @@ -160,11 +159,6 @@ pub struct InsertKeyArgs {
key_uri: String,
}

#[derive(Clone, Debug, Deserialize, Parser)]
pub struct UpdateValidatorsArgs {
validators: Vec<String>,
}

#[derive(Clone, Debug, Deserialize, Parser)]
pub struct UploadCodeArgs {
path: PathBuf,
Expand Down Expand Up @@ -258,33 +252,6 @@ impl ExtraCommands {
println!("Ethereum address: {}", pub_key.to_address());
}

ExtraCommands::UpdateValidators(ref update_validators_args) => {
let validator_addresses = update_validators_args
.validators
.iter()
.map(|validator| validator.parse::<Address>())
.collect::<Result<Vec<_>>>()?;

let validators = validator_addresses
.into_iter()
.map(|address| address.0.into())
.collect();

let Some((sender_address, ethexe_ethereum)) =
maybe_sender_address.zip(maybe_ethereum)
else {
bail!("please provide signer address");
};

println!("Updating validators for Router from {sender_address}...");

let tx = ethexe_ethereum
.router()
.update_validators(validators)
.await?;
println!("Completed in transaction {tx:?}");
}

ExtraCommands::UploadCode(ref upload_code_args) => {
let path = &upload_code_args.path;

Expand Down
40 changes: 27 additions & 13 deletions ethexe/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ use crate::{
config::{Config, ConfigPublicKey, PrometheusConfig},
metrics::MetricsService,
};
use anyhow::{anyhow, Result};
use anyhow::{anyhow, bail, Result};
use ethexe_common::{
router::{
BlockCommitment, CodeCommitment, RequestEvent as RouterRequestEvent, StateTransition,
},
BlockRequestEvent,
events::{BlockRequestEvent, RouterRequestEvent},
gear::{BlockCommitment, CodeCommitment, StateTransition},
};
use ethexe_db::{BlockMetaStorage, CodesStorage, Database};
use ethexe_ethereum::{primitives::U256, router::RouterQuery};
Expand Down Expand Up @@ -108,7 +106,16 @@ impl Service {
let router_query = RouterQuery::new(&config.ethereum_rpc, ethereum_router_address).await?;

let genesis_block_hash = router_query.genesis_block_hash().await?;
log::info!("👶 Genesis block hash: {genesis_block_hash:?}");

if genesis_block_hash.is_zero() {
log::error!(
"👶 Genesis block hash wasn't found. Call router.lookupGenesisHash() first"
);

bail!("Failed to query valid genesis hash");
} else {
log::info!("👶 Genesis block hash: {genesis_block_hash:?}");
}

let validators = router_query.validators().await?;
log::info!("👥 Validators set: {validators:?}");
Expand Down Expand Up @@ -357,7 +364,9 @@ impl Service {
db.set_block_header(block_data.hash, block_data.header);

let mut commitments = vec![];

let last_committed_chain = query.get_last_committed_chain(block_data.hash).await?;

for block_hash in last_committed_chain.into_iter().rev() {
let transitions = Self::process_one_block(db, query, processor, block_hash).await?;

Expand All @@ -366,12 +375,17 @@ impl Service {
continue;
}

let header = db
.block_header(block_hash)
.ok_or_else(|| anyhow!("header not found, but most exist"))?;

commitments.push(BlockCommitment {
block_hash,
pred_block_hash: block_data.hash,
prev_commitment_hash: db
.block_prev_commitment(block_hash)
hash: block_hash,
timestamp: header.timestamp,
previous_committed_block: db
.previous_committed_block(block_hash)
.ok_or_else(|| anyhow!("Prev commitment not found"))?,
predecessor_block: block_data.hash,
transitions,
});
}
Expand Down Expand Up @@ -668,7 +682,7 @@ impl Service {
};

let last_not_empty_block = match block_is_empty {
true => match db.block_prev_commitment(chain_head) {
true => match db.previous_committed_block(chain_head) {
Some(prev_commitment) => prev_commitment,
None => {
log::warn!("Failed to get previous commitment for {chain_head}");
Expand Down Expand Up @@ -918,7 +932,7 @@ mod tests {
node_name: "test".to_string(),
ethereum_rpc: "ws://54.67.75.1:8546".into(),
ethereum_beacon_rpc: "http://localhost:5052".into(),
ethereum_router_address: "0xa9e7B594e18e28b1Cc0FA4000D92ded887CB356F"
ethereum_router_address: "0x051193e518181887088df3891cA0E5433b094A4a"
.parse()
.expect("infallible"),
max_commitment_depth: 1000,
Expand Down Expand Up @@ -947,7 +961,7 @@ mod tests {
node_name: "test".to_string(),
ethereum_rpc: "wss://ethereum-holesky-rpc.publicnode.com".into(),
ethereum_beacon_rpc: "http://localhost:5052".into(),
ethereum_router_address: "0xa9e7B594e18e28b1Cc0FA4000D92ded887CB356F"
ethereum_router_address: "0x051193e518181887088df3891cA0E5433b094A4a"
.parse()
.expect("infallible"),
max_commitment_depth: 1000,
Expand Down
17 changes: 9 additions & 8 deletions ethexe/cli/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use alloy::{
};
use anyhow::Result;
use ethexe_common::{
db::CodesStorage, mirror::Event as MirrorEvent, router::Event as RouterEvent, BlockEvent,
db::CodesStorage,
events::{BlockEvent, MirrorEvent, RouterEvent},
};
use ethexe_db::{BlockMetaStorage, Database, MemDb, ScheduledTask};
use ethexe_ethereum::{router::RouterQuery, Ethereum};
Expand Down Expand Up @@ -194,7 +195,7 @@ async fn mailbox() {
let mut listener = env.events_publisher().subscribe().await;
let block_data = listener
.apply_until_block_event_with_header(|event, block_data| match event {
BlockEvent::Mirror { address, event } if address == pid => {
BlockEvent::Mirror { actor_id, event } if actor_id == pid => {
if let MirrorEvent::Message {
id,
destination,
Expand Down Expand Up @@ -298,7 +299,7 @@ async fn mailbox() {

let block_data = listener
.apply_until_block_event_with_header(|event, block_data| match event {
BlockEvent::Mirror { address, event } if address == pid => match event {
BlockEvent::Mirror { actor_id, event } if actor_id == pid => match event {
MirrorEvent::ValueClaimed { claimed_id, .. }
if claimed_id == mid_expected_message =>
{
Expand Down Expand Up @@ -1393,8 +1394,8 @@ mod utils {

self.listener
.apply_until_block_event(|event| match event {
BlockEvent::Router(RouterEvent::CodeGotValidated { id, valid })
if id == self.code_id =>
BlockEvent::Router(RouterEvent::CodeGotValidated { code_id, valid })
if code_id == self.code_id =>
{
valid_info = Some(valid);
Ok(Some(()))
Expand Down Expand Up @@ -1447,7 +1448,7 @@ mod utils {
{
code_id_info = Some(code_id);
}
BlockEvent::Mirror { address, event } if address == self.program_id => {
BlockEvent::Mirror { actor_id, event } if actor_id == self.program_id => {
match event {
MirrorEvent::MessageQueueingRequested {
id,
Expand Down Expand Up @@ -1521,7 +1522,7 @@ mod utils {
self.listener
.apply_until_block_event(|event| match event {
BlockEvent::Mirror {
address,
actor_id,
event:
MirrorEvent::Reply {
reply_to,
Expand All @@ -1532,7 +1533,7 @@ mod utils {
} if reply_to == self.message_id => {
info = Some(ReplyInfo {
message_id: reply_to,
program_id: address,
program_id: actor_id,
reply_payload: payload,
reply_code,
reply_value: value,
Expand Down
Loading

0 comments on commit 5edf3a1

Please sign in to comment.