From 9e4fe75471f635a4ba91f17ee76f75200eb91de8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 9 Feb 2023 19:44:32 -0800 Subject: [PATCH] fix: correctly convert v2 bytes in traces into "blocks" (#364) The condition was inverted. --- rust/src/fvm/engine.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/rust/src/fvm/engine.rs b/rust/src/fvm/engine.rs index b0420a39..86d393f2 100644 --- a/rust/src/fvm/engine.rs +++ b/rust/src/fvm/engine.rs @@ -232,6 +232,17 @@ mod v2 { ThreadedExecutor2(BaseExecutor2::new(machine)) } + fn bytes_to_block(bytes: RawBytes2) -> Option { + if bytes.is_empty() { + None + } else { + Some(IpldBlock { + data: bytes.into(), + codec: DAG_CBOR, + }) + } + } + impl CgoExecutor for CgoExecutor2 { fn execute_message( &mut self, @@ -356,18 +367,12 @@ mod v2 { from, to: Address::from_bytes(&to.to_bytes()).unwrap(), method, - params: params.is_empty().then(|| IpldBlock { - codec: DAG_CBOR, - data: params.into(), - }), + params: bytes_to_block(params), value: TokenAmount::from_atto(value.atto().clone()), }), ExecutionEvent2::CallReturn(ret) => Some(ExecutionEvent::CallReturn( ExitCode::OK, - ret.is_empty().then(|| IpldBlock { - codec: DAG_CBOR, - data: ret.into(), - }), + bytes_to_block(ret), )), ExecutionEvent2::CallAbort(ec) => { Some(ExecutionEvent::CallReturn(ExitCode::new(ec.value()), None))