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

add interop net #4462

Merged
merged 1 commit into from
Jun 10, 2021
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
6 changes: 5 additions & 1 deletion cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var daemonCmd = &cmds.Command{
cmds.StringOption(GenesisFile, "path of file or HTTP(S) URL containing archive of genesis block DAG data"),
cmds.StringOption(PeerKeyFile, "path of file containing key to use for new node's libp2p identity"),
cmds.StringOption(WalletKeyFile, "path of file containing keys to import into the wallet on initialization"),
cmds.StringOption(Network, "when set, populates config with network specific parameters").WithDefault("testnetnet"),
cmds.StringOption(Network, "when set, populates config with network specific parameters, eg. 2k,nerpa,cali,interop,mainnet,testnetnet").WithDefault("testnetnet"),
cmds.StringOption(Password, "set wallet password"),
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
Expand Down Expand Up @@ -301,6 +301,8 @@ func setConfigFromOptions(cfg *config.Config, network string) error {
netcfg = networks.Net2k()
case "cali":
netcfg = networks.Calibration()
case "interop":
netcfg = networks.InteropNet()
default:
return fmt.Errorf("unknown network name %s", network)
}
Expand All @@ -327,6 +329,8 @@ func loadGenesis(ctx context.Context, rep repo.Repo, sourceName string, network
bs, err = asset.Asset("fixtures/_assets/car/nerpanet.car")
case "cali":
bs, err = asset.Asset("fixtures/_assets/car/calibnet.car")
case "interop":
bs, err = asset.Asset("fixtures/_assets/car/interopnet.car")
default:
bs, err = asset.Asset("fixtures/_assets/car/devnet.car")
}
Expand Down
Binary file added fixtures/_assets/car/interopnet.car
Binary file not shown.
209 changes: 131 additions & 78 deletions fixtures/asset/asset.go

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions fixtures/networks/interopnet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package networks

import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/venus/pkg/constants"

"github.com/filecoin-project/venus/pkg/config"
)

func InteropNet() *NetworkConf {
return &NetworkConf{
Bootstrap: config.BootstrapConfig{
Addresses: []string{
"/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWN86wA54r3v9M8bBYbc1vK9W1ehHDxVGPRaoeUYuXF8R7",
"/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWNZ41kev8mtBZgWe43qam1VX9pJyf87jnaisQP2urZZ2M",
},
MinPeerThreshold: 0,
Period: "30s",
},
Network: config.NetworkParamsConfig{
DevNet: true,
ReplaceProofTypes: []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg2KiBV1,
abi.RegisteredSealProof_StackedDrg8MiBV1,
abi.RegisteredSealProof_StackedDrg512MiBV1,
},
NetworkType: constants.NetworkInterop,
BlockDelay: 30,
ConsensusMinerMinPower: 2048,
ForkUpgradeParam: &config.ForkUpgradeConfig{
UpgradeBreezeHeight: -1,
UpgradeSmokeHeight: -1,
UpgradeIgnitionHeight: -2,
UpgradeRefuelHeight: -3,
UpgradeAssemblyHeight: -5,
UpgradeTapeHeight: -4,
UpgradeLiftoffHeight: -6,
UpgradeKumquatHeight: -7,
UpgradeCalicoHeight: -8,
UpgradePersianHeight: -9,
UpgradeOrangeHeight: -10,
UpgradeTrustHeight: -12,
UpgradeNorwegianHeight: -13,
UpgradeTurboHeight: -14,
UpgradeHyperdriveHeight: -15,

BreezeGasTampingDuration: 0,
UpgradeClausHeight: -11,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
PreCommitChallengeDelay: abi.ChainEpoch(10),
},
}
}
13 changes: 7 additions & 6 deletions pkg/consensus/proof_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package consensus

import (
"context"
"github.com/filecoin-project/venus/pkg/constants"

proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" // todo ref lotus
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
"github.com/filecoin-project/venus/pkg/constants"

address "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
"go.opencensus.io/trace"
Expand All @@ -17,9 +17,10 @@ import (

// Interface to PoSt verification, modify by force EPoStVerifier -> ProofVerifier
type ProofVerifier interface {
VerifySeal(info proof2.SealVerifyInfo) (bool, error)
VerifyWinningPoSt(ctx context.Context, info proof2.WinningPoStVerifyInfo) (bool, error)
VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error)
VerifySeal(info proof5.SealVerifyInfo) (bool, error)
VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error)
VerifyWinningPoSt(ctx context.Context, info proof5.WinningPoStVerifyInfo) (bool, error)
VerifyWindowPoSt(ctx context.Context, info proof5.WindowPoStVerifyInfo) (bool, error)
GenerateWinningPoStSectorChallenge(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, eligibleSectorCount uint64) ([]uint64, error)
}

Expand Down
14 changes: 9 additions & 5 deletions pkg/consensus/proof_verifier_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@ package consensus
import (
"context"

proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" // todo ref lotus

"github.com/filecoin-project/go-state-types/abi"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"

"github.com/filecoin-project/venus/pkg/util/ffiwrapper"
)

type genFakeVerifier struct{}

var _ ffiwrapper.Verifier = (*genFakeVerifier)(nil)

func (m genFakeVerifier) VerifySeal(svi proof2.SealVerifyInfo) (bool, error) {
func (m genFakeVerifier) VerifySeal(svi proof5.SealVerifyInfo) (bool, error) {
return true, nil
}

func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info proof2.WinningPoStVerifyInfo) (bool, error) {
func (m genFakeVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) {
panic("implement me")
}

func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info proof5.WinningPoStVerifyInfo) (bool, error) {
panic("not supported")
}

func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error) {
func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info proof5.WindowPoStVerifyInfo) (bool, error) {
panic("not supported")
}

Expand Down
1 change: 1 addition & 0 deletions pkg/constants/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ const (
NetworkDebug = 0x3
NetworkCalibnet = 0x4
NetworkNerpa = 0x5
NetworkInterop = 0x6
)
2 changes: 2 additions & 0 deletions pkg/migration/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func Version3Upgrade(repoPath string) error {
case constants.NetworkCalibnet:
fallthrough
case constants.NetworkNerpa:
fallthrough
case constants.NetworkInterop:
cfg.API.VenusAuthURL = ""
}

Expand Down
12 changes: 8 additions & 4 deletions pkg/util/ffiwrapper/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/runtime/proof"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
)

// FakeVerifier is a simple mock Verifier for testing.
Expand All @@ -13,15 +13,19 @@ type FakeVerifier struct {

var _ Verifier = (*FakeVerifier)(nil)

func (f *FakeVerifier) VerifySeal(proof.SealVerifyInfo) (bool, error) {
func (f *FakeVerifier) VerifySeal(proof5.SealVerifyInfo) (bool, error) {
return true, nil
}

func (f *FakeVerifier) VerifyWinningPoSt(context.Context, proof.WinningPoStVerifyInfo) (bool, error) {
func (f *FakeVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) {
return true, nil
}

func (f *FakeVerifier) VerifyWindowPoSt(context.Context, proof.WindowPoStVerifyInfo) (bool, error) {
func (f *FakeVerifier) VerifyWinningPoSt(context.Context, proof5.WinningPoStVerifyInfo) (bool, error) {
return true, nil
}

func (f *FakeVerifier) VerifyWindowPoSt(context.Context, proof5.WindowPoStVerifyInfo) (bool, error) {
return true, nil
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/util/ffiwrapper/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"

"github.com/filecoin-project/go-state-types/abi"
proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
"github.com/filecoin-project/specs-storage/storage"
"github.com/ipfs/go-cid"

Expand All @@ -27,9 +27,10 @@ type Storage interface {
}

type Verifier interface {
VerifySeal(proof2.SealVerifyInfo) (bool, error)
VerifyWinningPoSt(ctx context.Context, info proof2.WinningPoStVerifyInfo) (bool, error)
VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error)
VerifySeal(proof5.SealVerifyInfo) (bool, error)
VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error)
VerifyWinningPoSt(ctx context.Context, info proof5.WinningPoStVerifyInfo) (bool, error)
VerifyWindowPoSt(ctx context.Context, info proof5.WindowPoStVerifyInfo) (bool, error)

GenerateWinningPoStSectorChallenge(context.Context, abi.RegisteredPoStProof, abi.ActorID, abi.PoStRandomness, uint64) ([]uint64, error)
}
Expand Down
18 changes: 11 additions & 7 deletions pkg/util/ffiwrapper/verifier_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (

ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/go-state-types/abi"
proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
"github.com/filecoin-project/specs-storage/storage"
"go.opencensus.io/trace"
"golang.org/x/xerrors"

"github.com/filecoin-project/venus/pkg/util/storiface"
)

func (sb *Sealer) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof2.SectorInfo, randomness abi.PoStRandomness) ([]proof2.PoStProof, error) {
func (sb *Sealer) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof5.SectorInfo, randomness abi.PoStRandomness) ([]proof5.PoStProof, error) {
randomness[31] &= 0x3f
privsectors, skipped, done, err := sb.pubSectorToPriv(ctx, minerID, sectorInfo, nil, abi.RegisteredSealProof.RegisteredWinningPoStProof) // TODO: FAULTS?
if err != nil {
Expand All @@ -29,7 +29,7 @@ func (sb *Sealer) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID,
return ffi.GenerateWinningPoSt(minerID, privsectors, randomness)
}

func (sb *Sealer) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof2.SectorInfo, randomness abi.PoStRandomness) ([]proof2.PoStProof, []abi.SectorID, error) {
func (sb *Sealer) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof5.SectorInfo, randomness abi.PoStRandomness) ([]proof5.PoStProof, []abi.SectorID, error) {
randomness[31] &= 0x3f
privsectors, skipped, done, err := sb.pubSectorToPriv(ctx, minerID, sectorInfo, nil, abi.RegisteredSealProof.RegisteredWindowPoStProof)
if err != nil {
Expand All @@ -54,7 +54,7 @@ func (sb *Sealer) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, s
return proof, faultyIDs, err
}

func (sb *Sealer) pubSectorToPriv(ctx context.Context, mid abi.ActorID, sectorInfo []proof2.SectorInfo, faults []abi.SectorNumber, rpt func(abi.RegisteredSealProof) (abi.RegisteredPoStProof, error)) (ffi.SortedPrivateSectorInfo, []abi.SectorID, func(), error) {
func (sb *Sealer) pubSectorToPriv(ctx context.Context, mid abi.ActorID, sectorInfo []proof5.SectorInfo, faults []abi.SectorNumber, rpt func(abi.RegisteredSealProof) (abi.RegisteredPoStProof, error)) (ffi.SortedPrivateSectorInfo, []abi.SectorID, func(), error) {
fmap := map[abi.SectorNumber]struct{}{}
for _, fault := range faults {
fmap[fault] = struct{}{}
Expand Down Expand Up @@ -110,19 +110,23 @@ type proofVerifier struct{}

var ProofVerifier = proofVerifier{}

func (proofVerifier) VerifySeal(info proof2.SealVerifyInfo) (bool, error) {
func (proofVerifier) VerifySeal(info proof5.SealVerifyInfo) (bool, error) {
return ffi.VerifySeal(info)
}

func (proofVerifier) VerifyWinningPoSt(ctx context.Context, info proof2.WinningPoStVerifyInfo) (bool, error) {
func (verifier proofVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) {
return ffi.VerifyAggregateSeals(aggregate)
}

func (proofVerifier) VerifyWinningPoSt(ctx context.Context, info proof5.WinningPoStVerifyInfo) (bool, error) {
info.Randomness[31] &= 0x3f
_, span := trace.StartSpan(ctx, "VerifyWinningPoSt")
defer span.End()

return ffi.VerifyWinningPoSt(info)
}

func (proofVerifier) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error) {
func (proofVerifier) VerifyWindowPoSt(ctx context.Context, info proof5.WindowPoStVerifyInfo) (bool, error) {
info.Randomness[31] &= 0x3f
_, span := trace.StartSpan(ctx, "VerifyWindowPoSt")
defer span.End()
Expand Down
4 changes: 2 additions & 2 deletions pkg/vm/dispatch/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dispatch
import (
"github.com/filecoin-project/go-state-types/exitcode"
rtt "github.com/filecoin-project/go-state-types/rt"
"github.com/filecoin-project/specs-actors/actors/runtime"
rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime"
"github.com/ipfs/go-cid"
xerrors "github.com/pkg/errors"

Expand Down Expand Up @@ -69,7 +69,7 @@ func (b *CodeLoaderBuilder) Add(predict ActorPredicate, actor Actor) *CodeLoader
}

// Add lets you add an actor dispatch table for a given version.
func (b *CodeLoaderBuilder) AddMany(predict ActorPredicate, actors ...runtime.VMActor) *CodeLoaderBuilder {
func (b *CodeLoaderBuilder) AddMany(predict ActorPredicate, actors ...rt5.VMActor) *CodeLoaderBuilder {
for _, actor := range actors {
b.Add(predict, actor)
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package runtime

import (
"fmt"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/network"
"github.com/ipfs/go-cid"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/exitcode"
specsruntime "github.com/filecoin-project/specs-actors/actors/runtime"
rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime"
)

// Runtime has operations in the VM that are exposed to all actors.
Expand All @@ -27,15 +28,15 @@ type InvocationContext interface {
// Store is the raw store for IPLD objects.
//
// Note: this is required for custom data structures.
Store() specsruntime.Store
Store() rt5.Store
// Message contains information available to the actor about the executing message.
Message() specsruntime.Message
Message() rt5.Message
// ValidateCaller validates the caller against a patter.
//
// All actor methods MUST call this method before returning.
ValidateCaller(CallerPattern)
// StateHandle handles access to the actor state.
State() specsruntime.StateHandle
State() rt5.StateHandle
// Send allows actors to invoke methods on other actors
Send(toAddr address.Address, methodNum abi.MethodNum, params cbor.Marshaler, value abi.TokenAmount, out cbor.Er) exitcode.ExitCode
// Balance is the current balance on the current actors account.
Expand Down
6 changes: 3 additions & 3 deletions pkg/vm/vmcontext/actor_state_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package vmcontext
import (
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/exitcode"
specsruntime "github.com/filecoin-project/specs-actors/actors/runtime"
rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime"
"github.com/filecoin-project/venus/pkg/vm/runtime"
"github.com/ipfs/go-cid"
)
Expand Down Expand Up @@ -31,7 +31,7 @@ type actorStateHandleContext interface {
// NewActorStateHandle returns a new `ActorStateHandle`
//
// Note: just visible for testing.
func NewActorStateHandle(ctx actorStateHandleContext) specsruntime.StateHandle {
func NewActorStateHandle(ctx actorStateHandleContext) rt5.StateHandle {
aux := newActorStateHandle(ctx)
return &aux
}
Expand All @@ -44,7 +44,7 @@ func newActorStateHandle(ctx actorStateHandleContext) actorStateHandle {
}
}

var _ specsruntime.StateHandle = (*actorStateHandle)(nil)
var _ rt5.StateHandle = (*actorStateHandle)(nil)

func (h *actorStateHandle) StateCreate(obj cbor.Marshaler) {
// Store the new stateView.
Expand Down
8 changes: 4 additions & 4 deletions pkg/vm/vmcontext/actor_state_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/filecoin-project/venus/pkg/util"

"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/specs-actors/actors/runtime"
rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime"
"github.com/ipfs/go-cid"
"github.com/stretchr/testify/assert"

Expand Down Expand Up @@ -179,7 +179,7 @@ func TestActorStateHandle(t *testing.T) {
func TestActorStateHandleNilState(t *testing.T) {
tf.UnitTest(t)

setup := func() (runtime.StateHandle, func()) {
setup := func() (rt5.StateHandle, func()) {
store := vmcontext.NewTestStorage(nil)
ctx := fakeActorStateHandleContext{
store: store,
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestActorStateHandleNilState(t *testing.T) {
}

type fakeActorStateHandleContext struct {
store runtime.Store
store rt5.Store
head cid.Cid
allowSideEffects bool
}
Expand Down Expand Up @@ -263,7 +263,7 @@ func (ctx *fakeActorStateHandleContext) Replace(expected cid.Cid, obj cbor.Marsh

type testSetup struct {
initialstate testActorStateHandleState
h runtime.StateHandle
h rt5.StateHandle
cleanup func()
}

Expand Down
Loading