Skip to content
Merged

Fixes #850

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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/core/services/web-node.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
14 changes: 6 additions & 8 deletions node/src/consensus/consensus_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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 }
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions node/src/snark_pool/snark_pool_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum SnarkPoolAction {
},
#[action_event(level = trace)]
P2pSendAll,
#[action_event(level = trace)]
P2pSend {
peer_id: PeerId,
},
Expand Down
12 changes: 5 additions & 7 deletions node/web/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand All @@ -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(),
Expand Down Expand Up @@ -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))
Expand Down
7 changes: 3 additions & 4 deletions snark/src/block_verify/snark_block_verify_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockHash>,
on_error: redux::Callback<(BlockHash, SnarkBlockVerifyError)>,
},
Expand All @@ -32,9 +33,7 @@ pub enum SnarkBlockVerifyAction {
impl redux::EnablingCondition<crate::SnarkState> 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
Expand Down
9 changes: 5 additions & 4 deletions snark/src/block_verify/snark_block_verify_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub fn reducer<State, Action>(
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(),
Expand All @@ -42,13 +42,14 @@ pub fn reducer<State, Action>(
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) {
Expand Down
Loading