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

feat: handle Unknown transactions, blocks and consensus parameters #2154

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
df9f96d
fuel-client: default to `Unknown` transaction type
hal3e Sep 3, 2024
0a3fd21
Merge branch 'master' into hal3e/unknown-variants
hal3e Sep 16, 2024
96d4ccf
Merge branch 'master' into hal3e/unknown-variants
hal3e Sep 17, 2024
43ee053
Work in progress
hal3e Sep 16, 2024
2e6344a
add `Unknown` variant to CParams and children
hal3e Sep 17, 2024
fd676bf
add changelog
hal3e Sep 17, 2024
a07f855
fix tests
hal3e Sep 17, 2024
c524651
insta review
hal3e Sep 17, 2024
59a8fd1
merge master
hal3e Sep 17, 2024
10336a7
merge master
hal3e Sep 18, 2024
9976e14
merge master
hal3e Sep 18, 2024
4b2430e
update changelogmd
hal3e Sep 18, 2024
4537a65
update changelogmd
hal3e Sep 18, 2024
675ce5e
fix merge remove wasm bytecode
hal3e Sep 18, 2024
ac37dcd
pr comments
hal3e Sep 18, 2024
217393e
Merge branch 'master' into hal3e/unknown-variants
MitchTurner Sep 19, 2024
d2409e7
Merge branch 'master' into hal3e/unknown-variants
hal3e Sep 19, 2024
2b63e5e
Merge branch 'master' into hal3e/unknown-variants
hal3e Sep 19, 2024
dbf8849
Merge branch 'master' into hal3e/unknown-variants
hal3e Sep 20, 2024
c85e7df
add Block and Header `Unknown` variant
hal3e Sep 20, 2024
6275d95
update changelog
hal3e Sep 20, 2024
30644d2
Merge branch 'master' into hal3e/unknown-variants
hal3e Sep 20, 2024
bd8aa31
Merge branch 'master' into hal3e/unknown-variants
hal3e Sep 20, 2024
5cf5057
merge master
hal3e Sep 26, 2024
3d039ae
merge master
hal3e Sep 27, 2024
1ece59d
merge master
hal3e Oct 2, 2024
0d5cbcb
Merge branch 'master' into hal3e/unknown-variants
hal3e Oct 2, 2024
015976a
Merge branch 'master' into hal3e/unknown-variants
hal3e Oct 3, 2024
0b0404f
merge master
hal3e Nov 6, 2024
d72f065
update changelog
hal3e Nov 6, 2024
a1b07af
fix spelling error
hal3e Nov 6, 2024
b1c255e
insta review
hal3e Nov 6, 2024
c7492c5
Merge branch 'master' into hal3e/unknown-variants
hal3e Nov 14, 2024
f42ace8
pr comments
hal3e Nov 14, 2024
10649aa
update cynic version
hal3e Nov 14, 2024
694d3b3
fmt
hal3e Nov 14, 2024
dbffb57
Merge branch 'master' into hal3e/unknown-variants
hal3e Nov 14, 2024
b7a3a66
Merge branch 'master' into hal3e/unknown-variants
hal3e Nov 14, 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
119 changes: 61 additions & 58 deletions CHANGELOG.md

Large diffs are not rendered by default.

472 changes: 343 additions & 129 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fuel-vm-private = { version = "0.57.0", package = "fuel-vm", default-features =
# Common dependencies
anyhow = "1.0"
async-trait = "0.1"
cynic = { version = "2.2.1", features = ["http-reqwest"] }
cynic = { version = "3.1.0", features = ["http-reqwest"] }
clap = "4.4"
derivative = { version = "2" }
derive_more = { version = "0.99" }
Expand All @@ -117,7 +117,7 @@ serde_with = { version = "3.4", default-features = false }
strum = { version = "0.25" }
strum_macros = "0.25"
# enable cookie store to support L7 sticky sessions
reqwest = { version = "0.11.16", default-features = false, features = [
reqwest = { version = "0.12.0", default-features = false, features = [
"rustls-tls",
"cookies",
] }
Expand Down
Empty file.
47 changes: 34 additions & 13 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,17 @@ use schema::{
balance::BalanceArgs,
blob::BlobByIdArgs,
block::BlockByIdArgs,
coins::CoinByIdArgs,
contract::ContractByIdArgs,
coins::{
CoinByIdArgs,
CoinsConnectionArgs,
},
contract::{
ContractBalancesConnectionArgs,
ContractByIdArgs,
},
gas_price::BlockHorizonArgs,
tx::{
TransactionsByOwnerConnectionArgs,
TxArg,
TxIdArgs,
},
Expand Down Expand Up @@ -366,7 +374,9 @@ impl FuelClient {
&self,
block_horizon: u32,
) -> io::Result<EstimateGasPrice> {
let query = schema::gas_price::QueryEstimateGasPrice::build(block_horizon.into());
let query = schema::gas_price::QueryEstimateGasPrice::build(BlockHorizonArgs {
block_horizon: Some(block_horizon.into()),
});
self.query(query).await.map(|r| r.estimate_gas_price)
}

Expand Down Expand Up @@ -750,7 +760,8 @@ impl FuelClient {
&self,
request: PaginationRequest<String>,
) -> io::Result<PaginatedResult<TransactionResponse, String>> {
let query = schema::tx::TransactionsQuery::build(request.into());
let query =
schema::tx::TransactionsQuery::build(schema::ConnectionArgs::from(request));
let transactions = self.query(query).await?.transactions.try_into()?;
Ok(transactions)
}
Expand All @@ -762,7 +773,9 @@ impl FuelClient {
request: PaginationRequest<String>,
) -> io::Result<PaginatedResult<TransactionResponse, String>> {
let owner: schema::Address = (*owner).into();
let query = schema::tx::TransactionsByOwnerQuery::build((owner, request).into());
let query = schema::tx::TransactionsByOwnerQuery::build(
TransactionsByOwnerConnectionArgs::from((owner, request)),
);

let transactions = self.query(query).await?.transactions_by_owner.try_into()?;
Ok(transactions)
Expand Down Expand Up @@ -874,7 +887,8 @@ impl FuelClient {
&self,
request: PaginationRequest<String>,
) -> io::Result<PaginatedResult<types::Block, String>> {
let query = schema::block::BlocksQuery::build(request.into());
let query =
schema::block::BlocksQuery::build(schema::ConnectionArgs::from(request));
hal3e marked this conversation as resolved.
Show resolved Hide resolved

let blocks = self.query(query).await?.blocks.try_into()?;

Expand All @@ -901,7 +915,9 @@ impl FuelClient {
Some(asset_id) => (*asset_id).into(),
None => schema::AssetId::default(),
};
let query = schema::coins::CoinsQuery::build((owner, asset_id, request).into());
let query = schema::coins::CoinsQuery::build(CoinsConnectionArgs::from((
owner, asset_id, request,
)));

let coins = self.query(query).await?.coins.into();
Ok(coins)
Expand Down Expand Up @@ -937,7 +953,7 @@ impl FuelClient {
)
.map(Into::into);
let query = schema::coins::CoinsToSpendQuery::build(
(owner, spend_query, excluded_ids).into(),
schema::coins::CoinsToSpendArgs::from((owner, spend_query, excluded_ids)),
);

let coins_per_asset = self
Expand Down Expand Up @@ -1001,7 +1017,9 @@ impl FuelClient {
request: PaginationRequest<String>,
) -> io::Result<PaginatedResult<types::Balance, String>> {
let owner: schema::Address = (*owner).into();
let query = schema::balance::BalancesQuery::build((owner, request).into());
let query = schema::balance::BalancesQuery::build(
schema::balance::BalancesConnectionArgs::from((owner, request)),
);

let balances = self.query(query).await?.balances.into();
Ok(balances)
Expand All @@ -1013,8 +1031,9 @@ impl FuelClient {
request: PaginationRequest<String>,
) -> io::Result<PaginatedResult<types::ContractBalance, String>> {
let contract_id: schema::ContractId = (*contract).into();
let query =
schema::contract::ContractBalancesQuery::build((contract_id, request).into());
let query = schema::contract::ContractBalancesQuery::build(
ContractBalancesConnectionArgs::from((contract_id, request)),
);

let balances = self.query(query).await?.contract_balances.into();

Expand All @@ -1036,7 +1055,9 @@ impl FuelClient {
request: PaginationRequest<String>,
) -> io::Result<PaginatedResult<types::Message, String>> {
let owner: Option<schema::Address> = owner.map(|owner| (*owner).into());
let query = schema::message::OwnedMessageQuery::build((owner, request).into());
let query = schema::message::OwnedMessageQuery::build(
schema::message::OwnedMessagesConnectionArgs::from((owner, request)),
);

let messages = self.query(query).await?.messages.into();

Expand Down Expand Up @@ -1106,7 +1127,7 @@ impl FuelClient {
pub async fn transparent_transaction(
&self,
id: &TxId,
) -> io::Result<Option<Transaction>> {
) -> io::Result<Option<types::TransactionType>> {
let query = schema::tx::TransactionQuery::build(TxIdArgs { id: (*id).into() });

let transaction = self.query(query).await?.transaction;
Expand Down
4 changes: 2 additions & 2 deletions crates/client/src/client/schema/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::Bytes32;
use crate::client::schema::{
schema,
BlockId,
ConnectionArgs,
ConnectionArgsFields,
PageInfo,
Signature,
Tai64Timestamp,
Expand Down Expand Up @@ -226,7 +226,7 @@ mod tests {
#[test]
fn blocks_connection_query_gql_output() {
use cynic::QueryBuilder;
let operation = BlocksQuery::build(ConnectionArgs {
let operation = BlocksQuery::build(crate::client::schema::ConnectionArgs {
after: None,
before: None,
first: None,
Expand Down
25 changes: 25 additions & 0 deletions crates/client/src/client/schema/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub struct ConsensusParameters {
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum ConsensusParametersVersion {
V1,
#[cynic(fallback)]
Unknown,
}

#[derive(cynic::QueryFragment, Clone, Debug)]
Expand All @@ -48,6 +50,8 @@ pub struct TxParameters {
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum TxParametersVersion {
V1,
#[cynic(fallback)]
Unknown,
}

impl TryFrom<TxParameters> for fuel_core_types::fuel_tx::TxParameters {
Expand All @@ -66,6 +70,7 @@ impl TryFrom<TxParameters> for fuel_core_types::fuel_tx::TxParameters {
}
.into(),
),
_ => Err(ConversionError::UnknownVariant("TxParametersVersion")),
}
}
}
Expand All @@ -84,6 +89,8 @@ pub struct PredicateParameters {
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum PredicateParametersVersion {
V1,
#[cynic(fallback)]
Unknown,
}

impl TryFrom<PredicateParameters> for fuel_core_types::fuel_tx::PredicateParameters {
Expand All @@ -100,6 +107,9 @@ impl TryFrom<PredicateParameters> for fuel_core_types::fuel_tx::PredicateParamet
}
.into(),
),
_ => Err(ConversionError::UnknownVariant(
"PredicateParametersVersion",
)),
}
}
}
Expand All @@ -116,6 +126,8 @@ pub struct ScriptParameters {
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum ScriptParametersVersion {
V1,
#[cynic(fallback)]
Unknown,
}

impl TryFrom<ScriptParameters> for fuel_core_types::fuel_tx::ScriptParameters {
Expand All @@ -130,6 +142,7 @@ impl TryFrom<ScriptParameters> for fuel_core_types::fuel_tx::ScriptParameters {
}
.into(),
),
_ => Err(ConversionError::UnknownVariant("ScriptParametersVersion")),
}
}
}
Expand All @@ -146,6 +159,8 @@ pub struct ContractParameters {
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum ContractParametersVersion {
V1,
#[cynic(fallback)]
Unknown,
}

impl TryFrom<ContractParameters> for fuel_core_types::fuel_tx::ContractParameters {
Expand All @@ -160,6 +175,7 @@ impl TryFrom<ContractParameters> for fuel_core_types::fuel_tx::ContractParameter
}
.into(),
),
_ => Err(ConversionError::UnknownVariant("ContractParametersVersion")),
}
}
}
Expand All @@ -176,6 +192,8 @@ pub struct FeeParameters {
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum FeeParametersVersion {
V1,
#[cynic(fallback)]
Unknown,
}

impl TryFrom<FeeParameters> for fuel_core_types::fuel_tx::FeeParameters {
Expand All @@ -190,6 +208,7 @@ impl TryFrom<FeeParameters> for fuel_core_types::fuel_tx::FeeParameters {
}
.into(),
),
_ => Err(ConversionError::UnknownVariant("FeeParametersVersion")),
}
}
}
Expand Down Expand Up @@ -321,6 +340,8 @@ pub struct GasCosts {
#[cynic(schema_path = "./assets/schema.sdl")]
pub enum GasCostsVersion {
V1,
#[cynic(fallback)]
Unknown,
}

impl TryFrom<GasCosts> for fuel_core_types::fuel_tx::GasCosts {
Expand Down Expand Up @@ -447,6 +468,7 @@ impl TryFrom<GasCosts> for fuel_core_types::fuel_tx::GasCosts {
}
.into(),
)),
_ => Err(ConversionError::UnknownVariant("GasCostsVersion")),
}
}
}
Expand Down Expand Up @@ -497,6 +519,9 @@ impl TryFrom<ConsensusParameters> for fuel_core_types::fuel_tx::ConsensusParamet
}
.into(),
),
_ => Err(ConversionError::UnknownVariant(
"ConsensusParametersVersion",
)),
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/client/src/client/schema/gas_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ mod tests {
fn estimate_gas_price_query_gql_output() {
use cynic::QueryBuilder;
let arbitrary_horizon = 10;
let operation = QueryEstimateGasPrice::build(arbitrary_horizon.into());
let operation = QueryEstimateGasPrice::build(BlockHorizonArgs {
hal3e marked this conversation as resolved.
Show resolved Hide resolved
block_horizon: Some(arbitrary_horizon.into()),
});
insta::assert_snapshot!(operation.query)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
source: crates/client/src/client/schema/balance.rs
expression: operation.query
---
query($owner: Address!, $assetId: AssetId!) {
query BalanceQuery($owner: Address!, $assetId: AssetId!) {
balance(owner: $owner, assetId: $assetId) {
owner
amount
assetId
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/client/src/client/schema/balance.rs
expression: operation.query
---
query($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
query BalancesQuery($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
balances(filter: $filter, after: $after, before: $before, first: $first, last: $last) {
edges {
cursor
Expand All @@ -20,5 +20,3 @@ query($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/client/src/client/schema/block.rs
expression: operation.query
---
query($height: U32) {
query BlockByHeightQuery($height: U32) {
block(height: $height) {
version
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/client/src/client/schema/block.rs
expression: operation.query
---
query($id: BlockId) {
query BlockByIdQuery($id: BlockId) {
block(id: $id) {
version
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
source: crates/client/src/client/schema/block.rs
expression: operation.query
---
mutation($startTimestamp: Tai64Timestamp, $blocksToProduce: U32!) {
mutation BlockMutation($startTimestamp: Tai64Timestamp, $blocksToProduce: U32!) {
produceBlocks(blocksToProduce: $blocksToProduce, startTimestamp: $startTimestamp)
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/client/src/client/schema/block.rs
expression: operation.query
---
query($after: String, $before: String, $first: Int, $last: Int) {
query BlocksQuery($after: String, $before: String, $first: Int, $last: Int) {
blocks(after: $after, before: $before, first: $first, last: $last) {
edges {
cursor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/client/src/client/schema/chain.rs
expression: operation.query
---
query {
query ChainQuery {
chain {
daHeight
name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/client/src/client/schema/coins.rs
expression: operation.query
---
query($utxoId: UtxoId!) {
query CoinByIdQuery($utxoId: UtxoId!) {
coin(utxoId: $utxoId) {
amount
blockCreated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/client/src/client/schema/coins.rs
expression: operation.query
---
query($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
query CoinsQuery($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
coins(filter: $filter, after: $after, before: $before, first: $first, last: $last) {
edges {
cursor
Expand Down
Loading
Loading