Skip to content

Commit

Permalink
chore: update the lotus to 1.25.0 (#1274)
Browse files Browse the repository at this point in the history
* Update lotus version to 1.25.0 for network version 21
  • Loading branch information
Terryhung authored Dec 6, 2023
1 parent 6050165 commit db73bf1
Show file tree
Hide file tree
Showing 28 changed files with 2,075 additions and 167 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ orbs:
executors:
dockerizer:
docker:
- image: cimg/go:1.19.12
- image: cimg/go:1.20.7
environment:
IMAGE_NAME: filecoin/lily
golang:
docker:
- image: cimg/go:1.19.12
- image: cimg/go:1.20.7

commands:
install-deps:
Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:
test:
resource_class: xlarge
docker:
- image: cimg/go:1.19.12
- image: cimg/go:1.20.7
- image: timescale/timescaledb:2.5.0-pg13
environment:
POSTGRES_PASSWORD: password
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
integration-test:
resource_class: large
docker:
- image: cimg/go:1.19.12
- image: cimg/go:1.20.7
- image: timescale/timescaledb:2.5.0-pg13
environment:
POSTGRES_PASSWORD: password
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL=/usr/bin/env bash

GO_BUILD_IMAGE?=golang:1.19.12
GO_BUILD_IMAGE?=golang:1.20.7
PG_IMAGE?=postgres:10
REDIS_IMAGE?=redis:6
LILY_IMAGE_NAME?=filecoin/lily
Expand Down
14 changes: 11 additions & 3 deletions chain/actors/builtin/datacap/datacap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
builtin12 "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/manifest"
"github.com/ipfs/go-cid"
Expand All @@ -17,8 +17,8 @@ import (
)

var (
Address = builtin11.DatacapActorAddr
Methods = builtin11.MethodsDatacap
Address = builtin12.DatacapActorAddr
Methods = builtin12.MethodsDatacap
)

func Load(store adt.Store, act *types.Actor) (State, error) {
Expand All @@ -38,6 +38,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
case actorstypes.Version11:
return load11(store, act.Head)

case actorstypes.Version12:
return load12(store, act.Head)

}
}

Expand All @@ -56,6 +59,9 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address
case actorstypes.Version11:
return make11(store, governor, bitwidth)

case actorstypes.Version12:
return make12(store, governor, bitwidth)

default:
return nil, xerrors.Errorf("datacap actor only valid for actors v9 and above, got %d", av)
}
Expand Down Expand Up @@ -83,6 +89,7 @@ func AllCodes() []cid.Cid {
(&state9{}).Code(),
(&state10{}).Code(),
(&state11{}).Code(),
(&state12{}).Code(),
}
}

Expand All @@ -91,5 +98,6 @@ func VersionCodes() map[actorstypes.Version]cid.Cid {
actorstypes.Version9: (&state9{}).Code(),
actorstypes.Version10: (&state10{}).Code(),
actorstypes.Version11: (&state11{}).Code(),
actorstypes.Version12: (&state12{}).Code(),
}
}
94 changes: 94 additions & 0 deletions chain/actors/builtin/datacap/v12.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package datacap

import (
"crypto/sha256"
"fmt"

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

actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/manifest"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"

datacap12 "github.com/filecoin-project/go-state-types/builtin/v12/datacap"
adt12 "github.com/filecoin-project/go-state-types/builtin/v12/util/adt"
)

var _ State = (*state12)(nil)

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

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

out.State = *s

return &out, nil
}

type state12 struct {
datacap12.State
store adt.Store
}

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

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

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

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

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

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

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

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

func (s *state12) ActorVersion() actorstypes.Version {
return actorstypes.Version12
}

func (s *state12) 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.

154 changes: 154 additions & 0 deletions chain/actors/builtin/init/v12.go

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

Loading

0 comments on commit db73bf1

Please sign in to comment.