forked from filecoin-project/filecoin-ffi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfvm_stub.go
More file actions
92 lines (78 loc) · 2.24 KB
/
Copy pathfvm_stub.go
File metadata and controls
92 lines (78 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//go:build !fvm
package ffi
import (
"context"
"errors"
"github.com/filecoin-project/filecoin-ffi/cgo"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
)
type FVM struct{}
type FVMOpts struct {
FVMVersion uint64
Externs cgo.Externs
Epoch abi.ChainEpoch
Timestamp uint64
ChainID uint64
BaseFee abi.TokenAmount
BaseCircSupply abi.TokenAmount
NetworkVersion network.Version
StateBase cid.Cid
Tracing bool
FlushAllBlocks bool
Debug bool
ActorRedirect cid.Cid
}
func CreateFVM(opts *FVMOpts) (*FVM, error) {
return nil, errors.New("FVM support not built in this binary")
}
func (f *FVM) ApplyMessage(_ []byte, _ uint) (*ApplyRet, error) {
return nil, errors.New("FVM support not built in this binary")
}
func (f *FVM) ApplyImplicitMessage(_ []byte) (*ApplyRet, error) {
return nil, errors.New("FVM support not built in this binary")
}
func (f *FVM) Flush() (cid.Cid, error) {
return cid.Undef, errors.New("FVM support not built in this binary")
}
// Minimal stubs to satisfy references
type ApplyRet struct {
Return []byte
ExitCode uint64
GasUsed int64
MinerPenalty abi.TokenAmount
MinerTip abi.TokenAmount
BaseFeeBurn abi.TokenAmount
OverEstimationBurn abi.TokenAmount
Refund abi.TokenAmount
GasRefund int64
GasBurned int64
ExecTraceBytes []byte
FailureInfo string
EventsRoot *cid.Cid
EventsBytes []byte
}
// Ensure cgo.Externs referenced to avoid unused import when stubbed
var _ = func() any { return context.TODO() }
// splitBigInt splits a big.Int into high and low uint64 values.
// This is used by tests and needs to be available even when FVM is not built.
func splitBigInt(i big.Int) (hi uint64, lo uint64, err error) {
if i.Sign() < 0 {
return 0, 0, xerrors.Errorf("negative number: %s", i)
}
words := i.Bits()
switch len(words) {
case 2:
hi = uint64(words[1])
fallthrough
case 1:
lo = uint64(words[0])
case 0:
default:
return 0, 0, xerrors.Errorf("exceeds max bigint size: %s", i)
}
return hi, lo, nil
}