Skip to content

Commit 49d0309

Browse files
AurelienFTrymnc
andauthored
Prevent dependency on blob transactions (#3030)
## Linked Issues/PRs Resolves #3017 ## Checklist - [x] Breaking changes are clearly marked as such in the PR description and changelog - [x] New behavior is reflected in tests - [x] [The specification](https://github.com/FuelLabs/fuel-specs/) matches the implemented behavior (link update PR if changes are needed) ### Before requesting review - [x] I have reviewed the code myself - [x] I have created follow-up issues caused by this PR and linked them here --------- Co-authored-by: Aaryamann Challani <[email protected]>
1 parent 85b2356 commit 49d0309

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

.changes/changed/3030.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disable dependency on blob transactions in transaction pool.

crates/services/txpool_v2/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ pub enum DependencyError {
107107
#[display(fmt = "The dependent transaction creates a diamond problem, \
108108
causing cycles in the dependency graph.")]
109109
DependentTransactionIsADiamondDeath,
110+
#[display(fmt = "The transaction depends on a blob transaction")]
111+
NotInsertedDependentOnBlob,
110112
}
111113

112114
#[derive(Clone, Debug)]

crates/services/txpool_v2/src/storage/graph.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,12 @@ impl Storage for GraphStorage {
591591
));
592592
}
593593

594+
if dependency_node.transaction.is_blob() {
595+
return Err(Error::Dependency(
596+
DependencyError::NotInsertedDependentOnBlob,
597+
));
598+
}
599+
594600
to_check.extend(self.get_direct_dependencies(node_id));
595601
}
596602

crates/services/txpool_v2/src/tests/tests_pool.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,39 @@ fn insert__tx_blob_already_in_db() {
13421342
universe.assert_pool_integrity(&[]);
13431343
}
13441344

1345+
#[test]
1346+
fn insert__dependent_on_blob() {
1347+
let mut universe = TestPoolUniverse::default().config(Config {
1348+
utxo_validation: false,
1349+
..Default::default()
1350+
});
1351+
universe.build_pool();
1352+
let (output_a, unset_input) = universe.create_output_and_input();
1353+
1354+
// Given
1355+
let program = vec![123; 123];
1356+
let blob_id = BlobId::compute(program.as_slice());
1357+
let tx = TransactionBuilder::blob(BlobBody {
1358+
id: blob_id,
1359+
witness_index: 0,
1360+
})
1361+
.add_witness(program.clone().into())
1362+
.add_fee_input()
1363+
.add_output(output_a)
1364+
.finalize_as_transaction();
1365+
let tx_id = tx.id(&ChainId::default());
1366+
1367+
let tx = universe.verify_and_insert(tx).unwrap();
1368+
1369+
let input_a = unset_input.into_input(UtxoId::new(tx_id, 0));
1370+
let dependent_tx = universe.build_script_transaction(Some(vec![input_a]), None, 1);
1371+
1372+
// When
1373+
universe.verify_and_insert(dependent_tx).unwrap_err();
1374+
// Then
1375+
universe.assert_pool_integrity(&[tx]);
1376+
}
1377+
13451378
#[test]
13461379
fn insert__if_tx3_depends_and_collides_with_tx2() {
13471380
let mut universe = TestPoolUniverse::default();

crates/types/src/services/txpool.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ impl PoolTransaction {
221221
self.max_gas_inner()
222222
}
223223
}
224+
225+
/// Returns true if the transaction is a blob.
226+
pub fn is_blob(&self) -> bool {
227+
matches!(self, PoolTransaction::Blob(_, _))
228+
}
224229
}
225230

226231
#[allow(missing_docs)]

0 commit comments

Comments
 (0)