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
67
68
69
70
71
72
73
74
75
76
77
use async_trait::async_trait;
use fuel_core_storage::{
transactional::StorageTransaction,
Result as StorageResult,
};
use fuel_core_types::{
blockchain::{
block::CompressedBlock,
primitives::{
BlockHeight,
DaBlockHeight,
},
},
fuel_tx::{
Bytes32,
Receipt,
},
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>>>;
}