Skip to content

Commit a8e24a8

Browse files
xgreenxnetromeAurelienFTrymnc
authored
Use a new feature from the VM to get all required inputs in one dry run (#2840)
This change starts using the FuelLabs/fuel-vm#918 feature for the `asemble_tx` endpoint. --------- Co-authored-by: Mårten Blankfors <[email protected]> Co-authored-by: AurelienFT <[email protected]> Co-authored-by: Aaryamann Challani <[email protected]>
1 parent 2e5f2a6 commit a8e24a8

File tree

25 files changed

+444
-156
lines changed

25 files changed

+444
-156
lines changed

.changes/added/2840.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Added a new CLI arguments:
2+
- `assemble-tx-dry-run-limit` - The max number how many times script can be executed during `assemble_tx` GraphQL request. Default value is `3` times.
3+
- `assemble-tx-estimate-predicates-limit` - The max number how many times predicates can be estimated during `assemble_tx` GraphQL request. Default values is `10` times.

.changes/breaking/2840.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CLI argument `vm-backtrace` is deprecated and does nothing. It will be removed in a future version of `fuel-core`.
2+
The `extra_tx_checks` field was renamed into `forbid_fake_coins` that affects JSON based serialization/deserialization.
3+
Renamed `extra_tx_checks_default` field into `forbid_fake_coins_default`.

.changes/changed/2840.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed `log_backtrace` logic from the executor. It is not needed anymore with the existence of the local debugger for the transactions.

.changes/fixed/2840.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed `fuel-core-client` receipt deserialization in the case if the `ContractId` is zero.

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/fuel-core/src/cli/run.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use fuel_core::{
3333
Config,
3434
DbType,
3535
RelayerConsensusConfig,
36-
VMConfig,
3736
},
3837
state::rocks_db::{
3938
ColumnsPolicy,
@@ -197,6 +196,7 @@ pub struct Command {
197196

198197
/// Enable logging of backtraces from vm errors
199198
#[arg(long = "vm-backtrace", env)]
199+
#[deprecated]
200200
pub vm_backtrace: bool,
201201

202202
/// Enable full utxo stateful validation
@@ -307,6 +307,7 @@ pub struct Command {
307307

308308
impl Command {
309309
pub async fn get_config(self) -> anyhow::Result<Config> {
310+
#[allow(deprecated)]
310311
let Command {
311312
service_name: name,
312313
max_database_cache_size,
@@ -319,7 +320,7 @@ impl Command {
319320
db_prune,
320321
snapshot,
321322
continue_on_error,
322-
vm_backtrace,
323+
vm_backtrace: _,
323324
debug,
324325
historical_execution,
325326
utxo_validation,
@@ -628,6 +629,9 @@ impl Command {
628629
max_concurrent_queries: graphql.graphql_max_concurrent_queries,
629630
request_body_bytes_limit: graphql.graphql_request_body_bytes_limit,
630631
api_request_timeout: graphql.api_request_timeout.into(),
632+
assemble_tx_dry_run_limit: graphql.assemble_tx_dry_run_limit,
633+
assemble_tx_estimate_predicates_limit: graphql
634+
.assemble_tx_estimate_predicates_limit,
631635
query_log_threshold_time: graphql.query_log_threshold_time.into(),
632636
costs: Costs {
633637
balance_query: graphql.costs.balance_query,
@@ -671,9 +675,6 @@ impl Command {
671675
executor_number_of_cores,
672676
block_production: trigger,
673677
predefined_blocks_path,
674-
vm: VMConfig {
675-
backtrace: vm_backtrace,
676-
},
677678
txpool: TxPoolConfig {
678679
max_txs_chain_count: tx_max_chain_count,
679680
max_txs_ttl: tx_pool_ttl,

bin/fuel-core/src/cli/run/graphql.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ pub struct GraphQLArgs {
6666
#[clap(long = "api-request-timeout", default_value = "30s", env)]
6767
pub api_request_timeout: humantime::Duration,
6868

69+
/// The max number how many times script can be executed
70+
/// during `assemble_tx` GraphQL request.
71+
#[clap(long = "assemble-tx-dry-run-limit", default_value = "3", env)]
72+
pub assemble_tx_dry_run_limit: usize,
73+
74+
/// The max number how many times predicate can be estimated
75+
/// during `assemble_tx` GraphQL request.
76+
#[clap(
77+
long = "assemble-tx-estimate-predicates-limit",
78+
default_value = "10",
79+
env
80+
)]
81+
pub assemble_tx_estimate_predicates_limit: usize,
82+
6983
/// Maximum allowed block lag for GraphQL fuel block height requests.
7084
/// The client waits for the node to catch up if it's behind by no more blocks than
7185
/// this tolerance.

crates/client/src/client/schema/tx/transparent_receipt.rs

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
7272
fn try_from(schema: Receipt) -> Result<Self, Self::Error> {
7373
Ok(match schema.receipt_type {
7474
ReceiptType::Call => fuel_tx::Receipt::Call {
75-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
75+
id: schema
76+
.id
77+
.map(Into::into)
78+
.unwrap_or(fuel_tx::ContractId::zeroed()),
7679
to: schema
7780
.to
78-
.ok_or_else(|| MissingField("to".to_string()))?
79-
.into(),
81+
.map(Into::into)
82+
.unwrap_or(fuel_tx::ContractId::zeroed()),
8083
amount: schema
8184
.amount
8285
.ok_or_else(|| MissingField("amount".to_string()))?
@@ -107,7 +110,10 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
107110
.into(),
108111
},
109112
ReceiptType::Return => fuel_tx::Receipt::Return {
110-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
113+
id: schema
114+
.id
115+
.map(Into::into)
116+
.unwrap_or(fuel_tx::ContractId::zeroed()),
111117
val: schema
112118
.val
113119
.ok_or_else(|| MissingField("val".to_string()))?
@@ -122,7 +128,10 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
122128
.into(),
123129
},
124130
ReceiptType::ReturnData => fuel_tx::Receipt::ReturnData {
125-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
131+
id: schema
132+
.id
133+
.map(Into::into)
134+
.unwrap_or(fuel_tx::ContractId::zeroed()),
126135
ptr: schema
127136
.ptr
128137
.ok_or_else(|| MissingField("ptr".to_string()))?
@@ -151,7 +160,10 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
151160
.into(),
152161
},
153162
ReceiptType::Panic => fuel_tx::Receipt::Panic {
154-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
163+
id: schema
164+
.id
165+
.map(Into::into)
166+
.unwrap_or(fuel_tx::ContractId::zeroed()),
155167
reason: schema
156168
.reason
157169
.ok_or_else(|| MissingField("reason".to_string()))?
@@ -167,7 +179,10 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
167179
contract_id: schema.contract_id.map(Into::into),
168180
},
169181
ReceiptType::Revert => fuel_tx::Receipt::Revert {
170-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
182+
id: schema
183+
.id
184+
.map(Into::into)
185+
.unwrap_or(fuel_tx::ContractId::zeroed()),
171186
ra: schema
172187
.ra
173188
.ok_or_else(|| MissingField("ra".to_string()))?
@@ -182,7 +197,10 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
182197
.into(),
183198
},
184199
ReceiptType::Log => fuel_tx::Receipt::Log {
185-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
200+
id: schema
201+
.id
202+
.map(Into::into)
203+
.unwrap_or(fuel_tx::ContractId::zeroed()),
186204
ra: schema
187205
.ra
188206
.ok_or_else(|| MissingField("ra".to_string()))?
@@ -209,7 +227,10 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
209227
.into(),
210228
},
211229
ReceiptType::LogData => fuel_tx::Receipt::LogData {
212-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
230+
id: schema
231+
.id
232+
.map(Into::into)
233+
.unwrap_or(fuel_tx::ContractId::zeroed()),
213234
ra: schema
214235
.ra
215236
.ok_or_else(|| MissingField("ra".to_string()))?
@@ -246,7 +267,10 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
246267
.into(),
247268
},
248269
ReceiptType::Transfer => fuel_tx::Receipt::Transfer {
249-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
270+
id: schema
271+
.id
272+
.map(Into::into)
273+
.unwrap_or(fuel_tx::ContractId::zeroed()),
250274
to: schema
251275
.to
252276
.ok_or_else(|| MissingField("to".to_string()))?
@@ -269,7 +293,10 @@ impl TryFrom<Receipt> for fuel_tx::Receipt {
269293
.into(),
270294
},
271295
ReceiptType::TransferOut => fuel_tx::Receipt::TransferOut {
272-
id: schema.id.map(|id| id.into()).unwrap_or_default(),
296+
id: schema
297+
.id
298+
.map(Into::into)
299+
.unwrap_or(fuel_tx::ContractId::zeroed()),
273300
to: schema
274301
.to_address
275302
.ok_or_else(|| MissingField("to_address".to_string()))?

crates/fuel-core/src/executor.rs

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,8 @@ mod tests {
171171
/// The executor already has these parameters, and this field allows us
172172
/// to override the existing value.
173173
pub consensus_parameters: ConsensusParameters,
174-
/// Print execution backtraces if transaction execution reverts.
175-
pub backtrace: bool,
176-
/// Default mode for utxo_validation
177-
pub utxo_validation_default: bool,
174+
/// Default mode for `forbid_fake_coins` in the executor.
175+
pub forbid_fake_coins_default: bool,
178176
}
179177

180178
#[derive(Clone, Debug)]
@@ -216,8 +214,7 @@ mod tests {
216214
config: Config,
217215
) -> Executor<Database, DisabledRelayer> {
218216
let executor_config = fuel_core_upgradable_executor::config::Config {
219-
backtrace: config.backtrace,
220-
utxo_validation_default: config.utxo_validation_default,
217+
forbid_fake_coins_default: config.forbid_fake_coins_default,
221218
native_executor_version: None,
222219
allow_historical_execution: true,
223220
};
@@ -825,7 +822,7 @@ mod tests {
825822
let mut validator = create_executor(
826823
Default::default(),
827824
Config {
828-
utxo_validation_default: false,
825+
forbid_fake_coins_default: false,
829826
..Default::default()
830827
},
831828
);
@@ -1158,7 +1155,7 @@ mod tests {
11581155

11591156
// setup executors with utxo-validation enabled
11601157
let config = Config {
1161-
utxo_validation_default: true,
1158+
forbid_fake_coins_default: true,
11621159
..Default::default()
11631160
};
11641161
let producer = create_executor(Database::default(), config.clone());
@@ -1286,7 +1283,7 @@ mod tests {
12861283
let mut executor = create_executor(
12871284
Database::default(),
12881285
Config {
1289-
utxo_validation_default: true,
1286+
forbid_fake_coins_default: true,
12901287
..Default::default()
12911288
},
12921289
);
@@ -1354,7 +1351,7 @@ mod tests {
13541351
let mut executor = create_executor(
13551352
db.clone(),
13561353
Config {
1357-
utxo_validation_default: true,
1354+
forbid_fake_coins_default: true,
13581355
..Default::default()
13591356
},
13601357
);
@@ -1423,7 +1420,7 @@ mod tests {
14231420
let mut executor = create_executor(
14241421
db.clone(),
14251422
Config {
1426-
utxo_validation_default: true,
1423+
forbid_fake_coins_default: true,
14271424
..Default::default()
14281425
},
14291426
);
@@ -1472,7 +1469,7 @@ mod tests {
14721469
let mut executor = create_executor(
14731470
db.clone(),
14741471
Config {
1475-
utxo_validation_default: true,
1472+
forbid_fake_coins_default: true,
14761473
..Default::default()
14771474
},
14781475
);
@@ -1667,7 +1664,7 @@ mod tests {
16671664
let mut executor = create_executor(
16681665
db.clone(),
16691666
Config {
1670-
utxo_validation_default: false,
1667+
forbid_fake_coins_default: false,
16711668
..Default::default()
16721669
},
16731670
);
@@ -1722,7 +1719,7 @@ mod tests {
17221719
let mut executor = create_executor(
17231720
db.clone(),
17241721
Config {
1725-
utxo_validation_default: false,
1722+
forbid_fake_coins_default: false,
17261723
..Default::default()
17271724
},
17281725
);
@@ -1824,7 +1821,7 @@ mod tests {
18241821
let mut executor = create_executor(
18251822
db.clone(),
18261823
Config {
1827-
utxo_validation_default: false,
1824+
forbid_fake_coins_default: false,
18281825
..Default::default()
18291826
},
18301827
);
@@ -1930,9 +1927,8 @@ mod tests {
19301927
let mut executor = create_executor(
19311928
db.clone(),
19321929
Config {
1933-
utxo_validation_default: false,
1930+
forbid_fake_coins_default: false,
19341931
consensus_parameters: consensus_parameters.clone(),
1935-
..Default::default()
19361932
},
19371933
);
19381934

@@ -2091,7 +2087,7 @@ mod tests {
20912087
let mut executor = create_executor(
20922088
db.clone(),
20932089
Config {
2094-
utxo_validation_default: true,
2090+
forbid_fake_coins_default: true,
20952091
..Default::default()
20962092
},
20972093
);
@@ -2380,7 +2376,7 @@ mod tests {
23802376
create_executor(
23812377
database,
23822378
Config {
2383-
utxo_validation_default: true,
2379+
forbid_fake_coins_default: true,
23842380
..Default::default()
23852381
},
23862382
)
@@ -2807,7 +2803,7 @@ mod tests {
28072803
let mut executor = create_executor(
28082804
database.clone(),
28092805
Config {
2810-
utxo_validation_default: true,
2806+
forbid_fake_coins_default: true,
28112807
..Default::default()
28122808
},
28132809
);
@@ -2871,7 +2867,7 @@ mod tests {
28712867
let mut executor = create_executor(
28722868
database.clone(),
28732869
Config {
2874-
utxo_validation_default: true,
2870+
forbid_fake_coins_default: true,
28752871
..Default::default()
28762872
},
28772873
);
@@ -2893,9 +2889,8 @@ mod tests {
28932889

28942890
let consensus_parameters = ConsensusParameters::default();
28952891
let config = Config {
2896-
utxo_validation_default: true,
2892+
forbid_fake_coins_default: true,
28972893
consensus_parameters: consensus_parameters.clone(),
2898-
..Default::default()
28992894
};
29002895

29012896
let mut tx = TransactionBuilder::script(
@@ -3088,7 +3083,7 @@ mod tests {
30883083
.finalize();
30893084

30903085
let config = Config {
3091-
utxo_validation_default: false,
3086+
forbid_fake_coins_default: false,
30923087
..Default::default()
30933088
};
30943089
let (sender, mut receiver) = tokio::sync::mpsc::channel(2);
@@ -3152,7 +3147,7 @@ mod tests {
31523147
.finalize();
31533148

31543149
let config = Config {
3155-
utxo_validation_default: false,
3150+
forbid_fake_coins_default: false,
31563151
..Default::default()
31573152
};
31583153
let (sender, mut receiver) = tokio::sync::mpsc::channel(2);

0 commit comments

Comments
 (0)