diff --git a/chain/actor.go b/chain/actor.go index 44aa39001..9bce56af1 100644 --- a/chain/actor.go +++ b/chain/actor.go @@ -205,10 +205,11 @@ type TypedActorExtractorMap struct { // Simplistic for now, will need to make into a slice when we have more actor versions CodeV1 cid.Cid CodeV2 cid.Cid + CodeV3 cid.Cid } func (t *TypedActorExtractorMap) Allow(code cid.Cid) bool { - return code == t.CodeV1 || code == t.CodeV2 + return code == t.CodeV1 || code == t.CodeV2 || code == t.CodeV3 } func (t *TypedActorExtractorMap) GetExtractor(code cid.Cid) (actorstate.ActorStateExtractor, bool) { diff --git a/chain/indexer.go b/chain/indexer.go index 6be663bc8..2cfb5b886 100644 --- a/chain/indexer.go +++ b/chain/indexer.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" logging "github.com/ipfs/go-log/v2" "go.opencensus.io/stats" "go.opencensus.io/tag" @@ -79,31 +80,37 @@ func NewTipSetIndexer(o lens.APIOpener, d model.Storage, window time.Duration, n tsi.actorProcessors[ActorStatesPowerTask] = NewActorStateProcessor(o, &TypedActorExtractorMap{ CodeV1: sa0builtin.StoragePowerActorCodeID, CodeV2: sa2builtin.StoragePowerActorCodeID, + CodeV3: sa3builtin.StoragePowerActorCodeID, }) case ActorStatesRewardTask: tsi.actorProcessors[ActorStatesRewardTask] = NewActorStateProcessor(o, &TypedActorExtractorMap{ CodeV1: sa0builtin.RewardActorCodeID, CodeV2: sa2builtin.RewardActorCodeID, + CodeV3: sa3builtin.RewardActorCodeID, }) case ActorStatesMinerTask: tsi.actorProcessors[ActorStatesMinerTask] = NewActorStateProcessor(o, &TypedActorExtractorMap{ CodeV1: sa0builtin.StorageMinerActorCodeID, CodeV2: sa2builtin.StorageMinerActorCodeID, + CodeV3: sa3builtin.StorageMinerActorCodeID, }) case ActorStatesInitTask: tsi.actorProcessors[ActorStatesInitTask] = NewActorStateProcessor(o, &TypedActorExtractorMap{ CodeV1: sa0builtin.InitActorCodeID, CodeV2: sa2builtin.InitActorCodeID, + CodeV3: sa3builtin.InitActorCodeID, }) case ActorStatesMarketTask: tsi.actorProcessors[ActorStatesMarketTask] = NewActorStateProcessor(o, &TypedActorExtractorMap{ CodeV1: sa0builtin.StorageMarketActorCodeID, CodeV2: sa2builtin.StorageMarketActorCodeID, + CodeV3: sa3builtin.StorageMarketActorCodeID, }) case ActorStatesMultisigTask: tsi.actorProcessors[ActorStatesMultisigTask] = NewActorStateProcessor(o, &TypedActorExtractorMap{ CodeV1: sa0builtin.MultisigActorCodeID, CodeV2: sa2builtin.MultisigActorCodeID, + CodeV3: sa3builtin.MultisigActorCodeID, }) default: return nil, xerrors.Errorf("unknown task: %s", task) diff --git a/extern/filecoin-ffi-stub/bls.go b/extern/filecoin-ffi-stub/bls.go new file mode 100644 index 000000000..602b492cb --- /dev/null +++ b/extern/filecoin-ffi-stub/bls.go @@ -0,0 +1,39 @@ +package ffi + +func Hash(message Message) Digest { + return Digest{} +} + +func Verify(signature *Signature, digests []Digest, publicKeys []PublicKey) bool { + return true +} + +func HashVerify(signature *Signature, messages []Message, publicKeys []PublicKey) bool { + return true +} + +func Aggregate(signatures []Signature) *Signature { + var s Signature + return &s +} + +func PrivateKeyGenerate() PrivateKey { + return PrivateKey{} +} + +func PrivateKeyGenerateWithSeed(seed PrivateKeyGenSeed) PrivateKey { + return PrivateKey{} +} + +func PrivateKeySign(privateKey PrivateKey, message Message) *Signature { + var s Signature + return &s +} + +func PrivateKeyPublicKey(privateKey PrivateKey) PublicKey { + return PublicKey{} +} + +func CreateZeroSignature() Signature { + return Signature{} +} diff --git a/extern/filecoin-ffi-stub/go.sum b/extern/filecoin-ffi-stub/go.sum new file mode 100644 index 000000000..655f2e372 --- /dev/null +++ b/extern/filecoin-ffi-stub/go.sum @@ -0,0 +1,140 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8= +github.com/filecoin-project/go-amt-ipld/v2 v2.1.0/go.mod h1:nfFPoGyX0CU9SkXX8EoCcSuHN1XcbN0c6KBh7yvP5fs= +github.com/filecoin-project/go-bitfield v0.2.0/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM= +github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= +github.com/filecoin-project/go-state-types v0.0.0-20200904021452-1883f36ca2f4 h1:EG5midq073Dk3b1hgkjE/blVA2z9G7INKppmT5ZeCOs= +github.com/filecoin-project/go-state-types v0.0.0-20200904021452-1883f36ca2f4/go.mod h1:IQ0MBPnonv35CJHtWSN3YY1Hz2gkPru1Q9qoaYLxx9I= +github.com/filecoin-project/specs-actors v0.9.4 h1:FePB+hrctHHiTbmaY4hnvBJzfgckN3eJreUZWpS5yks= +github.com/filecoin-project/specs-actors v0.9.4/go.mod h1:BStZQzx5x7TmCkLv0Bpa07U6cPKol6fd3w9KjMPZ6Z4= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU= +github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= +github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= +github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= +github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= +github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= +github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog= +github.com/ipfs/go-cid v0.0.6-0.20200501230655-7c82f3b81c00/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog= +github.com/ipfs/go-cid v0.0.6/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= +github.com/ipfs/go-cid v0.0.7 h1:ysQJVJA3fNDF1qigJbsSQOdjhVLsOEoPdh0+R97k3jY= +github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= +github.com/ipfs/go-hamt-ipld v0.1.1/go.mod h1:1EZCr2v0jlCnhpa+aZ0JZYp8Tt2w16+JJOAVz17YcDk= +github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc= +github.com/ipfs/go-ipld-cbor v0.0.4/go.mod h1:BkCduEx3XBCO6t2Sfo5BaHzuok7hbhdMm9Oh8B2Ftq4= +github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dCDnkOJhcZkms= +github.com/ipfs/go-ipld-format v0.0.2/go.mod h1:4B6+FM2u9OJ9zCV+kSbgFAZlOrv1Hqbf0INGQgiKf9k= +github.com/ipfs/go-log v1.0.4/go.mod h1:oDCg2FkjogeFOhqqb+N39l2RpTNPL6F/StPkB3kPgcs= +github.com/ipfs/go-log/v2 v2.0.5/go.mod h1:eZs4Xt4ZUJQFM3DlanGhy7TkwwawCZcSByscwkWG+dw= +github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52/go.mod h1:fdg+/X9Gg4AsAIzWpEHwnqd+QY3b7lajxyjE1m4hkq4= +github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g= +github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= +github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= +github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= +github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU= +github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= +github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= +github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc= +github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= +github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= +github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= +github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= +github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= +github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs= +github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk= +github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= +github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= +github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= +github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= +github.com/multiformats/go-multihash v0.0.14 h1:QoBceQYQQtNUuf6s7wHxnE2c8bhbMqhfGzNI032se/I= +github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= +github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg= +github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/polydawn/refmt v0.0.0-20190809202753-05966cbd336a/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= +github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa/go.mod h1:2RVY1rIf+2J2o/IM9+vPq9RzmHDSseB7FoXiSNIUsoU= +github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= +github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= +github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= +github.com/whyrusleeping/cbor-gen v0.0.0-20200414195334-429a0b5e922e/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= +github.com/whyrusleeping/cbor-gen v0.0.0-20200504204219-64967432584d/go.mod h1:W5MvapuoHRP8rz4vxjwCK1pDqF1aQcWsV5PZ+AHbqdg= +github.com/whyrusleeping/cbor-gen v0.0.0-20200715143311-227fab5a2377/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/cbor-gen v0.0.0-20200810223238-211df3b9e24c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/cbor-gen v0.0.0-20200812213548-958ddffe352c h1:otRnI08JoahNBxUFqX3372Ab9GnTj8L5J9iP5ImyxGU= +github.com/whyrusleeping/cbor-gen v0.0.0-20200812213548-958ddffe352c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/xorcare/golden v0.6.0/go.mod h1:7T39/ZMvaSEZlBPoYfVFmsBLmUl3uz9IuzWj/U6FtvQ= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= +golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU= +golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSFqbNiQZpcgJQAgJsK6k= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/extern/filecoin-ffi-stub/types.go b/extern/filecoin-ffi-stub/types.go new file mode 100644 index 000000000..5eacc69ff --- /dev/null +++ b/extern/filecoin-ffi-stub/types.go @@ -0,0 +1,31 @@ +package ffi + +// SignatureBytes is the length of a BLS signature +const SignatureBytes = 96 + +// PrivateKeyBytes is the length of a BLS private key +const PrivateKeyBytes = 32 + +// PublicKeyBytes is the length of a BLS public key +const PublicKeyBytes = 48 + +// DigestBytes is the length of a BLS message hash/digest +const DigestBytes = 96 + +// Signature is a compressed affine +type Signature [SignatureBytes]byte + +// PrivateKey is a compressed affine +type PrivateKey [PrivateKeyBytes]byte + +// PublicKey is a compressed affine +type PublicKey [PublicKeyBytes]byte + +// Message is a byte slice +type Message []byte + +// Digest is a compressed affine +type Digest [DigestBytes]byte + +// Used when generating a private key deterministically +type PrivateKeyGenSeed [32]byte diff --git a/go.mod b/go.mod index 8c11b805c..01335b952 100644 --- a/go.mod +++ b/go.mod @@ -9,12 +9,13 @@ require ( github.com/fatih/color v1.10.0 // indirect github.com/filecoin-project/go-address v0.0.5-0.20201103152444-f2023ef3f5bb github.com/filecoin-project/go-bitfield v0.2.3-0.20201110211213-fe2c1862e816 - github.com/filecoin-project/go-fil-markets v1.0.10 + github.com/filecoin-project/go-fil-markets v1.1.2 github.com/filecoin-project/go-multistore v0.0.3 - github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc - github.com/filecoin-project/lotus v1.4.1-pre1.0.20210114132837-5453e70cabb9 + github.com/filecoin-project/go-state-types v0.0.0-20210119062722-4adba5aaea71 + github.com/filecoin-project/lotus v1.5.0-pre1 github.com/filecoin-project/specs-actors v0.9.13 - github.com/filecoin-project/specs-actors/v2 v2.3.3 + github.com/filecoin-project/specs-actors/v2 v2.3.4 + github.com/filecoin-project/specs-actors/v3 v3.0.1-0.20210122191213-c7ea99141c44 github.com/filecoin-project/statediff v0.0.8-0.20201027195725-7eaa5391a639 github.com/go-pg/migrations/v8 v8.0.1 github.com/go-pg/pg/v10 v10.3.1 diff --git a/go.sum b/go.sum index 89ccedfee..ff7821b2e 100644 --- a/go.sum +++ b/go.sum @@ -139,6 +139,7 @@ github.com/cheggaaa/pb/v3 v3.0.5/go.mod h1:X1L61/+36nz9bjIsrDU52qHKOQukUQe2Ge+Yv github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -152,6 +153,8 @@ github.com/cockroachdb/pebble v0.0.0-20201001221639-879f3bfeef07/go.mod h1:hU7vh github.com/cockroachdb/redact v0.0.0-20200622112456-cd282804bbd3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327 h1:7grrpcfCtbZLsjtB0DgMuzs1umsJmpzaHMZ6cO6iAWw= +github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -164,6 +167,8 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= +github.com/coreos/go-systemd/v22 v22.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg= +github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -253,6 +258,8 @@ github.com/filecoin-project/go-address v0.0.5-0.20201103152444-f2023ef3f5bb/go.m github.com/filecoin-project/go-amt-ipld/v2 v2.1.0/go.mod h1:nfFPoGyX0CU9SkXX8EoCcSuHN1XcbN0c6KBh7yvP5fs= github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349 h1:pIuR0dnMD0i+as8wNnjjHyQrnhP5O5bmba/lmgQeRgU= github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349/go.mod h1:vgmwKBkx+ca5OIeEvstiQgzAZnb7R6QaqE1oEDSqa6g= +github.com/filecoin-project/go-amt-ipld/v3 v3.0.0 h1:Ou/q82QeHGOhpkedvaxxzpBYuqTxLCcj5OChkDNx4qc= +github.com/filecoin-project/go-amt-ipld/v3 v3.0.0/go.mod h1:Qa95YNAbtoVCTSVtX38aAC1ptBnJfPma1R/zZsKmx4o= github.com/filecoin-project/go-bitfield v0.2.0/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM= github.com/filecoin-project/go-bitfield v0.2.1/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM= github.com/filecoin-project/go-bitfield v0.2.3-0.20201110211213-fe2c1862e816 h1:RMdzMqe3mu2Z/3N3b9UEfkbGZxukstmZgNC024ybWhA= @@ -265,8 +272,8 @@ github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 h1:2pMX github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= github.com/filecoin-project/go-data-transfer v0.6.7/go.mod h1:C++k1U6+jMQODOaen5OPDo9XQbth9Yq3ie94vNjBJbk= github.com/filecoin-project/go-data-transfer v1.0.1/go.mod h1:UxvfUAY9v3ub0a21BSK9u3pB2aq30Y0KMsG+w9/ysyo= -github.com/filecoin-project/go-data-transfer v1.2.3 h1:rM/HgGOOMsKvmeQjY7CVR3v7Orxf04LJSSczSpGlhg4= -github.com/filecoin-project/go-data-transfer v1.2.3/go.mod h1:ZAH51JZFR8NZC4FPiDPG+swjgui0q6zTMJbztc6pHhY= +github.com/filecoin-project/go-data-transfer v1.2.7 h1:WE5Cpp9eMt5BDoWOVR64QegSn6bwHQaDzyyjVU377Y0= +github.com/filecoin-project/go-data-transfer v1.2.7/go.mod h1:mvjZ+C3NkBX10JP4JMu27DCjUouHFjHwUGh+Xc4yvDA= github.com/filecoin-project/go-ds-versioning v0.1.0 h1:y/X6UksYTsK8TLCI7rttCKEvl8btmWxyFMEeeWGUxIQ= github.com/filecoin-project/go-ds-versioning v0.1.0/go.mod h1:mp16rb4i2QPmxBnmanUx8i/XANp+PFCCJWiAb+VW4/s= github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= @@ -274,12 +281,14 @@ github.com/filecoin-project/go-fil-commcid v0.0.0-20201016201715-d41df56b4f6a h1 github.com/filecoin-project/go-fil-commcid v0.0.0-20201016201715-d41df56b4f6a/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= github.com/filecoin-project/go-fil-markets v0.7.0/go.mod h1:5Pt4DXQqUoUrp9QzlSdlYTpItXxwAtqKrxRWQ6hAOqk= github.com/filecoin-project/go-fil-markets v1.0.5-0.20201113164554-c5eba40d5335/go.mod h1:AJySOJC00JRWEZzRG2KsfUnqEf5ITXxeX09BE9N4f9c= -github.com/filecoin-project/go-fil-markets v1.0.10 h1:1QunPsgApTLNXVlaXoPMxyrMtOsMLPOQq3RUjGRmgVI= -github.com/filecoin-project/go-fil-markets v1.0.10/go.mod h1:tcXby9CsTNuHu19dH05YZ5pNDsoYcQXSrbkxzVeMJrY= +github.com/filecoin-project/go-fil-markets v1.1.2 h1:5FVdDmF9GvW6Xllql9OGiJXEZjh/tu590BXSQH2W/vU= +github.com/filecoin-project/go-fil-markets v1.1.2/go.mod h1:6oTRaAsHnCqhi3mpZqdvnWIzH6QzHQc4dbhJrI9/BfQ= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0/go.mod h1:7aWZdaQ1b16BVoQUYR+eEvrDCGJoPLxFpDynFjYfBjI= +github.com/filecoin-project/go-hamt-ipld/v3 v3.0.0 h1:aEOgJxSMbJ7XtuX3WxXvbpkBDp4Sqn3jyx/umGyL8s4= +github.com/filecoin-project/go-hamt-ipld/v3 v3.0.0/go.mod h1:gXpNmr3oQx8l3o7qkGyDjJjYSRX7hp/FGOStdqrWyDI= github.com/filecoin-project/go-jsonrpc v0.1.2-0.20200822201400-474f4fdccc52/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4= github.com/filecoin-project/go-jsonrpc v0.1.2 h1:MTebUawBHLxxY9gDi1WXuGc89TWIDmsgoDqeZSk9KRw= github.com/filecoin-project/go-jsonrpc v0.1.2/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4= @@ -293,8 +302,9 @@ github.com/filecoin-project/go-state-types v0.0.0-20200903145444-247639ffa6ad/go github.com/filecoin-project/go-state-types v0.0.0-20200904021452-1883f36ca2f4/go.mod h1:IQ0MBPnonv35CJHtWSN3YY1Hz2gkPru1Q9qoaYLxx9I= github.com/filecoin-project/go-state-types v0.0.0-20200905071437-95828685f9df/go.mod h1:IQ0MBPnonv35CJHtWSN3YY1Hz2gkPru1Q9qoaYLxx9I= github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= -github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc h1:+hbMY4Pcx2oizrfH08VWXwrj5mU8aJT6g0UNxGHFCGU= github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= +github.com/filecoin-project/go-state-types v0.0.0-20210119062722-4adba5aaea71 h1:Cas/CUB4ybYpdxvW7LouaydE16cpwdq3vvS3qgZuU+Q= +github.com/filecoin-project/go-state-types v0.0.0-20210119062722-4adba5aaea71/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-statemachine v0.0.0-20200714194326-a77c3ae20989/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe h1:dF8u+LEWeIcTcfUcCf3WFVlc81Fr2JKg8zPzIbBDKDw= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= @@ -303,8 +313,8 @@ github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZO github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg= github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8= github.com/filecoin-project/lotus v0.9.0/go.mod h1:8Qg5wmvHgCvxq2gCq9iziPlcNHl58dtzozf4StZ68Kk= -github.com/filecoin-project/lotus v1.4.1-pre1.0.20210114132837-5453e70cabb9 h1:O7RFHY4NCTeifBsrmsP1JblbHJRgck7ABYhaNOOHtY4= -github.com/filecoin-project/lotus v1.4.1-pre1.0.20210114132837-5453e70cabb9/go.mod h1:BPXneuj21cQVmjIj/o0fKYmWsKFTtufvSQ1LDb4ABoc= +github.com/filecoin-project/lotus v1.5.0-pre1 h1:Lg/hyYa7bt0TleBtCyVJ6eH2qFPlgTED9gJn2zaDWHU= +github.com/filecoin-project/lotus v1.5.0-pre1/go.mod h1:dy72fuvT8q2UkA6c88fZQ5I5l4+sEsfLQwQCZVE1e/U= github.com/filecoin-project/specs-actors v0.9.4/go.mod h1:BStZQzx5x7TmCkLv0Bpa07U6cPKol6fd3w9KjMPZ6Z4= github.com/filecoin-project/specs-actors v0.9.7/go.mod h1:wM2z+kwqYgXn5Z7scV1YHLyd1Q1cy0R8HfTIWQ0BFGU= github.com/filecoin-project/specs-actors v0.9.12/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= @@ -312,8 +322,10 @@ github.com/filecoin-project/specs-actors v0.9.13 h1:rUEOQouefi9fuVY/2HOroROJlZbO github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= github.com/filecoin-project/specs-actors/v2 v2.0.1/go.mod h1:v2NZVYinNIKA9acEMBm5wWXxqv5+frFEbekBFemYghY= github.com/filecoin-project/specs-actors/v2 v2.3.2/go.mod h1:UuJQLoTx/HPvvWeqlIFmC/ywlOLHNe8SNQ3OunFbu2Y= -github.com/filecoin-project/specs-actors/v2 v2.3.3 h1:5Pd6pjU7VjUye+Hz4gYBCPAFdBxtEbHsgGYvWmfc83w= -github.com/filecoin-project/specs-actors/v2 v2.3.3/go.mod h1:UuJQLoTx/HPvvWeqlIFmC/ywlOLHNe8SNQ3OunFbu2Y= +github.com/filecoin-project/specs-actors/v2 v2.3.4 h1:NZK2oMCcA71wNsUzDBmLQyRMzcCnX9tDGvwZ53G67j8= +github.com/filecoin-project/specs-actors/v2 v2.3.4/go.mod h1:UuJQLoTx/HPvvWeqlIFmC/ywlOLHNe8SNQ3OunFbu2Y= +github.com/filecoin-project/specs-actors/v3 v3.0.1-0.20210122191213-c7ea99141c44 h1:QYCM/E0u5XJVJENnegPR7I7meciI3CITylc9BzyoiFE= +github.com/filecoin-project/specs-actors/v3 v3.0.1-0.20210122191213-c7ea99141c44/go.mod h1:aVf248CfjfyCmVel4UuFAA3u+9UQjqtqHpgfYv+M+9U= github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796/go.mod h1:nJRRM7Aa9XVvygr3W9k6xGF46RWzr2zxF/iGoAIfA/g= github.com/filecoin-project/specs-storage v0.1.1-0.20201105051918-5188d9774506 h1:Ur/l2+6qN+lQiqjozWWc5p9UDaAMDZKTlDS98oRnlIw= github.com/filecoin-project/specs-storage v0.1.1-0.20201105051918-5188d9774506/go.mod h1:nJRRM7Aa9XVvygr3W9k6xGF46RWzr2zxF/iGoAIfA/g= @@ -367,6 +379,7 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= +github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= @@ -600,9 +613,8 @@ github.com/ipfs/go-graphsync v0.1.0/go.mod h1:jMXfqIEDFukLPZHqDPp8tJMbHO9Rmeb9CE github.com/ipfs/go-graphsync v0.2.1/go.mod h1:gEBvJUNelzMkaRPJTpg/jaKN4AQW/7wDWu0K92D8o10= github.com/ipfs/go-graphsync v0.4.2/go.mod h1:/VmbZTUdUMTbNkgzAiCEucIIAU3BkLE2cZrDCVUhyi0= github.com/ipfs/go-graphsync v0.4.3/go.mod h1:mPOwDYv128gf8gxPFgXnz4fNrSYPsWyqisJ7ych+XDY= -github.com/ipfs/go-graphsync v0.5.0/go.mod h1:e2ZxnClqBBYAtd901g9vXMJzS47labjAtOzsWtOzKNk= -github.com/ipfs/go-graphsync v0.5.1 h1:4fXBRvRKicTgTmCFMmEua/H5jvmAOLgU9Z7PCPWt2ec= -github.com/ipfs/go-graphsync v0.5.1/go.mod h1:e2ZxnClqBBYAtd901g9vXMJzS47labjAtOzsWtOzKNk= +github.com/ipfs/go-graphsync v0.5.2 h1:USD+daaSC+7pLHCxROThSaF6SF7WYXF03sjrta0rCfA= +github.com/ipfs/go-graphsync v0.5.2/go.mod h1:e2ZxnClqBBYAtd901g9vXMJzS47labjAtOzsWtOzKNk= github.com/ipfs/go-hamt-ipld v0.1.1 h1:0IQdvwnAAUKmDE+PMJa5y1QiwOPHpI9+eAbQEEEYthk= github.com/ipfs/go-hamt-ipld v0.1.1/go.mod h1:1EZCr2v0jlCnhpa+aZ0JZYp8Tt2w16+JJOAVz17YcDk= github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08= @@ -835,7 +847,6 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d h1:68u9r4wEvL3gYg2jvAOgROwZ3H+Y3hIDk4tbbmIjcYQ= @@ -1354,6 +1365,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs= github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0= +github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing-contrib/go-grpc v0.0.0-20180928155321-4b5a12d3ff02/go.mod h1:JNdpVEzCpXBgIiv4ds+TzhN1hrtxq6ClLrTlT9OQRSc= github.com/opentracing-contrib/go-grpc v0.0.0-20191001143057-db30781987df h1:vdYtBU6zvL7v+Tr+0xFM/qhahw/EvY8DMMunZHKH6eE= github.com/opentracing-contrib/go-grpc v0.0.0-20191001143057-db30781987df/go.mod h1:DYR5Eij8rJl8h7gblRrOZ8g0kW1umSpKqYIBTgeDtLo= @@ -1431,8 +1444,8 @@ github.com/prometheus/procfs v0.1.0 h1:jhMy6QXfi3y2HEzFoyuCj40z4OZIIHHPtFyCMftmv github.com/prometheus/procfs v0.1.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/raulk/clock v1.1.0 h1:dpb29+UKMbLqiU/jqIJptgLR1nn23HLgMY0sTCDza5Y= github.com/raulk/clock v1.1.0/go.mod h1:3MpVxdZ/ODBQDxbN+kzshf5OSZwPjtMDx6BBXBmOeY0= -github.com/raulk/go-watchdog v0.0.1 h1:q0ad0fanW8uaLRTvxQ0RfdADBiKa6CL6NMByhB0vpBs= -github.com/raulk/go-watchdog v0.0.1/go.mod h1:dIvQcKy0laxuHGda1ms8/2T9wE3ZJRbz9bxEO7c0q1M= +github.com/raulk/go-watchdog v1.0.1 h1:qgm3DIJAeb+2byneLrQJ7kvmDLGxN2vy3apXyGaDKN4= +github.com/raulk/go-watchdog v1.0.1/go.mod h1:lzSbAl5sh4rtI8tYHU01BWIDzgzqaQLj6RcA1i4mlqI= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -1490,8 +1503,9 @@ github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745/go.mod h1:G81a github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= @@ -1552,6 +1566,7 @@ github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6 github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.0.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= diff --git a/tasks/actorstate/account.go b/tasks/actorstate/account.go index bebbc9159..1023f25e5 100644 --- a/tasks/actorstate/account.go +++ b/tasks/actorstate/account.go @@ -6,6 +6,7 @@ import ( "github.com/filecoin-project/sentinel-visor/model" sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" ) // AccountExtractor is a state extractor that deals with Account actors. @@ -14,6 +15,7 @@ type AccountExtractor struct{} func init() { Register(sa0builtin.AccountActorCodeID, AccountExtractor{}) Register(sa2builtin.AccountActorCodeID, AccountExtractor{}) + Register(sa3builtin.AccountActorCodeID, AccountExtractor{}) } // Extract will create persistable data for a given actor's state. diff --git a/tasks/actorstate/actorstate.go b/tasks/actorstate/actorstate.go index d5ffeade0..708f26bc0 100644 --- a/tasks/actorstate/actorstate.go +++ b/tasks/actorstate/actorstate.go @@ -10,12 +10,14 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/sentinel-visor/model" "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/util/adt" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" + + "github.com/filecoin-project/sentinel-visor/model" ) var log = logging.Logger("actorstate") @@ -77,5 +79,8 @@ func ActorNameByCode(code cid.Cid) string { if name := builtin.ActorNameByCode(code); name != "" { return name } - return builtin2.ActorNameByCode(code) + if name := builtin2.ActorNameByCode(code); name != "" { + return name + } + return builtin3.ActorNameByCode(code) } diff --git a/tasks/actorstate/actorstate_test.go b/tasks/actorstate/actorstate_test.go index 13fc52432..939da0fe0 100644 --- a/tasks/actorstate/actorstate_test.go +++ b/tasks/actorstate/actorstate_test.go @@ -23,6 +23,9 @@ import ( sa2power "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" sa2reward "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + sa3init "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" + sa3power "github.com/filecoin-project/specs-actors/v3/actors/builtin/power" + sa3reward "github.com/filecoin-project/specs-actors/v3/actors/builtin/reward" "github.com/ipfs/go-cid" cbornode "github.com/ipfs/go-ipld-cbor" "github.com/stretchr/testify/require" @@ -269,6 +272,12 @@ func (m *MockAPI) mustCreateEmptyPowerStateV2() *sa2power.State { return sa2power.ConstructState(emptyClaimsMap, cronEventQueueMMap) } +func (m *MockAPI) mustCreateEmptyPowerStateV3() *sa3power.State { + st, err := sa3power.ConstructState(m.store) + require.NoError(m.t, err) + return st +} + func (m *MockAPI) mustCreateEmptyRewardStateV0(currRealizedPower abi.StoragePower) *sa0reward.State { return sa0reward.ConstructState(currRealizedPower) } @@ -277,6 +286,10 @@ func (m *MockAPI) mustCreateEmptyRewardStateV2(currRealizedPower abi.StoragePowe return sa2reward.ConstructState(currRealizedPower) } +func (m *MockAPI) mustCreateEmptyRewardStateV3(currRealizedPower abi.StoragePower) *sa3reward.State { + return sa3reward.ConstructState(currRealizedPower) +} + func (m *MockAPI) mustCreateEmptyInitStateV0() *sa0init.State { emptyMap, err := adt.MakeEmptyMap(m.store).Root() require.NoError(m.t, err) @@ -291,6 +304,12 @@ func (m *MockAPI) mustCreateEmptyInitStateV2() *sa2init.State { return sa2init.ConstructState(emptyMap, "visor-testing") } +func (m *MockAPI) mustCreateEmptyInitStateV3() *sa3init.State { + st, err := sa3init.ConstructState(m.store, "visor-testing") + require.NoError(m.t, err) + return st +} + func (m *MockAPI) mustCreateAccountStateV0(addr address.Address) *sa0account.State { return &sa0account.State{Address: addr} } diff --git a/tasks/actorstate/init.go b/tasks/actorstate/init.go index bd4d5cf58..74cd5f88f 100644 --- a/tasks/actorstate/init.go +++ b/tasks/actorstate/init.go @@ -10,6 +10,7 @@ import ( sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" "github.com/filecoin-project/sentinel-visor/model" initmodel "github.com/filecoin-project/sentinel-visor/model/actors/init" @@ -23,6 +24,7 @@ type InitExtractor struct{} func init() { Register(sa0builtin.InitActorCodeID, InitExtractor{}) Register(sa2builtin.InitActorCodeID, InitExtractor{}) + Register(sa3builtin.InitActorCodeID, InitExtractor{}) } func (InitExtractor) Extract(ctx context.Context, a ActorInfo, node ActorStateAPI) (model.Persistable, error) { diff --git a/tasks/actorstate/init_test.go b/tasks/actorstate/init_test.go index 29d52a783..0def70598 100644 --- a/tasks/actorstate/init_test.go +++ b/tasks/actorstate/init_test.go @@ -12,6 +12,8 @@ import ( tutils "github.com/filecoin-project/specs-actors/support/testing" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" sa2init "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" + sa3init "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -230,3 +232,109 @@ func TestInitExtractorV2(t *testing.T) { assert.EqualValues(t, pkAddrToMod.String(), is[1].Address) }) } + +func TestInitExtractorV3(t *testing.T) { + ctx := context.Background() + + mapi := NewMockAPI(t) + + state := mapi.mustCreateEmptyInitStateV3() + minerAddr := tutils.NewIDAddr(t, 1234) + + t.Run("genesis init state extraction", func(t *testing.T) { + // return map keyed on stringified id address and value stringified pk Address. + addToInitActor := func(state *sa3init.State, numAddrs int) map[string]string { + out := map[string]string{} + for i := 0; i < numAddrs; i++ { + addr := tutils.NewSECP256K1Addr(t, fmt.Sprintf("%d", i)) + idAddr, err := state.MapAddressToNewID(mapi.store, addr) + require.NoError(t, err) + out[idAddr.String()] = addr.String() + } + return out + } + // add 2 addresses in the init actor. + addrMap := addToInitActor(state, 2) + + // persist state + stateCid, err := mapi.Store().Put(ctx, state) + require.NoError(t, err) + stateTs := mapi.fakeTipset(minerAddr, 1, WithHeight(0)) // genesis + mapi.setActor(stateTs.Key(), init_.Address, &types.Actor{Code: sa3builtin.InitActorCodeID, Head: stateCid}) + + info := actorstate.ActorInfo{ + Epoch: 0, // genesis + Actor: types.Actor{Code: sa3builtin.InitActorCodeID, Head: stateCid}, + Address: init_.Address, + ParentTipSet: stateTs.Parents(), + TipSet: stateTs.Key(), + ParentStateRoot: stateTs.ParentState(), + } + + ex := actorstate.InitExtractor{} + res, err := ex.Extract(ctx, info, mapi) + require.NoError(t, err) + + is, ok := res.(initmodel.IdAddressList) + require.True(t, ok) + require.NotNil(t, is) + + assert.Len(t, is, 2) + assert.EqualValues(t, addrMap[is[0].ID], is[0].Address) + assert.EqualValues(t, addrMap[is[1].ID], is[1].Address) + }) + + t.Run("init state extraction with new address and modified address", func(t *testing.T) { + // setup the base state with an address in it, we will modify it in the following state. + pkAddrToMod := tutils.NewSECP256K1Addr(t, fmt.Sprintf("%d", 1)) + idAddrToMod, err := state.MapAddressToNewID(mapi.store, pkAddrToMod) + require.NoError(t, err) + + // persist base state. + baseStateCid, err := mapi.Store().Put(ctx, state) + require.NoError(t, err) + baseTs := mapi.fakeTipset(minerAddr, 1) + mapi.setActor(baseTs.Key(), init_.Address, &types.Actor{Code: sa3builtin.InitActorCodeID, Head: baseStateCid}) + + // setup following state. + // add a new address. + pkNewAddr := tutils.NewSECP256K1Addr(t, fmt.Sprintf("%d", 2)) + idNewAddr, err := state.MapAddressToNewID(mapi.store, pkNewAddr) + require.NoError(t, err) + + // modify an existing address + idAddrAfterMod, err := state.MapAddressToNewID(mapi.store, pkAddrToMod) + require.NoError(t, err) + // sanity check the address receieved a new ID address + require.NotEqual(t, idAddrToMod, idAddrAfterMod) + + // persist new state. + stateCid, err := mapi.Store().Put(ctx, state) + require.NoError(t, err) + stateTs := mapi.fakeTipset(minerAddr, 1) + mapi.setActor(stateTs.Key(), init_.Address, &types.Actor{Code: sa3builtin.InitActorCodeID, Head: stateCid}) + + info := actorstate.ActorInfo{ + Epoch: 1, + Actor: types.Actor{Code: sa3builtin.InitActorCodeID, Head: stateCid}, + Address: init_.Address, + ParentTipSet: baseTs.Key(), + TipSet: stateTs.Key(), + ParentStateRoot: baseStateCid, + } + + ex := actorstate.InitExtractor{} + res, err := ex.Extract(ctx, info, mapi) + require.NoError(t, err) + + is, ok := res.(initmodel.IdAddressList) + require.True(t, ok) + require.NotNil(t, is) + + assert.Len(t, is, 2) + assert.EqualValues(t, idNewAddr.String(), is[0].ID) + assert.EqualValues(t, pkNewAddr.String(), is[0].Address) + assert.EqualValues(t, idAddrAfterMod.String(), is[1].ID) + assert.EqualValues(t, pkAddrToMod.String(), is[1].Address) + }) +} diff --git a/tasks/actorstate/market.go b/tasks/actorstate/market.go index 58a16ddbf..3a6f26428 100644 --- a/tasks/actorstate/market.go +++ b/tasks/actorstate/market.go @@ -10,6 +10,7 @@ import ( "github.com/filecoin-project/lotus/chain/events/state" sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" "github.com/filecoin-project/sentinel-visor/metrics" "github.com/filecoin-project/sentinel-visor/model" @@ -24,6 +25,7 @@ type StorageMarketExtractor struct{} func init() { Register(sa0builtin.StorageMarketActorCodeID, StorageMarketExtractor{}) Register(sa2builtin.StorageMarketActorCodeID, StorageMarketExtractor{}) + Register(sa3builtin.StorageMarketActorCodeID, StorageMarketExtractor{}) } func (m StorageMarketExtractor) Extract(ctx context.Context, a ActorInfo, node ActorStateAPI) (model.Persistable, error) { diff --git a/tasks/actorstate/miner.go b/tasks/actorstate/miner.go index a9214584b..2a610f531 100644 --- a/tasks/actorstate/miner.go +++ b/tasks/actorstate/miner.go @@ -15,6 +15,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" "github.com/filecoin-project/sentinel-visor/metrics" "github.com/filecoin-project/sentinel-visor/model" @@ -29,6 +30,7 @@ type StorageMinerExtractor struct{} func init() { Register(sa0builtin.StorageMinerActorCodeID, StorageMinerExtractor{}) Register(sa2builtin.StorageMinerActorCodeID, StorageMinerExtractor{}) + Register(sa3builtin.StorageMinerActorCodeID, StorageMinerExtractor{}) } func (m StorageMinerExtractor) Extract(ctx context.Context, a ActorInfo, node ActorStateAPI) (model.Persistable, error) { diff --git a/tasks/actorstate/multisig.go b/tasks/actorstate/multisig.go index b60df59c9..dd7e81863 100644 --- a/tasks/actorstate/multisig.go +++ b/tasks/actorstate/multisig.go @@ -7,6 +7,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" "go.opentelemetry.io/otel/api/global" "golang.org/x/xerrors" @@ -18,6 +19,7 @@ import ( func init() { Register(sa0builtin.MultisigActorCodeID, MultiSigActorExtractor{}) Register(sa2builtin.MultisigActorCodeID, MultiSigActorExtractor{}) + Register(sa3builtin.MultisigActorCodeID, MultiSigActorExtractor{}) } type MultiSigActorExtractor struct{} diff --git a/tasks/actorstate/multisig_test.go b/tasks/actorstate/multisig_test.go index a03c21323..e70857f0c 100644 --- a/tasks/actorstate/multisig_test.go +++ b/tasks/actorstate/multisig_test.go @@ -15,10 +15,12 @@ import ( sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" - sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" + multisig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig" + adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" multisigmodel "github.com/filecoin-project/sentinel-visor/model/actors/multisig" "github.com/filecoin-project/sentinel-visor/tasks/actorstate" @@ -478,5 +480,235 @@ func TestMultisigExtractorV2(t *testing.T) { assert.Len(t, firstTx.Approved, 1) assert.EqualValues(t, firstTx.Approved[0].String(), singleTx.Approved[0]) }) +} + +func TestMultisigExtractorV3(t *testing.T) { + ctx := context.Background() + + mapi := NewMockAPI(t) + minerAddr := tutils.NewIDAddr(t, 1234) + + emptyMap, err := adt3.MakeEmptyMap(mapi.store, sa3builtin.DefaultHamtBitwidth) + require.NoError(t, err) + + emptyPending, err := emptyMap.Root() + require.NoError(t, err) + + multiSigAddress := tutils.NewIDAddr(t, 9999) + emptyTxState := &multisig3.State{ + Signers: []address.Address{tutils.NewIDAddr(t, 1234)}, + NumApprovalsThreshold: 1, + NextTxnID: 0, + InitialBalance: abi.NewTokenAmount(0), + StartEpoch: 0, + UnlockDuration: 0, + PendingTxns: emptyPending, + } + + t.Run("single transaction added", func(t *testing.T) { + // initialize with empty transaction state + emptyTxStateCid, err := mapi.Store().Put(ctx, emptyTxState) + require.NoError(t, err) + emptyTxStateTs := mapi.fakeTipset(minerAddr, 1) + mapi.setActor(emptyTxStateTs.Key(), multiSigAddress, &types.Actor{Code: sa3builtin.MultisigActorCodeID, Head: emptyTxStateCid}) + + // + // add a transaction in subsequent state. + pendingMap, err := adt3.AsMap(mapi.store, emptyTxState.PendingTxns, sa3builtin.DefaultHamtBitwidth) + require.NoError(t, err) + + expectedTx := &multisig3.Transaction{ + To: tutils.NewIDAddr(t, 8888), + Value: abi.NewTokenAmount(10), + Method: sa3builtin.MethodSend, + Params: runtime.CBORBytes([]byte{1, 2, 3, 4}), + Approved: []address.Address{tutils.NewIDAddr(t, 7777)}, + } + expectedTxID := multisig3.TxnID(1) + require.NoError(t, pendingMap.Put(expectedTxID, expectedTx)) + + // copy empty state and modify + newTxState := *emptyTxState + newTxState.PendingTxns, err = pendingMap.Root() + require.NoError(t, err) + + txStateCid, err := mapi.Store().Put(ctx, &newTxState) + require.NoError(t, err) + + txStateTs := mapi.fakeTipset(minerAddr, 2) + mapi.setActor(txStateTs.Key(), multiSigAddress, &types.Actor{Code: sa3builtin.MultisigActorCodeID, Head: txStateCid}) + + // + // create actor info, previous state has no transaction, current state has a single transaction + info := actorstate.ActorInfo{ + Actor: types.Actor{Code: sa3builtin.MultisigActorCodeID, Head: txStateCid}, + Epoch: 1, // not genesis + Address: multiSigAddress, + TipSet: txStateTs.Key(), + ParentTipSet: emptyTxStateTs.Key(), + } + + ex := actorstate.MultiSigActorExtractor{} + res, err := ex.Extract(ctx, info, mapi) + require.NoError(t, err) + + ms, ok := res.(*multisigmodel.MultisigTaskResult) + require.True(t, ok) + require.NotNil(t, ms) + + assert.Len(t, ms.TransactionModel, 1) + actualTx := ms.TransactionModel[0] + assert.EqualValues(t, expectedTx.To.String(), actualTx.To) + assert.EqualValues(t, expectedTx.Params, actualTx.Params) + assert.EqualValues(t, expectedTx.Method, actualTx.Method) + assert.EqualValues(t, expectedTx.Value.String(), actualTx.Value) + assert.Len(t, actualTx.Approved, 1) + assert.EqualValues(t, expectedTx.Approved[0].String(), actualTx.Approved[0]) + }) + + t.Run("single transaction added and single transaction modified", func(t *testing.T) { + // initialize with single transaction in state. + singleTxState := *emptyTxState + txMap, err := adt3.AsMap(mapi.store, singleTxState.PendingTxns, sa3builtin.DefaultHamtBitwidth) + require.NoError(t, err) + + // save the new tx + firstTx := &multisig3.Transaction{ + To: tutils.NewIDAddr(t, 8888), + Value: abi.NewTokenAmount(10), + Method: sa3builtin.MethodSend, + Params: runtime.CBORBytes([]byte{1, 2, 3, 4}), + Approved: []address.Address{tutils.NewIDAddr(t, 7777)}, + } + firstTxID := multisig3.TxnID(1) + require.NoError(t, txMap.Put(firstTxID, firstTx)) + singleTxState.PendingTxns, err = txMap.Root() + require.NoError(t, err) + + // update global state + singleTxStateCid, err := mapi.Store().Put(ctx, &singleTxState) + require.NoError(t, err) + singleTxStateTs := mapi.fakeTipset(minerAddr, 1) + mapi.setActor(singleTxStateTs.Key(), multiSigAddress, &types.Actor{Code: sa3builtin.MultisigActorCodeID, Head: singleTxStateCid}) + + // create second tx + txMap, err = adt3.AsMap(mapi.store, singleTxState.PendingTxns, sa3builtin.DefaultHamtBitwidth) + require.NoError(t, err) + secondTx := &multisig3.Transaction{ + To: tutils.NewIDAddr(t, 8888), + Value: abi.NewTokenAmount(10), + Method: sa3builtin.MethodsAccount.PubkeyAddress, + Params: runtime.CBORBytes([]byte{1, 2, 3, 4}), + Approved: []address.Address{tutils.NewIDAddr(t, 7777)}, + } + secondTxId := multisig2.TxnID(2) + require.NoError(t, txMap.Put(secondTxId, secondTx)) + + // modify first tx + var firstTxMod multisig2.Transaction + found, err := txMap.Get(firstTxID, &firstTxMod) + require.NoError(t, err) + require.True(t, found) + firstTxMod.Approved = append(firstTxMod.Approved, tutils.NewIDAddr(t, 898989)) + require.NoError(t, txMap.Put(firstTxID, &firstTxMod)) + + // create second state with a newly added tx and a modified tx. + secondTxState := singleTxState + secondTxState.PendingTxns, err = txMap.Root() + require.NoError(t, err) + + // update global state + secondTxStateCid, err := mapi.Store().Put(ctx, &secondTxState) + require.NoError(t, err) + + secondTxStateTs := mapi.fakeTipset(minerAddr, 2) + mapi.setActor(secondTxStateTs.Key(), multiSigAddress, &types.Actor{Code: sa3builtin.MultisigActorCodeID, Head: secondTxStateCid}) + + // + // create actor info, previous state has single tx, current state has a new tx and modified tx. + info := actorstate.ActorInfo{ + Actor: types.Actor{Code: sa3builtin.MultisigActorCodeID, Head: secondTxStateCid}, + Epoch: 1, // not genesis + Address: multiSigAddress, + TipSet: secondTxStateTs.Key(), + ParentTipSet: singleTxStateTs.Key(), + } + + ex := actorstate.MultiSigActorExtractor{} + res, err := ex.Extract(ctx, info, mapi) + require.NoError(t, err) + + ms, ok := res.(*multisigmodel.MultisigTaskResult) + require.True(t, ok) + require.NotNil(t, ms) + + assert.Len(t, ms.TransactionModel, 2) + newTx := ms.TransactionModel[0] + assert.EqualValues(t, secondTx.To.String(), newTx.To) + assert.EqualValues(t, secondTx.Params, newTx.Params) + assert.EqualValues(t, secondTx.Method, newTx.Method) + assert.EqualValues(t, secondTx.Value.String(), newTx.Value) + assert.Len(t, secondTx.Approved, 1) + assert.EqualValues(t, secondTx.Approved[0].String(), newTx.Approved[0]) + + modTx := ms.TransactionModel[1] + assert.EqualValues(t, firstTxMod.To.String(), modTx.To) + assert.EqualValues(t, firstTxMod.Params, modTx.Params) + assert.EqualValues(t, firstTxMod.Method, modTx.Method) + assert.EqualValues(t, firstTxMod.Value.String(), modTx.Value) + assert.Len(t, firstTxMod.Approved, 2) + assert.EqualValues(t, firstTxMod.Approved[0].String(), modTx.Approved[0]) + assert.EqualValues(t, firstTxMod.Approved[1].String(), modTx.Approved[1]) + }) + + t.Run("genesis special case", func(t *testing.T) { + // initialize with single transaction in state. + singleTxState := *emptyTxState + txMap, err := adt3.AsMap(mapi.store, singleTxState.PendingTxns, sa3builtin.DefaultHamtBitwidth) + require.NoError(t, err) + + // save the new tx + firstTx := &multisig3.Transaction{ + To: tutils.NewIDAddr(t, 8888), + Value: abi.NewTokenAmount(10), + Method: sa3builtin.MethodSend, + Params: runtime.CBORBytes([]byte{1, 2, 3, 4}), + Approved: []address.Address{tutils.NewIDAddr(t, 7777)}, + } + firstTxID := multisig2.TxnID(1) + require.NoError(t, txMap.Put(firstTxID, firstTx)) + singleTxState.PendingTxns, err = txMap.Root() + require.NoError(t, err) + + // update global state + singleTxStateCid, err := mapi.Store().Put(ctx, &singleTxState) + require.NoError(t, err) + genesisTs := mapi.fakeTipset(minerAddr, 1, WithHeight(0)) + mapi.setActor(genesisTs.Key(), multiSigAddress, &types.Actor{Code: sa3builtin.MultisigActorCodeID, Head: singleTxStateCid}) + + info := actorstate.ActorInfo{ + Actor: types.Actor{Code: sa3builtin.MultisigActorCodeID, Head: singleTxStateCid}, + Epoch: 0, // genesis + Address: multiSigAddress, + TipSet: genesisTs.Key(), + } + + ex := actorstate.MultiSigActorExtractor{} + res, err := ex.Extract(ctx, info, mapi) + require.NoError(t, err) + + ms, ok := res.(*multisigmodel.MultisigTaskResult) + require.True(t, ok) + require.NotNil(t, ms) + + assert.Len(t, ms.TransactionModel, 1) + singleTx := ms.TransactionModel[0] + assert.EqualValues(t, firstTx.To.String(), singleTx.To) + assert.EqualValues(t, firstTx.Params, singleTx.Params) + assert.EqualValues(t, firstTx.Method, singleTx.Method) + assert.EqualValues(t, firstTx.Value.String(), singleTx.Value) + assert.Len(t, firstTx.Approved, 1) + assert.EqualValues(t, firstTx.Approved[0].String(), singleTx.Approved[0]) + }) } diff --git a/tasks/actorstate/power.go b/tasks/actorstate/power.go index 677150b18..1c339709e 100644 --- a/tasks/actorstate/power.go +++ b/tasks/actorstate/power.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin/power" sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" "github.com/filecoin-project/sentinel-visor/metrics" "github.com/filecoin-project/sentinel-visor/model" @@ -25,6 +26,7 @@ type StoragePowerExtractor struct{} func init() { Register(sa0builtin.StoragePowerActorCodeID, StoragePowerExtractor{}) Register(sa2builtin.StoragePowerActorCodeID, StoragePowerExtractor{}) + Register(sa3builtin.StoragePowerActorCodeID, StoragePowerExtractor{}) } func NewPowerStateExtractionContext(ctx context.Context, a ActorInfo, node ActorStateAPI) (*PowerStateExtractionContext, error) { diff --git a/tasks/actorstate/power_test.go b/tasks/actorstate/power_test.go index 4f9523cf2..3a498e005 100644 --- a/tasks/actorstate/power_test.go +++ b/tasks/actorstate/power_test.go @@ -21,6 +21,10 @@ import ( sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" sa2smoothing "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" + power3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/power" + adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" + sa3smoothing "github.com/filecoin-project/specs-actors/v3/actors/util/smoothing" powermodel "github.com/filecoin-project/sentinel-visor/model/actors/power" "github.com/filecoin-project/sentinel-visor/tasks/actorstate" @@ -78,7 +82,6 @@ func TestPowerExtractV0(t *testing.T) { assert.EqualValues(t, state.ThisEpochQAPowerSmoothed.VelocityEstimate.String(), cp.ChainPowerModel.QASmoothedVelocityEstimate, "QASmoothedVelocityEstimate") assert.EqualValues(t, state.MinerCount, cp.ChainPowerModel.MinerCount, "MinerCount") assert.EqualValues(t, state.MinerAboveMinPowerCount, cp.ChainPowerModel.ParticipatingMinerCount, "ParticipatingMinerCount") - }) t.Run("power claim model", func(t *testing.T) { @@ -233,3 +236,107 @@ func TestPowerExtractV2(t *testing.T) { assert.EqualValues(t, newClaim.RawBytePower.String(), cp.ClaimStateModel[0].RawBytePower) }) } + +func TestPowerExtractV3(t *testing.T) { + ctx := context.Background() + + mapi := NewMockAPI(t) + + state := mapi.mustCreateEmptyPowerStateV3() + minerAddr := tutils.NewIDAddr(t, 1234) + + t.Run("power state model", func(t *testing.T) { + state.TotalRawBytePower = abi.NewStoragePower(1000) + state.TotalBytesCommitted = abi.NewStoragePower(0) + state.TotalQualityAdjPower = abi.NewStoragePower(0) + state.TotalQABytesCommitted = abi.NewStoragePower(0) + state.TotalPledgeCollateral = abi.NewTokenAmount(0) + state.ThisEpochRawBytePower = abi.NewStoragePower(0) + state.ThisEpochQualityAdjPower = abi.NewStoragePower(0) + state.ThisEpochPledgeCollateral = abi.NewTokenAmount(0) + state.ThisEpochQAPowerSmoothed = sa3smoothing.NewEstimate(big.NewInt(800_000_000_000), big.NewInt(6_000_000_000)) + state.MinerCount = 0 + state.MinerAboveMinPowerCount = 0 + + stateCid, err := mapi.Store().Put(ctx, state) + require.NoError(t, err) + + stateTs := mapi.fakeTipset(minerAddr, 1) + mapi.setActor(stateTs.Key(), power.Address, &types.Actor{Code: sa3builtin.StoragePowerActorCodeID, Head: stateCid}) + + info := actorstate.ActorInfo{ + Actor: types.Actor{Code: sa3builtin.StoragePowerActorCodeID, Head: stateCid}, + Address: power.Address, + TipSet: stateTs.Key(), + ParentStateRoot: stateTs.ParentState(), + } + + ex := actorstate.StoragePowerExtractor{} + res, err := ex.Extract(ctx, info, mapi) + require.NoError(t, err) + + cp, ok := res.(*powermodel.PowerTaskResult) + require.True(t, ok) + require.NotNil(t, cp) + + assert.EqualValues(t, info.ParentStateRoot.String(), cp.ChainPowerModel.StateRoot, "StateRoot") + assert.EqualValues(t, state.TotalRawBytePower.String(), cp.ChainPowerModel.TotalRawBytesPower, "TotalRawBytesPower") + assert.EqualValues(t, state.TotalQualityAdjPower.String(), cp.ChainPowerModel.TotalQABytesPower, "TotalQABytesPower") + assert.EqualValues(t, state.TotalBytesCommitted.String(), cp.ChainPowerModel.TotalRawBytesCommitted, "TotalRawBytesCommitted") + assert.EqualValues(t, state.TotalQABytesCommitted.String(), cp.ChainPowerModel.TotalQABytesCommitted, "TotalQABytesCommitted") + assert.EqualValues(t, state.TotalPledgeCollateral.String(), cp.ChainPowerModel.TotalPledgeCollateral, "TotalPledgeCollateral") + assert.EqualValues(t, state.ThisEpochQAPowerSmoothed.PositionEstimate.String(), cp.ChainPowerModel.QASmoothedPositionEstimate, "QASmoothedPositionEstimate") + assert.EqualValues(t, state.ThisEpochQAPowerSmoothed.VelocityEstimate.String(), cp.ChainPowerModel.QASmoothedVelocityEstimate, "QASmoothedVelocityEstimate") + assert.EqualValues(t, state.MinerCount, cp.ChainPowerModel.MinerCount, "MinerCount") + assert.EqualValues(t, state.MinerAboveMinPowerCount, cp.ChainPowerModel.ParticipatingMinerCount, "ParticipatingMinerCount") + }) + + t.Run("power claim model", func(t *testing.T) { + claimMap, err := adt3.AsMap(mapi.store, state.Claims, sa3builtin.DefaultHamtBitwidth) + require.NoError(t, err) + newClaim := power3.Claim{ + WindowPoStProofType: abi.RegisteredPoStProof_StackedDrgWinning64GiBV1, + RawBytePower: abi.NewStoragePower(10), + QualityAdjPower: abi.NewStoragePower(5), + } + + oldStateCid, err := mapi.Store().Put(ctx, state) + require.NoError(t, err) + + oldStateTs := mapi.fakeTipset(minerAddr, 1) + mapi.setActor(oldStateTs.Key(), power.Address, &types.Actor{Code: sa3builtin.StoragePowerActorCodeID, Head: oldStateCid}) + + err = claimMap.Put(abi.AddrKey(minerAddr), &newClaim) + require.NoError(t, err) + + state.Claims, err = claimMap.Root() + require.NoError(t, err) + + newStateCid, err := mapi.Store().Put(ctx, state) + require.NoError(t, err) + + newStateTs := mapi.fakeTipset(minerAddr, 1) + mapi.setActor(newStateTs.Key(), power.Address, &types.Actor{Code: sa3builtin.StoragePowerActorCodeID, Head: newStateCid}) + + info := actorstate.ActorInfo{ + Epoch: 1, + Actor: types.Actor{Code: sa3builtin.StoragePowerActorCodeID, Head: newStateCid}, + Address: power.Address, + ParentTipSet: oldStateTs.Key(), + TipSet: newStateTs.Key(), + ParentStateRoot: newStateTs.ParentState(), + } + + ex := actorstate.StoragePowerExtractor{} + res, err := ex.Extract(ctx, info, mapi) + require.NoError(t, err) + + cp, ok := res.(*powermodel.PowerTaskResult) + require.True(t, ok) + require.NotNil(t, cp) + + assert.Len(t, cp.ClaimStateModel, 1) + assert.EqualValues(t, newClaim.QualityAdjPower.String(), cp.ClaimStateModel[0].QualityAdjPower) + assert.EqualValues(t, newClaim.RawBytePower.String(), cp.ClaimStateModel[0].RawBytePower) + }) +} diff --git a/tasks/actorstate/reward.go b/tasks/actorstate/reward.go index 0328b240b..3db10e89e 100644 --- a/tasks/actorstate/reward.go +++ b/tasks/actorstate/reward.go @@ -6,6 +6,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin/reward" sa0builtin "github.com/filecoin-project/specs-actors/actors/builtin" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" "go.opentelemetry.io/otel/api/global" "github.com/filecoin-project/sentinel-visor/metrics" @@ -21,6 +22,7 @@ type RewardExtractor struct{} func init() { Register(sa0builtin.RewardActorCodeID, RewardExtractor{}) Register(sa2builtin.RewardActorCodeID, RewardExtractor{}) + Register(sa3builtin.RewardActorCodeID, RewardExtractor{}) } func (RewardExtractor) Extract(ctx context.Context, a ActorInfo, node ActorStateAPI) (model.Persistable, error) { diff --git a/tasks/actorstate/reward_test.go b/tasks/actorstate/reward_test.go index 106d733e6..192f4d1ab 100644 --- a/tasks/actorstate/reward_test.go +++ b/tasks/actorstate/reward_test.go @@ -18,6 +18,8 @@ import ( sa0smoothing "github.com/filecoin-project/specs-actors/actors/util/smoothing" sa2builtin "github.com/filecoin-project/specs-actors/v2/actors/builtin" sa2smoothing "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing" + sa3builtin "github.com/filecoin-project/specs-actors/v3/actors/builtin" + sa3smoothing "github.com/filecoin-project/specs-actors/v3/actors/util/smoothing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -41,7 +43,7 @@ func TestRewardExtractV0(t *testing.T) { stateCid, err := mapi.Store().Put(ctx, state) require.NoError(t, err) - minerAddr := tutils.NewIDAddr(t, 00) + minerAddr := tutils.NewIDAddr(t, 0o0) stateTs := mapi.fakeTipset(minerAddr, 1) mapi.setActor(stateTs.Key(), reward.Address, &types.Actor{Code: sa0builtin.RewardActorCodeID, Head: stateCid}) @@ -119,3 +121,52 @@ func TestRewardExtractV2(t *testing.T) { assert.EqualValues(t, state.ThisEpochReward.String(), cr.NewReward, "NewReward") assert.EqualValues(t, state.EffectiveNetworkTime, cr.EffectiveNetworkTime, "EffectiveNetworkTime") } + +func TestRewardExtractV3(t *testing.T) { + ctx := context.Background() + + mapi := NewMockAPI(t) + + state := mapi.mustCreateEmptyRewardStateV3(abi.NewStoragePower(500)) + + state.CumsumBaseline = big.NewInt(1000) + state.CumsumRealized = big.NewInt(2000) + state.EffectiveNetworkTime = abi.ChainEpoch(3000) + state.EffectiveBaselinePower = abi.NewStoragePower(4000) + state.ThisEpochReward = abi.NewTokenAmount(5000) + state.ThisEpochRewardSmoothed = sa3smoothing.NewEstimate(big.NewInt(6000), big.NewInt(60)) + state.ThisEpochBaselinePower = abi.NewStoragePower(7000) + state.TotalStoragePowerReward = abi.NewStoragePower(8000) + + stateCid, err := mapi.Store().Put(ctx, state) + require.NoError(t, err) + + minerAddr := tutils.NewIDAddr(t, 123) + stateTs := mapi.fakeTipset(minerAddr, 1) + mapi.setActor(stateTs.Key(), reward.Address, &types.Actor{Code: sa3builtin.RewardActorCodeID, Head: stateCid}) + + info := actorstate.ActorInfo{ + Actor: types.Actor{Code: sa3builtin.RewardActorCodeID, Head: stateCid}, + Address: power.Address, + TipSet: stateTs.Key(), + } + + ex := actorstate.RewardExtractor{} + res, err := ex.Extract(ctx, info, mapi) + require.NoError(t, err) + + cr, ok := res.(*rewardmodel.ChainReward) + require.True(t, ok) + require.NotNil(t, cr) + + assert.EqualValues(t, info.ParentStateRoot.String(), cr.StateRoot, "StateRoot") + assert.EqualValues(t, state.CumsumBaseline.String(), cr.CumSumBaseline, "CumSumBaseline") + assert.EqualValues(t, state.CumsumRealized.String(), cr.CumSumRealized, "CumSumRealized") + assert.EqualValues(t, state.EffectiveBaselinePower.String(), cr.EffectiveBaselinePower, "EffectiveBaselinePower") + assert.EqualValues(t, state.ThisEpochBaselinePower.String(), cr.NewBaselinePower, "NewBaselinePower") + assert.EqualValues(t, state.ThisEpochRewardSmoothed.PositionEstimate.String(), cr.NewRewardSmoothedPositionEstimate, "NewRewardSmoothedPositionEstimate") + assert.EqualValues(t, state.ThisEpochRewardSmoothed.VelocityEstimate.String(), cr.NewRewardSmoothedVelocityEstimate, "NewRewardSmoothedVelocityEstimate") + assert.EqualValues(t, state.TotalStoragePowerReward.String(), cr.TotalMinedReward, "TotalMinedReward") + assert.EqualValues(t, state.ThisEpochReward.String(), cr.NewReward, "NewReward") + assert.EqualValues(t, state.EffectiveNetworkTime, cr.EffectiveNetworkTime, "EffectiveNetworkTime") +}