diff --git a/pkg/vm/vmcontext/runtime_adapter.go b/pkg/vm/vmcontext/runtime_adapter.go index f52bf70340..2f01cb2c88 100644 --- a/pkg/vm/vmcontext/runtime_adapter.go +++ b/pkg/vm/vmcontext/runtime_adapter.go @@ -4,10 +4,6 @@ import ( "context" "fmt" - "github.com/filecoin-project/venus/venus-shared/actors/aerrors" - - "github.com/filecoin-project/venus/venus-shared/actors/builtin" - "github.com/ipfs/go-cid" cbor2 "github.com/ipfs/go-ipld-cbor" logging "github.com/ipfs/go-log/v2" @@ -21,9 +17,17 @@ import ( "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/rt" rt0 "github.com/filecoin-project/specs-actors/actors/runtime" + rt2 "github.com/filecoin-project/specs-actors/v2/actors/runtime" + rt3 "github.com/filecoin-project/specs-actors/v3/actors/runtime" + rt4 "github.com/filecoin-project/specs-actors/v4/actors/runtime" rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime" + rt6 "github.com/filecoin-project/specs-actors/v6/actors/runtime" + rt7 "github.com/filecoin-project/specs-actors/v7/actors/runtime" + "github.com/filecoin-project/venus/pkg/vm/gas" "github.com/filecoin-project/venus/pkg/vm/runtime" + "github.com/filecoin-project/venus/venus-shared/actors/aerrors" + "github.com/filecoin-project/venus/venus-shared/actors/builtin" "github.com/filecoin-project/venus/venus-shared/types" ) @@ -41,8 +45,13 @@ func init() { var actorLog = logging.Logger("vm.actors") -var _ rt5.Runtime = (*runtimeAdapter)(nil) var _ rt0.Runtime = (*runtimeAdapter)(nil) +var _ rt2.Runtime = (*runtimeAdapter)(nil) +var _ rt3.Runtime = (*runtimeAdapter)(nil) +var _ rt4.Runtime = (*runtimeAdapter)(nil) +var _ rt5.Runtime = (*runtimeAdapter)(nil) +var _ rt6.Runtime = (*runtimeAdapter)(nil) +var _ rt7.Runtime = (*runtimeAdapter)(nil) type runtimeAdapter struct { ctx *invocationContext diff --git a/pkg/vm/vmcontext/syscalls.go b/pkg/vm/vmcontext/syscalls.go index f7576b443a..e3ca994c94 100644 --- a/pkg/vm/vmcontext/syscalls.go +++ b/pkg/vm/vmcontext/syscalls.go @@ -10,8 +10,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" - rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" + rt7 "github.com/filecoin-project/specs-actors/v7/actors/runtime" + proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" "github.com/ipfs/go-cid" "github.com/filecoin-project/venus/pkg/crypto" @@ -32,12 +32,13 @@ type SyscallsStateView interface { type SyscallsImpl interface { VerifySignature(ctx context.Context, view SyscallsStateView, signature crypto.Signature, signer address.Address, plaintext []byte) error HashBlake2b(data []byte) [32]byte - ComputeUnsealedSectorCID(ctx context.Context, proof5 abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error) - VerifySeal(ctx context.Context, info proof5.SealVerifyInfo) error - BatchVerifySeals(ctx context.Context, vis map[address.Address][]proof5.SealVerifyInfo) (map[address.Address][]bool, error) - VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) error - VerifyPoSt(ctx context.Context, info proof5.WindowPoStVerifyInfo) error - VerifyConsensusFault(ctx context.Context, h1, h2, extra []byte, curEpoch abi.ChainEpoch, msg VmMessage, gasIpld cbornode.IpldStore, view SyscallsStateView, getter LookbackStateGetter) (*rt5.ConsensusFault, error) + ComputeUnsealedSectorCID(ctx context.Context, proof7 abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error) + VerifySeal(ctx context.Context, info proof7.SealVerifyInfo) error + BatchVerifySeals(ctx context.Context, vis map[address.Address][]proof7.SealVerifyInfo) (map[address.Address][]bool, error) + VerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) error + VerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) error + VerifyPoSt(ctx context.Context, info proof7.WindowPoStVerifyInfo) error + VerifyConsensusFault(ctx context.Context, h1, h2, extra []byte, curEpoch abi.ChainEpoch, msg VmMessage, gasIpld cbornode.IpldStore, view SyscallsStateView, getter LookbackStateGetter) (*rt7.ConsensusFault, error) } type syscalls struct { @@ -50,7 +51,7 @@ type syscalls struct { stateView SyscallsStateView } -var _ rt5.Syscalls = (*syscalls)(nil) +var _ rt7.Syscalls = (*syscalls)(nil) func (sys syscalls) VerifySignature(signature crypto.Signature, signer address.Address, plaintext []byte) error { charge, err := sys.pricelist.OnVerifySignature(signature.Type, len(plaintext)) @@ -71,24 +72,24 @@ func (sys syscalls) ComputeUnsealedSectorCID(proof abi.RegisteredSealProof, piec return sys.impl.ComputeUnsealedSectorCID(sys.vm.context, proof, pieces) } -func (sys syscalls) VerifySeal(info proof5.SealVerifyInfo) error { +func (sys syscalls) VerifySeal(info proof7.SealVerifyInfo) error { sys.gasTank.Charge(sys.pricelist.OnVerifySeal(info), "VerifySeal") return sys.impl.VerifySeal(sys.vm.context, info) } -func (sys syscalls) VerifyPoSt(info proof5.WindowPoStVerifyInfo) error { +func (sys syscalls) VerifyPoSt(info proof7.WindowPoStVerifyInfo) error { sys.gasTank.Charge(sys.pricelist.OnVerifyPost(info), "VerifyWindowPoSt") return sys.impl.VerifyPoSt(sys.vm.context, info) } -func (sys syscalls) VerifyConsensusFault(h1, h2, extra []byte) (*rt5.ConsensusFault, error) { +func (sys syscalls) VerifyConsensusFault(h1, h2, extra []byte) (*rt7.ConsensusFault, error) { sys.gasTank.Charge(sys.pricelist.OnVerifyConsensusFault(), "VerifyConsensusFault") return sys.impl.VerifyConsensusFault(sys.vm.context, h1, h2, extra, sys.vm.currentEpoch, sys.vmMsg, sys.gasBlockStore, sys.stateView, sys.vm.vmOption.LookbackStateGetter) } var BatchSealVerifyParallelism = 2 * goruntime.NumCPU() -func (sys syscalls) BatchVerifySeals(vis map[address.Address][]proof5.SealVerifyInfo) (map[address.Address][]bool, error) { +func (sys syscalls) BatchVerifySeals(vis map[address.Address][]proof7.SealVerifyInfo) (map[address.Address][]bool, error) { out := make(map[address.Address][]bool) sema := make(chan struct{}, BatchSealVerifyParallelism) @@ -100,7 +101,7 @@ func (sys syscalls) BatchVerifySeals(vis map[address.Address][]proof5.SealVerify for i, s := range seals { wg.Add(1) - go func(ma address.Address, ix int, svi proof5.SealVerifyInfo, res []bool) { + go func(ma address.Address, ix int, svi proof7.SealVerifyInfo, res []bool) { defer wg.Done() sema <- struct{}{} @@ -120,7 +121,12 @@ func (sys syscalls) BatchVerifySeals(vis map[address.Address][]proof5.SealVerify return out, nil } -func (sys *syscalls) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) error { +func (sys *syscalls) VerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) error { sys.gasTank.Charge(sys.pricelist.OnVerifyAggregateSeals(aggregate), "VerifyAggregateSeals") return sys.impl.VerifyAggregateSeals(aggregate) } + +func (sys *syscalls) VerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) error { + sys.gasTank.Charge(sys.pricelist.OnVerifyReplicaUpdate(update), "OnVerifyReplicaUpdate") + return sys.impl.VerifyReplicaUpdate(update) +} diff --git a/tools/gengen/util/generator.go b/tools/gengen/util/generator.go index 39717a8019..9dd19f3887 100644 --- a/tools/gengen/util/generator.go +++ b/tools/gengen/util/generator.go @@ -84,7 +84,7 @@ func NewGenesisGenerator(bs blockstore.Blockstore) *GenesisGenerator { vmOption := vm.VmOption{ CircSupplyCalculator: csc, - NetworkVersion: network.Version15, + NetworkVersion: network.Version6, LookbackStateGetter: vmcontext.LookbackStateGetterForTipset(context.TODO(), chainStore, chainFork, nil), Rnd: chainRand, BaseFee: abi.NewTokenAmount(InitialBaseFee),