fuel_core_producer/
ports.rs1use fuel_core_storage::{
2 transactional::Changes,
3 Result as StorageResult,
4};
5use fuel_core_types::{
6 blockchain::{
7 block::CompressedBlock,
8 header::{
9 ConsensusParametersVersion,
10 StateTransitionBytecodeVersion,
11 },
12 primitives::DaBlockHeight,
13 },
14 fuel_tx::{
15 Bytes32,
16 Transaction,
17 },
18 fuel_types::BlockHeight,
19 services::{
20 block_producer::Components,
21 executor::{
22 Result as ExecutorResult,
23 TransactionExecutionStatus,
24 UncommittedResult,
25 },
26 },
27};
28use std::borrow::Cow;
29
30pub trait BlockProducerDatabase: Send + Sync {
31 fn latest_height(&self) -> Option<BlockHeight>;
33
34 fn get_block(&self, height: &BlockHeight) -> StorageResult<Cow<CompressedBlock>>;
36
37 fn block_header_merkle_root(&self, height: &BlockHeight) -> StorageResult<Bytes32>;
39
40 fn latest_consensus_parameters_version(
42 &self,
43 ) -> StorageResult<ConsensusParametersVersion>;
44
45 fn latest_state_transition_bytecode_version(
47 &self,
48 ) -> StorageResult<StateTransitionBytecodeVersion>;
49}
50
51pub trait TxPool: Send + Sync {
52 type TxSource;
54
55 #[allow(async_fn_in_trait)]
57 async fn get_source(
58 &self,
59 gas_price: u64,
60 block_height: BlockHeight,
62 ) -> anyhow::Result<Self::TxSource>;
63}
64
65pub struct RelayerBlockInfo {
66 pub gas_cost: u64,
67 pub tx_count: u64,
68}
69
70#[async_trait::async_trait]
71pub trait Relayer: Send + Sync {
72 async fn wait_for_at_least_height(
74 &self,
75 height: &DaBlockHeight,
76 ) -> anyhow::Result<DaBlockHeight>;
77
78 async fn get_cost_and_transactions_number_for_block(
80 &self,
81 height: &DaBlockHeight,
82 ) -> anyhow::Result<RelayerBlockInfo>;
83}
84
85pub trait BlockProducer<TxSource>: Send + Sync {
86 fn produce_without_commit(
89 &self,
90 component: Components<TxSource>,
91 ) -> ExecutorResult<UncommittedResult<Changes>>;
92}
93
94pub trait DryRunner: Send + Sync {
95 fn dry_run(
99 &self,
100 block: Components<Vec<Transaction>>,
101 utxo_validation: Option<bool>,
102 ) -> ExecutorResult<Vec<TransactionExecutionStatus>>;
103}