Skip to content

Commit

Permalink
chore: upgrade the lotus to v1.32.0-rc1 for nv25 (#1329)
Browse files Browse the repository at this point in the history
* chore: upgrade the lotus to v1.31.0

* chore: upgrade lotus to v1.32.0-rc1

* chore: update the extern/filecon-ffi
  • Loading branch information
Terryhung authored Dec 13, 2024
1 parent 536300f commit 38317f5
Show file tree
Hide file tree
Showing 26 changed files with 2,057 additions and 106 deletions.
14 changes: 11 additions & 3 deletions chain/actors/builtin/datacap/datacap.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
builtin15 "github.com/filecoin-project/go-state-types/builtin"
builtin16 "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/manifest"

Expand All @@ -17,8 +17,8 @@ import (
)

var (
Address = builtin15.DatacapActorAddr
Methods = builtin15.MethodsDatacap
Address = builtin16.DatacapActorAddr
Methods = builtin16.MethodsDatacap
)

func Load(store adt.Store, act *types.Actor) (State, error) {
Expand Down Expand Up @@ -50,6 +50,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version15:
return load15(store, act.Head)

case actorstypes.Version16:
return load16(store, act.Head)

}
}

Expand Down Expand Up @@ -80,6 +83,9 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address
case actorstypes.Version15:
return make15(store, governor, bitwidth)

case actorstypes.Version16:
return make16(store, governor, bitwidth)

default:
return nil, xerrors.Errorf("datacap actor only valid for actors v9 and above, got %d", av)
}
Expand Down Expand Up @@ -111,6 +117,7 @@ func AllCodes() []cid.Cid {
(&state13{}).Code(),
(&state14{}).Code(),
(&state15{}).Code(),
(&state16{}).Code(),
}
}

Expand All @@ -123,5 +130,6 @@ func VersionCodes() map[actorstypes.Version]cid.Cid {
actorstypes.Version13: (&state13{}).Code(),
actorstypes.Version14: (&state14{}).Code(),
actorstypes.Version15: (&state15{}).Code(),
actorstypes.Version16: (&state16{}).Code(),
}
}
94 changes: 94 additions & 0 deletions chain/actors/builtin/datacap/v16.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package datacap

import (
"crypto/sha256"
"fmt"

"github.com/ipfs/go-cid"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
datacap16 "github.com/filecoin-project/go-state-types/builtin/v16/datacap"
adt16 "github.com/filecoin-project/go-state-types/builtin/v16/util/adt"
"github.com/filecoin-project/go-state-types/manifest"

"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
)

var _ State = (*state16)(nil)

func load16(store adt.Store, root cid.Cid) (State, error) {
out := state16{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}

func make16(store adt.Store, governor address.Address, bitwidth uint64) (State, error) {
out := state16{store: store}
s, err := datacap16.ConstructState(store, governor, bitwidth)
if err != nil {
return nil, err
}

out.State = *s

return &out, nil
}

type state16 struct {
datacap16.State
store adt.Store
}

func (s *state16) Governor() (address.Address, error) {
return s.State.Governor, nil
}

func (s *state16) GetState() interface{} {
return &s.State
}

func (s *state16) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
return forEachClient(s.store, actorstypes.Version16, s.VerifiedClients, cb)
}

func (s *state16) VerifiedClients() (adt.Map, error) {
return adt16.AsMap(s.store, s.Token.Balances, int(s.Token.HamtBitWidth))
}

func (s *state16) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
return getDataCap(s.store, actorstypes.Version16, s.VerifiedClients, addr)
}

func (s *state16) VerifiedClientsMapBitWidth() int {
return int(s.Token.HamtBitWidth)
}

func (s *state16) VerifiedClientsMapHashFunction() func(input []byte) []byte {
return func(input []byte) []byte {
res := sha256.Sum256(input)
return res[:]
}
}

func (s *state16) ActorKey() string {
return manifest.DatacapKey
}

func (s *state16) ActorVersion() actorstypes.Version {
return actorstypes.Version16
}

func (s *state16) Code() cid.Cid {
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
if !ok {
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
}

return code
}
14 changes: 11 additions & 3 deletions chain/actors/builtin/init/init.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

152 changes: 152 additions & 0 deletions chain/actors/builtin/init/v16.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions chain/actors/builtin/market/market.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 38317f5

Please sign in to comment.