Skip to content

Commit 52e9e12

Browse files
fridrik01Stebalien
authored andcommitted
feat: add new fields to message trace for supporting new trace api
1 parent 8c2147f commit 52e9e12

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

rust/src/fvm/engine.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ mod v2 {
429429
method,
430430
params: bytes_to_block(params),
431431
value: TokenAmount::from_atto(value.atto().clone()),
432+
gas_limit: msg.gas_limit,
433+
read_only: false,
432434
}),
433435
ExecutionEvent2::CallReturn(ret) => Some(ExecutionEvent::CallReturn(
434436
ExitCode::OK,

rust/src/fvm/machine.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,17 @@ fn fvm_machine_execute_message(
216216
method,
217217
params,
218218
value,
219+
gas_limit,
220+
read_only,
219221
}) => {
220222
break build_lotus_trace(
221223
from,
222224
to,
223225
method,
224226
params,
225227
value,
228+
gas_limit,
229+
read_only,
226230
&mut initial_gas_charges.into_iter().chain(&mut trace_iter),
227231
)
228232
.ok()
@@ -378,6 +382,8 @@ pub struct TraceMessage {
378382
#[serde(with = "strict_bytes")]
379383
pub params: Vec<u8>,
380384
pub codec: u64,
385+
pub gas_limit: u64,
386+
pub read_only: bool,
381387
}
382388

383389
#[derive(Serialize_tuple, Deserialize_tuple, Debug, PartialEq, Eq, Clone)]
@@ -394,6 +400,8 @@ fn build_lotus_trace(
394400
method: u64,
395401
params: Option<IpldBlock>,
396402
value: TokenAmount,
403+
gas_limit: u64,
404+
read_only: bool,
397405
trace_iter: &mut impl Iterator<Item = ExecutionEvent>,
398406
) -> anyhow::Result<Trace> {
399407
let params = params.unwrap_or_default();
@@ -405,6 +413,8 @@ fn build_lotus_trace(
405413
method_num: method,
406414
params: params.data,
407415
codec: params.codec,
416+
gas_limit,
417+
read_only,
408418
},
409419
msg_ret: TraceReturn {
410420
exit_code: ExitCode::OK,
@@ -423,9 +433,11 @@ fn build_lotus_trace(
423433
method,
424434
params,
425435
value,
436+
gas_limit,
437+
read_only,
426438
} => {
427439
new_trace.subcalls.push(build_lotus_trace(
428-
from, to, method, params, value, trace_iter,
440+
from, to, method, params, value, gas_limit, read_only, trace_iter,
429441
)?);
430442
}
431443
ExecutionEvent::CallReturn(exit_code, return_data) => {
@@ -501,6 +513,8 @@ mod test {
501513
params: None,
502514
to: Address::new_id(0),
503515
value: TokenAmount::default(),
516+
gas_limit: u64::MAX,
517+
read_only: false,
504518
};
505519
let return_result =
506520
ExecutionEvent::CallError(SyscallError::new(IllegalArgument, "illegal"));
@@ -524,6 +538,8 @@ mod test {
524538
0,
525539
None,
526540
TokenAmount::default(),
541+
u64::MAX,
542+
false,
527543
&mut trace_iter,
528544
)
529545
.unwrap();

0 commit comments

Comments
 (0)