use async_trait::async_trait;
use fuel_core_storage::{
transactional::StorageTransaction,
Result as StorageResult,
};
use fuel_core_types::{
blockchain::{
block::CompressedBlock,
primitives::DaBlockHeight,
},
fuel_tx::{
Bytes32,
Receipt,
},
fuel_types::BlockHeight,
services::{
executor::{
ExecutionBlock,
Result as ExecutorResult,
UncommittedResult,
},
txpool::ArcPoolTx,
},
};
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 current_block_height(&self) -> StorageResult<BlockHeight>;
}
#[async_trait]
pub trait TxPool: Send + Sync {
fn get_includable_txs(
&self,
block_height: BlockHeight,
max_gas: u64,
) -> Vec<ArcPoolTx>;
}
#[async_trait::async_trait]
pub trait Relayer: Send + Sync {
async fn wait_for_at_least(
&self,
height: &DaBlockHeight,
) -> anyhow::Result<DaBlockHeight>;
}
pub trait Executor<Database>: Send + Sync {
fn execute_without_commit(
&self,
block: ExecutionBlock,
) -> ExecutorResult<UncommittedResult<StorageTransaction<Database>>>;
fn dry_run(
&self,
block: ExecutionBlock,
utxo_validation: Option<bool>,
) -> ExecutorResult<Vec<Vec<Receipt>>>;
}