Trait serai_processor::networks::Network

source ·
pub trait Network: 'static + Send + Sync + Clone + PartialEq + Debug {
    type Curve: Curve;
    type Transaction: Transaction<Self>;
    type Block: Block<Self>;
    type Output: Output<Self>;
    type SignableTransaction: SignableTransaction;
    type Eventuality: Eventuality;
    type TransactionMachine: PreprocessMachine<Signature = <Self::Eventuality as Eventuality>::Completion>;
    type Scheduler: Scheduler<Self>;
    type Address: Send + Sync + Clone + PartialEq + Eq + Debug + ToString + TryInto<Vec<u8>> + TryFrom<Vec<u8>>;
Show 7 associated constants and 16 methods const NETWORK: ExternalNetworkId; const ID: &'static str; const ESTIMATED_BLOCK_TIME_IN_SECONDS: usize; const CONFIRMATIONS: usize; const MAX_OUTPUTS: usize; const DUST: u64; const COST_TO_AGGREGATE: u64; // Required methods fn tweak_keys(key: &mut ThresholdKeys<Self::Curve>); fn branch_address( key: <Self::Curve as Ciphersuite>::G, ) -> Option<Self::Address>; fn change_address( key: <Self::Curve as Ciphersuite>::G, ) -> Option<Self::Address>; fn forward_address( key: <Self::Curve as Ciphersuite>::G, ) -> Option<Self::Address>; fn get_latest_block_number<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, NetworkError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_block<'life0, 'async_trait>( &'life0 self, number: usize, ) -> Pin<Box<dyn Future<Output = Result<Self::Block, NetworkError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_outputs<'life0, 'life1, 'async_trait>( &'life0 self, block: &'life1 Self::Block, key: <Self::Curve as Ciphersuite>::G, ) -> Pin<Box<dyn Future<Output = Vec<Self::Output>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_eventuality_completions<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, eventualities: &'life1 mut EventualitiesTracker<Self::Eventuality>, block: &'life2 Self::Block, ) -> Pin<Box<dyn Future<Output = HashMap<[u8; 32], (usize, <Self::Transaction as Transaction<Self>>::Id, <Self::Eventuality as Eventuality>::Completion)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn needed_fee<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, block_number: usize, inputs: &'life1 [Self::Output], payments: &'life2 [Payment<Self>], change: &'life3 Option<Self::Address>, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>, NetworkError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn signable_transaction<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, block_number: usize, plan_id: &'life1 [u8; 32], key: <Self::Curve as Ciphersuite>::G, inputs: &'life2 [Self::Output], payments: &'life3 [Payment<Self>], change: &'life4 Option<Self::Address>, scheduler_addendum: &'life5 <Self::Scheduler as Scheduler<Self>>::Addendum, ) -> Pin<Box<dyn Future<Output = Result<Option<(Self::SignableTransaction, Self::Eventuality)>, NetworkError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait; fn attempt_sign<'life0, 'async_trait>( &'life0 self, keys: ThresholdKeys<Self::Curve>, transaction: Self::SignableTransaction, ) -> Pin<Box<dyn Future<Output = Result<Self::TransactionMachine, NetworkError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn publish_completion<'life0, 'life1, 'async_trait>( &'life0 self, completion: &'life1 <Self::Eventuality as Eventuality>::Completion, ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn confirm_completion<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, eventuality: &'life1 Self::Eventuality, claim: &'life2 <Self::Eventuality as Eventuality>::Claim, ) -> Pin<Box<dyn Future<Output = Result<Option<<Self::Eventuality as Eventuality>::Completion>, NetworkError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; // Provided methods fn get_latest_block_number_with_retries<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_block_with_retries<'life0, 'async_trait>( &'life0 self, block_number: usize, ) -> Pin<Box<dyn Future<Output = Self::Block> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn prepare_send<'life0, 'async_trait>( &'life0 self, block_number: usize, plan: Plan<Self>, operating_costs: u64, ) -> Pin<Box<dyn Future<Output = Result<PreparedSend<Self>, NetworkError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}

Required Associated Types§

source

type Curve: Curve

The elliptic curve used for this network.

source

type Transaction: Transaction<Self>

The type representing the transaction for this network.

source

type Block: Block<Self>

The type representing the block for this network.

source

type Output: Output<Self>

The type containing all information on a scanned output.

source

type SignableTransaction: SignableTransaction

The type containing all information on a planned transaction, waiting to be signed.

source

type Eventuality: Eventuality

The type containing all information to check if a plan was completed.

This must be binding to both the outputs expected and the plan ID.

source

type TransactionMachine: PreprocessMachine<Signature = <Self::Eventuality as Eventuality>::Completion>

The FROST machine to sign a transaction.

source

type Scheduler: Scheduler<Self>

The scheduler for this network.

source

type Address: Send + Sync + Clone + PartialEq + Eq + Debug + ToString + TryInto<Vec<u8>> + TryFrom<Vec<u8>>

The type representing an address.

Required Associated Constants§

source

const NETWORK: ExternalNetworkId

Network ID for this network.

source

const ID: &'static str

String ID for this network.

source

const ESTIMATED_BLOCK_TIME_IN_SECONDS: usize

The estimated amount of time a block will take.

source

const CONFIRMATIONS: usize

The amount of confirmations required to consider a block ‘final’.

source

const MAX_OUTPUTS: usize

The maximum amount of outputs which will fit in a TX. This should be equal to MAX_INPUTS unless one is specifically limited. A TX with MAX_INPUTS and MAX_OUTPUTS must not exceed the max size.

source

const DUST: u64

Minimum output value which will be handled.

For any received output, there’s the cost to spend the output. This value MUST exceed the cost to spend said output, and should by a notable margin (not just 2x, yet an order of magnitude).

source

const COST_TO_AGGREGATE: u64

The cost to perform input aggregation with a 2-input 1-output TX.

Required Methods§

source

fn tweak_keys(key: &mut ThresholdKeys<Self::Curve>)

Tweak keys for this network.

source

fn branch_address(key: <Self::Curve as Ciphersuite>::G) -> Option<Self::Address>

Address for the given group key to use for scheduled branches.

source

fn change_address(key: <Self::Curve as Ciphersuite>::G) -> Option<Self::Address>

Address for the given group key to use for change.

source

fn forward_address( key: <Self::Curve as Ciphersuite>::G, ) -> Option<Self::Address>

Address for forwarded outputs from prior multisigs.

forward_address must only return None if explicit forwarding isn’t necessary.

source

fn get_latest_block_number<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the latest block’s number.

source

fn get_block<'life0, 'async_trait>( &'life0 self, number: usize, ) -> Pin<Box<dyn Future<Output = Result<Self::Block, NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a block by its number.

source

fn get_outputs<'life0, 'life1, 'async_trait>( &'life0 self, block: &'life1 Self::Block, key: <Self::Curve as Ciphersuite>::G, ) -> Pin<Box<dyn Future<Output = Vec<Self::Output>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the outputs within a block for a specific key.

source

fn get_eventuality_completions<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, eventualities: &'life1 mut EventualitiesTracker<Self::Eventuality>, block: &'life2 Self::Block, ) -> Pin<Box<dyn Future<Output = HashMap<[u8; 32], (usize, <Self::Transaction as Transaction<Self>>::Id, <Self::Eventuality as Eventuality>::Completion)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get the registered eventualities completed within this block, and any prior blocks which registered eventualities may have been completed in.

This may panic if not fed a block greater than the tracker’s block number.

Plan ID -> (block number, TX ID, completion)

source

fn needed_fee<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, block_number: usize, inputs: &'life1 [Self::Output], payments: &'life2 [Payment<Self>], change: &'life3 Option<Self::Address>, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>, NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Returns the needed fee to fulfill this Plan at this fee rate.

Returns None if this Plan isn’t fulfillable (such as when the fee exceeds the input value).

source

fn signable_transaction<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, block_number: usize, plan_id: &'life1 [u8; 32], key: <Self::Curve as Ciphersuite>::G, inputs: &'life2 [Self::Output], payments: &'life3 [Payment<Self>], change: &'life4 Option<Self::Address>, scheduler_addendum: &'life5 <Self::Scheduler as Scheduler<Self>>::Addendum, ) -> Pin<Box<dyn Future<Output = Result<Option<(Self::SignableTransaction, Self::Eventuality)>, NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Create a SignableTransaction for the given Plan.

The expected flow is:

  1. Call needed_fee
  2. If the Plan is fulfillable, amortize the fee
  3. Call signable_transaction which MUST NOT return None if the above was done properly

This takes a destructured Plan as some of these arguments are malleated from the original Plan.

source

fn attempt_sign<'life0, 'async_trait>( &'life0 self, keys: ThresholdKeys<Self::Curve>, transaction: Self::SignableTransaction, ) -> Pin<Box<dyn Future<Output = Result<Self::TransactionMachine, NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempt to sign a SignableTransaction.

source

fn publish_completion<'life0, 'life1, 'async_trait>( &'life0 self, completion: &'life1 <Self::Eventuality as Eventuality>::Completion, ) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Publish a completion.

source

fn confirm_completion<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, eventuality: &'life1 Self::Eventuality, claim: &'life2 <Self::Eventuality as Eventuality>::Claim, ) -> Pin<Box<dyn Future<Output = Result<Option<<Self::Eventuality as Eventuality>::Completion>, NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Confirm a plan was completed by the specified transaction, per our bounds.

Returns Err if there was an error with the confirmation methodology. Returns Ok(None) if this is not a valid completion. Returns Ok(Some(_)) with the completion if it’s valid.

Provided Methods§

source

fn get_latest_block_number_with_retries<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the latest block’s number, retrying until success.

source

fn get_block_with_retries<'life0, 'async_trait>( &'life0 self, block_number: usize, ) -> Pin<Box<dyn Future<Output = Self::Block> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a block, retrying until success.

source

fn prepare_send<'life0, 'async_trait>( &'life0 self, block_number: usize, plan: Plan<Self>, operating_costs: u64, ) -> Pin<Box<dyn Future<Output = Result<PreparedSend<Self>, NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Prepare a SignableTransaction for a transaction.

This must not persist anything as we will prepare Plans we never intend to execute.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Network for Bitcoin

source§

impl Network for Monero

source§

impl<D: Db> Network for Ethereum<D>