Skip to content

Commit

Permalink
Merge branch 'master' into safer-ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Apr 25, 2022
2 parents b31c9e7 + 791b682 commit abf7231
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
34 changes: 18 additions & 16 deletions cgo/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ type PoStProofGo struct {

/// FvmMachineExecuteResponse is a go allocated version of `FvmMachineExecuteResponse`.
type FvmMachineExecuteResponseGo struct {
ExitCode uint64
ReturnVal []byte
GasUsed uint64
PenaltyHi uint64
PenaltyLo uint64
MinerTipHi uint64
MinerTipLo uint64
ExecTrace []byte
ExitCode uint64
ReturnVal []byte
GasUsed uint64
PenaltyHi uint64
PenaltyLo uint64
MinerTipHi uint64
MinerTipLo uint64
ExecTrace []byte
FailureInfo string
}

func (ptr SliceBoxedUint8) slice() []byte {
Expand Down Expand Up @@ -608,13 +609,14 @@ func (ptr *FvmMachine) Destroy() {

func (r FvmMachineExecuteResponse) copy() FvmMachineExecuteResponseGo {
return FvmMachineExecuteResponseGo{
ExitCode: uint64(r.exit_code),
ReturnVal: r.return_val.copy(),
GasUsed: uint64(r.gas_used),
PenaltyHi: uint64(r.penalty_hi),
PenaltyLo: uint64(r.penalty_lo),
MinerTipHi: uint64(r.miner_tip_hi),
MinerTipLo: uint64(r.miner_tip_lo),
ExecTrace: r.exec_trace.copy(),
ExitCode: uint64(r.exit_code),
ReturnVal: r.return_val.copy(),
GasUsed: uint64(r.gas_used),
PenaltyHi: uint64(r.penalty_hi),
PenaltyLo: uint64(r.penalty_lo),
MinerTipHi: uint64(r.miner_tip_hi),
MinerTipLo: uint64(r.miner_tip_lo),
ExecTrace: r.exec_trace.copy(),
FailureInfo: string(r.failure_info.copy()),
}
}
3 changes: 3 additions & 0 deletions fvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (f *FVM) ApplyMessage(msgBytes []byte, chainLen uint) (*ApplyRet, error) {
MinerPenalty: reformBigInt(resp.PenaltyHi, resp.PenaltyLo),
MinerTip: reformBigInt(resp.MinerTipHi, resp.MinerTipLo),
ExecTraceBytes: resp.ExecTrace,
FailureInfo: resp.FailureInfo,
}, nil
}

Expand All @@ -134,6 +135,7 @@ func (f *FVM) ApplyImplicitMessage(msgBytes []byte) (*ApplyRet, error) {
GasUsed: int64(resp.GasUsed),
MinerPenalty: reformBigInt(resp.PenaltyHi, resp.PenaltyLo),
MinerTip: reformBigInt(resp.MinerTipHi, resp.MinerTipLo),
FailureInfo: resp.FailureInfo,
}, nil
}

Expand All @@ -154,6 +156,7 @@ type ApplyRet struct {
MinerPenalty abi.TokenAmount
MinerTip abi.TokenAmount
ExecTraceBytes []byte
FailureInfo string
}

// NOTE: We only support 64bit platforms
Expand Down
5 changes: 5 additions & 0 deletions rust/src/fvm/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ fn fvm_machine_execute_message(
None
};

let failure_info = apply_ret
.failure_info
.map(|info| info.to_string().into_boxed_str().into());

// TODO: use the non-bigint token amount everywhere in the FVM
let penalty: u128 = apply_ret.penalty.try_into().unwrap();
let miner_tip: u128 = apply_ret.miner_tip.try_into().unwrap();
Expand Down Expand Up @@ -190,6 +194,7 @@ fn fvm_machine_execute_message(
miner_tip_hi: (miner_tip >> u64::BITS) as u64,
miner_tip_lo: miner_tip as u64,
exec_trace,
failure_info,
})
})
}
Expand Down
1 change: 1 addition & 0 deletions rust/src/fvm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ pub struct FvmMachineExecuteResponse {
pub miner_tip_hi: u64,
pub miner_tip_lo: u64,
pub exec_trace: Option<c_slice::Box<u8>>,
pub failure_info: Option<str::Box>,
}

0 comments on commit abf7231

Please sign in to comment.