fuel_poa_coordinator/
ports.rs

1use fuel_core_interfaces::{
2    common::{
3        fuel_asm::Word,
4        fuel_tx::{
5            Receipt,
6            Transaction,
7        },
8    },
9    db::DatabaseTransaction,
10    executor::UncommittedResult,
11    model::{
12        BlockHeight,
13        BlockId,
14        FuelBlockConsensus,
15    },
16};
17
18pub trait BlockDb: Send + Sync {
19    fn block_height(&self) -> anyhow::Result<BlockHeight>;
20
21    // Returns error if already sealed
22    fn seal_block(
23        &mut self,
24        block_id: BlockId,
25        consensus: FuelBlockConsensus,
26    ) -> anyhow::Result<()>;
27}
28
29// TODO: Replace by the analog from the `fuel-core-storage`.
30pub type DBTransaction<Database> = Box<dyn DatabaseTransaction<Database>>;
31
32#[async_trait::async_trait]
33pub trait BlockProducer<Database>: Send + Sync {
34    // TODO: Right now production and execution of the block is one step, but in the future,
35    //  `produce_block` should only produce a block without affecting the blockchain state.
36    async fn produce_and_execute_block(
37        &self,
38        height: BlockHeight,
39        max_gas: Word,
40    ) -> anyhow::Result<UncommittedResult<DBTransaction<Database>>>;
41
42    async fn dry_run(
43        &self,
44        transaction: Transaction,
45        height: Option<BlockHeight>,
46        utxo_validation: Option<bool>,
47    ) -> anyhow::Result<Vec<Receipt>>;
48}