diff --git a/.gitmodules b/.gitmodules index e6f8e3a6..de6b6f05 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "vendor/smoldot"] path = vendor/smoldot - url = https://github.com/ermalkaleci/smoldot.git + url = https://github.com/smol-dot/smoldot.git diff --git a/executor/Cargo.lock b/executor/Cargo.lock index ece6835c..7cd0f1a7 100644 --- a/executor/Cargo.lock +++ b/executor/Cargo.lock @@ -47,7 +47,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45e900cdcd39bb94a14487d3f7ef92ca222162e6c7c3fe7cb3550ea75fb486ed" dependencies = [ - "event-listener", + "event-listener 3.0.1", "event-listener-strategy", "pin-project-lite", ] @@ -395,13 +395,23 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "event-listener" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "218a870470cce1469024e9fb66b901aa983929d81304a1cdb299f28118e550d5" +dependencies = [ + "concurrent-queue", + "pin-project-lite", +] + [[package]] name = "event-listener-strategy" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" dependencies = [ - "event-listener", + "event-listener 3.0.1", "pin-project-lite", ] @@ -603,9 +613,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" dependencies = [ "either", ] @@ -1094,7 +1104,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "smoldot" -version = "0.14.0" +version = "0.16.0" dependencies = [ "arrayvec 0.7.4", "async-lock", @@ -1108,7 +1118,7 @@ dependencies = [ "derive_more", "ed25519-zebra", "either", - "event-listener", + "event-listener 4.0.2", "fnv", "futures-lite", "futures-util", diff --git a/executor/src/proof.rs b/executor/src/proof.rs index 175e022b..20df1c96 100644 --- a/executor/src/proof.rs +++ b/executor/src/proof.rs @@ -21,9 +21,6 @@ pub fn decode_proof( let entries = decoded .iter_ordered() .filter(|(key, entry)| { - if key.key.is_empty() { - return false; - } if !key.trie_root_hash.eq(&trie_root_hash.0) { return false; } @@ -33,9 +30,7 @@ pub fn decode_proof( ) }) .map(|(key, entry)| { - let key = HexString( - nibbles_to_bytes_suffix_extend(key.key.iter().cloned()).collect::>(), - ); + let key = HexString(nibbles_to_bytes_suffix_extend(key.key).collect::>()); match entry.trie_node_info.storage_value { StorageValue::Known { value, .. } => (key, HexString(value.to_vec())), _ => unreachable!(), @@ -75,9 +70,7 @@ pub fn create_proof( for (entry_key, value) in decoded.iter_ordered() { let decoded_value = trie_node::decode(value.node_value).unwrap(); - if let trie_structure::Entry::Vacant(vacant) = - trie.node(entry_key.key.iter().map(|x| x.to_owned())) - { + if let trie_structure::Entry::Vacant(vacant) = trie.node(entry_key.key) { if let trie_node::StorageValue::Unhashed(value) = decoded_value.storage_value { vacant.insert_storage_value().insert(value.to_vec(), vec![]); } diff --git a/executor/src/task.rs b/executor/src/task.rs index 4a72ceaa..f3580a5e 100644 --- a/executor/src/task.rs +++ b/executor/src/task.rs @@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize}; use serde_wasm_bindgen::{from_value, to_value}; use smoldot::{ executor::{ - host::{Config, HeapPages, HostVmPrototype}, - runtime_host::{self, OffchainContext, RuntimeHostVm}, + host::{Config, HeapPages, HostVmPrototype, LogEmitInfo}, + runtime_call::{self, OffchainContext, RuntimeCall}, storage_diff::TrieDiff, CoreVersionRef, }, @@ -14,7 +14,6 @@ use smoldot::{ calculate_root::{root_merkle_value, RootMerkleValueCalculation}, nibbles_to_bytes_suffix_extend, HashFunction, TrieEntryVersion, }, - verify::body_only::LogEmitInfo, }; use std::collections::BTreeMap; use wasm_bindgen::prelude::*; @@ -134,7 +133,7 @@ pub async fn run_task(task: TaskCall, js: crate::JsCallback) -> Result = vec![]; for (call, params) in task.calls { - let mut vm = runtime_host::run(runtime_host::Config { + let mut vm = runtime_call::run(runtime_call::Config { virtual_machine: vm_proto.clone(), function_to_call: call.as_str(), parameter: params.into_iter().map(|x| x.0), @@ -148,11 +147,11 @@ pub async fn run_task(task: TaskCall, js: crate::JsCallback) -> Result { + RuntimeCall::Finished(res) => { break res; } - RuntimeHostVm::StorageGet(req) => { + RuntimeCall::StorageGet(req) => { let key = if let Some(child) = req.child_trie() { HexString(prefixed_child_key( child.as_ref().iter().copied(), @@ -184,13 +183,13 @@ pub async fn run_task(task: TaskCall, js: crate::JsCallback) -> Result { + RuntimeCall::ClosestDescendantMerkleValue(req) => { let value = js.get_state_root().await?; let value = from_value::(value).map(|x| x.0)?; req.inject_merkle_value(Some(value.as_ref())) } - RuntimeHostVm::NextKey(req) => { + RuntimeCall::NextKey(req) => { if req.branch_nodes() { // root_calculation, skip req.inject_key(None::>.map(|x| x.into_iter())) @@ -222,7 +221,7 @@ pub async fn run_task(task: TaskCall, js: crate::JsCallback) -> Result { + RuntimeCall::SignatureVerification(req) => { let bypass = task.mock_signature_host && is_magic_signature(req.signature().as_ref()); if bypass { @@ -232,7 +231,7 @@ pub async fn run_task(task: TaskCall, js: crate::JsCallback) -> Result { + RuntimeCall::OffchainStorageSet(req) => { offchain_storage_changes.insert( req.key().as_ref().to_vec(), req.value().map(|x| x.as_ref().to_vec()), @@ -240,7 +239,7 @@ pub async fn run_task(task: TaskCall, js: crate::JsCallback) -> Result match ctx { + RuntimeCall::Offchain(ctx) => match ctx { OffchainContext::StorageGet(req) => { let key = HexString(req.key().as_ref().to_vec()); let key = to_value(&key)?; @@ -292,7 +291,7 @@ pub async fn run_task(task: TaskCall, js: crate::JsCallback) -> Result { + RuntimeCall::LogEmit(req) => { { match req.info() { LogEmitInfo::Num(v) => { diff --git a/vendor/smoldot b/vendor/smoldot index 01e2f459..79e9d454 160000 --- a/vendor/smoldot +++ b/vendor/smoldot @@ -1 +1 @@ -Subproject commit 01e2f4596d9f619767a3ccbd8c95a43af478885c +Subproject commit 79e9d45400c2456fafab1cf310172f5ccfbd25d8