Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8a6502c
Started work on the `assemble_tx` endpoint.
xgreenx Feb 26, 2025
a19bcc3
Implemented remaining logic
xgreenx Feb 27, 2025
8a5ff0c
fix: Updated integer types in client
netrome Feb 27, 2025
59bc96a
feat: Support assembleTx in client
netrome Feb 27, 2025
6d87183
fix: Use HexString instead of passing around Vec<u8>
netrome Feb 27, 2025
2a42e40
fix: Integer changes in tests
netrome Feb 27, 2025
1c3561d
fix: Typo
netrome Feb 27, 2025
04660bd
fix: Cleanup
netrome Feb 27, 2025
2da4546
Re-worked some tests to use new assemble tx API. ALong with it fixed …
xgreenx Feb 28, 2025
cdf2970
Merge branch 'refs/heads/master' into feature/assemble-tx
xgreenx Feb 28, 2025
30177d0
Updated CHANGELOG
xgreenx Feb 28, 2025
2bc6258
refactor: Tidy up `FuelCoreClientExt` trait
netrome Feb 28, 2025
7f7df62
refactor: Simplify control flow in assemble_transaction impl
netrome Feb 28, 2025
208f60b
refactor: Reorder trait methods
netrome Feb 28, 2025
7fd6d51
refactor: Tidy up `AssembleTx::new` logic
netrome Feb 28, 2025
0b38697
Remove breaking change from API
xgreenx Feb 28, 2025
f307ba5
Use GraphQL to produce a block, it awaits off-chain database to index…
xgreenx Feb 28, 2025
9eddbf9
feat: Don't use bool for `destroy` option
netrome Mar 3, 2025
a2942f1
fix: Remove unsafe array slicing
netrome Mar 3, 2025
2646e53
feat: Break out big loop to dedicated `populate_missing_contract_inpu…
netrome Mar 3, 2025
3885dee
Removed unnessesary cover tip step
xgreenx Mar 3, 2025
03b281e
We still need to cover fee because fake coin doesn't have any amount …
xgreenx Mar 3, 2025
14ecbce
Added protection over many estimation of predicates
xgreenx Mar 3, 2025
a6963e7
Merge branch 'master' into feature/assemble-tx
xgreenx Mar 3, 2025
25d26d7
Merge branch 'master' into feature/assemble-tx
AurelienFT Mar 4, 2025
71d5b1e
Fix tests compilation
AurelienFT Mar 4, 2025
c8c1e49
Fixed witness index
xgreenx Mar 4, 2025
d118248
Fixed the issues with custom witness limit.
xgreenx Mar 4, 2025
00fda90
Merge branch 'master' into feature/assemble-tx
xgreenx Mar 4, 2025
28a3c10
Include `gas_price` into the response.
xgreenx Mar 4, 2025
eb7aa08
Fixed wrong `used_gas` calculation logic
xgreenx Mar 4, 2025
dfa5e81
Added filling of missing witnesses
xgreenx Mar 5, 2025
78c1e4c
Merge branch 'refs/heads/master' into feature/assemble-tx
xgreenx Mar 6, 2025
af19011
Resolved conflicts
xgreenx Mar 6, 2025
269ab9f
Make CI happy
xgreenx Mar 6, 2025
c2e215a
Make CI happy
xgreenx Mar 6, 2025
c86be0a
Fixed flaky test
xgreenx Mar 6, 2025
c0f51fe
Merge branch 'master' into feature/assemble-tx
netrome Mar 6, 2025
3c29542
Add more tests for the change and variable outputs
xgreenx Mar 6, 2025
dfd59ca
Handle cases with zero gas price and when we don't need base asset to…
xgreenx Mar 7, 2025
7a42126
Make audit happy
xgreenx Mar 7, 2025
a5fed62
Merge branch 'master' into feature/assemble-tx
xgreenx Mar 7, 2025
ca42157
Merge branch 'master' into feature/assemble-tx
rymnc Mar 7, 2025
1760da4
Fixed panic during adding change outputs.
xgreenx Mar 9, 2025
13e0607
Make CI happy
xgreenx Mar 9, 2025
4ce0dc9
Merge branch 'master' into feature/assemble-tx
xgreenx Mar 11, 2025
876241e
Merge branch 'master' into feature/assemble-tx
xgreenx Mar 11, 2025
14f842a
Merge branch 'master' into feature/assemble-tx
xgreenx Mar 11, 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
1 change: 1 addition & 0 deletions bin/fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ impl Command {
coins_to_spend: graphql.costs.coins_to_spend,
get_peers: graphql.costs.get_peers,
estimate_predicates: graphql.costs.estimate_predicates,
assemble_tx: graphql.costs.assemble_tx,
dry_run: graphql.costs.dry_run,
storage_read_replay: graphql.costs.storage_read_replay,
submit: graphql.costs.submit,
Expand Down
8 changes: 8 additions & 0 deletions bin/fuel-core/src/cli/run/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ pub struct QueryCosts {
)]
pub dry_run: usize,

/// Query costs for assembling the transaction.
#[clap(
long = "query-cost-assemble-tx",
default_value = DEFAULT_QUERY_COSTS.assemble_tx.to_string(),
env
)]
pub assemble_tx: usize,

/// Query costs for generating execution trace for a block.
#[clap(
long = "query-cost-storage-read-replay",
Expand Down
98 changes: 95 additions & 3 deletions crates/client/assets/schema.sdl
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
input Account @oneOf {
address: Address
predicate: Predicate
}

scalar Address

type AssembleTransactionResult {
transaction: Transaction!
status: DryRunTransactionStatus!
}

scalar AssetId

type AssetInfoDetails {
Expand Down Expand Up @@ -128,6 +138,18 @@ type ChangeOutput {
assetId: AssetId!
}

input ChangePolicy @oneOf {
"""
Adds `Output::Change` to the transaction if it is not already present.
Sending remaining assets to the provided address.
"""
change: Address
"""
Destroys the remaining assets by the transaction for provided address.
"""
destroy: Boolean
}

type Coin {
utxoId: UtxoId!
owner: Address!
Expand Down Expand Up @@ -865,6 +887,12 @@ type Policies {
maxFee: U64
}

input Predicate {
predicateAddress: Address!
predicate: [Int!]!
predicateData: [Int!]!
}

type PredicateParameters {
version: PredicateParametersVersion!
maxPredicateLength: U64!
Expand Down Expand Up @@ -935,6 +963,60 @@ type Query {
transactions(first: Int, after: String, last: Int, before: String): TransactionConnection!
transactionsByOwner(owner: Address!, first: Int, after: String, last: Int, before: String): TransactionConnection!
"""
Assembles the transaction based on the provided requirements.
The return transaction contains:
- Input coins to cover `required_balances`
- Input coins to cover the fee of the transaction based on the gas price from `block_horizon`
- `Change` or `Destroy` outputs for all assets from the inputs
- `Variable` outputs in the case they are required during the execution
- `Contract` inputs and outputs in the case they are required during the execution
- Reserved witness slots for signed coins filled with `64` zeroes
- Set script gas limit(unless `script` is empty)
- Estimated predicates, if `estimate_predicates == true`

Returns an error if:
- The number of required balances exceeds the maximum number of inputs allowed.
- The fee address index is out of bounds.
- The same asset has multiple change policies(either the receiver of
the change is different, or one of the policies states about the destruction
of the token while the other does not). The `Change` output from the transaction
also count as a `ChangePolicy`.
- The number of excluded coin IDs exceeds the maximum number of inputs allowed.
- Required assets have multiple entries.
- If accounts don't have sufficient amounts to cover the transaction requirements in assets.
- If a constructed transaction breaks the rules defined by consensus parameters.
"""
assembleTx(
"""
The original transaction that contains application level logic only
"""
tx: HexString!,
"""
Number of blocks into the future to estimate the gas price for
"""
blockHorizon: U32!,
"""
The list of required balances for the transaction to include as inputs. The list should be created based on the application-required assets. The base asset requirement should not require assets to cover the transaction fee, which will be calculated and added automatically at the end of the assembly process.
"""
requiredBalances: [RequiredBalance!]!,
"""
The index from the `required_balances` list that points to the address who pays fee for the transaction. If you only want to cover the fee of transaction, you can set the required balance to 0, set base asset and point to this required address.
"""
feeAddressIndex: U8!,
"""
The list of resources to exclude from the selection for the inputs
"""
excludeInput: ExcludeInput,
"""
Perform the estimation of the predicates before cover fee of the transaction
"""
estimatePredicates: Boolean,
"""
During the phase of the fee calculation, adds `reserve_gas` to the total gas used by the transaction and fetch assets to cover the fee.
"""
reserveGas: U64
): AssembleTransactionResult!
"""
Estimate the predicate gas for the provided transaction
"""
estimatePredicates(tx: HexString!): Transaction!
Expand Down Expand Up @@ -987,7 +1069,7 @@ type Query {
"""
The excluded coins from the selection.
"""
excludedIds: ExcludeInput
excludeInput: ExcludeInput
): [[CoinType!]!]!
daCompressedBlock(
"""
Expand Down Expand Up @@ -1095,6 +1177,13 @@ scalar RelayedTransactionId

union RelayedTransactionStatus = RelayedTransactionFailed

input RequiredBalance {
assetId: AssetId!
amount: U64!
account: Account!
changePolicy: ChangePolicy!
}

enum ReturnType {
RETURN
RETURN_DATA
Expand Down Expand Up @@ -1140,11 +1229,11 @@ input SpendQueryElementInput {
"""
Target amount for the query.
"""
amount: U64!
amount: U128!
"""
The maximum number of currencies for selection.
"""
max: U32
max: U16
}

type SqueezedOutStatus {
Expand Down Expand Up @@ -1333,6 +1422,8 @@ scalar U32

scalar U64

scalar U8

union UpgradePurpose = ConsensusParametersPurpose | StateTransitionPurpose

type UploadedBytecode {
Expand All @@ -1359,6 +1450,7 @@ type VariableOutput {
}

directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
directive @oneOf on INPUT_OBJECT
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
schema {
query: Query
Expand Down
Loading
Loading