refactor(mantle): Transaction Traits (#3168)

This commit is contained in:
Álex
2026-07-23 23:21:03 +02:00
committed by GitHub
parent 1be5503699
commit 5db6f708bd
86 changed files with 465 additions and 561 deletions
+7 -5
View File
@@ -5,7 +5,9 @@ use lb_chain_service::api::CryptarchiaServiceApi;
use lb_core::{
block::{Block as CoreBlock, BlockTransactions},
mantle::{
StorageSize, Transaction, TransactionHasher, TxHash, transactions::states::Unverified,
TxHash,
traits::{Hashable, StorageSize, hashable},
transactions::states::Unverified,
},
};
use lb_node::{
@@ -31,12 +33,12 @@ pub struct TxWithId {
tx: SignedMantleTx<Unverified>,
}
impl Transaction for TxWithId {
impl Hashable for TxWithId {
//noinspection RsTypeCheck: The type is correct, but the linter is confused by
// the closure.
const HASHER: TransactionHasher<Self> =
|tx| <SignedMantleTx<Unverified> as Transaction>::HASHER(&tx.tx);
type Hash = <SignedMantleTx<Unverified> as Transaction>::Hash;
const HASHER: hashable::Hasher<Self> =
|tx| <SignedMantleTx<Unverified> as Hashable>::HASHER(&tx.tx);
type Hash = <SignedMantleTx<Unverified> as Hashable>::Hash;
fn as_signing(&self) -> Vec<u8> {
self.tx.as_signing()
+7 -11
View File
@@ -8,7 +8,7 @@ use lb_api_service::http::mempool;
use lb_core::{
header::HeaderId as CoreHeaderId,
mantle::{
MantleTx, Note, NoteId as CoreNoteId, Op, OpProof, SignedMantleTx, Transaction,
MantleTx, Note, NoteId as CoreNoteId, Op, OpProof, SignedMantleTx,
gas::GasCost,
ledger::{Inputs, Outputs},
ops::{
@@ -18,6 +18,7 @@ use lb_core::{
},
transfer::TransferOp,
},
traits::Hashable,
transactions::{
MantleTxBuilder,
states::{Preverified, Unverified},
@@ -715,7 +716,7 @@ pub(crate) fn transfer_funds_sync(
)
})?;
if let Err(error) = mempool::add_tx(handle, signed_tx.clone(), Transaction::hash).await {
if let Err(error) = mempool::add_tx(handle, signed_tx.clone(), Hashable::hash).await {
return Err(OperationStatus::error(
OperationStatusCode::DynError,
format!("Failed to add transaction to mempool: {error}"),
@@ -1002,7 +1003,7 @@ pub(crate) fn channel_deposit_with_notes_sync(
})?
.response;
if let Err(error) = mempool::add_tx(handle, signed_tx.clone(), Transaction::hash).await {
if let Err(error) = mempool::add_tx(handle, signed_tx.clone(), Hashable::hash).await {
return Err(OperationStatus::error(
OperationStatusCode::DynError,
format!("Failed to add transaction to mempool: {error}"),
@@ -1353,7 +1354,7 @@ pub(crate) fn channel_deposit_sync(
})?;
// 6. Submit to the mempool.
if let Err(error) = mempool::add_tx(handle, signed_tx.clone(), Transaction::hash).await {
if let Err(error) = mempool::add_tx(handle, signed_tx.clone(), Hashable::hash).await {
return Err(OperationStatus::error(
OperationStatusCode::DynError,
format!("Failed to add transaction to mempool: {error}"),
@@ -1623,7 +1624,7 @@ pub type FfiSubmitTransactionResult = FfiStatusResult<Hash>;
///
/// Mirrors the node's `POST /mempool/add/tx` HTTP handler. The transaction is
/// a JSON string with the exact same schema as the HTTP request body — for
/// example a transaction funded via [`wallet_fund_tx`] and completed with the
/// example, a transaction funded via [`wallet_fund_tx`] and completed with the
/// caller's op proofs.
///
/// # Arguments
@@ -1683,12 +1684,7 @@ pub unsafe extern "C" fn submit_signed_transaction(
let transaction_hash = preverified_tx.hash().as_signing_bytes();
let runtime_handle = node.get_runtime_handle();
let submit_result = runtime_handle.block_on(async {
mempool::add_tx(
node.get_overwatch_handle(),
preverified_tx,
Transaction::hash,
)
.await
mempool::add_tx(node.get_overwatch_handle(), preverified_tx, Hashable::hash).await
});
if let Err(error) = submit_result {
return FfiSubmitTransactionResult::err(OperationStatus::error(
+2 -1
View File
@@ -17,7 +17,7 @@ use lb_poseidon2::Digest;
use logos_blockchain_core::{
crypto::{Hasher, ZkHasher},
mantle::{
MantleTx, SignedMantleTx, Transaction as _, TxHash,
MantleTx, SignedMantleTx, TxHash,
nom::NomEncode as _,
ops::{
Op, OpProof,
@@ -26,6 +26,7 @@ use logos_blockchain_core::{
inscribe::{Inscription, InscriptionOp},
},
},
traits::Hashable as _,
transactions::{
codec::{decode_signed_mantle_tx, encode_signed_mantle_tx},
states::Unverified,
+2 -1
View File
@@ -1270,9 +1270,10 @@ mod tests {
use crate::{
header::HeaderId,
mantle::{
CryptarchiaParameter, GenesisTime, GenesisTx as _, NoteId,
CryptarchiaParameter, GenesisTime, NoteId,
nom::NomEncode as _,
ops::channel::{ChannelId, MsgId, inscribe::Inscription},
traits::genesis::GenesisTx as _,
transactions::states::Preverified,
},
sdp::{Locator, ProviderId, ServiceType},
+20 -14
View File
@@ -12,7 +12,10 @@ use serde::{Deserialize, Serialize, de::DeserializeOwned};
use crate::{
codec::{DeserializeOp as _, SerializeOp as _},
header::{ContentId, Header, HeaderId},
mantle::{StorageSize, Transaction, TxHash},
mantle::{
TxHash,
traits::{Hashable, StorageSize},
},
proofs::leader_proof::{Groth16LeaderProof, LeaderProof as _},
utils::merkle,
};
@@ -65,7 +68,7 @@ pub struct Block<Tx> {
impl<'de, Tx> Deserialize<'de> for Block<Tx>
where
Tx: Clone + Eq + Deserialize<'de> + Transaction<Hash = TxHash> + StorageSize,
Tx: Clone + Eq + Deserialize<'de> + Hashable<Hash = TxHash> + StorageSize,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -123,7 +126,7 @@ impl<Tx> Block<Tx> {
signing_key: &Ed25519Key,
) -> Result<Self, Error>
where
Tx: Transaction<Hash = TxHash> + StorageSize,
Tx: Hashable<Hash = TxHash> + StorageSize,
{
// 1. Non-genesis blocks only
if slot == Slot::genesis() {
@@ -162,7 +165,7 @@ impl<Tx> Block<Tx> {
signature: Ed25519Signature,
) -> Result<Self, Error>
where
Tx: Transaction<Hash = TxHash> + StorageSize,
Tx: Hashable<Hash = TxHash> + StorageSize,
{
let block = Self {
header,
@@ -176,7 +179,7 @@ impl<Tx> Block<Tx> {
fn into_verified(self) -> Result<Self, Error>
where
Tx: Transaction<Hash = TxHash> + StorageSize,
Tx: Hashable<Hash = TxHash> + StorageSize,
{
// 1. Non-genesis blocks only
if self.header.slot() == Slot::genesis() {
@@ -205,7 +208,7 @@ impl<Tx> Block<Tx> {
fn validate_total_transactions_size(&self) -> Result<usize, Error>
where
Tx: Transaction<Hash = TxHash> + StorageSize,
Tx: Hashable<Hash = TxHash> + StorageSize,
{
let mut total = 0usize;
@@ -230,7 +233,7 @@ impl<Tx> Block<Tx> {
fn calculate_content_id(transactions: &[Tx]) -> ContentId
where
Tx: Transaction<Hash = TxHash>,
Tx: Hashable<Hash = TxHash>,
{
let root_hash = merkle::calculate_block_root(transactions);
ContentId::from(root_hash)
@@ -263,10 +266,10 @@ impl<Tx> Block<Tx> {
pub fn to_proposal(self) -> Proposal
where
Tx: Transaction<Hash = TxHash>,
Tx: Hashable<Hash = TxHash>,
{
let mempool_transactions: Vec<TxHash> =
self.transactions.iter().map(Transaction::hash).collect();
self.transactions.iter().map(Hashable::hash).collect();
let references = References {
mempool_transactions,
};
@@ -279,7 +282,7 @@ impl<Tx> Block<Tx> {
}
}
impl<Tx: Clone + Eq + Serialize + DeserializeOwned + Transaction<Hash = TxHash> + StorageSize>
impl<Tx: Clone + Eq + Serialize + DeserializeOwned + Hashable<Hash = TxHash> + StorageSize>
TryFrom<Bytes> for Block<Tx>
{
type Error = crate::codec::Error;
@@ -294,7 +297,9 @@ impl<Tx: Clone + Eq + Serialize + DeserializeOwned + Transaction<Hash = TxHash>
}
}
impl<Tx: Clone + Eq + Serialize + DeserializeOwned> TryFrom<Block<Tx>> for Bytes {
impl<Tx: Clone + Eq + Serialize + DeserializeOwned + Hashable<Hash = TxHash>> TryFrom<Block<Tx>>
for Bytes
{
type Error = crate::codec::Error;
fn try_from(block: Block<Tx>) -> Result<Self, Self::Error> {
@@ -316,9 +321,10 @@ mod tests {
use crate::{
crypto::ZkHasher,
mantle::{
MantleTx, TransactionHasher,
MantleTx,
ledger::{Note, Utxo},
ops::leader_claim::VoucherCm,
traits::hashable,
transactions::Ops,
},
proofs::leader_proof::{LeaderPrivate, LeaderPublic},
@@ -471,10 +477,10 @@ mod tests {
#[derive(Clone, Copy, Debug)]
struct TestMantleTx<const SIZE: usize>;
impl<const SIZE: usize> Transaction for TestMantleTx<SIZE> {
impl<const SIZE: usize> Hashable for TestMantleTx<SIZE> {
//noinspection RsTypeCheck: The type is correct, but the linter is confused by
// the closure.
const HASHER: TransactionHasher<Self> = |_tx| TxHash::from([0u8; 32]);
const HASHER: hashable::Hasher<Self> = |_tx| TxHash::from([0u8; 32]);
type Hash = TxHash;
fn as_signing(&self) -> Vec<u8> {
+2 -1
View File
@@ -319,7 +319,7 @@ mod block_root_test_vectors {
use super::*;
use crate::{
mantle::{
MantleTx, Note, Op, Transaction as _,
MantleTx, Note, Op,
channel::{SlotTimeframe, SlotTimeout},
ledger::{Inputs, NoteId, Outputs},
ops::{
@@ -334,6 +334,7 @@ mod block_root_test_vectors {
leader_claim::{LeaderClaimOp, VoucherCm},
transfer::TransferOp,
},
traits::Hashable as _,
transactions::Ops,
},
sdp::{
+3
View File
@@ -115,11 +115,14 @@ pub trait GasCalculator {
&self,
context: &Self::Context,
) -> Result<GasCost, GasOverflow>;
fn storage_gas_cost(&self, context: &Self::Context) -> Result<GasCost, GasOverflow>;
fn execution_gas_consumption<Constants: GasConstants>(
&self,
context: &Self::Context,
) -> Result<Gas, GasOverflow>;
fn storage_gas_consumption(&self, context: &Self::Context) -> Result<Gas, GasOverflow>;
}
+6 -3
View File
@@ -8,7 +8,10 @@ use serde::{Serialize, de::DeserializeOwned};
use crate::{
codec::SerializeOp as _,
mantle::{StorageSize, Transaction, TransactionHasher, TxHash},
mantle::{
TxHash,
traits::{Hashable, Hasher, StorageSize},
},
};
#[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
@@ -38,10 +41,10 @@ impl<M: Serialize + DeserializeOwned + Clone> MockTransaction<M> {
}
}
impl<M: Serialize + DeserializeOwned + Clone> Transaction for MockTransaction<M> {
impl<M: Serialize + DeserializeOwned + Clone> Hashable for MockTransaction<M> {
//noinspection RsTypeCheck: The type is correct, but the linter is confused by
// the closure.
const HASHER: TransactionHasher<Self> = Self::id;
const HASHER: Hasher<Self> = Self::id;
type Hash = MockTxId;
fn as_signing(&self) -> Vec<u8> {
+1 -164
View File
@@ -5,177 +5,14 @@ pub mod ledger;
pub mod mock;
pub mod nom;
pub mod ops;
pub mod traits;
pub mod transactions;
use std::hash::Hash;
pub use gas::{GasCalculator, GasConstants};
pub use ledger::{Note, NoteId, Utxo, Value};
pub use ops::{Op, OpProof};
use ops::{channel::inscribe::InscriptionOp, sdp::SDPDeclareOp};
use thiserror::Error;
pub use transactions::{CryptarchiaParameter, GenesisTime};
pub use crate::mantle::transactions::{MantleTx, SignedMantleTx, TxHash, VerificationError};
use crate::mantle::{
gas::{Gas, GasCost, GasOverflow},
ops::transfer::TransferOp,
transactions::tx::VerifiedOps,
};
pub const MAX_MANTLE_TXS: usize = 1024;
pub type TransactionHasher<T> = fn(&T) -> <T as Transaction>::Hash;
pub trait StorageSize {
fn storage_size(&self) -> usize;
}
pub trait Transaction {
const HASHER: TransactionHasher<Self>;
type Hash: Hash + Eq + Clone;
fn hash(&self) -> Self::Hash {
Self::HASHER(self)
}
/// Returns the bytes' that are used to form a signature of a transaction.
///
/// The resulting bytes' are then used by the `HASHER`
/// to produce the transaction's unique hash, which is what is typically
/// signed by the transaction originator.
fn as_signing(&self) -> Vec<u8>;
}
// TODO: Purge out gas fns
pub trait AuthenticatedMantleTx: Transaction<Hash = TxHash> + GasCalculator + StorageSize {
type Context;
/// Returns the underlying `MantleTx` that this transaction represents.
fn mantle_tx(&self) -> &MantleTx;
/// Returns an iterator over the operations and their corresponding proofs
/// in this transaction.
fn ops_with_proof(&self) -> impl Iterator<Item = (&Op, &OpProof)>;
// Gas Cost functions with context already handled
fn total_gas_cost<Constants: GasConstants>(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<GasCost, GasOverflow>;
fn storage_gas_cost(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<GasCost, GasOverflow>;
fn execution_gas_consumption<Constants: GasConstants>(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<Gas, GasOverflow>;
fn storage_gas_consumption(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<Gas, GasOverflow>;
}
pub trait PreverifiedMantleTx: AuthenticatedMantleTx {
/// Returns the cursor to the verified operations in this transaction.
fn verified_ops(&self) -> VerifiedOps<'_>;
}
/// A genesis transaction as specified in
// https://www.notion.so/nomos-tech/v1-1-Bedrock-Genesis-Block-32e261aa09df80689540ec445172b00d
pub trait GenesisTx: Transaction<Hash = TxHash> {
fn genesis_transfer(&self) -> &TransferOp;
fn genesis_inscription(&self) -> &InscriptionOp;
fn cryptarchia_parameter(&self) -> CryptarchiaParameter;
fn sdp_declarations(&self) -> impl Iterator<Item = (&SDPDeclareOp, &OpProof)>;
fn mantle_tx(&self) -> &MantleTx;
}
impl<T: Transaction> Transaction for &T {
//noinspection RsTypeCheck: The type is correct, but the linter is confused by
// the closure.
const HASHER: TransactionHasher<Self> = |tx| T::HASHER(tx);
type Hash = T::Hash;
fn as_signing(&self) -> Vec<u8> {
T::as_signing(self)
}
}
impl<T: StorageSize> StorageSize for &T {
fn storage_size(&self) -> usize {
T::storage_size(self)
}
}
impl<T: AuthenticatedMantleTx> AuthenticatedMantleTx for &T {
type Context = <T as AuthenticatedMantleTx>::Context;
fn mantle_tx(&self) -> &MantleTx {
T::mantle_tx(self)
}
fn ops_with_proof(&self) -> impl Iterator<Item = (&Op, &OpProof)> {
T::ops_with_proof(self)
}
fn total_gas_cost<Constants: GasConstants>(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<GasCost, GasOverflow> {
<T as AuthenticatedMantleTx>::total_gas_cost::<Constants>(self, context)
}
fn storage_gas_cost(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<GasCost, GasOverflow> {
<T as AuthenticatedMantleTx>::storage_gas_cost(self, context)
}
fn execution_gas_consumption<Constants: GasConstants>(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<Gas, GasOverflow> {
<T as AuthenticatedMantleTx>::execution_gas_consumption::<Constants>(self, context)
}
fn storage_gas_consumption(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<Gas, GasOverflow> {
<T as AuthenticatedMantleTx>::storage_gas_consumption(self, context)
}
}
impl<T: PreverifiedMantleTx> PreverifiedMantleTx for &T {
fn verified_ops(&self) -> VerifiedOps<'_> {
T::verified_ops(self)
}
}
impl<T: GenesisTx> GenesisTx for &T {
fn genesis_transfer(&self) -> &TransferOp {
T::genesis_transfer(self)
}
fn genesis_inscription(&self) -> &InscriptionOp {
T::genesis_inscription(self)
}
fn cryptarchia_parameter(&self) -> CryptarchiaParameter {
T::cryptarchia_parameter(self)
}
fn sdp_declarations(&self) -> impl Iterator<Item = (&SDPDeclareOp, &OpProof)> {
T::sdp_declarations(self)
}
fn mantle_tx(&self) -> &MantleTx {
T::mantle_tx(self)
}
}
#[derive(Debug, Error)]
pub enum Error {
#[error("Invalid witness")]
InvalidWitness,
}
+2 -1
View File
@@ -304,10 +304,11 @@ mod mantle_test_vectors {
use super::*;
use crate::{
mantle::{
MantleTx, Note, Transaction as _,
MantleTx, Note,
channel::{SlotTimeframe, SlotTimeout},
ledger::{Inputs, NoteId, Outputs},
ops::channel::{ChannelId, MsgId, config::Keys, deposit::Metadata},
traits::Hashable as _,
transactions::Ops,
},
sdp::{
+37
View File
@@ -0,0 +1,37 @@
use crate::mantle::{
CryptarchiaParameter, MantleTx, OpProof, TxHash,
ops::{channel::inscribe::InscriptionOp, sdp::SDPDeclareOp, transfer::TransferOp},
traits::Hashable,
};
/// A genesis transaction as specified in the
/// [Spec](https://www.notion.so/nomos-tech/v1-1-Bedrock-Genesis-Block-32e261aa09df80689540ec445172b00d).
pub trait GenesisTx: Hashable<Hash = TxHash> {
fn genesis_transfer(&self) -> &TransferOp;
fn genesis_inscription(&self) -> &InscriptionOp;
fn cryptarchia_parameter(&self) -> CryptarchiaParameter;
fn sdp_declarations(&self) -> impl Iterator<Item = (&SDPDeclareOp, &OpProof)>;
fn mantle_tx(&self) -> &MantleTx;
}
impl<T: GenesisTx> GenesisTx for &T {
fn genesis_transfer(&self) -> &TransferOp {
T::genesis_transfer(self)
}
fn genesis_inscription(&self) -> &InscriptionOp {
T::genesis_inscription(self)
}
fn cryptarchia_parameter(&self) -> CryptarchiaParameter {
T::cryptarchia_parameter(self)
}
fn sdp_declarations(&self) -> impl Iterator<Item = (&SDPDeclareOp, &OpProof)> {
T::sdp_declarations(self)
}
fn mantle_tx(&self) -> &MantleTx {
T::mantle_tx(self)
}
}
+30
View File
@@ -0,0 +1,30 @@
use std::hash::Hash;
pub type Hasher<T> = fn(&T) -> <T as Hashable>::Hash;
pub trait Hashable {
const HASHER: Hasher<Self>;
type Hash: Hash + Eq + Clone;
fn hash(&self) -> Self::Hash {
Self::HASHER(self)
}
/// Returns the bytes that are used to form a signature of a transaction.
///
/// The resulting bytes are then used by the `HASHER` to produce the
/// transaction's unique hash, which is what is typically signed by the
/// transaction originator.
fn as_signing(&self) -> Vec<u8>;
}
impl<T: Hashable> Hashable for &T {
//noinspection RsTypeCheck: The type is correct, but the linter is confused by
// the closure.
const HASHER: Hasher<Self> = |tx| T::HASHER(tx);
type Hash = T::Hash;
fn as_signing(&self) -> Vec<u8> {
T::as_signing(self)
}
}
+25
View File
@@ -0,0 +1,25 @@
use crate::mantle::{
GasCalculator, MantleTx, Op, OpProof, TxHash,
traits::{Hashable, StorageSize},
};
pub type OpWithProof<'a> = (&'a Op, &'a OpProof);
pub trait MantleTxWithProofs: Hashable<Hash = TxHash> + GasCalculator + StorageSize {
/// Returns the underlying `MantleTx` that this transaction represents.
fn mantle_tx(&self) -> &MantleTx;
/// Returns an iterator over the operations and their corresponding proofs
/// in this transaction.
fn ops_with_proof(&self) -> impl Iterator<Item = OpWithProof<'_>>;
}
impl<T: MantleTxWithProofs> MantleTxWithProofs for &T {
fn mantle_tx(&self) -> &MantleTx {
T::mantle_tx(self)
}
fn ops_with_proof(&self) -> impl Iterator<Item = OpWithProof<'_>> {
T::ops_with_proof(self)
}
}
+11
View File
@@ -0,0 +1,11 @@
pub mod genesis;
pub mod hashable;
pub mod mantle_tx;
pub mod preverified_tx;
pub mod storage;
pub use genesis::GenesisTx;
pub use hashable::{Hashable, Hasher};
pub use mantle_tx::MantleTxWithProofs;
pub use preverified_tx::PreverifiedMantleTx;
pub use storage::StorageSize;
+12
View File
@@ -0,0 +1,12 @@
use crate::mantle::{traits::mantle_tx::MantleTxWithProofs, transactions::tx::VerifiedOps};
pub trait PreverifiedMantleTx: MantleTxWithProofs {
/// Returns the cursor to the verified operations in this transaction.
fn verified_ops(&self) -> VerifiedOps<'_>;
}
impl<T: PreverifiedMantleTx> PreverifiedMantleTx for &T {
fn verified_ops(&self) -> VerifiedOps<'_> {
T::verified_ops(self)
}
}
+9
View File
@@ -0,0 +1,9 @@
pub trait StorageSize {
fn storage_size(&self) -> usize;
}
impl<T: StorageSize> StorageSize for &T {
fn storage_size(&self) -> usize {
T::storage_size(self)
}
}
+2 -1
View File
@@ -103,7 +103,7 @@ mod tests {
use super::*;
use crate::{
mantle::{
Note, NoteId, OpProof, Transaction as _, Utxo,
Note, NoteId, OpProof, Utxo,
ledger::{BoundedInputs, BoundedOutputs, Inputs, Outputs},
ops::{
channel::{
@@ -116,6 +116,7 @@ mod tests {
sdp::{SDPActiveOp, SDPDeclareOp, SDPWithdrawOp},
transfer::TransferOp,
},
traits::Hashable as _,
transactions::{GasPrices, Ops, tx::OpsProofs},
},
proofs::{
+6 -6
View File
@@ -14,7 +14,7 @@ use super::{SignedMantleTx, TxHash};
use crate::{
crypto::{Digest as _, Hasher},
mantle::{
MantleTx, OpProof, Transaction, TransactionHasher,
MantleTx, OpProof,
gas::{Gas, GasCalculator, GasConstants, GasCost, GasOverflow, GasPrice},
nom::{NomDecode, NomEncode},
ops::{
@@ -24,6 +24,7 @@ use crate::{
sdp::SDPDeclareOp,
transfer::TransferOp,
},
traits::{GenesisTx as GenesisTxTrait, Hashable, hashable},
transactions::states::Preverified,
},
};
@@ -159,11 +160,12 @@ fn valid_cryptarchia_inscription(
)
}
impl Transaction for GenesisTx {
impl Hashable for GenesisTx {
//noinspection RsTypeCheck: The type is correct, but the linter is confused by
// the closure.
const HASHER: TransactionHasher<Self> = |tx| TxHash(Hasher::digest(tx.as_signing()).into());
const HASHER: hashable::Hasher<Self> = |tx| TxHash(Hasher::digest(tx.as_signing()).into());
type Hash = TxHash;
fn as_signing(&self) -> Vec<u8> {
self.tx.as_signing()
}
@@ -199,7 +201,7 @@ impl GasCalculator for GenesisTx {
}
}
impl crate::mantle::GenesisTx for GenesisTx {
impl GenesisTxTrait for GenesisTx {
fn genesis_transfer(&self) -> &TransferOp {
// Safe to unwrap because we validated this in from_tx
match &self.mantle_tx().ops()[0] {
@@ -776,8 +778,6 @@ mod tests {
#[test]
fn test_genesis_tx_cryptarchia_parameter() {
use crate::mantle::GenesisTx as _;
let param = cryptarchia_param();
let tx = create_trusted_tx(
vec![Op::ChannelInscribe(inscription_op(
+12 -39
View File
@@ -17,7 +17,6 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::{
crypto::{Digest as _, Hash, Hasher},
mantle::{
AuthenticatedMantleTx, PreverifiedMantleTx, StorageSize, Transaction, TransactionHasher,
Value,
channel::Channels,
gas::{Gas, GasCalculator, GasConstants, GasCost, GasOverflow, GasPrice},
@@ -37,6 +36,10 @@ use crate::{
},
transfer::{TransferOp, TransferValidationContext},
},
traits::{
Hashable, MantleTxWithProofs, PreverifiedMantleTx, StorageSize, hashable,
mantle_tx::OpWithProof,
},
transactions::{
MAX_OPS_PER_TX, Ops,
codec::{
@@ -326,12 +329,12 @@ impl MantleTx {
}
}
static MANTLE_TXHASH_V1_BYTES: LazyLock<Vec<u8>> = LazyLock::new(|| b"MANTLE_TXHASH_V1".to_vec());
static MANTLE_TX_HASH_V1_BYTES: LazyLock<Vec<u8>> = LazyLock::new(|| b"MANTLE_TXHASH_V1".to_vec());
impl Transaction for MantleTx {
impl Hashable for MantleTx {
//noinspection RsTypeCheck: The type is correct, but the linter is confused by
// the closure.
const HASHER: TransactionHasher<Self> = |tx| {
const HASHER: hashable::Hasher<Self> = |tx| {
let bytes: [u8; 32] = Hasher::digest(tx.as_signing()).into();
TxHash::from(bytes)
};
@@ -340,7 +343,7 @@ impl Transaction for MantleTx {
fn as_signing(&self) -> Vec<u8> {
// constant and structure as defined in the Mantle specification:
// https://www.notion.so/nomos-tech/v1-3-Mantle-Specification-31e261aa09df818f9327ee87e5a6d433#31e261aa09df80aea7cff4eb98d61b6e
let mut buffer = MANTLE_TXHASH_V1_BYTES.to_vec();
let mut buffer = MANTLE_TX_HASH_V1_BYTES.to_vec();
buffer.extend(self.encode());
buffer
}
@@ -926,10 +929,10 @@ fn verify_channel_multi_sig(
Ok(())
}
impl<State: VerificationState> Transaction for SignedMantleTx<State> {
impl<State: VerificationState> Hashable for SignedMantleTx<State> {
//noinspection RsTypeCheck: The type is correct, but the linter is confused by
// the closure.
const HASHER: TransactionHasher<Self> = |tx| {
const HASHER: hashable::Hasher<Self> = |tx| {
let bytes: [u8; 32] = Hasher::digest(tx.as_signing()).into();
TxHash::from(bytes)
};
@@ -940,44 +943,14 @@ impl<State: VerificationState> Transaction for SignedMantleTx<State> {
}
}
impl<State: VerificationState> AuthenticatedMantleTx for SignedMantleTx<State> {
type Context = GasPrices;
impl<State: VerificationState> MantleTxWithProofs for SignedMantleTx<State> {
fn mantle_tx(&self) -> &MantleTx {
&self.mantle_tx
}
fn ops_with_proof(&self) -> impl Iterator<Item = (&Op, &OpProof)> {
fn ops_with_proof(&self) -> impl Iterator<Item = OpWithProof<'_>> {
self.ops_with_proof()
}
fn total_gas_cost<Constants: GasConstants>(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<GasCost, GasOverflow> {
GasCalculator::total_gas_cost::<Constants>(&self, &context)
}
fn storage_gas_cost(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<GasCost, GasOverflow> {
GasCalculator::storage_gas_cost(&self, &context)
}
fn execution_gas_consumption<Constants: GasConstants>(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<Gas, GasOverflow> {
GasCalculator::execution_gas_consumption::<Constants>(&self, &context)
}
fn storage_gas_consumption(
&self,
context: <Self as AuthenticatedMantleTx>::Context,
) -> Result<Gas, GasOverflow> {
GasCalculator::storage_gas_consumption(&self, &context)
}
}
impl PreverifiedMantleTx for SignedMantleTx<Preverified> {
+4 -4
View File
@@ -1,6 +1,6 @@
use crate::{
crypto::{Digest as _, Hash, Hasher},
mantle::{Transaction, TxHash},
mantle::{TxHash, traits::Hashable},
};
pub fn node(left: impl AsRef<[u8]>, right: impl AsRef<[u8]>) -> [u8; 32] {
@@ -11,12 +11,12 @@ pub fn node(left: impl AsRef<[u8]>, right: impl AsRef<[u8]>) -> [u8; 32] {
}
// Calculates a 32-byte Merkle root of transactions
pub fn calculate_block_root<T: Transaction<Hash = TxHash>>(transactions: &[T]) -> Hash {
let mut leaves: Vec<_> = transactions.iter().map(Transaction::hash).collect();
pub fn calculate_block_root<T: Hashable<Hash = TxHash>>(transactions: &[T]) -> Hash {
let mut leaves: Vec<_> = transactions.iter().map(Hashable::hash).collect();
let target_size = leaves.len().max(1).next_power_of_two();
let zero_leaf: <T as Transaction>::Hash = [0u8; 32].into();
let zero_leaf: <T as Hashable>::Hash = [0u8; 32].into();
leaves.resize(target_size, zero_leaf);
while leaves.len() > 1 {
@@ -5,8 +5,9 @@ use lb_common_http_client::CommonHttpClient;
use lb_core::{
header::HeaderId,
mantle::{
Op, SignedMantleTx, Transaction as _, TxHash,
Op, SignedMantleTx, TxHash,
ops::channel::{ChannelId, inscribe::InscriptionOp},
traits::Hashable as _,
transactions::states::Unverified,
},
};
@@ -4,7 +4,7 @@ use lb_common_http_client::{ChainServiceInfo, CommonHttpClient};
use lb_core::{
header::HeaderId,
mantle::{
MantleTx, SignedMantleTx, Transaction as _,
MantleTx, SignedMantleTx,
ops::{
Op, OpProof,
channel::{
@@ -12,6 +12,7 @@ use lb_core::{
inscribe::{Inscription, InscriptionOp},
},
},
traits::Hashable as _,
transactions::states::{Unverified, VerificationState},
},
};
@@ -2,12 +2,13 @@ use std::path::PathBuf;
use lb_core::{
mantle::{
Op, OpProof, SignedMantleTx, Transaction as _,
Op, OpProof, SignedMantleTx,
nom::NomEncode as _,
ops::channel::{
ChannelId, ChannelKeyIndex,
config::{ChannelConfigOp, Keys},
},
traits::Hashable as _,
transactions::codec::encode_signed_mantle_tx,
},
proofs::channel_multi_sig_proof::{ChannelMultiSigProof, IndexedSignature},
@@ -1,5 +1,5 @@
use lb_core::mantle::{
Op, OpProof, SignedMantleTx, Transaction as _, ops::channel::inscribe::Inscription,
Op, OpProof, SignedMantleTx, ops::channel::inscribe::Inscription, traits::Hashable as _,
};
use lb_key_management_system_service::keys::ZkKey;
@@ -2,8 +2,9 @@ use std::path::PathBuf;
use lb_core::{
mantle::{
Op, OpProof, SignedMantleTx, Transaction as _,
Op, OpProof, SignedMantleTx,
ops::channel::{ChannelId, ChannelKeyIndex},
traits::Hashable as _,
transactions::codec::encode_signed_mantle_tx,
},
proofs::channel_multi_sig_proof::{ChannelMultiSigProof, IndexedSignature},
@@ -7,7 +7,7 @@ mod tests {
};
use lb_core::mantle::{
MantleTx, Note, NoteId, Op, SignedMantleTx, Transaction as _, Utxo, Value,
MantleTx, Note, NoteId, Op, SignedMantleTx, Utxo, Value,
ledger::Inputs,
nom::NomEncode as _,
ops::channel::{
@@ -15,6 +15,7 @@ mod tests {
inscribe::{Inscription, InscriptionOp},
withdraw::ChannelWithdrawOp,
},
traits::Hashable as _,
transactions::{Ops, codec::encode_signed_mantle_tx, tx::OpsProofs},
};
use lb_groth16::{Fr, fr_to_bytes};
+9 -11
View File
@@ -8,10 +8,11 @@ use lb_core::{
crypto::{ZkDigest, ZkHasher},
events::TxEvent,
mantle::{
GenesisTx, NoteId, Utxo, Value,
NoteId, Utxo, Value,
gas::{Gas, GasConstants, GasCost, GasPrice},
ledger::Operation as _,
ops::transfer::TransferOp,
traits::GenesisTx,
transactions::{GENESIS_EXECUTION_GAS_PRICE, GENESIS_STORAGE_GAS_PRICE},
},
proofs::leader_proof::{self, LeaderPublic},
@@ -726,12 +727,13 @@ pub mod tests {
use lb_core::{
crypto::{Digest as _, Hasher},
mantle::{
AuthenticatedMantleTx, MantleTx, Note, Op,
GasCalculator as _, MantleTx, Note, Op,
OpProof::ZkSig,
SignedMantleTx, Transaction as _,
SignedMantleTx,
gas::MainnetGasConstants,
ledger::{Inputs, Outputs},
ops::{leader_claim::VoucherCm, sdp::SDPDeclareOp},
traits::Hashable as _,
transactions::{
GasPrices,
states::{Preverified, Unverified},
@@ -1592,8 +1594,7 @@ pub mod tests {
vec![output_note],
);
let _fees =
AuthenticatedMantleTx::total_gas_cost::<MainnetGasConstants>(&tx, GasPrices::new(0, 0));
let _fees = tx.total_gas_cost::<MainnetGasConstants>(&GasPrices::new(0, 0));
let result = ledger_state.try_apply_transfer::<(), MainnetGasConstants>(&transfer_op);
assert!(result.is_err());
@@ -1618,8 +1619,7 @@ pub mod tests {
let (tx, transfer_op, _transfer_sig) =
create_tx_with_transfer(&[(&note_sk, &input_utxo)], vec![output_note1, output_note2]);
let _fees =
AuthenticatedMantleTx::total_gas_cost::<MainnetGasConstants>(&tx, GasPrices::new(0, 0));
let _fees = tx.total_gas_cost::<MainnetGasConstants>(&GasPrices::new(0, 0));
let (new_state, balance, events) = ledger_state
.try_apply_transfer::<(), MainnetGasConstants>(&transfer_op)
.unwrap();
@@ -1651,8 +1651,7 @@ pub mod tests {
vec![],
);
let _fees =
AuthenticatedMantleTx::total_gas_cost::<MainnetGasConstants>(&tx, GasPrices::new(0, 0));
let _fees = tx.total_gas_cost::<MainnetGasConstants>(&GasPrices::new(0, 0));
let (final_state, final_balance, events) = new_state
.try_apply_transfer::<(), MainnetGasConstants>(&transfer_op)
.unwrap();
@@ -1760,8 +1759,7 @@ pub mod tests {
let (tx, transfer_op, _transfer_sig) =
create_tx_with_transfer(&[(&input_sk, &input_utxo)], vec![]);
let _fees =
AuthenticatedMantleTx::total_gas_cost::<MainnetGasConstants>(&tx, GasPrices::new(0, 0));
let _fees = tx.total_gas_cost::<MainnetGasConstants>(&GasPrices::new(0, 0));
let result = ledger_state.try_apply_transfer::<(), MainnetGasConstants>(&transfer_op);
assert!(result.is_ok());
+24 -33
View File
@@ -15,8 +15,7 @@ use lb_core::{
block::BlockNumber,
events::{Events, HeaderEvent, TxEvent},
mantle::{
AuthenticatedMantleTx, GenesisTx, NoteId, Op, PreverifiedMantleTx, TxHash, Utxo, Value,
VerificationError,
NoteId, Op, TxHash, Utxo, Value, VerificationError,
gas::{Gas, GasConstants, GasCost, GasOverflow},
ledger::Operation as _,
ops::{
@@ -26,6 +25,7 @@ use lb_core::{
},
leader_claim::LeaderClaimExecutionContext,
},
traits::{GenesisTx, MantleTxWithProofs, PreverifiedMantleTx},
transactions::{GasPrices, MantleTxContext, MantleTxGasContext},
},
proofs::leader_proof,
@@ -146,7 +146,7 @@ where
txs: impl Iterator<Item = &'tx Tx>,
) -> Result<(Id, LedgerState, Events), LedgerError<Id>>
where
Tx: PreverifiedMantleTx + 'tx + AuthenticatedMantleTx<Context = GasPrices>,
Tx: PreverifiedMantleTx<Context = GasPrices> + 'tx,
LeaderProof: leader_proof::LeaderProof,
Constants: GasConstants,
{
@@ -216,7 +216,7 @@ impl LedgerState {
config: &Config,
) -> Result<(Self, Events), LedgerError<Id>>
where
Tx: PreverifiedMantleTx + 'tx + AuthenticatedMantleTx<Context = GasPrices>,
Tx: PreverifiedMantleTx<Context = GasPrices> + 'tx,
LeaderProof: leader_proof::LeaderProof,
Constants: GasConstants,
{
@@ -364,7 +364,7 @@ impl LedgerState {
txs: impl Iterator<Item = &'tx Tx>,
) -> Result<(Self, Vec<TxEvent>), LedgerError<Id>>
where
Tx: PreverifiedMantleTx + 'tx + AuthenticatedMantleTx<Context = GasPrices>,
Tx: PreverifiedMantleTx<Context = GasPrices> + 'tx,
{
let mut total_block_execution_gas: Gas = 0.into();
let mut total_fee_burned: GasCost = 0.into();
@@ -382,8 +382,7 @@ impl LedgerState {
storage_gas_price: *self.cryptarchia_ledger.storage_gas_price(),
};
// Check the transaction is balanced
let total_gas_cost =
AuthenticatedMantleTx::total_gas_cost::<Constants>(tx, gas_prices.clone())?;
let total_gas_cost = tx.total_gas_cost::<Constants>(&gas_prices)?;
tracing::debug!(
balance,
total_gas_cost = total_gas_cost.into_inner(),
@@ -400,23 +399,16 @@ impl LedgerState {
// Update the total of fee burned and tipped in the block
let tx_fee_burned = GasCost::calculate(
AuthenticatedMantleTx::execution_gas_consumption::<Constants>(
tx,
gas_prices.clone(),
)?,
tx.execution_gas_consumption::<Constants>(&gas_prices)?,
gas_prices.execution_base_gas_price,
)?
.checked_add(AuthenticatedMantleTx::storage_gas_cost(
tx,
gas_prices.clone(),
)?)?;
.checked_add(tx.storage_gas_cost(&gas_prices)?)?;
let tx_fee_tip = GasCost::from(balance as Value).checked_sub(tx_fee_burned)?;
total_fee_burned = total_fee_burned.checked_add(tx_fee_burned)?;
total_fee_tip = total_fee_tip.checked_add(tx_fee_tip)?;
total_block_execution_gas = total_block_execution_gas.checked_add(
AuthenticatedMantleTx::execution_gas_consumption::<Constants>(tx, gas_prices)?,
)?;
total_block_execution_gas = total_block_execution_gas
.checked_add(tx.execution_gas_consumption::<Constants>(&gas_prices)?)?;
// Check that the block is not exceeding the Gas limit
if total_block_execution_gas > EXECUTION_GAS_LIMIT {
@@ -674,7 +666,7 @@ impl LedgerState {
tx: &'tx Tx,
) -> Result<(Self, Balance, Vec<TxEvent>), LedgerError<Id>>
where
Tx: PreverifiedMantleTx + 'tx + AuthenticatedMantleTx<Context = GasPrices>,
Tx: PreverifiedMantleTx + 'tx + MantleTxWithProofs<Context = GasPrices>,
{
let mut verified_ops = tx.verified_ops();
@@ -709,7 +701,7 @@ mod tests {
use lb_core::{
events::TxEventPayload,
mantle::{
MantleTx, Note, OpProof, SignedMantleTx, Transaction as _,
GasCalculator as _, MantleTx, Note, OpProof, SignedMantleTx,
gas::MainnetGasConstants,
ledger::{Inputs, Outputs, Utxos},
ops::{
@@ -725,6 +717,7 @@ mod tests {
sdp::SDPActiveOp,
transfer::TransferOp,
},
traits::Hashable as _,
transactions::{
Ops,
states::{Preverified, Unverified},
@@ -949,9 +942,11 @@ mod tests {
vec![output_note],
std::slice::from_ref(&sk),
);
let fees =
AuthenticatedMantleTx::total_gas_cost::<MainnetGasConstants>(&tx, GasPrices::default())
.unwrap();
let default_gas_prices = GasPrices::default();
let fees = tx
.total_gas_cost::<MainnetGasConstants>(&default_gas_prices)
.unwrap();
output_note.value = utxo.note.value - fees.into_inner();
let tx = create_tx(vec![utxo.id()], vec![output_note], &[sk])
@@ -1645,11 +1640,9 @@ mod tests {
std::slice::from_ref(&sk),
);
// Pays 2925 fees = 2705 execution base fee + 0 execution tip + 220 storage
let fees = AuthenticatedMantleTx::total_gas_cost::<MainnetGasConstants>(
&tx,
ledger.get_gas_prices(),
)
.unwrap();
let fees = tx
.total_gas_cost::<MainnetGasConstants>(&ledger.get_gas_prices())
.unwrap();
output_note.value = utxo.note.value - fees.into_inner();
let tx = create_tx(vec![utxo.id()], vec![output_note], &[sk])
.preverify()
@@ -1688,11 +1681,9 @@ mod tests {
update_ledger_prices(&mut ledger, 1, 1);
// The tx pays 794 fees = 590 execution base fee + 0 execution tip + 204
// storage
let fees = AuthenticatedMantleTx::total_gas_cost::<MainnetGasConstants>(
&tx,
ledger.get_gas_prices(),
)
.unwrap();
let fees = tx
.total_gas_cost::<MainnetGasConstants>(&ledger.get_gas_prices())
.unwrap();
output_note.value = utxo.note.value - fees.into_inner();
let tx = create_tx(
vec![utxo.id()],
+2 -1
View File
@@ -7,7 +7,7 @@ use lb_core::{
crypto::ZkHasher,
events::TxEvent,
mantle::{
GenesisTx, NoteId, Value,
NoteId, Value,
ledger::Operation as _,
ops::{
channel::{
@@ -18,6 +18,7 @@ use lb_core::{
sdp::{SDPActiveOp, SDPDeclareOp, SDPWithdrawOp},
transfer::TransferError,
},
traits::GenesisTx,
},
sdp::locked_notes::LockedNotes,
};
+1 -1
View File
@@ -95,7 +95,7 @@ pub mod transfer_funds {
use lb_core::{
header::HeaderId,
mantle::{
SignedMantleTx, Transaction as _, Value, transactions::states::VerificationState,
SignedMantleTx, Value, traits::Hashable as _, transactions::states::VerificationState,
},
};
use lb_key_management_system_keys::keys::ZkPublicKey;
+4 -4
View File
@@ -20,7 +20,7 @@ use lb_chain_leader_service::api::ChainLeaderServiceData;
use lb_chain_service::CryptarchiaConsensus;
use lb_core::{
header::HeaderId,
mantle::{SignedMantleTx, Transaction, transactions::states::Preverified},
mantle::{SignedMantleTx, traits::Hashable, transactions::states::Preverified},
};
pub use lb_http_api_common::settings::AxumBackendSettings;
use lb_http_api_common::{metrics::http_metrics_middleware, paths};
@@ -113,7 +113,7 @@ where
MempoolStorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -151,13 +151,13 @@ where
TxMempoolService<
lb_tx_service::network::adapters::libp2p::Libp2pAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
MempoolStorageAdapter,
RuntimeServiceId,
>,
+47 -46
View File
@@ -26,8 +26,9 @@ use lb_core::{
events::Events,
header::HeaderId,
mantle::{
Op, OpProof, SignedMantleTx, Transaction, TxHash,
Op, OpProof, SignedMantleTx, TxHash,
ops::channel::ChannelId,
traits::Hashable,
transactions::{
MantleTxBuilder,
states::{Preverified, Unverified},
@@ -379,7 +380,7 @@ where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -396,13 +397,13 @@ where
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -427,13 +428,13 @@ where
)]
pub async fn mantle_status<StorageAdapter, RuntimeServiceId>(
State(handle): State<OverwatchHandle<RuntimeServiceId>>,
Json(items): Json<Vec<<SignedMantleTx<Preverified> as Transaction>::Hash>>,
Json(items): Json<Vec<<SignedMantleTx<Preverified> as Hashable>::Hash>>,
) -> Response
where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -450,13 +451,13 @@ where
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -698,7 +699,7 @@ where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -715,13 +716,13 @@ where
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -734,14 +735,14 @@ where
Libp2pNetworkBackend,
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
StorageAdapter,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>(&handle, tx, Transaction::hash))
>(&handle, tx, Hashable::hash))
}
#[utoipa::path(
@@ -759,7 +760,7 @@ where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -777,13 +778,13 @@ where
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -804,7 +805,7 @@ where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -822,13 +823,13 @@ where
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -851,7 +852,7 @@ where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -868,13 +869,13 @@ where
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -887,13 +888,13 @@ where
.relay::<TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -956,7 +957,7 @@ where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -974,13 +975,13 @@ where
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -1025,14 +1026,14 @@ where
Libp2pNetworkBackend,
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
StorageAdapter,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>(&handle, signed_tx, Transaction::hash)
>(&handle, signed_tx, Hashable::hash)
.await?;
Ok(ChannelDepositResponseBody { hash: tx_hash })
@@ -1726,7 +1727,7 @@ pub mod wallet {
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -1744,13 +1745,13 @@ pub mod wallet {
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -1787,14 +1788,14 @@ pub mod wallet {
Libp2pNetworkBackend,
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
StorageAdapter,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>(&handle, transaction.clone(), Transaction::hash)
>(&handle, transaction.clone(), Hashable::hash)
.await
{
return (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response();
@@ -1823,7 +1824,7 @@ pub mod wallet {
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -1841,13 +1842,13 @@ pub mod wallet {
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -1883,7 +1884,7 @@ pub mod wallet {
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -1901,13 +1902,13 @@ pub mod wallet {
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -1943,7 +1944,7 @@ pub mod wallet {
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Item = SignedMantleTx<Preverified>,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
> + Send
+ Sync
+ Clone
@@ -1961,13 +1962,13 @@ pub mod wallet {
TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -7,7 +7,7 @@ use serde::Serialize;
#[derive(Serialize)]
#[serde(remote = "MantleTx")]
pub struct ApiTransactionSerializer {
#[serde(getter = "<MantleTx as lb_core::mantle::Transaction>::hash")]
#[serde(getter = "<MantleTx as lb_core::mantle::traits::Hashable>::hash")]
hash: TxHash,
#[serde(getter = "MantleTx::ops")]
ops: Ops,
+1 -1
View File
@@ -1,5 +1,5 @@
use lb_core::mantle::{
SignedMantleTx, Transaction as _, TxHash, transactions::states::Preverified,
SignedMantleTx, TxHash, traits::Hashable as _, transactions::states::Preverified,
};
use lb_services_utils::overwatch::RecoveryData;
use lb_tx_service::{
+1 -1
View File
@@ -1,4 +1,4 @@
use lb_core::mantle::GenesisTx as _;
use lb_core::mantle::traits::GenesisTx as _;
use lb_cryptarchia_engine::{EpochConfig, time::SlotConfig};
use lb_time_service::{
TimeServiceSettings,
@@ -3,7 +3,7 @@ use lb_chain_network_service::network::adapters::libp2p::LibP2pAdapter;
use lb_chain_service::CryptarchiaConsensus;
use lb_core::{
header::HeaderId,
mantle::{SignedMantleTx, Transaction, TxHash, transactions::states::Preverified},
mantle::{SignedMantleTx, TxHash, traits::Hashable, transactions::states::Preverified},
};
use lb_key_management_system_service::backend::preload::PreloadKMSBackend;
use lb_sdp_service::{SdpSettings, state::SdpState};
@@ -19,7 +19,7 @@ pub mod sdp;
pub type TxMempoolService<RuntimeServiceId> = lb_tx_service::TxMempoolService<
lb_tx_service::network::adapters::libp2p::Libp2pAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
@@ -28,13 +28,13 @@ pub type TxMempoolService<RuntimeServiceId> = lb_tx_service::TxMempoolService<
TxHash,
RocksStorageAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
>,
RuntimeServiceId,
>,
RocksStorageAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
>,
RuntimeServiceId,
>;
@@ -44,17 +44,17 @@ pub type TimeService<RuntimeServiceId> =
pub type MempoolAdapter<RuntimeServiceId> = lb_tx_service::network::adapters::libp2p::Libp2pAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>;
pub type MempoolBackend<RuntimeServiceId> = Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RocksStorageAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
>,
RuntimeServiceId,
>;
@@ -110,7 +110,7 @@ pub type SdpMempoolAdapter<RuntimeServiceId> = sdp::mempool::SdpMempoolAdapter<
TxHash,
RocksStorageAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
>,
RuntimeServiceId,
>,
@@ -5,7 +5,7 @@ use std::{
use lb_core::{
header::HeaderId,
mantle::{SignedMantleTx, Transaction as _, TxHash, transactions::states::Preverified},
mantle::{SignedMantleTx, TxHash, traits::Hashable as _, transactions::states::Preverified},
};
use lb_sdp_service::mempool::{MempoolAdapterError, SdpMempoolAdapter as SdpMempoolAdapterTrait};
use lb_storage_service::StorageService;
+1 -1
View File
@@ -17,7 +17,7 @@ use lb_core::mantle::transactions::states::Preverified;
pub use lb_core::{
codec,
header::HeaderId,
mantle::{SignedMantleTx, Transaction, TxHash},
mantle::{SignedMantleTx, TxHash, traits::Hashable},
};
pub use lb_network_service::backends::libp2p::Libp2p as NetworkBackend;
pub use lb_storage_service::backends::{
+24 -78
View File
@@ -13,7 +13,7 @@ use lb_core::{
events::Events,
header::HeaderId,
mantle::{
SignedMantleTx, Transaction, TxHash, channel::ChannelState, ops::channel::ChannelId,
SignedMantleTx, TxHash, channel::ChannelState, ops::channel::ChannelId, traits::Hashable,
transactions::states::Preverified,
},
sdp::{Declaration, DeclarationId},
@@ -61,13 +61,13 @@ pub struct BlockWithChainState<Tx> {
pub type MempoolService<StorageAdapter, RuntimeServiceId> = TxMempoolService<
MempoolNetworkAdapter<
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
RuntimeServiceId,
>,
Mempool<
HeaderId,
SignedMantleTx<Preverified>,
<SignedMantleTx<Preverified> as Transaction>::Hash,
<SignedMantleTx<Preverified> as Hashable>::Hash,
StorageAdapter,
RuntimeServiceId,
>,
@@ -98,7 +98,7 @@ pub async fn mantle_mempool_metrics<StorageAdapter, RuntimeServiceId>(
where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
Item = SignedMantleTx<Preverified>,
> + Clone
+ 'static,
@@ -128,12 +128,12 @@ where
pub async fn mantle_mempool_status<StorageAdapter, RuntimeServiceId>(
handle: &overwatch::overwatch::handle::OverwatchHandle<RuntimeServiceId>,
items: Vec<<SignedMantleTx<Preverified> as Transaction>::Hash>,
items: Vec<<SignedMantleTx<Preverified> as Hashable>::Hash>,
) -> Result<Vec<Status>, super::DynError>
where
StorageAdapter: lb_tx_service::storage::MempoolStorageAdapter<
RuntimeServiceId,
Key = <SignedMantleTx<Preverified> as Transaction>::Hash,
Key = <SignedMantleTx<Preverified> as Hashable>::Hash,
Item = SignedMantleTx<Preverified>,
> + Clone
+ 'static,
@@ -233,14 +233,8 @@ pub async fn get_new_blocks_stream<
super::DynError,
>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -331,14 +325,8 @@ async fn load_blocks_with_chain_state_by_ids<Transaction, StorageBackend, Runtim
blocks_limit: usize,
) -> Result<Vec<BlockWithChainState<Transaction>>, super::DynError>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -411,14 +399,8 @@ async fn fetch_and_load_mutable_blocks<Transaction, StorageBackend, RuntimeServi
descending: bool,
) -> Result<Vec<BlockWithChainState<Transaction>>, super::DynError>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -524,14 +506,8 @@ async fn fetch_and_load_immutable_blocks<Transaction, StorageBackend, RuntimeSer
descending: bool,
) -> Result<Vec<BlockWithChainState<Transaction>>, super::DynError>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -568,14 +544,8 @@ pub async fn get_blocks_in_slot_range_with_snapshot<Transaction, StorageBackend,
chain_info: &CryptarchiaInfo,
) -> Result<Vec<BlockWithChainState<Transaction>>, super::DynError>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -748,14 +718,8 @@ pub async fn get_immutable_blocks<Transaction, StorageBackend, RuntimeServiceId>
to_slot: usize,
) -> Result<Vec<Block<Transaction>>, super::DynError>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -803,14 +767,8 @@ pub async fn get_block<Transaction, StorageBackend, RuntimeServiceId>(
header_id: HeaderId,
) -> Result<Option<Block<Transaction>>, super::DynError>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -847,14 +805,8 @@ pub async fn get_transactions<Transaction, StorageBackend, RuntimeServiceId>(
super::DynError,
>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -889,14 +841,8 @@ pub async fn get_transaction<Transaction, StorageBackend, RuntimeServiceId>(
tx_hash: TxHash,
) -> Result<Option<Transaction>, super::DynError>
where
Transaction: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ lb_core::mantle::Transaction<Hash = TxHash>,
Transaction:
Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
StorageBackend: lb_storage_service::backends::StorageBackend + Send + Sync + 'static,
<StorageBackend as StorageChainApi>::Block:
TryFrom<Block<Transaction>> + TryInto<Block<Transaction>>,
@@ -8,7 +8,10 @@ use futures::{StreamExt as _, TryStreamExt as _};
use lb_core::{
block::Block,
header::HeaderId,
mantle::{StorageSize, Transaction, TxHash},
mantle::{
TxHash,
traits::{Hashable, StorageSize},
},
};
use lb_storage_service::{StorageMsg, StorageService, backends::rocksdb::RocksBackend};
use overwatch::services::{ServiceData, relay::OutboundRelay};
@@ -36,7 +39,7 @@ where
+ DeserializeOwned
+ Clone
+ Eq
+ Transaction<Hash = TxHash>
+ Hashable<Hash = TxHash>
+ StorageSize
+ 'static,
{
+5 -2
View File
@@ -1,7 +1,10 @@
use lb_core::{
block::Block,
header::HeaderId,
mantle::{StorageSize, Transaction, TxHash},
mantle::{
TxHash,
traits::{Hashable, StorageSize},
},
};
use lb_storage_service::{StorageService, backends::rocksdb::RocksBackend};
use overwatch::services::{ServiceData, relay::OutboundRelay};
@@ -22,7 +25,7 @@ pub trait StorageAdapter<RuntimeServiceId> {
+ DeserializeOwned
+ Clone
+ Eq
+ Transaction<Hash = TxHash>
+ Hashable<Hash = TxHash>
+ StorageSize
+ 'static;
+10 -8
View File
@@ -20,8 +20,10 @@ use lb_core::{
block::{Block, BlockTransactions, Error as BlockError, MAX_BLOCK_TRANSACTIONS_SIZE},
header::HeaderId,
mantle::{
AuthenticatedMantleTx, SignedMantleTx, StorageSize, Transaction, TxHash,
gas::MainnetGasConstants, transactions::states::Preverified,
SignedMantleTx, TxHash,
gas::MainnetGasConstants,
traits::{Hashable, MantleTxWithProofs, StorageSize},
transactions::states::Preverified,
},
proofs::leader_proof::{Groth16LeaderProof, LeaderPrivate},
};
@@ -170,7 +172,7 @@ pub struct CryptarchiaLeader<
Mempool::RecoveryState: Serialize + DeserializeOwned,
Mempool::Settings: Clone,
Mempool::Item: Clone + Eq + Debug + 'static,
Mempool::Item: AuthenticatedMantleTx,
Mempool::Item: MantleTxWithProofs,
MempoolNetAdapter:
MempoolNetworkAdapter<RuntimeServiceId, Payload = Mempool::Item, Key = Mempool::Key>,
<MempoolNetAdapter as MempoolNetworkAdapter<RuntimeServiceId>>::Settings: Send + Sync,
@@ -209,7 +211,7 @@ where
Mempool::RecoveryState: Serialize + DeserializeOwned,
Mempool::Storage: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
Mempool::Settings: Clone,
Mempool::Item: AuthenticatedMantleTx + Clone + Eq + Debug,
Mempool::Item: MantleTxWithProofs + Clone + Eq + Debug,
MempoolNetAdapter:
MempoolNetworkAdapter<RuntimeServiceId, Payload = Mempool::Item, Key = Mempool::Key>,
<MempoolNetAdapter as MempoolNetworkAdapter<RuntimeServiceId>>::Settings: Send + Sync,
@@ -266,7 +268,7 @@ where
Mempool::Storage: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
Mempool::RecoveryState: Serialize + DeserializeOwned,
Mempool::Settings: Clone + Send + Sync + 'static,
Mempool::Item: Transaction<Hash = Mempool::Key>
Mempool::Item: Hashable<Hash = Mempool::Key>
+ Debug
+ Clone
+ Eq
@@ -276,7 +278,7 @@ where
+ Sync
+ Unpin
+ 'static,
Mempool::Item: AuthenticatedMantleTx,
Mempool::Item: MantleTxWithProofs,
MempoolNetAdapter: MempoolNetworkAdapter<RuntimeServiceId, Payload = Mempool::Item, Key = Mempool::Key>
+ Send
+ Sync
@@ -551,7 +553,7 @@ where
+ 'static,
Mempool::RecoveryState: Serialize + DeserializeOwned,
Mempool::Settings: Clone + Send + Sync + 'static,
Mempool::Item: AuthenticatedMantleTx<Hash = Mempool::Key>
Mempool::Item: MantleTxWithProofs<Hash = Mempool::Key>
+ Debug
+ Clone
+ Eq
@@ -654,7 +656,7 @@ where
// Transactions that never became applicable are genuinely invalid against
// this block's ledger state and can be evicted from the mempool.
let invalid_tx_hashes: Vec<_> = pending.iter().map(Transaction::hash).collect();
let invalid_tx_hashes: Vec<_> = pending.iter().map(Hashable::hash).collect();
if !invalid_tx_hashes.is_empty()
&& let Err(e) = relays
@@ -3,7 +3,7 @@ use std::pin::Pin;
use futures::Stream;
use lb_core::{
header::HeaderId,
mantle::{Transaction, TxHash},
mantle::{TxHash, traits::Hashable},
};
use lb_tx_service::MempoolMsg;
use overwatch::services::relay::OutboundRelay;
@@ -25,7 +25,7 @@ impl<Tx> MempoolAdapter<Tx> {
#[async_trait::async_trait]
impl<Tx> MempoolAdapterTrait<Tx> for MempoolAdapter<Tx>
where
Tx: Transaction<Hash = TxHash> + Send + Sync + 'static,
Tx: Hashable<Hash = TxHash> + Send + Sync + 'static,
{
async fn get_mempool_view(
&self,
+2 -2
View File
@@ -4,7 +4,7 @@ use std::fmt::Debug;
use lb_chain_service::api::CryptarchiaServiceData;
use lb_core::{
header::HeaderId,
mantle::{AuthenticatedMantleTx, TxHash},
mantle::{TxHash, traits::MantleTxWithProofs},
};
use lb_storage_service::StorageService;
use lb_time_service::{TimeService, TimeServiceMessage, backends::TimeBackend as TimeBackendTrait};
@@ -50,7 +50,7 @@ where
+ Send
+ Sync
+ 'static
+ AuthenticatedMantleTx,
+ MantleTxWithProofs,
Mempool::Settings: Clone,
MempoolNetAdapter: MempoolNetworkAdapter<RuntimeServiceId, Payload = Mempool::Item, Key = Mempool::Key>
+ Send
@@ -12,7 +12,7 @@ use lb_chain_service::{
use lb_core::{
block::Block,
header::HeaderId,
mantle::{AuthenticatedMantleTx, TxHash},
mantle::{TxHash, traits::MantleTxWithProofs},
};
use lb_cryptarchia_sync::GetTipResponse;
use lb_tx_service::backend::RecoverableMempool;
@@ -33,7 +33,7 @@ pub trait IbdBlockProcessor<B> {
pub struct ChainNetworkIbdBlockProcessor<Cryptarchia, Mempool, RuntimeServiceId>
where
Cryptarchia: CryptarchiaServiceData,
Cryptarchia::Tx: AuthenticatedMantleTx + Debug + Clone + Send + Sync,
Cryptarchia::Tx: MantleTxWithProofs + Debug + Clone + Send + Sync,
Mempool:
RecoverableMempool<BlockId = HeaderId, Key = TxHash, Item = Cryptarchia::Tx> + Send + Sync,
RuntimeServiceId: Send + Sync,
@@ -46,7 +46,7 @@ impl<Cryptarchia, Mempool, RuntimeServiceId> IbdBlockProcessor<Block<Cryptarchia
for ChainNetworkIbdBlockProcessor<Cryptarchia, Mempool, RuntimeServiceId>
where
Cryptarchia: CryptarchiaServiceData,
Cryptarchia::Tx: AuthenticatedMantleTx + Debug + Clone + Send + Sync,
Cryptarchia::Tx: MantleTxWithProofs + Debug + Clone + Send + Sync,
Mempool:
RecoverableMempool<BlockId = HeaderId, Key = TxHash, Item = Cryptarchia::Tx> + Send + Sync,
RuntimeServiceId: Send + Sync,
+15 -12
View File
@@ -19,7 +19,10 @@ use lb_chain_service::api::{CryptarchiaServiceApi, CryptarchiaServiceData};
use lb_core::{
block::{Block, BlockTransactions, Proposal},
header::HeaderId,
mantle::{AuthenticatedMantleTx, Transaction, TxHash},
mantle::{
TxHash,
traits::{Hashable, MantleTxWithProofs},
},
};
pub use lb_cryptarchia_engine::{Epoch, Slot};
pub use lb_ledger::EpochState;
@@ -125,7 +128,7 @@ pub struct ChainNetwork<
Mempool::Settings: Clone,
Mempool::Storage: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
Mempool::Item: Clone + Eq + Debug + 'static,
Mempool::Item: AuthenticatedMantleTx,
Mempool::Item: MantleTxWithProofs,
MempoolNetAdapter:
MempoolNetworkAdapter<RuntimeServiceId, Payload = Mempool::Item, Key = Mempool::Key>,
MempoolNetAdapter::Settings: Send + Sync,
@@ -153,7 +156,7 @@ where
Mempool::RecoveryState: Serialize + for<'de> Deserialize<'de>,
Mempool::Settings: Clone,
Mempool::Storage: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
Mempool::Item: AuthenticatedMantleTx + Clone + Eq + Debug,
Mempool::Item: MantleTxWithProofs + Clone + Eq + Debug,
MempoolNetAdapter:
MempoolNetworkAdapter<RuntimeServiceId, Payload = Mempool::Item, Key = Mempool::Key>,
MempoolNetAdapter::Settings: Send + Sync,
@@ -190,8 +193,8 @@ where
Mempool::RecoveryState: Serialize + for<'de> Deserialize<'de>,
Mempool::Settings: Clone + Send + Sync + 'static,
Mempool::Storage: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
Mempool::Item: Transaction<Hash = Mempool::Key>
+ AuthenticatedMantleTx
Mempool::Item: Hashable<Hash = Mempool::Key>
+ MantleTxWithProofs
+ Debug
+ Clone
+ Eq
@@ -507,8 +510,8 @@ where
Mempool::RecoveryState: Serialize + for<'de> Deserialize<'de>,
Mempool::Settings: Clone + Send + Sync + 'static,
Mempool::Storage: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
Mempool::Item: Transaction<Hash = Mempool::Key>
+ AuthenticatedMantleTx
Mempool::Item: Hashable<Hash = Mempool::Key>
+ MantleTxWithProofs
+ Debug
+ Clone
+ Eq
@@ -776,7 +779,7 @@ async fn should_process_block<Cryptarchia, RuntimeServiceId>(
) -> Result<(), DoNotProcessBlock>
where
Cryptarchia: CryptarchiaServiceData,
Cryptarchia::Tx: AuthenticatedMantleTx + Debug + Clone + Send + Sync,
Cryptarchia::Tx: MantleTxWithProofs + Debug + Clone + Send + Sync,
RuntimeServiceId: Send + Sync,
{
if !is_after_lib(cryptarchia, block_id, block_slot).await {
@@ -808,7 +811,7 @@ async fn is_after_lib<Cryptarchia, RuntimeServiceId>(
) -> bool
where
Cryptarchia: CryptarchiaServiceData,
Cryptarchia::Tx: AuthenticatedMantleTx + Debug + Clone + Send + Sync,
Cryptarchia::Tx: MantleTxWithProofs + Debug + Clone + Send + Sync,
RuntimeServiceId: Send + Sync,
{
match cryptarchia.info().await {
@@ -931,7 +934,7 @@ async fn apply_block_and_reconcile_mempool<Cryptarchia, Mempool, RuntimeServiceI
) -> Result<(), Error>
where
Cryptarchia: CryptarchiaServiceData,
Cryptarchia::Tx: AuthenticatedMantleTx + Debug + Clone + Send + Sync,
Cryptarchia::Tx: MantleTxWithProofs + Debug + Clone + Send + Sync,
Mempool:
RecoverableMempool<BlockId = HeaderId, Key = TxHash, Item = Cryptarchia::Tx> + Send + Sync,
RuntimeServiceId: Send + Sync,
@@ -956,7 +959,7 @@ where
.remove_transactions(
&block
.transactions_iter()
.map(Transaction::hash)
.map(Hashable::hash)
.collect::<Vec<_>>(),
)
.await
@@ -990,7 +993,7 @@ async fn reconstruct_block_from_proposal<Item>(
mempool: &MempoolAdapter<Item>,
) -> Result<Block<Item>, Error>
where
Item: AuthenticatedMantleTx<Hash = TxHash> + Clone + Send + Sync + 'static,
Item: MantleTxWithProofs<Hash = TxHash> + Clone + Send + Sync + 'static,
{
let mempool_hashes: Vec<TxHash> = proposal.mempool_transactions().to_vec();
let mempool_response = mempool
@@ -1,6 +1,6 @@
use lb_core::{
header::HeaderId,
mantle::{Transaction, TxHash},
mantle::{TxHash, traits::Hashable},
};
use lb_tx_service::{MempoolMsg, TransactionsByHashesResponse};
use overwatch::services::relay::OutboundRelay;
@@ -23,7 +23,7 @@ impl<Tx> MempoolAdapter<Tx> {
#[async_trait::async_trait]
impl<Tx> MempoolAdapterTrait<Tx> for MempoolAdapter<Tx>
where
Tx: Transaction<Hash = TxHash> + Send + Sync + 'static,
Tx: Hashable<Hash = TxHash> + Send + Sync + 'static,
{
async fn add_transaction(&self, tx: Tx) -> Result<(), overwatch::DynError> {
let (reply_sender, reply_receiver) = oneshot::channel();
@@ -6,7 +6,7 @@ use lb_core::{
block::{Block, Proposal},
codec::DeserializeOp as _,
header::HeaderId,
mantle::AuthenticatedMantleTx,
mantle::traits::MantleTxWithProofs,
};
use lb_cryptarchia_sync::GetTipResponse;
use lb_network_service::{
@@ -25,7 +25,6 @@ use rand::{seq::IteratorRandom as _, thread_rng};
use serde::{Deserialize, Serialize, de::DeserializeOwned};
use tokio::sync::oneshot;
use tokio_stream::{StreamExt as _, wrappers::errors::BroadcastStreamRecvError};
use tracing::debug;
use crate::{
metrics,
@@ -93,14 +92,7 @@ where
additional_blocks: HashSet<HeaderId>,
) -> Result<BlockDownloadStream<Tx>, DynError>
where
Tx: AuthenticatedMantleTx
+ Serialize
+ DeserializeOwned
+ Clone
+ Eq
+ Send
+ Sync
+ 'static,
Tx: MantleTxWithProofs + Serialize + DeserializeOwned + Clone + Eq + Send + Sync + 'static,
{
let mut stream = self
.request_blocks_from_peer(
@@ -175,7 +167,7 @@ where
#[async_trait::async_trait]
impl<Tx, RuntimeServiceId> NetworkAdapter<RuntimeServiceId> for LibP2pAdapter<Tx, RuntimeServiceId>
where
Tx: AuthenticatedMantleTx + Serialize + DeserializeOwned + Clone + Eq + Send + Sync + 'static,
Tx: MantleTxWithProofs + Serialize + DeserializeOwned + Clone + Eq + Send + Sync + 'static,
{
type Backend = Libp2p;
type Settings = LibP2pAdapterSettings;
@@ -289,7 +281,7 @@ where
.choose_multiple(&mut thread_rng(), max_peers);
if sampled.is_empty() {
debug!("tip poll: no connected peers to sample");
tracing::debug!("tip poll: no connected peers to sample");
return Box::new(stream::empty::<GetTipResponse>());
}
let result_stream = FuturesStreamExt::filter_map(
@@ -306,13 +298,15 @@ where
)))
.await
{
debug!("tip poll: failed to send GetTip to peer {peer:?}: {e}");
tracing::debug!("tip poll: failed to send GetTip to peer {peer:?}: {e}");
None
} else {
match receiver.await.ok() {
None => None,
Some(Err(e)) => {
debug!("tip poll: failed to send GetTip to peer {peer:?}: {e}");
tracing::debug!(
"tip poll: failed to send GetTip to peer {peer:?}: {e}"
);
None
}
Some(Ok(tip)) => Some(tip),
@@ -415,7 +409,7 @@ where
)
.await?;
debug!("received a stream of orphan parents from peer: {peer}");
tracing::debug!("received a stream of orphan parents from peer: {peer}");
Ok(stream)
}
+2 -2
View File
@@ -7,7 +7,7 @@ use std::{
use lb_chain_service::api::{CryptarchiaServiceApi, CryptarchiaServiceData};
use lb_core::{
header::HeaderId,
mantle::{AuthenticatedMantleTx, TxHash},
mantle::{TxHash, traits::MantleTxWithProofs},
};
use lb_network_service::{NetworkService, message::BackendNetworkMsg};
use lb_storage_service::StorageService;
@@ -61,7 +61,7 @@ where
+ Send
+ Sync
+ 'static
+ AuthenticatedMantleTx,
+ MantleTxWithProofs,
Mempool::Settings: Clone + Send + Sync,
Mempool::Storage: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
MempoolNetAdapter: MempoolNetworkAdapter<RuntimeServiceId, Payload = Mempool::Item, Key = Mempool::Key>
+5 -4
View File
@@ -26,7 +26,8 @@ use lb_core::{
events::Events,
header::HeaderId,
mantle::{
AuthenticatedMantleTx, GenesisTx as _, PreverifiedMantleTx, gas::MainnetGasConstants,
gas::MainnetGasConstants,
traits::{GenesisTx as _, MantleTxWithProofs, PreverifiedMantleTx},
transactions::GasPrices,
},
sdp::{Declaration, DeclarationId},
@@ -373,7 +374,7 @@ impl Cryptarchia {
current_slot: Slot,
) -> Result<(PrunedBlocks<HeaderId>, ReorgedBlocks<HeaderId>, Events), Error>
where
Tx: PreverifiedMantleTx + 'tx + AuthenticatedMantleTx<Context = GasPrices> + Clone,
Tx: PreverifiedMantleTx + 'tx + MantleTxWithProofs<Context = GasPrices>,
{
let header = block.header();
let id = header.id();
@@ -559,7 +560,7 @@ impl<Tx, Storage, TimeBackend, RuntimeServiceId> ServiceCore<RuntimeServiceId>
for CryptarchiaConsensus<Tx, Storage, TimeBackend, RuntimeServiceId>
where
Tx: PreverifiedMantleTx
+ AuthenticatedMantleTx<Context = GasPrices>
+ MantleTxWithProofs<Context = GasPrices>
+ Debug
+ Clone
+ Eq
@@ -830,7 +831,7 @@ impl<Tx, Storage, TimeBackend, RuntimeServiceId>
CryptarchiaConsensus<Tx, Storage, TimeBackend, RuntimeServiceId>
where
Tx: PreverifiedMantleTx
+ AuthenticatedMantleTx<Context = GasPrices>
+ MantleTxWithProofs<Context = GasPrices>
+ Debug
+ Clone
+ Eq
+1 -6
View File
@@ -2,11 +2,7 @@ use std::fmt::{Debug, Display};
use bytes::Bytes;
use lb_chain_broadcast_service::{BlockBroadcastMsg, BlockBroadcastService};
use lb_core::{
block::Block,
events::Events,
mantle::{AuthenticatedMantleTx, PreverifiedMantleTx},
};
use lb_core::{block::Block, events::Events, mantle::traits::PreverifiedMantleTx};
use lb_storage_service::{
StorageMsg, StorageService, api::chain::StorageChainApi, backends::StorageBackend,
};
@@ -41,7 +37,6 @@ where
impl<Tx, Storage, RuntimeServiceId> CryptarchiaConsensusRelays<Tx, Storage, RuntimeServiceId>
where
Tx: PreverifiedMantleTx
+ AuthenticatedMantleTx
+ Debug
+ Clone
+ Eq
+1 -1
View File
@@ -1,6 +1,6 @@
use std::{collections::HashSet, time::SystemTime};
use lb_core::{header::HeaderId, mantle::GenesisTx as _};
use lb_core::{header::HeaderId, mantle::traits::GenesisTx as _};
use lb_ledger::LedgerState;
use overwatch::{DynError, services::state::ServiceState};
use serde::{Deserialize, Serialize};
@@ -11,7 +11,7 @@ use lb_core::{
codec::{DeserializeOp as _, SerializeOp as _},
events::Events,
header::HeaderId,
mantle::{Transaction, TxHash},
mantle::{TxHash, traits::Hashable},
};
use lb_cryptarchia_engine::Slot;
use lb_storage_service::{
@@ -52,14 +52,7 @@ where
<Storage as StorageChainApi>::Block: TryFrom<Block<Tx>> + TryInto<Block<Tx>>,
<Storage as StorageChainApi>::Tx: From<Bytes> + AsRef<[u8]>,
<Storage as StorageChainApi>::Events: TryFrom<Events> + TryInto<Events>,
Tx: Clone
+ Eq
+ Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static
+ Transaction<Hash = TxHash>,
Tx: Clone + Eq + Serialize + DeserializeOwned + Send + Sync + 'static + Hashable<Hash = TxHash>,
{
type Backend = Storage;
type Block = Block<Tx>;
+4 -4
View File
@@ -15,7 +15,7 @@ use std::{
use futures::StreamExt as _;
use lb_core::{
block::MAX_BLOCK_TRANSACTIONS_SIZE,
mantle::{StorageSize, Transaction},
mantle::traits::{Hashable, StorageSize},
};
use lb_log_targets::mempool;
use lb_network_service::{NetworkService, message::BackendNetworkMsg};
@@ -163,7 +163,7 @@ where
Pool: MemPoolTrait<Storage = StorageAdapter> + RecoverableMempool + Send + Sync,
StorageAdapter: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
<Pool as RecoverableMempool>::RecoveryState: Debug + Send + Sync,
Pool::Item: Transaction<Hash = Pool::Key> + StorageSize + Clone + Send + 'static,
Pool::Item: Hashable<Hash = Pool::Key> + StorageSize + Clone + Send + 'static,
Pool::Settings: Clone + Sync + Send,
NetworkAdapter:
NetworkAdapterTrait<RuntimeServiceId, Payload = Pool::Item, Key = Pool::Key> + Send + Sync,
@@ -264,7 +264,7 @@ impl<Pool, NetworkAdapter, RecoveryBackend, StorageAdapter, RuntimeServiceId>
where
Pool: MemPoolTrait<Storage = StorageAdapter> + RecoverableMempool + Send + Sync,
StorageAdapter: MempoolStorageAdapter<RuntimeServiceId> + Clone + Send + Sync,
Pool::Item: Transaction<Hash = Pool::Key> + StorageSize + Clone + Send + 'static,
Pool::Item: Hashable<Hash = Pool::Key> + StorageSize + Clone + Send + 'static,
Pool::Settings: Clone,
NetworkAdapter: NetworkAdapterTrait<RuntimeServiceId, Payload = Pool::Item> + Send + Sync,
NetworkAdapter::Settings: Clone + Send + 'static,
@@ -459,7 +459,7 @@ where
})?;
let mut fetched_by_hash = items_stream
.map(|tx| (Transaction::hash(&tx), tx))
.map(|tx| (Hashable::hash(&tx), tx))
.collect::<BTreeMap<_, _>>()
.await;
+4 -4
View File
@@ -16,8 +16,7 @@ use lb_core::{
events::Events,
header::HeaderId,
mantle::{
AuthenticatedMantleTx, NoteId, Op, OpProof, SignedMantleTx, Transaction as _, TxHash, Utxo,
Value, VerificationError,
NoteId, Op, OpProof, SignedMantleTx, TxHash, Utxo, Value, VerificationError,
gas::{GasCost, GasOverflow, MainnetGasConstants},
ledger::Inputs,
ops::{
@@ -27,6 +26,7 @@ use lb_core::{
},
sdp::{SDPActiveOp, SDPDeclareOp, SDPWithdrawOp},
},
traits::{Hashable as _, MantleTxWithProofs},
transactions::{
MantleTxBuilder, MantleTxContext, TxBuilderError, states::Preverified, tx::OpsProofs,
},
@@ -306,7 +306,7 @@ impl<Kms, Cryptarchia, Tx, Storage, RuntimeServiceId> ServiceCore<RuntimeService
for WalletService<Kms, Cryptarchia, Tx, Storage, RuntimeServiceId>
where
Kms: KmsServiceData<Backend = KmsBackend> + Send + Sync,
Tx: AuthenticatedMantleTx + Send + Sync + Clone + Eq + Serialize + DeserializeOwned + 'static,
Tx: MantleTxWithProofs + Send + Sync + Clone + Eq + Serialize + DeserializeOwned + 'static,
Cryptarchia: CryptarchiaServiceData<Tx = Tx>,
Storage: StorageBackend + Send + Sync + 'static,
<Storage as StorageChainApi>::Block: TryFrom<Block<Tx>> + TryInto<Block<Tx>>,
@@ -463,7 +463,7 @@ impl<Kms, Cryptarchia, Tx, Storage, RuntimeServiceId>
WalletService<Kms, Cryptarchia, Tx, Storage, RuntimeServiceId>
where
Kms: KmsServiceData<Backend = KmsBackend>,
Tx: AuthenticatedMantleTx + Send + Sync + Clone + Eq + Serialize + DeserializeOwned + 'static,
Tx: MantleTxWithProofs + Send + Sync + Clone + Eq + Serialize + DeserializeOwned + 'static,
Cryptarchia: CryptarchiaServiceData<Tx = Tx> + Send + 'static,
Storage: StorageBackend + Send + Sync + 'static,
<Storage as StorageChainApi>::Block: TryFrom<Block<Tx>> + TryInto<Block<Tx>>,
+1 -1
View File
@@ -3,7 +3,7 @@ use std::{collections::HashSet, hash::BuildHasher, time::Duration};
use lb_common_http_client::ApiBlock;
use lb_core::{
header::HeaderId,
mantle::{Transaction as _, TxHash},
mantle::{TxHash, traits::Hashable as _},
};
use lb_testing_framework::NodeHttpClient;
use tokio::time::{sleep, timeout};
+1 -1
View File
@@ -5,7 +5,7 @@ use std::{
time::Duration,
};
use lb_core::mantle::{GenesisTx as _, Utxo};
use lb_core::mantle::{Utxo, traits::GenesisTx as _};
use lb_key_management_system_service::keys::ZkPublicKey;
use lb_libp2p::Multiaddr;
use lb_node::{UserConfig, config::RunConfig};
@@ -2,9 +2,10 @@ use std::collections::{HashMap, HashSet};
use lb_common_http_client::{ApiBlock, Error as HttpClientError};
use lb_core::mantle::{
Op, OpProof, SignedMantleTx, Transaction as _, TxHash, Utxo,
Op, OpProof, SignedMantleTx, TxHash, Utxo,
gas::MainnetGasConstants,
ops::channel::{ChannelId, ChannelKeyIndex},
traits::Hashable as _,
transactions::{
GasPrices, MantleTxBuilder, MantleTxContext, MantleTxGasContext, states::Unverified,
tx::OpsProofs,
@@ -156,7 +157,7 @@ where
let mut transactions_hashes = HashSet::new();
for block in tail_blocks {
apply_block_transactions(&mut chain_state, &block);
transactions_hashes.extend(block.transactions.iter().map(lb_node::Transaction::hash));
transactions_hashes.extend(block.transactions.iter().map(lb_node::Hashable::hash));
}
Ok((
@@ -2,7 +2,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use lb_common_http_client::ApiBlock;
use lb_core::mantle::{
NoteId, SignedMantleTx, Transaction as _, TxHash, Utxo, ops::Op,
NoteId, SignedMantleTx, TxHash, Utxo, ops::Op, traits::Hashable as _,
transactions::states::Unverified,
};
use lb_key_management_system_service::keys::ZkPublicKey;
@@ -211,13 +211,14 @@ mod tests {
use lb_core::{
header::{ContentId, HeaderId},
mantle::{
MantleTx, Note, SignedMantleTx, Transaction as _, Utxo,
MantleTx, Note, SignedMantleTx, Utxo,
ledger::{Inputs, Outputs},
ops::{
Op,
channel::{ChannelId, deposit::DepositOp},
transfer::TransferOp,
},
traits::Hashable as _,
transactions::{states::Unverified, tx::OpsProofs},
},
proofs::leader_proof::Groth16LeaderProof,
@@ -3,7 +3,8 @@
use std::collections::HashMap;
use lb_core::mantle::{
MantleTx, NoteId, Op, Transaction as _, TxHash, Utxo,
MantleTx, NoteId, Op, TxHash, Utxo,
traits::Hashable as _,
transactions::{MantleTxBuilder, MantleTxContext},
};
use lb_key_management_system_service::keys::ZkPublicKey;
@@ -3,9 +3,9 @@
use std::collections::HashMap;
use lb_core::mantle::{
AuthenticatedMantleTx as _, MantleTx, NoteId, Op, OpProof, SignedMantleTx, Transaction as _,
TxHash,
GasCalculator as _, MantleTx, NoteId, Op, OpProof, SignedMantleTx, TxHash,
gas::MainnetGasConstants,
traits::Hashable as _,
transactions::{MantleTxBuilder, MantleTxContext, tx::OpsProofs},
};
use lb_key_management_system_service::keys::ZkKey;
@@ -32,7 +32,7 @@ pub(super) fn sign_prepared_wallet_transaction(
let signed_tx = SignedMantleTx::new(mantle_tx, op_proofs).preverify()?;
let spent_fee = signed_tx
.total_gas_cost::<MainnetGasConstants>(gas_prices)?
.total_gas_cost::<MainnetGasConstants>(&gas_prices)?
.into_inner();
Ok(SignedWalletTransaction::new(
@@ -3,7 +3,8 @@ use std::{collections::BTreeSet, time::Duration};
use lb_core::{
codec::DeserializeOp as _,
mantle::{
SignedMantleTx, Transaction as _, TxHash,
SignedMantleTx, TxHash,
traits::Hashable as _,
transactions::{states::Preverified, tx::OpsProofs},
},
};
@@ -10,7 +10,7 @@ use cucumber::gherkin::Table;
use futures::future::try_join_all;
use hex::ToHex as _;
use lb_chain_service::{ChainServiceInfo, ChainServiceMode, CryptarchiaInfo, State};
use lb_core::mantle::{GenesisTx as _, Utxo, ops::OpId as _};
use lb_core::mantle::{Utxo, ops::OpId as _, traits::GenesisTx as _};
use lb_http_api_common::paths::CRYPTARCHIA_INFO;
use lb_libp2p::PeerId;
use lb_node::config::{
@@ -2,9 +2,10 @@ use std::{collections::HashSet, time::Duration};
use lb_common_http_client::ApiBlock;
use lb_core::mantle::{
MantleTx, Note, Op, OpProof, SignedMantleTx, Transaction as _, TxHash,
MantleTx, Note, Op, OpProof, SignedMantleTx, TxHash,
ledger::{Inputs, Outputs},
ops::transfer::TransferOp,
traits::Hashable as _,
transactions::states::Unverified,
};
use lb_key_management_system_service::keys::{ZkKey, ZkPublicKey};
@@ -14,7 +14,7 @@ use std::{
use futures::StreamExt as _;
use lb_common_http_client::{CommonHttpClient, Slot};
use lb_core::mantle::{
MantleTx, Note, Op, OpProof, Transaction as _, Utxo, Value,
MantleTx, Note, Op, OpProof, Utxo, Value,
gas::GasCost,
ledger::{Inputs, Outputs, OutputsError},
ops::{
@@ -26,6 +26,7 @@ use lb_core::mantle::{
},
transfer::TransferOp,
},
traits::Hashable as _,
transactions::{builder::MantleTxBuilder, states::Unverified, tx::OpsProofs},
};
use lb_http_api_common::bodies::{
+2 -1
View File
@@ -4,12 +4,13 @@
use cucumber::{gherkin::Step, when};
use lb_core::mantle::{
Note, Op, OpProof, SignedMantleTx, Transaction as _,
Note, Op, OpProof, SignedMantleTx,
gas::GasCost,
ops::channel::{
ChannelId, MsgId,
inscribe::{Inscription, InscriptionOp},
},
traits::Hashable as _,
transactions::builder::MantleTxBuilder,
};
use lb_http_api_common::bodies::wallet::fund::{WalletFundRequestBody, WalletFundResponseBody};
+2 -1
View File
@@ -4,9 +4,10 @@ use lb_chain_service::{ChainServiceMode, State};
use lb_core::{
block::genesis::GenesisBlockBuilder,
mantle::{
GenesisTime, GenesisTx as _,
GenesisTime,
nom::NomEncode as _,
ops::channel::inscribe::{Inscription, InscriptionOp},
traits::GenesisTx as _,
},
};
use lb_node::config::{RunConfig, cryptarchia::deployment::EpochConfig};
+2 -1
View File
@@ -6,10 +6,11 @@ use lb_core::{
events::{Event, Events, TxEvent, TxEventPayload},
header::HeaderId,
mantle::{
GenesisTx as _, NoteId, Transaction as _, TxHash,
NoteId, TxHash,
gas::GasCost,
ledger::Inputs,
ops::channel::{ChannelId, deposit::DepositOp},
traits::{GenesisTx as _, Hashable as _},
},
};
use lb_http_api_common::bodies::{
+1 -1
View File
@@ -9,7 +9,7 @@ use lb_http_api_common::bodies::wallet::{
};
use lb_key_management_system_service::keys::ZkPublicKey;
use lb_node::{
Transaction as _, TxHash,
Hashable as _, TxHash,
config::{RunConfig, cryptarchia::deployment::EpochConfig},
};
use lb_testing_framework::{
+1 -1
View File
@@ -12,7 +12,7 @@ use std::{
use lb_chain_service::Epoch;
use lb_common_http_client::Error;
use lb_core::{
mantle::{NoteId, OpProof, Transaction as _, Utxo, ops::Op},
mantle::{NoteId, OpProof, Utxo, ops::Op, traits::Hashable as _},
sdp::{
Declaration, DeclarationId, DeclarationMessage, Locator, ProviderId, ServiceType,
WithdrawMessage,
+1 -1
View File
@@ -10,7 +10,7 @@ pub use lb_config as configs;
use lb_config::kms::key_id_for_preload_backend;
use lb_core::{
block::genesis::GenesisBlock,
mantle::{GenesisTx as _, Note, NoteId},
mantle::{traits::GenesisTx as _, Note, NoteId},
sdp::{Locator, ServiceType},
};
use lb_key_management_system_service::keys::ZkKey;
@@ -3,7 +3,7 @@ use cfgsync_adapter::MaterializedArtifacts;
use cfgsync_artifacts::ArtifactFile;
use lb_core::{
block::genesis::GenesisBlock,
mantle::GenesisTx as _,
mantle::traits::GenesisTx as _,
sdp::{Locator, ServiceType},
};
use lb_libp2p::{Multiaddr, Protocol};
@@ -2,7 +2,7 @@ use std::collections::HashSet;
use lb_core::{
block::genesis::GenesisBlock,
mantle::{GenesisTx as _, Note},
mantle::{Note, traits::GenesisTx as _},
sdp::{Locator, ServiceType},
};
use lb_key_management_system_service::keys::{Key, ZkKey};
@@ -8,7 +8,7 @@ use std::{
use async_trait::async_trait;
use lb_core::mantle::{
MantleTx, SignedMantleTx, Transaction as _,
MantleTx, SignedMantleTx,
ops::{
Op, OpProof,
channel::{
@@ -16,6 +16,7 @@ use lb_core::mantle::{
inscribe::{Inscription, InscriptionOp},
},
},
traits::Hashable as _,
transactions::{TxHash, states::Preverified},
};
use lb_key_management_system_service::keys::Ed25519Key;
@@ -9,9 +9,10 @@ use std::{
use async_trait::async_trait;
use lb_core::mantle::{
GasCalculator as _, GenesisTx as _, Note, OpProof, SignedMantleTx, Transaction as _, Utxo,
GasCalculator as _, Note, OpProof, SignedMantleTx, Utxo,
gas::MainnetGasConstants,
ops::OpId as _,
traits::{GenesisTx as _, Hashable as _},
transactions::{GasPrices, MantleTxBuilder, MantleTxGasContext, states::Preverified},
};
use lb_key_management_system_service::keys::{ZkKey, ZkPublicKey};
+1 -1
View File
@@ -22,7 +22,7 @@ use lb_groth16::{AdditiveGroup as _, CompressedGroth16Proof, Fr};
use lb_key_management_system_service::keys::{
Ed25519Key, Ed25519Signature, ZkKey, ZkPublicKey, ZkSignature,
};
use lb_node::{SignedMantleTx, Transaction as _};
use lb_node::{Hashable as _, SignedMantleTx};
use num_bigint::BigUint;
use time::OffsetDateTime;
+1 -1
View File
@@ -17,7 +17,7 @@ use std::sync::LazyLock;
use blend::GeneralBlendConfig;
use lb_core::{
block::genesis::GenesisBlock,
mantle::GenesisTx as _,
mantle::traits::GenesisTx as _,
sdp::{Locator, ServiceType},
};
use lb_node::config::KmsConfig;
+1 -1
View File
@@ -1,7 +1,7 @@
use std::iter::repeat_n;
use lb_core::{
mantle::{GenesisTx as _, Op, transactions::GenesisTx},
mantle::{Op, traits::GenesisTx as _, transactions::GenesisTx},
sdp::DeclarationId,
};
+4 -3
View File
@@ -15,13 +15,14 @@ use lb_core::{
events::{Event, Events, HeaderEvent, TxEvent, TxEventPayload},
header::HeaderId,
mantle::{
AuthenticatedMantleTx, GasConstants, NoteId, TxHash, Utxo, Value,
GasConstants, NoteId, TxHash, Utxo, Value,
ops::{
Op, OpId as _,
channel::{channel_transfer::ChannelTransferOp, withdraw::ChannelWithdrawOp},
leader_claim::{VoucherCm, VoucherNullifier},
transfer::TransferOp,
},
traits::MantleTxWithProofs,
transactions::{MantleTxContext, builder::MantleTxBuilder},
},
proofs::leader_proof::LeaderProof as _,
@@ -106,7 +107,7 @@ impl WalletBlock {
#[must_use]
pub fn from_block<Tx>(block: &Block<Tx>, epoch: Epoch, events: &Events) -> Self
where
Tx: AuthenticatedMantleTx + Clone,
Tx: MantleTxWithProofs + Clone,
{
// TODO: devise a better way to mirror ledger's execution always correctly: https://github.com/logos-blockchain/logos-blockchain/issues/2627
let (header_events, tx_events) = group_events(events);
@@ -509,7 +510,7 @@ fn transform_txs<'t, Tx>(
mut events_by_tx: HashMap<TxHash, HashMap<Hash, TxEventPayload>>,
) -> impl Iterator<Item = WalletTx> + 't
where
Tx: AuthenticatedMantleTx + 't,
Tx: MantleTxWithProofs + 't,
{
txs.map(move |tx| {
let mut events_by_op = events_by_tx.remove(&tx.hash()).unwrap_or_default();
+2 -1
View File
@@ -11,9 +11,10 @@ use lb_core::{
events::TxEvent,
header::HeaderId,
mantle::{
Op, SignedMantleTx, Transaction as _, TxHash, Value,
Op, SignedMantleTx, TxHash, Value,
channel::ChannelState,
ops::{OpId as _, channel::ChannelId},
traits::Hashable as _,
transactions::states::{Unverified, VerificationState},
},
};
+2 -1
View File
@@ -595,7 +595,7 @@ mod tests {
use lb_core::{
header::HeaderId,
mantle::{
MantleTx, Note, Op, SignedMantleTx, Transaction as _, Utxo,
MantleTx, Note, Op, SignedMantleTx, Utxo,
ledger::Inputs,
ops::{
OpProof,
@@ -606,6 +606,7 @@ mod tests {
withdraw::ChannelWithdrawOp,
},
},
traits::Hashable as _,
transactions::{Ops, tx::OpsProofs},
},
};
+2 -1
View File
@@ -5,11 +5,12 @@ use lb_core::{
crypto::Hash,
header::HeaderId,
mantle::{
SignedMantleTx, Transaction as _, Value,
SignedMantleTx, Value,
ops::{
Op, OpId as _,
channel::{ChannelId, MsgId, inscribe::Inscription},
},
traits::Hashable as _,
transactions::{
TxHash,
states::{Unverified, VerificationState},
+4 -3
View File
@@ -3,11 +3,12 @@ use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
use lb_core::{
header::HeaderId,
mantle::{
SignedMantleTx, Transaction as _,
SignedMantleTx,
ops::{
Op,
channel::{ChannelId, MsgId, inscribe::Inscription},
},
traits::Hashable as _,
transactions::{TxHash, states::Unverified},
},
};
@@ -973,8 +974,8 @@ impl TxState {
#[cfg(test)]
mod tests {
use lb_core::mantle::{
MantleTx, Op::ChannelInscribe, Transaction as _, ops::channel::inscribe::InscriptionOp,
transactions::tx::OpsProofs,
MantleTx, Op::ChannelInscribe, ops::channel::inscribe::InscriptionOp,
traits::Hashable as _, transactions::tx::OpsProofs,
};
use lb_key_management_system_service::keys::Ed25519PublicKey;
+2 -1
View File
@@ -1,6 +1,6 @@
use lb_core::{
mantle::{
MantleTx, SignedMantleTx, Transaction as _, Value,
MantleTx, SignedMantleTx, Value,
channel::{ChannelState, SlotTimeframe, SlotTimeout},
ops::{
Op, OpProof,
@@ -10,6 +10,7 @@ use lb_core::{
inscribe::{Inscription, InscriptionOp},
},
},
traits::Hashable as _,
transactions::{MantleTxBuilder, Ops, TxHash, states::Unverified, tx::OpsProofs},
},
proofs::channel_multi_sig_proof::{ChannelMultiSigProof, IndexedSignature},
+2 -1
View File
@@ -5,13 +5,14 @@ use lb_core::{
crypto::Hash,
header::HeaderId,
mantle::{
SignedMantleTx, Transaction as _, Value,
SignedMantleTx, Value,
channel::ChannelState,
gas::GasCost,
ledger::{Inputs, Outputs},
ops::channel::{
ChannelId, MsgId, deposit::Metadata, inscribe::Inscription, withdraw::ChannelWithdrawOp,
},
traits::Hashable as _,
transactions::{TxHash, states::Unverified},
},
};
+2 -1
View File
@@ -11,9 +11,10 @@ use lb_common_http_client::{ProcessedBlockEvent, Slot};
use lb_core::{
header::HeaderId,
mantle::{
MantleTx, Op, SignedMantleTx, Transaction as _,
MantleTx, Op, SignedMantleTx,
channel::{ChannelState, SlotTimeframe, SlotTimeout},
ops::channel::{ChannelId, MsgId, config::Keys, inscribe::Inscription},
traits::Hashable as _,
transactions::{Ops, TxHash, states::Unverified},
},
};