use async_trait::async_trait;
use 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 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>;
}
#[async_trait]
pub trait TxPool: Send + Sync {
type TxSource;
fn get_source(
&self,
block_height: BlockHeight,
) -> Self::TxSource;
}
#[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_for_block(&self, height: &DaBlockHeight) -> anyhow::Result<u64>;
}
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>>;
}