Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle FTI messages in executor #1787

Merged
merged 63 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
64e8f3f
fti processing wip
Voxelot Mar 29, 2024
5dbccbb
update changelog
MitchTurner Apr 2, 2024
4868e5e
WIP add storage for L1 tx status
MitchTurner Apr 2, 2024
ca2e14b
Use types specific to relayed txs
MitchTurner Apr 2, 2024
2b0fc50
Add failing test for checking the events are stored in db
MitchTurner Apr 3, 2024
40dd37f
Implement code so test passes :)
MitchTurner Apr 3, 2024
57760ad
Merge branch 'master' into feature/process-fti-events
MitchTurner Apr 3, 2024
bca0830
WIP add graphql endpoints + client method
MitchTurner Apr 3, 2024
f626949
Get graphql compiling
MitchTurner Apr 3, 2024
611f9ff
Get failing test compiling
MitchTurner Apr 4, 2024
2c26842
Add actual value to test
MitchTurner Apr 4, 2024
63ed88d
Use union instead of enum for status
MitchTurner Apr 4, 2024
a672cd0
Cleanup
MitchTurner Apr 4, 2024
a25d9fe
Merge branch 'master' into feature/process-fti-events
MitchTurner Apr 4, 2024
065e93f
Add test for including relayed txs in block
MitchTurner Apr 4, 2024
21181a1
Fix test for relayed tx inclusion
MitchTurner Apr 4, 2024
bdc6103
Add test to show mints are not allowed
MitchTurner Apr 4, 2024
6542953
Merge branch 'master' into feature/process-fti-events
MitchTurner Apr 5, 2024
a96c787
Add test for duplicate relayed txs
MitchTurner Apr 5, 2024
a2a9576
Add test for invalid relayed tx
MitchTurner Apr 5, 2024
4b4d343
Add test for verifier to see failed relayed tx events
MitchTurner Apr 5, 2024
8fbda0f
Add test for not charging for L1 txs on L2
MitchTurner Apr 6, 2024
9422061
WIP cleanup
MitchTurner Apr 6, 2024
ae4ffce
More cleanup of executor tests
MitchTurner Apr 6, 2024
b83e337
Remove clones
MitchTurner Apr 6, 2024
78a26c3
Cleanup tests
MitchTurner Apr 6, 2024
98c5a08
Appease Clippy-sama
MitchTurner Apr 6, 2024
88cf656
Merge branch 'master' into feature/process-fti-events
MitchTurner Apr 6, 2024
18a78b3
Fix integ test
MitchTurner Apr 6, 2024
43e7ef4
WTF, why does this fix this?
MitchTurner Apr 6, 2024
109271c
Use `RelayedTransctionId` instead of `Bytes32`
MitchTurner Apr 8, 2024
ab27552
Fix formatting for attributes macros
MitchTurner Apr 8, 2024
33354f1
Update crates/client/src/client/types.rs
MitchTurner Apr 9, 2024
1af20a0
Update crates/client/src/client/schema/relayed_tx.rs
MitchTurner Apr 9, 2024
ab23700
Merge branch 'master' into feature/process-fti-events
MitchTurner Apr 9, 2024
c17faa8
Add log instead of comment for unknown executor events in worker service
MitchTurner Apr 9, 2024
eb33a4f
Update crates/fuel-core/src/graphql_api/storage/relayed_transactions.rs
MitchTurner Apr 9, 2024
752e17c
Update relayed_transactions.rs
MitchTurner Apr 9, 2024
c7382df
Remove non-exhaustive for events type, move variable, remove comment
MitchTurner Apr 10, 2024
4ec1a61
Merge branch 'master' into feature/process-fti-events
MitchTurner Apr 10, 2024
8ca67e2
Remove timestamp from failure type
MitchTurner Apr 11, 2024
e384ce5
Remove relayed tx variant of `MaybeCheckedTransaction` and clean up e…
MitchTurner Apr 11, 2024
2b1f517
Merge branch 'master' into feature/process-fti-events
MitchTurner Apr 11, 2024
8420a6c
Use test helper state watcher
MitchTurner Apr 11, 2024
135c9af
Include test for relayed txs that pass checks but fail execution, fix…
MitchTurner Apr 11, 2024
d766383
Add low max gas test, fix code to pass test
MitchTurner Apr 11, 2024
c63a7a4
Remove skips for relayed txs and only skip regular txs
MitchTurner Apr 11, 2024
593d244
Simplify code more and fix some compilation stuff
MitchTurner Apr 11, 2024
ce3bae9
Refactor `validate_forced_tx` to be more declarative
MitchTurner Apr 11, 2024
4c4333c
Add test showing relayed tx can spend message from same da block
MitchTurner Apr 12, 2024
1ef3464
Appease Clippy-sama
MitchTurner Apr 12, 2024
8e28483
Fix more CI checks
MitchTurner Apr 12, 2024
fa58407
Fix silly bug in code
MitchTurner Apr 12, 2024
9a7b027
Fix that closure more and do other cleanup
MitchTurner Apr 12, 2024
3fc2085
Appease Clippy-san
MitchTurner Apr 12, 2024
c6c1b2d
Use display impls of errors instead of hardcoding
MitchTurner Apr 12, 2024
dab539c
Remove unnecessary check
MitchTurner Apr 12, 2024
a8e714f
Remove extra semi-colons
MitchTurner Apr 12, 2024
c83eb18
Add specific values to low gas test
MitchTurner Apr 12, 2024
d344888
Use actual tx_id in error for failed execution
MitchTurner Apr 13, 2024
99d21e6
Cleanup
MitchTurner Apr 13, 2024
9c703f3
Cleanup max gas calc
MitchTurner Apr 13, 2024
abae5ab
Remove comments
MitchTurner Apr 13, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Description of the upcoming release here.

### Added

- [#1787](https://github.com/FuelLabs/fuel-core/pull/1787): Handle processing of relayed (forced) transactions
- [#1786](https://github.com/FuelLabs/fuel-core/pull/1786): Regenesis now includes off-chain tables.
- [#1716](https://github.com/FuelLabs/fuel-core/pull/1716): Added support of WASM state transition along with upgradable execution that works with native(std) and WASM(non-std) executors. The `fuel-core` now requires a `wasm32-unknown-unknown` target to build.
- [#1770](https://github.com/FuelLabs/fuel-core/pull/1770): Add the new L1 event type for forced transactions.
Expand Down
10 changes: 10 additions & 0 deletions crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ type Query {
messages(owner: Address, first: Int, after: String, last: Int, before: String): MessageConnection!
messageProof(transactionId: TransactionId!, nonce: Nonce!, commitBlockId: BlockId, commitBlockHeight: U32): MessageProof
messageStatus(nonce: Nonce!): MessageStatus!
relayedTransactionStatus(id: RelayedTransactionId!): RelayedTransactionStatus
}

type Receipt {
Expand Down Expand Up @@ -902,6 +903,15 @@ enum ReceiptType {
BURN
}

type RelayedTransactionFailed {
blockHeight: U32!
failure: String!
}

scalar RelayedTransactionId

union RelayedTransactionStatus = RelayedTransactionFailed

enum ReturnType {
RETURN
RETURN_DATA
Expand Down
21 changes: 21 additions & 0 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::client::{
contract::ContractBalanceQueryArgs,
gas_price::EstimateGasPrice,
message::MessageStatusArgs,
relayed_tx::RelayedTransactionStatusArgs,
tx::DryRunArg,
Tai64Timestamp,
TransactionId,
Expand All @@ -22,6 +23,7 @@ use crate::client::{
ContractId,
UtxoId,
},
RelayedTransactionStatus,
},
};
use anyhow::Context;
Expand All @@ -41,6 +43,7 @@ use fuel_core_types::{
Word,
},
fuel_tx::{
Bytes32,
Receipt,
Transaction,
TxId,
Expand Down Expand Up @@ -968,6 +971,24 @@ impl FuelClient {

Ok(proof)
}

pub async fn relayed_transaction_status(
&self,
id: &Bytes32,
Voxelot marked this conversation as resolved.
Show resolved Hide resolved
) -> io::Result<Option<RelayedTransactionStatus>> {
let query = schema::relayed_tx::RelayedTransactionStatusQuery::build(
RelayedTransactionStatusArgs {
id: id.to_owned().into(),
},
);
let status = self
.query(query)
.await?
.relayed_transaction_status
.map(|status| status.try_into())
.transpose()?;
Ok(status)
}
}

#[cfg(any(test, feature = "test-helpers"))]
Expand Down
2 changes: 2 additions & 0 deletions crates/client/src/client/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub mod gas_price;
pub mod primitives;
pub mod tx;

pub mod relayed_tx;

#[derive(cynic::QueryFragment, Clone, Debug)]
#[cynic(schema_path = "./assets/schema.sdl", graphql_type = "Query")]
pub struct Health {
Expand Down
1 change: 1 addition & 0 deletions crates/client/src/client/schema/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ fuel_type_scalar!(AssetId, AssetId);
fuel_type_scalar!(ContractId, ContractId);
fuel_type_scalar!(Salt, Salt);
fuel_type_scalar!(TransactionId, Bytes32);
fuel_type_scalar!(RelayedTransactionId, Bytes32);
fuel_type_scalar!(Signature, Bytes64);
fuel_type_scalar!(Nonce, Nonce);

Expand Down
39 changes: 39 additions & 0 deletions crates/client/src/client/schema/relayed_tx.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use crate::client::schema::{
schema,
RelayedTransactionId,
U32,
};

#[derive(cynic::QueryFragment, Clone, Debug)]
#[cynic(
schema_path = "./assets/schema.sdl",
graphql_type = "Query",
variables = "RelayedTransactionStatusArgs"
)]
pub struct RelayedTransactionStatusQuery {
#[arguments(id: $id)]
pub relayed_transaction_status: Option<RelayedTransactionStatus>,
}

#[derive(cynic::QueryVariables, Debug)]
pub struct RelayedTransactionStatusArgs {
/// Transaction id that contains the output message.
pub id: RelayedTransactionId,
}

#[allow(clippy::enum_variant_names)]
#[derive(cynic::InlineFragments, Clone, Debug)]
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum RelayedTransactionStatus {
/// Transaction was included in a block, but the execution was reverted
Failed(RelayedTransactionFailed),
#[cynic(fallback)]
Unknown,
}

#[derive(cynic::QueryFragment, Clone, Debug, PartialEq, Eq)]
#[cynic(schema_path = "./assets/schema.sdl")]
pub struct RelayedTransactionFailed {
pub block_height: U32,
pub failure: String,
}
29 changes: 29 additions & 0 deletions crates/client/src/client/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub use message::{
pub use node_info::NodeInfo;

use crate::client::schema::{
relayed_tx::RelayedTransactionStatus as SchemaRelayedTransactionStatus,
tx::{
OpaqueTransaction,
TransactionStatus as SchemaTxStatus,
Expand Down Expand Up @@ -169,3 +170,31 @@ impl TryFrom<OpaqueTransaction> for TransactionResponse {
})
}
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum RelayedTransactionStatus {
Failed {
Voxelot marked this conversation as resolved.
Show resolved Hide resolved
block_height: BlockHeight,
failure: String,
},
}

impl TryFrom<SchemaRelayedTransactionStatus> for RelayedTransactionStatus {
type Error = ConversionError;

fn try_from(status: SchemaRelayedTransactionStatus) -> Result<Self, Self::Error> {
Ok(match status {
SchemaRelayedTransactionStatus::Failed(s) => {
RelayedTransactionStatus::Failed {
block_height: s.block_height.into(),
failure: s.failure,
}
}
SchemaRelayedTransactionStatus::Unknown => {
return Err(Self::Error::UnknownVariant(
"SchemaRelayedTransactionStatus",
));
}
})
}
}
1 change: 0 additions & 1 deletion crates/fuel-core/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ mod tests {
.insert(&prev_height, &CompressedBlock::default());

// Then
assert!(result.is_err());
assert_eq!(
result.unwrap_err().to_string(),
StorageError::from(DatabaseError::HeightsAreNotLinked {
Expand Down
Loading
Loading