Skip to content
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0f80f28
Skeleton for validation
AurelienFT May 27, 2025
256ba83
lock
AurelienFT May 27, 2025
2da2db1
chore: clean up validation
rymnc May 27, 2025
b0d171a
feat(parallel-executor): dependency graph for validation (#3032)
rymnc May 30, 2025
3e7acc7
chore: integrate dependency graph into recreate_block
rymnc Jun 2, 2025
b674d25
Add more logic for taking transaction to execute along with their dat…
AurelienFT Jun 11, 2025
e1ea432
Merge branch 'create_exec_sequencer_skeleton' into create_validation
AurelienFT Jun 12, 2025
4817870
Add more field on validation result
AurelienFT Jun 12, 2025
6616a3c
Add execution of transactions in validation
AurelienFT Jun 13, 2025
f86763b
Generate validation result
AurelienFT Jun 13, 2025
03f029a
Add creation of the block in validator
AurelienFT Jun 13, 2025
1ee06cb
add todo
AurelienFT Jun 13, 2025
d06b26c
Add coin verification on validation
AurelienFT Jun 16, 2025
a7e9500
Merge branch 'create_exec_sequencer_skeleton' into create_validation
AurelienFT Jun 16, 2025
2273de6
Add coin to root module
AurelienFT Jun 16, 2025
273d966
Update coin usage
AurelienFT Jun 16, 2025
e94256f
Merge branch 'create_exec_sequencer_skeleton' into create_validation
AurelienFT Jun 16, 2025
c27abc8
add creation of executor in validator
AurelienFT Jun 16, 2025
532f6fd
Merge branch 'create_exec_sequencer_skeleton' into create_validation
AurelienFT Jun 19, 2025
584fbb8
Fix validator compilation error
AurelienFT Jun 24, 2025
f759871
Fix all compilation error
AurelienFT Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/services/executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ where
}

#[allow(clippy::too_many_arguments)]
fn execute_transaction_and_commit<'a, W>(
pub fn execute_transaction_and_commit<'a, W>(
&'a self,
block: &'a mut PartialFuelBlock,
storage_tx: &mut BlockStorageTransaction<W>,
Expand Down
89 changes: 73 additions & 16 deletions crates/services/parallel-executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ use crate::{
SchedulerError,
SchedulerExecutionResult,
},
txs_ext::TxCoinbaseExt,
validator::{
self,
Validator,
},
};
use fuel_core_executor::{
executor::ExecutionData,
Expand All @@ -30,9 +35,12 @@ use fuel_core_storage::{
},
};
use fuel_core_types::{
blockchain::block::{
Block,
PartialFuelBlock,
blockchain::{
block::{
Block,
PartialFuelBlock,
},
header::PartialBlockHeader,
},
fuel_tx::{
ContractId,
Expand Down Expand Up @@ -70,23 +78,34 @@ mod defaults {

pub struct Executor<S, R, P> {
scheduler: Scheduler<R, S, P>,
relayer: R,
validator: Validator,
}

impl<S, R, P> Executor<S, R, P> {
impl<S, R, P> Executor<S, R, P>
where
R: Clone,
{
pub fn new(
storage_view_provider: S,
relayer_view_provider: R,
relayer: R,
preconfirmation_sender: P,
config: Config,
) -> Result<Self, SchedulerError> {
let scheduler = Scheduler::new(
config,
relayer_view_provider,
config.clone(),
relayer.clone(),
storage_view_provider,
preconfirmation_sender,
)?;

Ok(Self { scheduler })
let validator = Validator::new(config);

Ok(Self {
scheduler,
relayer,
validator,
})
}
}

Expand Down Expand Up @@ -130,6 +149,44 @@ where
self.finalize_block(&mut components, scheduler_result, &mut memory)
}

async fn validate_block(
mut self,
block: &Block,
block_storage_tx: StorageTransaction<View>,
) -> Result<validator::ValidationResult, SchedulerError> {
let mut data = ExecutionData::new();

let partial_header = PartialBlockHeader::from(block.header());
let mut partial_block = PartialFuelBlock::new(partial_header, vec![]);
let transactions = block.transactions();
let mut memory = MemoryInstance::new();

let (gas_price, coinbase_contract_id) = transactions.coinbase()?;

let block_storage_tx = self.process_l1_txs(
&mut partial_block,
coinbase_contract_id,
&mut data,
&mut memory,
block_storage_tx,
)?;
let processed_l1_tx_count = partial_block.transactions.len();

let components = Components {
header_to_produce: partial_block.header,
transactions_source: transactions.iter().cloned().skip(processed_l1_tx_count),
coinbase_recipient: coinbase_contract_id,
gas_price,
};

let executed_block_result = self
.validator
.validate_block(self.relayer.clone(), components, block_storage_tx, block)
.await?;

Ok(executed_block_result)
}

/// Process DA changes if the DA height has changed
async fn process_da_if_needed(
&mut self,
Expand All @@ -156,12 +213,17 @@ where
.is_some();

if should_process_da {
let storage_tx = StorageTransaction::transaction(
view,
ConflictPolicy::Fail,
Default::default(),
);
let storage_tx = self.process_l1_txs(
partial_block,
components.coinbase_recipient,
execution_data,
memory,
view,
storage_tx,
)?;
Ok(storage_tx.into_changes())
} else {
Expand All @@ -176,14 +238,8 @@ where
coinbase_contract_id: ContractId,
execution_data: &mut ExecutionData,
memory: &mut MemoryInstance,
view: View,
mut storage_tx: StorageTransaction<View>,
) -> Result<StorageTransaction<View>, SchedulerError> {
let mut storage_tx = StorageTransaction::transaction(
view,
ConflictPolicy::Fail,
Default::default(),
);

self.scheduler
.executor
.process_l1_txs(
Expand Down Expand Up @@ -281,6 +337,7 @@ where
let block = partial_block
.generate(
&execution_data.message_ids,
// TODO:
Default::default(),
#[cfg(feature = "fault-proving")]
&Default::default(),
Expand Down
2 changes: 2 additions & 0 deletions crates/services/parallel-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ pub mod config;
pub mod executor;
pub(crate) mod l1_execution_data;
pub mod ports;
pub(crate) mod txs_ext;

mod once_transaction_source;
mod tx_waiter;
mod validator;

#[cfg(test)]
mod tests;
Expand Down
8 changes: 8 additions & 0 deletions crates/services/parallel-executor/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ pub enum SchedulerError {
StorageError(StorageError),
/// Internal error
InternalError(String),
/// Mint missing error
MintMissing,
/// Skipped transaction error
SkippedTransaction(ExecutorError),
/// Block mismatch
BlockMismatch,
/// Consensus parameters not found
ConsensusParametersNotFound(u32),
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
25 changes: 25 additions & 0 deletions crates/services/parallel-executor/src/txs_ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use fuel_core_types::fuel_tx::{
ContractId,
Transaction,
field::{
InputContract,
MintGasPrice,
},
};

use crate::scheduler::SchedulerError;

/// Returns the coinbase transaction details if it exists.
pub trait TxCoinbaseExt {
fn coinbase(&self) -> Result<(u64, ContractId), SchedulerError>;
}

impl TxCoinbaseExt for &[Transaction] {
fn coinbase(&self) -> Result<(u64, ContractId), SchedulerError> {
if let Some(Transaction::Mint(mint)) = self.last() {
Ok((*mint.gas_price(), mint.input_contract().contract_id))
} else {
Err(SchedulerError::MintMissing)
}
}
}
Loading
Loading