Skip to content

Commit

Permalink
Integrate verifreg changes to lotus
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Sep 21, 2022
1 parent 37be576 commit dc20122
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 6 deletions.
2 changes: 1 addition & 1 deletion chain/actors/builtin/verifreg/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ type State interface {
cbor.Marshaler

RootKey() (address.Address, error)
VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error)
VerifierDataCap(address.Address) (bool, abi.StoragePower, error)
RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error)
ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error
VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error)
ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error
GetState() interface{}
}
16 changes: 16 additions & 0 deletions chain/actors/builtin/verifreg/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import (
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt"
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{if (ge .v 9)}}
"github.com/filecoin-project/go-state-types/big"
"golang.org/x/xerrors"
{{end}}
)

var _ State = (*state{{.v}})(nil)
Expand Down Expand Up @@ -62,7 +66,11 @@ func (s *state{{.v}}) RootKey() (address.Address, error) {
}

func (s *state{{.v}}) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
{{if (le .v 8)}}
return getDataCap(s.store, actors.Version{{.v}}, s.verifiedClients, addr)
{{else}}
return false, big.Zero(), xerrors.Errorf("unsupported in actors v{{.v}}")
{{end}}
}

func (s *state{{.v}}) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -78,11 +86,19 @@ func (s *state{{.v}}) ForEachVerifier(cb func(addr address.Address, dcap abi.Sto
}

func (s *state{{.v}}) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
{{if (le .v 8)}}
return forEachCap(s.store, actors.Version{{.v}}, s.verifiedClients, cb)
{{else}}
return xerrors.Errorf("unsupported in actors v{{.v}}")
{{end}}
}

func (s *state{{.v}}) verifiedClients() (adt.Map, error) {
{{if (le .v 8)}}
return adt{{.v}}.AsMap(s.store, s.VerifiedClients{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
{{else}}
return nil, xerrors.Errorf("unsupported in actors v{{.v}}")
{{end}}
}

func (s *state{{.v}}) verifiers() (adt.Map, error) {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/verifreg/v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func (s *state0) RootKey() (address.Address, error) {
}

func (s *state0) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {

return getDataCap(s.store, actors.Version0, s.verifiedClients, addr)

}

func (s *state0) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -62,11 +64,15 @@ func (s *state0) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state0) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {

return forEachCap(s.store, actors.Version0, s.verifiedClients, cb)

}

func (s *state0) verifiedClients() (adt.Map, error) {

return adt0.AsMap(s.store, s.VerifiedClients)

}

func (s *state0) verifiers() (adt.Map, error) {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/verifreg/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func (s *state2) RootKey() (address.Address, error) {
}

func (s *state2) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {

return getDataCap(s.store, actors.Version2, s.verifiedClients, addr)

}

func (s *state2) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -62,11 +64,15 @@ func (s *state2) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state2) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {

return forEachCap(s.store, actors.Version2, s.verifiedClients, cb)

}

func (s *state2) verifiedClients() (adt.Map, error) {

return adt2.AsMap(s.store, s.VerifiedClients)

}

func (s *state2) verifiers() (adt.Map, error) {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/verifreg/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func (s *state3) RootKey() (address.Address, error) {
}

func (s *state3) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {

return getDataCap(s.store, actors.Version3, s.verifiedClients, addr)

}

func (s *state3) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -63,11 +65,15 @@ func (s *state3) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state3) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {

return forEachCap(s.store, actors.Version3, s.verifiedClients, cb)

}

func (s *state3) verifiedClients() (adt.Map, error) {

return adt3.AsMap(s.store, s.VerifiedClients, builtin3.DefaultHamtBitwidth)

}

func (s *state3) verifiers() (adt.Map, error) {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/verifreg/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func (s *state4) RootKey() (address.Address, error) {
}

func (s *state4) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {

return getDataCap(s.store, actors.Version4, s.verifiedClients, addr)

}

func (s *state4) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -63,11 +65,15 @@ func (s *state4) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state4) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {

return forEachCap(s.store, actors.Version4, s.verifiedClients, cb)

}

func (s *state4) verifiedClients() (adt.Map, error) {

return adt4.AsMap(s.store, s.VerifiedClients, builtin4.DefaultHamtBitwidth)

}

func (s *state4) verifiers() (adt.Map, error) {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/verifreg/v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func (s *state5) RootKey() (address.Address, error) {
}

func (s *state5) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {

return getDataCap(s.store, actors.Version5, s.verifiedClients, addr)

}

func (s *state5) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -63,11 +65,15 @@ func (s *state5) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state5) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {

return forEachCap(s.store, actors.Version5, s.verifiedClients, cb)

}

func (s *state5) verifiedClients() (adt.Map, error) {

return adt5.AsMap(s.store, s.VerifiedClients, builtin5.DefaultHamtBitwidth)

}

func (s *state5) verifiers() (adt.Map, error) {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/verifreg/v6.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func (s *state6) RootKey() (address.Address, error) {
}

func (s *state6) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {

return getDataCap(s.store, actors.Version6, s.verifiedClients, addr)

}

func (s *state6) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -63,11 +65,15 @@ func (s *state6) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state6) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {

return forEachCap(s.store, actors.Version6, s.verifiedClients, cb)

}

func (s *state6) verifiedClients() (adt.Map, error) {

return adt6.AsMap(s.store, s.VerifiedClients, builtin6.DefaultHamtBitwidth)

}

func (s *state6) verifiers() (adt.Map, error) {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/verifreg/v7.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func (s *state7) RootKey() (address.Address, error) {
}

func (s *state7) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {

return getDataCap(s.store, actors.Version7, s.verifiedClients, addr)

}

func (s *state7) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -63,11 +65,15 @@ func (s *state7) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state7) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {

return forEachCap(s.store, actors.Version7, s.verifiedClients, cb)

}

func (s *state7) verifiedClients() (adt.Map, error) {

return adt7.AsMap(s.store, s.VerifiedClients, builtin7.DefaultHamtBitwidth)

}

func (s *state7) verifiers() (adt.Map, error) {
Expand Down
6 changes: 6 additions & 0 deletions chain/actors/builtin/verifreg/v8.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func (s *state8) RootKey() (address.Address, error) {
}

func (s *state8) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {

return getDataCap(s.store, actors.Version8, s.verifiedClients, addr)

}

func (s *state8) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -63,11 +65,15 @@ func (s *state8) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state8) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {

return forEachCap(s.store, actors.Version8, s.verifiedClients, cb)

}

func (s *state8) verifiedClients() (adt.Map, error) {

return adt8.AsMap(s.store, s.VerifiedClients, builtin8.DefaultHamtBitwidth)

}

func (s *state8) verifiers() (adt.Map, error) {
Expand Down
14 changes: 11 additions & 3 deletions chain/actors/builtin/verifreg/v9.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package verifreg

import (
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
Expand Down Expand Up @@ -47,7 +49,9 @@ func (s *state9) RootKey() (address.Address, error) {
}

func (s *state9) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
return getDataCap(s.store, actors.Version9, s.verifiedClients, addr)

return false, big.Zero(), xerrors.Errorf("unsupported in actors v9")

}

func (s *state9) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
Expand All @@ -63,11 +67,15 @@ func (s *state9) ForEachVerifier(cb func(addr address.Address, dcap abi.StorageP
}

func (s *state9) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
return forEachCap(s.store, actors.Version9, s.verifiedClients, cb)

return xerrors.Errorf("unsupported in actors v9")

}

func (s *state9) verifiedClients() (adt.Map, error) {
return adt9.AsMap(s.store, s.VerifiedClients, builtin9.DefaultHamtBitwidth)

return nil, xerrors.Errorf("unsupported in actors v9")

}

func (s *state9) verifiers() (adt.Map, error) {
Expand Down
2 changes: 1 addition & 1 deletion chain/actors/builtin/verifreg/verifreg.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ type State interface {
cbor.Marshaler

RootKey() (address.Address, error)
VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error)
VerifierDataCap(address.Address) (bool, abi.StoragePower, error)
RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error)
ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error
VerifiedClientDataCap(address.Address) (bool, abi.StoragePower, error)
ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error
GetState() interface{}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ require (
github.com/filecoin-project/go-legs v0.4.4
github.com/filecoin-project/go-padreader v0.0.1
github.com/filecoin-project/go-paramfetch v0.0.4
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220921193302-60676bda3cb5
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220921200345-ad0c1bea9940
github.com/filecoin-project/go-statemachine v1.0.2
github.com/filecoin-project/go-statestore v0.2.0
github.com/filecoin-project/go-storedcounter v0.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220921193302-60676bda3cb5 h1:5FCdArFQ/nzsv2vBJ7ibLnocTf+pnnTVxcF0Ohe97O0=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220921193302-60676bda3cb5/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220921200345-ad0c1bea9940 h1:BSr7qqJkxBJI66H9hd09tJNtYSEuEkSSH81/+5wbp2I=
github.com/filecoin-project/go-state-types v0.1.12-beta.0.20220921200345-ad0c1bea9940/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
Expand Down

0 comments on commit dc20122

Please sign in to comment.