1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use async_trait::async_trait;
use fuel_core_interfaces::{
common::fuel_tx::Receipt,
db::DatabaseTransaction,
executor::{
Error as ExecutorError,
ExecutionBlock,
UncommittedResult,
},
model::{
ArcPoolTx,
BlockHeight,
DaBlockHeight,
FuelBlockDb,
},
};
use std::borrow::Cow;
pub trait BlockProducerDatabase: Send + Sync {
fn get_block(
&self,
fuel_height: BlockHeight,
) -> anyhow::Result<Option<Cow<FuelBlockDb>>>;
fn current_block_height(&self) -> anyhow::Result<BlockHeight>;
}
#[async_trait]
pub trait TxPool: Sync + Send {
async fn get_includable_txs(
&self,
block_height: BlockHeight,
max_gas: u64,
) -> anyhow::Result<Vec<ArcPoolTx>>;
}
#[async_trait::async_trait]
pub trait Relayer: Sync + Send {
async fn get_best_finalized_da_height(&self) -> anyhow::Result<DaBlockHeight>;
}
pub type DBTransaction<Database> = Box<dyn DatabaseTransaction<Database>>;
pub trait Executor<Database: ?Sized>: Sync + Send {
fn execute_without_commit(
&self,
block: ExecutionBlock,
) -> Result<UncommittedResult<DBTransaction<Database>>, ExecutorError>;
fn dry_run(
&self,
block: ExecutionBlock,
utxo_validation: Option<bool>,
) -> Result<Vec<Vec<Receipt>>, ExecutorError>;
}