fuel_core_producer/
ports.rsuse fuel_core_storage::{
transactional::Changes,
Result as StorageResult,
};
use fuel_core_types::{
blockchain::{
block::CompressedBlock,
header::{
ConsensusParametersVersion,
StateTransitionBytecodeVersion,
},
primitives::DaBlockHeight,
},
fuel_tx::{
Bytes32,
Transaction,
},
fuel_types::BlockHeight,
services::{
block_producer::Components,
executor::{
Result as ExecutorResult,
TransactionExecutionStatus,
UncommittedResult,
},
},
};
use std::borrow::Cow;
pub trait BlockProducerDatabase: Send + Sync {
fn latest_height(&self) -> Option<BlockHeight>;
fn get_block(&self, height: &BlockHeight) -> StorageResult<Cow<CompressedBlock>>;
fn block_header_merkle_root(&self, height: &BlockHeight) -> StorageResult<Bytes32>;
fn latest_consensus_parameters_version(
&self,
) -> StorageResult<ConsensusParametersVersion>;
fn latest_state_transition_bytecode_version(
&self,
) -> StorageResult<StateTransitionBytecodeVersion>;
}
pub trait TxPool: Send + Sync {
type TxSource;
#[allow(async_fn_in_trait)]
async fn get_source(
&self,
gas_price: u64,
block_height: BlockHeight,
) -> anyhow::Result<Self::TxSource>;
}
pub struct RelayerBlockInfo {
pub gas_cost: u64,
pub tx_count: u64,
}
#[async_trait::async_trait]
pub trait Relayer: Send + Sync {
async fn wait_for_at_least_height(
&self,
height: &DaBlockHeight,
) -> anyhow::Result<DaBlockHeight>;
async fn get_cost_and_transactions_number_for_block(
&self,
height: &DaBlockHeight,
) -> anyhow::Result<RelayerBlockInfo>;
}
pub trait BlockProducer<TxSource>: Send + Sync {
fn produce_without_commit(
&self,
component: Components<TxSource>,
) -> ExecutorResult<UncommittedResult<Changes>>;
}
pub trait DryRunner: Send + Sync {
fn dry_run(
&self,
block: Components<Vec<Transaction>>,
utxo_validation: Option<bool>,
) -> ExecutorResult<Vec<TransactionExecutionStatus>>;
}