diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index da4667b837..b3b835dfd8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -116,7 +116,7 @@ jobs: rustup default nightly rustup component add rustfmt rust-src rustup target add wasm32-unknown-unknown - cargo install -f wasm-bindgen-cli --version 0.2.93 + cargo install -f wasm-bindgen-cli --version 0.2.95 - name: Setup Rust Cache uses: Swatinem/rust-cache@v2 diff --git a/Cargo.lock b/Cargo.lock index 8d07ab5829..ccfe9faf58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2903,9 +2903,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -5686,7 +5686,7 @@ dependencies = [ [[package]] name = "redux" version = "0.1.0" -source = "git+https://github.com/openmina/redux-rs.git?rev=75d4d1d9#75d4d1d927f9031f0656b7f56c4a3ec398da138f" +source = "git+https://github.com/openmina/redux-rs.git?rev=bf0726e5#bf0726e596a456f2204c5138528ac7a64695e3b4" dependencies = [ "enum_dispatch", "linkme", @@ -7879,9 +7879,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -7890,9 +7890,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -7917,9 +7917,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7927,9 +7927,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -7940,9 +7940,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-bindgen-test" @@ -7996,9 +7996,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index f2e1251e2f..763bd8b627 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ poly-commitment = {git = "https://github.com/openmina/proof-systems", rev = "2fd libp2p = { git = "https://github.com/openmina/rust-libp2p", rev = "5c44c7d9", default-features = false } vrf = { path = "vrf" } openmina-node-account = { path = "node/account" } -redux = { git = "https://github.com/openmina/redux-rs.git", rev = "75d4d1d9", features = ["serde"] } +redux = { git = "https://github.com/openmina/redux-rs.git", rev = "bf0726e5", features = ["serde"] } serde = "1.0.190" serde_json = "1.0.107" serde_with = { version = "3.7.0", features = ["hex"] } diff --git a/frontend/src/app/core/services/web-node.service.ts b/frontend/src/app/core/services/web-node.service.ts index 2cf88833f7..6aae93ce76 100644 --- a/frontend/src/app/core/services/web-node.service.ts +++ b/frontend/src/app/core/services/web-node.service.ts @@ -44,6 +44,7 @@ export class WebNodeService { tap((webnode: any) => { console.log('----------------WEBNODE----------------'); console.log(webnode); + (window as any)["webnode"] = webnode; this.webnode$.next(webnode); }), switchMap(() => this.webnode$.asObservable()), diff --git a/node/src/consensus/consensus_reducer.rs b/node/src/consensus/consensus_reducer.rs index a73f5aaf8b..19fd383106 100644 --- a/node/src/consensus/consensus_reducer.rs +++ b/node/src/consensus/consensus_reducer.rs @@ -3,7 +3,7 @@ use openmina_core::{ bug_condition, consensus::{is_short_range_fork, long_range_fork_take, short_range_fork_take}, }; -use snark::block_verify::{SnarkBlockVerifyAction, SnarkBlockVerifyError}; +use snark::block_verify::{SnarkBlockVerifyAction, SnarkBlockVerifyError, SnarkBlockVerifyId}; use crate::{ transition_frontier::sync::{ @@ -48,11 +48,13 @@ impl ConsensusState { ); // Dispatch - let (dispatcher, global_state) = state_context.into_dispatcher_and_state(); - let req_id = global_state.snark.block_verify.next_req_id(); + let dispatcher = state_context.into_dispatcher(); dispatcher.push(SnarkBlockVerifyAction::Init { - req_id, block: (hash.clone(), block.clone()).into(), + on_init: redux::callback!( + on_received_block_snark_verify_init((hash: BlockHash, req_id: SnarkBlockVerifyId)) -> crate::Action { + ConsensusAction::BlockSnarkVerifyPending { hash, req_id } + }), on_success: redux::callback!( on_received_block_snark_verify_success(hash: BlockHash) -> crate::Action { ConsensusAction::BlockSnarkVerifySuccess { hash } @@ -62,10 +64,6 @@ impl ConsensusState { ConsensusAction::BlockSnarkVerifyError { hash, error } }), }); - dispatcher.push(ConsensusAction::BlockSnarkVerifyPending { - req_id, - hash: hash.clone(), - }); } ConsensusAction::BlockChainProofUpdate { hash, chain_proof } => { if state.best_tip.as_ref() == Some(hash) { diff --git a/node/src/snark_pool/snark_pool_actions.rs b/node/src/snark_pool/snark_pool_actions.rs index 4e8c120c10..305f8f737e 100644 --- a/node/src/snark_pool/snark_pool_actions.rs +++ b/node/src/snark_pool/snark_pool_actions.rs @@ -38,6 +38,7 @@ pub enum SnarkPoolAction { }, #[action_event(level = trace)] P2pSendAll, + #[action_event(level = trace)] P2pSend { peer_id: PeerId, }, diff --git a/node/web/src/node/builder.rs b/node/web/src/node/builder.rs index 576724e244..70c9a119c8 100644 --- a/node/web/src/node/builder.rs +++ b/node/web/src/node/builder.rs @@ -207,10 +207,6 @@ impl NodeBuilder { anyhow::anyhow!("transaction verifier index not set on the node builder!") })?; - let initial_time = self - .custom_initial_time - .unwrap_or_else(redux::Timestamp::global_now); - let transition_frontier = TransitionFrontierConfig::new(self.genesis_config); let protocol_constants = transition_frontier.genesis.protocol_constants()?; @@ -235,9 +231,7 @@ impl NodeBuilder { enabled_channels: ChannelId::iter_all().collect(), peer_discovery: !self.p2p_no_discovery, meshsub: P2pMeshsubConfig { - initial_time: initial_time - .checked_sub(redux::Timestamp::ZERO) - .unwrap_or_default(), + initial_time: Duration::ZERO, ..Default::default() }, timeouts: P2pTimeouts::default(), @@ -268,6 +262,10 @@ impl NodeBuilder { } let service = service.build()?; + + let initial_time = self + .custom_initial_time + .unwrap_or_else(redux::Timestamp::global_now); let state = node::State::new(node_config, &consensus_consts, initial_time); Ok(Node::new(self.rng_seed, state, service, None)) diff --git a/snark/src/block_verify/snark_block_verify_actions.rs b/snark/src/block_verify/snark_block_verify_actions.rs index 63eb3dba2f..ed5f5daf0c 100644 --- a/snark/src/block_verify/snark_block_verify_actions.rs +++ b/snark/src/block_verify/snark_block_verify_actions.rs @@ -9,8 +9,9 @@ pub type SnarkBlockVerifyActionWithMetaRef<'a> = redux::ActionWithMeta<&'a Snark #[derive(Serialize, Deserialize, Debug, Clone, ActionEvent)] pub enum SnarkBlockVerifyAction { Init { - req_id: SnarkBlockVerifyId, block: VerifiableBlockWithHash, + + on_init: redux::Callback<(BlockHash, SnarkBlockVerifyId)>, on_success: redux::Callback, on_error: redux::Callback<(BlockHash, SnarkBlockVerifyError)>, }, @@ -32,9 +33,7 @@ pub enum SnarkBlockVerifyAction { impl redux::EnablingCondition for SnarkBlockVerifyAction { fn is_enabled(&self, state: &crate::SnarkState, _time: redux::Timestamp) -> bool { match self { - SnarkBlockVerifyAction::Init { req_id, .. } => { - state.block_verify.jobs.next_req_id() == *req_id - } + SnarkBlockVerifyAction::Init { .. } => true, SnarkBlockVerifyAction::Pending { req_id } => state .block_verify .jobs diff --git a/snark/src/block_verify/snark_block_verify_reducer.rs b/snark/src/block_verify/snark_block_verify_reducer.rs index ba9ae5cb64..be207568d1 100644 --- a/snark/src/block_verify/snark_block_verify_reducer.rs +++ b/snark/src/block_verify/snark_block_verify_reducer.rs @@ -27,11 +27,11 @@ pub fn reducer( match action { SnarkBlockVerifyAction::Init { block, - req_id, + on_init, on_success, on_error, } => { - state.jobs.add(SnarkBlockVerifyStatus::Init { + let req_id = state.jobs.add(SnarkBlockVerifyStatus::Init { time: meta.time(), block: block.clone(), on_success: on_success.clone(), @@ -42,13 +42,14 @@ pub fn reducer( let verifier_index = state.verifier_index.clone(); let verifier_srs = state.verifier_srs.clone(); let dispatcher = state_context.into_dispatcher(); + dispatcher.push_callback(on_init.clone(), (block.hash_ref().clone(), req_id)); dispatcher.push(SnarkBlockVerifyEffectfulAction::Init { - req_id: *req_id, + req_id, block: block.clone(), verifier_index, verifier_srs, }); - dispatcher.push(SnarkBlockVerifyAction::Pending { req_id: *req_id }); + dispatcher.push(SnarkBlockVerifyAction::Pending { req_id }); } SnarkBlockVerifyAction::Pending { req_id } => { if let Some(req) = state.jobs.get_mut(*req_id) {