Skip to content

Commit

Permalink
Fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiencs committed Apr 16, 2024
1 parent 06b412a commit 92c2fc2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 74 deletions.
1 change: 1 addition & 0 deletions ledger/src/proofs/gates.rs
Expand Up @@ -267,6 +267,7 @@ pub fn read_constraints_data<F: FieldWitness>(
) -> Option<(InternalVars<F>, Vec<Vec<Option<V>>>)> {
use mina_p2p_messages::bigint::BigInt;

#[allow(non_local_definitions)]

Check warning on line 270 in ledger/src/proofs/gates.rs

View workflow job for this annotation

GitHub Actions / clippy

unknown lint: `non_local_definitions`

warning: unknown lint: `non_local_definitions` --> ledger/src/proofs/gates.rs:270:13 | 270 | #[allow(non_local_definitions)] | ^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unknown_lints)]` on by default
impl From<&VRaw> for V {
fn from(value: &VRaw) -> Self {
match value {
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/transaction_pool.rs
Expand Up @@ -1402,7 +1402,7 @@ mod transaction_hash {
}

// TODO: Remove this
struct Envelope<T> {
pub struct Envelope<T> {
pub data: T,
}

Expand Down
13 changes: 11 additions & 2 deletions node/native/src/service.rs
Expand Up @@ -14,9 +14,9 @@ use mina_p2p_messages::v2::{
};
#[cfg(not(feature = "p2p-libp2p"))]
use node::p2p::service_impl::mio::MioService;
use openmina_core::block::ArcBlockWithHash;
use node::snark::user_command_verify::{SnarkUserCommandVerifyId, SnarkUserCommandVerifyService};
use node::transaction_pool::VerifyUserCommandsService;
use node::transaction_pool::{TransactionPoolLedgerService, VerifyUserCommandsService};
use openmina_core::block::ArcBlockWithHash;
use rand::prelude::*;
use redux::ActionMeta;
use serde::Serialize;
Expand Down Expand Up @@ -433,6 +433,15 @@ impl SnarkBlockVerifyService for NodeService {
}
}

impl TransactionPoolLedgerService for NodeService {
fn get_mask(&self, ledger_hash: &LedgerHash) -> Result<ledger::Mask, String> {
self.ledger_manager
.get_mask(&ledger_hash)
.map(|(mask, _)| mask)
.ok_or_else(|| "Mask not found".to_string())
}
}

impl SnarkUserCommandVerifyService for NodeService {
fn verify_init(
&mut self,
Expand Down
2 changes: 1 addition & 1 deletion node/src/action_kind.rs
Expand Up @@ -423,7 +423,7 @@ pub enum ActionKind {
}

impl ActionKind {
pub const COUNT: u16 = 352;
pub const COUNT: u16 = 354;
}

impl std::fmt::Display for ActionKind {
Expand Down
9 changes: 9 additions & 0 deletions node/src/ledger/ledger_manager.rs
Expand Up @@ -21,6 +21,7 @@ use crate::block_producer::{
use crate::ledger::LedgerAddress;
use crate::p2p::channels::rpc::StagedLedgerAuxAndPendingCoinbases;
use crate::rpc::{RpcLedgerService, RpcScanStateSummaryScanStateJob};
use crate::transaction_pool::TransactionPoolLedgerService;
use crate::transition_frontier::sync::{
ledger::snarked::TransitionFrontierSyncLedgerSnarkedService,
ledger::staged::{
Expand Down Expand Up @@ -348,6 +349,14 @@ impl redux::TimeService for LedgerManager {}

impl redux::Service for LedgerManager {}

impl TransactionPoolLedgerService for LedgerManager {
fn get_mask(&self, ledger_hash: &LedgerHash) -> Result<Mask, String> {
self.get_mask(&ledger_hash)

Check warning on line 354 in node/src/ledger/ledger_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> node/src/ledger/ledger_manager.rs:354:23 | 354 | self.get_mask(&ledger_hash) | ^^^^^^^^^^^^ help: change this to: `ledger_hash` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 354 in node/src/ledger/ledger_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> node/src/ledger/ledger_manager.rs:354:23 | 354 | self.get_mask(&ledger_hash) | ^^^^^^^^^^^^ help: change this to: `ledger_hash` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
.map(|(mask, _)| mask)
.ok_or_else(|| "Mask not found".to_string())
}
}

impl TransitionFrontierSyncLedgerSnarkedService for LedgerManager {
fn compute_snarked_ledger_hashes(
&self,
Expand Down
80 changes: 10 additions & 70 deletions node/src/ledger/ledger_service.rs
Expand Up @@ -401,76 +401,7 @@ impl LedgerCtx {
Some(producers)
}

impl LedgerSyncState {
fn mask(&self, hash: &LedgerHash) -> Option<(Mask, bool)> {
self.snarked_ledgers
.get(hash)
.cloned()
.map(|mask| (mask, false))
.or_else(|| Some((self.staged_ledgers.get(hash)?.ledger(), true)))
}

fn pending_sync_snarked_ledger_mask(&self, hash: &LedgerHash) -> Result<Mask, String> {
self.snarked_ledgers
.get(hash)
.cloned()
.ok_or_else(|| format!("Missing sync snarked ledger {}", hash.to_string()))
}

/// Returns a [Mask] instance for the snarked ledger with [hash]. If it doesn't
/// exist a new instance is created.
fn snarked_ledger_mut(&mut self, hash: LedgerHash) -> &mut Mask {
self.snarked_ledgers.entry(hash.clone()).or_insert_with(|| {
let mut ledger = Mask::create(LEDGER_DEPTH);
ledger.set_cached_hash_unchecked(&LedgerAddress::root(), hash.0.to_field());
ledger
})
}

fn staged_ledger_mut(&mut self, hash: &LedgerHash) -> Option<&mut StagedLedger> {
self.staged_ledgers.get_mut(&hash)
}
}

pub trait LedgerService: redux::Service {
fn ctx(&self) -> &LedgerCtx;
fn ctx_mut(&mut self) -> &mut LedgerCtx;
}

impl<T: LedgerService> TransactionPoolLedgerService for T {
fn get_mask(&self, ledger_hash: &LedgerHash) -> Result<Mask, String> {
self.ctx()
.mask(&ledger_hash)
.map(|(mask, _)| mask)
.ok_or_else(|| "Mask not found".to_string())
}
}

impl<T: LedgerService> TransitionFrontierSyncLedgerSnarkedService for T {
fn compute_snarked_ledger_hashes(
&mut self,
snarked_ledger_hash: &LedgerHash,
) -> Result<(), String> {
self.ctx_mut()
.compute_snarked_ledger_hashes(snarked_ledger_hash)?;

Ok(())
}

fn copy_snarked_ledger_contents_for_sync(
&mut self,
origin_snarked_ledger_hash: LedgerHash,
target_snarked_ledger_hash: LedgerHash,
overwrite: bool,
) -> Result<bool, String> {
self.ctx_mut().copy_snarked_ledger_contents_for_sync(
origin_snarked_ledger_hash,
target_snarked_ledger_hash,
overwrite,
)
}

fn child_hashes_get(
pub fn child_hashes_get(
&mut self,
snarked_ledger_hash: LedgerHash,
parent: &LedgerAddress,
Expand Down Expand Up @@ -1149,6 +1080,15 @@ pub trait LedgerService: redux::Service {
fn ledger_manager(&self) -> &LedgerManager;
}

impl<T: LedgerService> TransactionPoolLedgerService for T {
fn get_mask(&self, ledger_hash: &LedgerHash) -> Result<Mask, String> {
self.ledger_manager()
.get_mask(&ledger_hash)

Check warning on line 1086 in node/src/ledger/ledger_service.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> node/src/ledger/ledger_service.rs:1086:23 | 1086 | .get_mask(&ledger_hash) | ^^^^^^^^^^^^ help: change this to: `ledger_hash` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Check warning on line 1086 in node/src/ledger/ledger_service.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> node/src/ledger/ledger_service.rs:1086:23 | 1086 | .get_mask(&ledger_hash) | ^^^^^^^^^^^^ help: change this to: `ledger_hash` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
.map(|(mask, _)| mask)
.ok_or_else(|| "Mask not found".to_string())
}
}

impl<T: LedgerService> TransitionFrontierSyncLedgerSnarkedService for T {
fn compute_snarked_ledger_hashes(
&self,
Expand Down

0 comments on commit 92c2fc2

Please sign in to comment.