Skip to content

Commit cbf868a

Browse files
committed
feat: switch to an FFI-level config
This means we don't construct a v3 config at the top level, then try to convert it to a v2 config. When we do that, we run into issues if, e.g., v3 doesn't define a price-list for a version only supported by v2. This PR also has a bit of cleanup: 1. Removes the manifest CID. 2. Changes the network version from u64 to u32 (simplifies some code). 3. Deletes all the overlay blockstore logic (was only used if the manifest was explicitly passed). Actor "overrides" should now only be done via "redirects".
1 parent f294254 commit cbf868a

File tree

7 files changed

+146
-372
lines changed

7 files changed

+146
-372
lines changed

cgo/fvm.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package cgo
88
*/
99
import "C"
1010

11-
func CreateFvmMachine(fvmVersion FvmRegisteredVersion, chainEpoch, chainTimestamp, chainId, baseFeeHi, baseFeeLo, baseCircSupplyHi, baseCircSupplyLo, networkVersion uint64, stateRoot SliceRefUint8, manifestCid SliceRefUint8, tracing bool, blockstoreId, externsId uint64) (*FvmMachine, error) {
11+
func CreateFvmMachine(fvmVersion FvmRegisteredVersion, chainEpoch, chainTimestamp, chainId, baseFeeHi, baseFeeLo, baseCircSupplyHi, baseCircSupplyLo, networkVersion uint64, stateRoot SliceRefUint8, tracing bool, blockstoreId, externsId uint64) (*FvmMachine, error) {
1212
resp := C.create_fvm_machine(
1313
fvmVersion,
1414
C.uint64_t(chainEpoch),
@@ -18,9 +18,8 @@ func CreateFvmMachine(fvmVersion FvmRegisteredVersion, chainEpoch, chainTimestam
1818
C.uint64_t(baseFeeLo),
1919
C.uint64_t(baseCircSupplyHi),
2020
C.uint64_t(baseCircSupplyLo),
21-
C.uint64_t(networkVersion),
21+
C.uint32_t(networkVersion),
2222
stateRoot,
23-
manifestCid,
2423
C.bool(tracing),
2524
C.uint64_t(blockstoreId),
2625
C.uint64_t(externsId),
@@ -47,7 +46,7 @@ func CreateFvmDebugMachine(fvmVersion FvmRegisteredVersion, chainEpoch, chainTim
4746
C.uint64_t(baseFeeLo),
4847
C.uint64_t(baseCircSupplyHi),
4948
C.uint64_t(baseCircSupplyLo),
50-
C.uint64_t(networkVersion),
49+
C.uint32_t(networkVersion),
5150
stateRoot,
5251
actorRedirect,
5352
C.bool(tracing),

fvm.go

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,5 @@
1-
//go:build cgo && (amd64 || arm64 || riscv64)
2-
// +build cgo
3-
// +build amd64 arm64 riscv64
4-
5-
package ffi
6-
7-
// #cgo linux LDFLAGS: ${SRCDIR}/libfilcrypto.a -Wl,-unresolved-symbols=ignore-all
8-
// #cgo darwin LDFLAGS: ${SRCDIR}/libfilcrypto.a -Wl,-undefined,dynamic_lookup
9-
// #cgo pkg-config: ${SRCDIR}/filcrypto.pc
10-
// #include "./filcrypto.h"
11-
import "C"
12-
import (
13-
"context"
14-
"fmt"
15-
gobig "math/big"
16-
"runtime"
17-
18-
"github.com/filecoin-project/filecoin-ffi/cgo"
19-
"github.com/filecoin-project/go-state-types/abi"
20-
"github.com/filecoin-project/go-state-types/big"
21-
"github.com/filecoin-project/go-state-types/network"
22-
"github.com/ipfs/go-cid"
23-
"golang.org/x/xerrors"
24-
)
25-
26-
type FVM struct {
27-
executor *cgo.FvmMachine
28-
}
29-
30-
const (
31-
applyExplicit = iota
32-
applyImplicit
33-
)
34-
35-
type FVMOpts struct {
36-
FVMVersion uint64
37-
Externs cgo.Externs
38-
39-
Epoch abi.ChainEpoch
40-
Timestamp uint64
41-
ChainID uint64
42-
BaseFee abi.TokenAmount
43-
BaseCircSupply abi.TokenAmount
44-
NetworkVersion network.Version
1+
//go:build cgo && (amd64 || arm64 || riscv64NetworkVersion network.Version
452
StateBase cid.Cid
46-
Manifest cid.Cid
473
Tracing bool
484

495
Debug bool
@@ -74,7 +30,6 @@ func CreateFVM(opts *FVMOpts) (*FVM, error) {
7430
baseCircSupplyLo,
7531
uint64(opts.NetworkVersion),
7632
cgo.AsSliceRefUint8(opts.StateBase.Bytes()),
77-
cgo.AsSliceRefUint8(opts.Manifest.Bytes()),
7833
opts.Tracing,
7934
exHandle, exHandle,
8035
)

rust/src/fvm/blockstore/fake.rs

Lines changed: 0 additions & 100 deletions
This file was deleted.

rust/src/fvm/blockstore/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
mod cgo;
2-
mod fake;
3-
mod overlay;
4-
52
pub use cgo::*;
6-
pub use fake::*;
7-
pub use overlay::*;

rust/src/fvm/blockstore/overlay.rs

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)