Skip to content

Commit 8631a4a

Browse files
committed
Ported block producer and VRF evaluator
1 parent 7d95965 commit 8631a4a

29 files changed

+976
-833
lines changed

node/common/src/service/block_producer/vrf_evaluator.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ pub fn vrf_evaluator(
5151
}
5252
}
5353

54-
impl node::block_producer::vrf_evaluator::BlockProducerVrfEvaluatorService for NodeService {
54+
impl node::block_producer_effectful::vrf_evaluator_effectful::BlockProducerVrfEvaluatorService
55+
for NodeService
56+
{
5557
fn evaluate(&mut self, data: VrfEvaluatorInput) {
5658
if let Some(bp) = self.block_producer.as_mut() {
5759
let _ = bp.vrf_evaluation_sender.send(data);

node/src/action.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub type ActionWithMeta = redux::ActionWithMeta<Action>;
55
pub type ActionWithMetaRef<'a> = redux::ActionWithMeta<&'a Action>;
66

77
pub use crate::block_producer::BlockProducerAction;
8+
pub use crate::block_producer_effectful::BlockProducerEffectfulAction;
89
pub use crate::consensus::ConsensusAction;
910
pub use crate::event_source::EventSourceAction;
1011
pub use crate::external_snark_worker::ExternalSnarkWorkerAction;
@@ -48,6 +49,7 @@ pub enum Action {
4849
TransactionPoolEffect(TransactionPoolEffectfulAction),
4950
ExternalSnarkWorker(ExternalSnarkWorkerAction),
5051
BlockProducer(BlockProducerAction),
52+
BlockProducerEffectful(BlockProducerEffectfulAction),
5153
Rpc(RpcAction),
5254
RpcEffectful(RpcEffectfulAction),
5355

@@ -92,6 +94,7 @@ impl redux::EnablingCondition<crate::State> for Action {
9294
Action::SnarkPoolEffect(a) => a.is_enabled(state, time),
9395
Action::ExternalSnarkWorker(a) => a.is_enabled(state, time),
9496
Action::BlockProducer(a) => a.is_enabled(state, time),
97+
Action::BlockProducerEffectful(a) => a.is_enabled(state, time),
9598
Action::Rpc(a) => a.is_enabled(state, time),
9699
Action::WatchedAccounts(a) => a.is_enabled(state, time),
97100
Action::TransactionPool(a) => a.is_enabled(state, time),

node/src/action_kind.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use strum_macros::VariantArray;
1717

1818
use crate::block_producer::vrf_evaluator::BlockProducerVrfEvaluatorAction;
1919
use crate::block_producer::BlockProducerAction;
20+
use crate::block_producer_effectful::vrf_evaluator_effectful::BlockProducerVrfEvaluatorEffectfulAction;
21+
use crate::block_producer_effectful::BlockProducerEffectfulAction;
2022
use crate::consensus::ConsensusAction;
2123
use crate::event_source::EventSourceAction;
2224
use crate::external_snark_worker::ExternalSnarkWorkerAction;
@@ -129,6 +131,13 @@ pub enum ActionKind {
129131
BlockProducerWonSlotTransactionsGet,
130132
BlockProducerWonSlotTransactionsSuccess,
131133
BlockProducerWonSlotWait,
134+
BlockProducerEffectfulBlockProveInit,
135+
BlockProducerEffectfulBlockProveSuccess,
136+
BlockProducerEffectfulBlockUnprovenBuild,
137+
BlockProducerEffectfulStagedLedgerDiffCreateInit,
138+
BlockProducerEffectfulStagedLedgerDiffCreateSuccess,
139+
BlockProducerEffectfulWonSlot,
140+
BlockProducerEffectfulWonSlotDiscard,
132141
BlockProducerVrfEvaluatorBeginDelegatorTableConstruction,
133142
BlockProducerVrfEvaluatorBeginEpochEvaluation,
134143
BlockProducerVrfEvaluatorCheckEpochBounds,
@@ -145,6 +154,7 @@ pub enum ActionKind {
145154
BlockProducerVrfEvaluatorProcessSlotEvaluationSuccess,
146155
BlockProducerVrfEvaluatorSelectInitialSlot,
147156
BlockProducerVrfEvaluatorWaitForNextEvaluation,
157+
BlockProducerVrfEvaluatorEffectfulEvaluateSlot,
148158
CheckTimeouts,
149159
ConsensusBestTipUpdate,
150160
ConsensusBlockChainProofUpdate,
@@ -694,7 +704,7 @@ pub enum ActionKind {
694704
}
695705

696706
impl ActionKind {
697-
pub const COUNT: u16 = 581;
707+
pub const COUNT: u16 = 589;
698708
}
699709

700710
impl std::fmt::Display for ActionKind {
@@ -721,6 +731,7 @@ impl ActionKindGet for Action {
721731
Self::TransactionPoolEffect(a) => a.kind(),
722732
Self::ExternalSnarkWorker(a) => a.kind(),
723733
Self::BlockProducer(a) => a.kind(),
734+
Self::BlockProducerEffectful(a) => a.kind(),
724735
Self::Rpc(a) => a.kind(),
725736
Self::RpcEffectful(a) => a.kind(),
726737
Self::WatchedAccounts(a) => a.kind(),
@@ -969,6 +980,25 @@ impl ActionKindGet for BlockProducerAction {
969980
}
970981
}
971982

983+
impl ActionKindGet for BlockProducerEffectfulAction {
984+
fn kind(&self) -> ActionKind {
985+
match self {
986+
Self::VrfEvaluator(a) => a.kind(),
987+
Self::WonSlot { .. } => ActionKind::BlockProducerEffectfulWonSlot,
988+
Self::WonSlotDiscard { .. } => ActionKind::BlockProducerEffectfulWonSlotDiscard,
989+
Self::StagedLedgerDiffCreateInit => {
990+
ActionKind::BlockProducerEffectfulStagedLedgerDiffCreateInit
991+
}
992+
Self::StagedLedgerDiffCreateSuccess => {
993+
ActionKind::BlockProducerEffectfulStagedLedgerDiffCreateSuccess
994+
}
995+
Self::BlockUnprovenBuild => ActionKind::BlockProducerEffectfulBlockUnprovenBuild,
996+
Self::BlockProveInit => ActionKind::BlockProducerEffectfulBlockProveInit,
997+
Self::BlockProveSuccess => ActionKind::BlockProducerEffectfulBlockProveSuccess,
998+
}
999+
}
1000+
}
1001+
9721002
impl ActionKindGet for RpcAction {
9731003
fn kind(&self) -> ActionKind {
9741004
match self {
@@ -1482,6 +1512,14 @@ impl ActionKindGet for BlockProducerVrfEvaluatorAction {
14821512
}
14831513
}
14841514

1515+
impl ActionKindGet for BlockProducerVrfEvaluatorEffectfulAction {
1516+
fn kind(&self) -> ActionKind {
1517+
match self {
1518+
Self::EvaluateSlot { .. } => ActionKind::BlockProducerVrfEvaluatorEffectfulEvaluateSlot,
1519+
}
1520+
}
1521+
}
1522+
14851523
impl ActionKindGet for P2pConnectionOutgoingAction {
14861524
fn kind(&self) -> ActionKind {
14871525
match self {

node/src/block_producer/block_producer_actions.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ use openmina_core::block::ArcBlockWithHash;
44
use openmina_core::ActionEvent;
55
use serde::{Deserialize, Serialize};
66

7+
use crate::block_producer_effectful::StagedLedgerDiffCreateOutput;
8+
79
use super::vrf_evaluator::BlockProducerVrfEvaluatorAction;
8-
use super::{
9-
BlockProducerCurrentState, BlockProducerWonSlot, BlockProducerWonSlotDiscardReason,
10-
StagedLedgerDiffCreateOutput,
11-
};
10+
use super::{BlockProducerCurrentState, BlockProducerWonSlot, BlockProducerWonSlotDiscardReason};
1211

1312
pub type BlockProducerActionWithMeta = redux::ActionWithMeta<BlockProducerAction>;
1413
pub type BlockProducerActionWithMetaRef<'a> = redux::ActionWithMeta<&'a BlockProducerAction>;

0 commit comments

Comments
 (0)