Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fvm debug execution #288

Merged
merged 6 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions cgo/fvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,33 @@ func CreateFvmMachine(fvmVersion FvmRegisteredVersion, chainEpoch, baseFeeHi, ba
return executor, nil
}

func CreateFvmDebugMachine(fvmVersion FvmRegisteredVersion, chainEpoch, baseFeeHi, baseFeeLo, baseCircSupplyHi, baseCircSupplyLo, networkVersion uint64, stateRoot SliceRefUint8, actorRedirect SliceRefUint8, tracing bool, blockstoreId, externsId uint64) (*FvmMachine, error) {
resp := C.create_fvm_debug_machine(
fvmVersion,
C.uint64_t(chainEpoch),
C.uint64_t(baseFeeHi),
C.uint64_t(baseFeeLo),
C.uint64_t(baseCircSupplyHi),
C.uint64_t(baseCircSupplyLo),
C.uint64_t(networkVersion),
stateRoot,
actorRedirect,
C.bool(tracing),
C.uint64_t(blockstoreId),
C.uint64_t(externsId),
)
// take out the pointer from the result to ensure it doesn't get freed
executor := resp.value
resp.value = nil
defer resp.destroy()

if err := CheckErr(resp); err != nil {
return nil, err
}

return executor, nil
}

func FvmMachineExecuteMessage(executor *FvmMachine, message SliceRefUint8, chainLen, applyKind uint64) (FvmMachineExecuteResponseGo, error) {
resp := C.fvm_machine_execute_message(
executor,
Expand Down
44 changes: 32 additions & 12 deletions fvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type FVMOpts struct {
StateBase cid.Cid
Manifest cid.Cid
Tracing bool

Debug bool
ActorRedirect cid.Cid
}

// CreateFVM creates a new FVM instance.
Expand All @@ -56,18 +59,35 @@ func CreateFVM(opts *FVMOpts) (*FVM, error) {
}

exHandle := cgo.Register(context.TODO(), opts.Externs)
executor, err := cgo.CreateFvmMachine(cgo.FvmRegisteredVersion(opts.FVMVersion),
uint64(opts.Epoch),
baseFeeHi,
baseFeeLo,
baseCircSupplyHi,
baseCircSupplyLo,
uint64(opts.NetworkVersion),
cgo.AsSliceRefUint8(opts.StateBase.Bytes()),
cgo.AsSliceRefUint8(opts.Manifest.Bytes()),
opts.Tracing,
exHandle, exHandle,
)
var executor *cgo.FvmMachine
if !opts.Debug {
executor, err = cgo.CreateFvmMachine(cgo.FvmRegisteredVersion(opts.FVMVersion),
uint64(opts.Epoch),
baseFeeHi,
baseFeeLo,
baseCircSupplyHi,
baseCircSupplyLo,
uint64(opts.NetworkVersion),
cgo.AsSliceRefUint8(opts.StateBase.Bytes()),
cgo.AsSliceRefUint8(opts.Manifest.Bytes()),
opts.Tracing,
exHandle, exHandle,
)
} else {
executor, err = cgo.CreateFvmDebugMachine(cgo.FvmRegisteredVersion(opts.FVMVersion),
uint64(opts.Epoch),
baseFeeHi,
baseFeeLo,
baseCircSupplyHi,
baseCircSupplyLo,
uint64(opts.NetworkVersion),
cgo.AsSliceRefUint8(opts.StateBase.Bytes()),
cgo.AsSliceRefUint8(opts.ActorRedirect.Bytes()),
opts.Tracing,
exHandle, exHandle,
)
}

if err != nil {
return nil, err
}
Expand Down
Loading