diff --git a/go.mod b/go.mod index 1f4b3512a5..1d8b5f8820 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,8 @@ require ( ) require ( + cosmossdk.io/collections v0.4.0 + cosmossdk.io/core v0.10.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 github.com/btcsuite/btcd/btcec/v2 v2.3.2 @@ -55,12 +57,12 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.5 // indirect cloud.google.com/go/storage v1.30.1 // indirect - cosmossdk.io/api v0.3.1 // indirect - cosmossdk.io/core v0.5.1 // indirect + cosmossdk.io/api v0.7.0 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/tools/rosetta v0.2.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect + github.com/DataDog/zstd v1.5.5 // indirect github.com/aws/aws-sdk-go v1.44.203 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bufbuild/protocompile v0.4.0 // indirect @@ -69,7 +71,9 @@ require ( github.com/cockroachdb/apd/v2 v2.0.2 // indirect github.com/cockroachdb/errors v1.10.0 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v0.0.0-20230525220056-bb4fc9527b3b // indirect github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cosmos/cosmos-db v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect @@ -185,8 +189,8 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.16.0 - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/procfs v0.10.1 // indirect github.com/rakyll/statik v0.1.7 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect @@ -227,3 +231,8 @@ replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alp replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 replace github.com/cosmos/cosmos-sdk => github.com/lavanet/cosmos-sdk v0.47.10-lava-cosmos // branch: v0.47.10-lava + +replace ( + cosmossdk.io/api => cosmossdk.io/api v0.3.1 + golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb +) diff --git a/go.sum b/go.sum index 59e78532cf..0e3e13e4b8 100644 --- a/go.sum +++ b/go.sum @@ -193,8 +193,10 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/api v0.3.1 h1:NNiOclKRR0AOlO4KIqeaG6PS6kswOMhHD0ir0SscNXE= cosmossdk.io/api v0.3.1/go.mod h1:DfHfMkiNA2Uhy8fj0JJlOCYOBp4eWUUJ1te5zBGNyIw= -cosmossdk.io/core v0.5.1 h1:vQVtFrIYOQJDV3f7rw4pjjVqc1id4+mE0L9hHP66pyI= -cosmossdk.io/core v0.5.1/go.mod h1:KZtwHCLjcFuo0nmDc24Xy6CRNEL9Vl/MeimQ2aC7NLE= +cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= +cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/core v0.10.0 h1:NP28Ol9YyRODmZLJg2ko/mUl40hMegeMzhJnG+XPkcY= +cosmossdk.io/core v0.10.0/go.mod h1:MygXNld9DvMgYY4yE76DM/mdZpgfeyRjy6FPjEEehlY= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= @@ -205,7 +207,6 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -220,12 +221,13 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSu github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= @@ -361,10 +363,13 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+0VUU= github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230525220056-bb4fc9527b3b h1:LCs8gDhg6vt8A3dN7AEJxmCoETZ4qkySoVJVm3rcSJk= +github.com/cockroachdb/pebble v0.0.0-20230525220056-bb4fc9527b3b/go.mod h1:TkdVsGYRqtULUppt2RbC+YaKtTHnHoWa2apfFrSKABw= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= @@ -390,6 +395,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= +github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= +github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU= github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -526,9 +533,6 @@ github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= @@ -1069,8 +1073,8 @@ github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1: github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= @@ -1079,8 +1083,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -1317,28 +1321,13 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us= golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1351,21 +1340,19 @@ golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1503,7 +1490,6 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1623,7 +1609,6 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -1632,9 +1617,7 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 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/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1651,7 +1634,6 @@ golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1683,6 +1665,7 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/proto/lavanet/lava/epochstorage/epoch_details.proto b/proto/lavanet/lava/epochstorage/epoch_details.proto index afade962f0..001a76e95e 100644 --- a/proto/lavanet/lava/epochstorage/epoch_details.proto +++ b/proto/lavanet/lava/epochstorage/epoch_details.proto @@ -6,6 +6,5 @@ option go_package = "github.com/lavanet/lava/v2/x/epochstorage/types"; message EpochDetails { uint64 startBlock = 1; uint64 earliestStart = 2; - repeated uint64 deletedEpochs =3; - + repeated uint64 deletedEpochs = 3; } diff --git a/proto/lavanet/lava/epochstorage/params.proto b/proto/lavanet/lava/epochstorage/params.proto index 4c77fa8a66..2264b24f20 100644 --- a/proto/lavanet/lava/epochstorage/params.proto +++ b/proto/lavanet/lava/epochstorage/params.proto @@ -9,9 +9,8 @@ option go_package = "github.com/lavanet/lava/v2/x/epochstorage/types"; message Params { option (gogoproto.goproto_stringer) = false; - uint64 unstakeHoldBlocks = 1 [(gogoproto.moretags) = "yaml:\"unstake_hold_blocks\""]; + reserved 1, 5; uint64 epochBlocks = 2 [(gogoproto.moretags) = "yaml:\"epoch_blocks\""]; uint64 epochsToSave = 3 [(gogoproto.moretags) = "yaml:\"epochs_to_save\""]; uint64 latestParamChange = 4 [(gogoproto.moretags) = "yaml:\"latest_param_change\""]; - uint64 unstakeHoldBlocksStatic = 5 [(gogoproto.moretags) = "yaml:\"unstake_hold_blocks_static\""]; } \ No newline at end of file diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 99de6972ad..8c9d9c0db7 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -32,5 +32,5 @@ done cd .. # move proto files to the right places -cp -r github.com/lavanet/lava/* ./ +cp -r github.com/lavanet/lava/v2/* ./ rm -rf github.com diff --git a/scripts/test/inich_100_providers.sh b/scripts/test/inich_100_providers.sh new file mode 100755 index 0000000000..46c96b23c0 --- /dev/null +++ b/scripts/test/inich_100_providers.sh @@ -0,0 +1,131 @@ +#!/bin/bash +__dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source $__dir/../useful_commands.sh +. ${__dir}/vars/variables.sh +# Making sure old screens are not running +echo "current vote number $(latest_vote)" +killall screen +screen -wipe +GASPRICE="0.000000001ulava" + +echo; echo "#### Sending proposal for specs ####" +cd ./cookbook/specs/ || exit +lavad tx gov submit-legacy-proposal spec-add ./ibc.json,./tendermint.json,./cosmoswasm.json,./cosmossdk.json,./cosmossdk_45.json,./cosmossdk_full.json,./ethermint.json,./ethereum.json,./cosmoshub.json,./lava.json,./osmosis.json,./fantom.json,./celo.json,./optimism.json,./arbitrum.json,./starknet.json,./aptos.json,./juno.json,./polygon.json,./evmos.json,./base.json,./canto.json,./sui.json,./solana.json,./bsc.json,./axelar.json,./avalanche.json,./fvm.json,./near.json,./sqdsubgraph.json,./agoric.json,./koii.json,./stargaze.json,./blast.json,./secret.json,./celestia.json --lava-dev-test -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +cd ../../ || exit +echo; echo "#### Waiting 2 blocks ####" +wait_count_blocks 2 + +echo; echo "#### Voting on specs proposal ####" +lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Waiting 4 blocks ####" +wait_count_blocks 4 +sleep 4 + +echo; echo "#### Sending proposal for test plans add ####" +lavad tx gov submit-legacy-proposal plans-add ./cookbook/plans/test_plans/default.json,./cookbook/plans/test_plans/temporary-add.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Waiting 2 blocks ####" +wait_count_blocks 2 + +echo; echo "#### Voting on plans test add proposal ####" +lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Waiting 4 blocks ####" +wait_count_blocks 2 + +echo; echo "#### Sending proposal for plans add ####" +lavad tx gov submit-legacy-proposal plans-add ./cookbook/plans/explorer.json,./cookbook/plans/adventurer.json,./cookbook/plans/whale.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Waiting 2 blocks ####" +wait_count_blocks 2 + +echo; echo "#### Voting on plans add proposal ####" +lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Waiting 4 blocks ####" +wait_count_blocks 4 + +PROVIDERSTAKE="500000000000ulava" + +PROVIDER1_LISTENER="127.0.0.1:2221" +PROVIDER2_LISTENER="127.0.0.1:2222" +PROVIDER3_LISTENER="127.0.0.1:2223" + +sleep 4 + +echo; echo "#### Sending proposal for plans del ####" +lavad tx gov submit-legacy-proposal plans-del ./cookbook/plans/test_plans/temporary-del.json -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Waiting 2 blocks ####" +wait_count_blocks 2 + +echo; echo "#### Voting on plans del proposal ####" +lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Sending proposal for plans del ####" +lavad tx subscription buy DefaultPlan "$(lavad keys show user1 -a)" --enable-auto-renewal -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE +# wait_count_blocks 2 +# lavad tx project set-policy $(lavad keys show user1 -a)-admin ./cookbook/projects/policy_all_chains_with_addon.yml -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +# MANTLE +CHAINS="ETH1,SEP1,HOL1,OSMOSIS,FTM250,CELO,LAV1,OSMOSIST,ALFAJORES,ARB1,ARBN,APT1,STRK,JUN1,COSMOSHUB,POLYGON1,EVMOS,OPTM,BASES,CANTO,SUIT,SOLANA,BSC,AXELAR,AVAX,FVM,NEAR,SQDSUBGRAPH,AGR,AGRT,KOIIT,AVAXT,CELESTIATM" +BASE_CHAINS="ETH1,LAV1" +# stake providers on all chains +echo; echo "#### Staking provider 1 ####" +lavad tx pairing bulk-stake-provider $CHAINS $PROVIDERSTAKE "$PROVIDER1_LISTENER,1" 1 "$(operator_address)" -y --delegate-commission 50 --delegate-limit $PROVIDERSTAKE --from servicer1 --provider-moniker "servicer1" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Staking provider 2 ####" +lavad tx pairing bulk-stake-provider $BASE_CHAINS $PROVIDERSTAKE "$PROVIDER2_LISTENER,1" 1 "$(operator_address)" -y --delegate-commission 50 --delegate-limit $PROVIDERSTAKE --from servicer2 --provider-moniker "servicer2" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Staking provider 3 ####" +lavad tx pairing bulk-stake-provider $BASE_CHAINS $PROVIDERSTAKE "$PROVIDER3_LISTENER,1" 1 "$(operator_address)" -y --delegate-commission 50 --delegate-limit $PROVIDERSTAKE --from servicer3 --provider-moniker "servicer3" --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Staking 100 providers ####" +users=() +for i in $(seq 1 100); do + users+=("useroren$i") +done + +for user in "${users[@]}"; do + lavad tx pairing stake-provider ETH1 600000000000ulava "127.0.0.1:2221,EU" EU "$(operator_address)" --from $user -y --provider-moniker $user --gas-adjustment "1.5" --gas "auto" --gas-prices 0.000000001ulava --delegate-limit 0ulava +done + +echo; echo "#### Waiting 1 block ####" +wait_count_blocks 1 + +echo; echo "#### Delegating provider 1 ####" +lavad tx dualstaking delegate "$(lavad keys show servicer1 -a)" ETH1 "$(operator_address)" $PROVIDERSTAKE -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Waiting 1 block ####" +wait_count_blocks 1 + +echo; echo "#### Delegating provider 2 ####" +lavad tx dualstaking delegate "$(lavad keys show servicer2 -a)" ETH1 "$(operator_address)" $PROVIDERSTAKE -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +echo; echo "#### Waiting 1 block ####" +wait_count_blocks 1 + +echo; echo "#### Delegating provider 3 ####" +lavad tx dualstaking delegate "$(lavad keys show servicer3 -a)" ETH1 "$(operator_address)" $PROVIDERSTAKE -y --from user1 --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +# we need to wait for the next epoch for the stake to take action. +echo; echo "#### Waiting 1 epoch ####" +sleep_until_next_epoch + +HEALTH_FILE="config/health_examples/health_template.yml" +create_health_config $HEALTH_FILE "$(lavad keys show user1 -a)" "$(lavad keys show servicer2 -a)" "$(lavad keys show servicer3 -a)" + +lavad tx gov submit-legacy-proposal set-iprpc-data 1000000000ulava --min-cost 100ulava --add-subscriptions $(lavad keys show -a user1) --from alice -y +wait_count_blocks 1 +lavad tx gov vote "$(latest_vote)" yes -y --from alice --gas-adjustment "1.5" --gas "auto" --gas-prices $GASPRICE + +for user in "${users[@]}"; do + lavad tx pairing stake-provider ETH1 600000000000ulava "127.0.0.1:2221,EU" EU "$(operator_address)" --from $user -y --provider-moniker $user --gas-adjustment "1.5" --gas "auto" --gas-prices 0.000000001ulava --delegate-limit 0ulava +done + +wait_count_blocks 1 + +for user in "${users[@]}"; do + lavad q pairing get-pairing ETH1 user1 +done \ No newline at end of file diff --git a/scripts/test/init_chain_100_providers.sh b/scripts/test/init_chain_100_providers.sh new file mode 100755 index 0000000000..403faf6fa5 --- /dev/null +++ b/scripts/test/init_chain_100_providers.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# make install-all +killall -9 lavad +__dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source $__dir/../useful_commands.sh + +# Check if jq is not installed +if ! command_exists jq; then + echo "jq not found. Please install jq using the init_install.sh script or manually." + exit 1 +fi + +rm -rf ~/.lava +chainID="lava" +lavad init validator --chain-id $chainID +lavad config broadcast-mode sync +lavad config keyring-backend test + +# Specify the file path, field to edit, and new value +path="$HOME/.lava/config/" +genesis='genesis.json' +config='config.toml' +app='app.toml' + +# Edit genesis file +if [ "$1" == "debug" ]; then + # Edit genesis file with additional line + data=$(cat "$path$genesis" \ + | jq '.app_state.gov.params.min_deposit[0].denom = "ulava"' \ + | jq '.app_state.gov.params.min_deposit[0].amount = "100"' \ + | jq '.app_state.gov.params.voting_period = "4s"' \ + | jq '.app_state.gov.params.expedited_voting_period = "3s"' \ + | jq '.app_state.gov.params.expedited_min_deposit[0].denom = "ulava"' \ + | jq '.app_state.gov.params.expedited_min_deposit[0].amount = "200"' \ + | jq '.app_state.gov.params.expedited_threshold = "0.67"' \ + | jq '.app_state.mint.params.mint_denom = "ulava"' \ + | jq '.app_state.staking.params.bond_denom = "ulava"' \ + | jq '.app_state.crisis.constant_fee.denom = "ulava"' \ + | jq '.app_state.epochstorage.params.epochsToSave = "5"' \ + | jq '.app_state.epochstorage.params.epochBlocks = "4"' \ + | jq '.app_state.distribution.params.community_tax = "0"' \ + | jq '.app_state.rewards.params.validators_subscription_participation = "0"' \ + | jq '.app_state.downtime.params.downtime_duration = "1s"' \ + ) +else + # Edit genesis file without the additional line + data=$(cat "$path$genesis" \ + | jq '.app_state.gov.params.min_deposit[0].denom = "ulava"' \ + | jq '.app_state.gov.params.min_deposit[0].amount = "100"' \ + | jq '.app_state.gov.params.voting_period = "4s"' \ + | jq '.app_state.gov.params.expedited_voting_period = "3s"' \ + | jq '.app_state.gov.params.expedited_min_deposit[0].denom = "ulava"' \ + | jq '.app_state.gov.params.expedited_min_deposit[0].amount = "200"' \ + | jq '.app_state.gov.params.expedited_threshold = "0.67"' \ + | jq '.app_state.mint.params.mint_denom = "ulava"' \ + | jq '.app_state.mint.params.mint_denom = "ulava"' \ + | jq '.app_state.staking.params.bond_denom = "ulava"' \ + | jq '.app_state.crisis.constant_fee.denom = "ulava"' \ + | jq '.app_state.downtime.params.downtime_duration = "6s"' \ + | jq '.app_state.downtime.params.epoch_duration = "10s"' \ + | jq '.app_state.epochstorage.params.epochsToSave = "8"' \ + | jq '.app_state.epochstorage.params.epochBlocks = "20"' \ + | jq '.app_state.pairing.params.recommendedEpochNumToCollectPayment = "2"' \ + ) +fi + +echo -n "$data" > "$path$genesis" + +echo "using genesis file" +echo "$(cat "$path$genesis")" + +# Determine OS +case "$(uname)" in + Darwin) + SED_INLINE="-i ''" ;; + Linux) + SED_INLINE="-i" ;; + *) + echo "unknown system: $(uname)" + exit 1 ;; +esac + + +sed $SED_INLINE \ +-e 's/timeout_propose = .*/timeout_propose = "1s"/' \ +-e 's/timeout_propose_delta = .*/timeout_propose_delta = "500ms"/' \ +-e 's/timeout_prevote = .*/timeout_prevote = "1s"/' \ +-e 's/timeout_prevote_delta = .*/timeout_prevote_delta = "500ms"/' \ +-e 's/timeout_precommit = .*/timeout_precommit = "500ms"/' \ +-e 's/timeout_precommit_delta = .*/timeout_precommit_delta = "1s"/' \ +-e 's/timeout_commit = .*/timeout_commit = "1s"/' \ +-e 's/skip_timeout_commit = .*/skip_timeout_commit = false/' "$path$config" + +# Edit app.toml file +sed $SED_INLINE -e "s/enable = .*/enable = true/" "$path$app" +sed $SED_INLINE -e "/Enable defines if the Rosetta API server should be enabled.*/{n;s/enable = .*/enable = false/}" "$path$app" + +# Add users +users=("alice" "bob" "user1" "user2" "user3" "user4" "user5" "servicer1" "servicer2" "servicer3" "servicer4" "servicer5" "servicer6" "servicer7" "servicer8" "servicer9" "servicer10" "useroren1" "useroren2" "useroren3" "useroren4" "useroren5" "useroren6" "useroren7" "useroren8" "useroren9" "useroren10" "useroren11" "useroren12" "useroren13" "useroren14" "useroren15" "useroren16" "useroren17" "useroren18" "useroren19" "useroren20" "useroren21" "useroren22" "useroren23" "useroren24" "useroren25" "useroren26" "useroren27" "useroren28" "useroren29" "useroren30" "useroren31" "useroren32" "useroren33" "useroren34" "useroren35" "useroren36" "useroren37" "useroren38" "useroren39" "useroren40" "useroren41" "useroren42" "useroren43" "useroren44" "useroren45" "useroren46" "useroren47" "useroren48" "useroren49" "useroren50" "useroren51" "useroren52" "useroren53" "useroren54" "useroren55" "useroren56" "useroren57" "useroren58" "useroren59" "useroren60" "useroren61" "useroren62" "useroren63" "useroren64" "useroren65" "useroren66" "useroren67" "useroren68" "useroren69" "useroren70" "useroren71" "useroren72" "useroren73" "useroren74" "useroren75" "useroren76" "useroren77" "useroren78" "useroren79" "useroren80" "useroren81" "useroren82" "useroren83" "useroren84" "useroren85" "useroren86" "useroren87" "useroren88" "useroren89" "useroren90" "useroren91" "useroren92" "useroren93" "useroren94" "useroren95" "useroren96" "useroren97" "useroren98" "useroren99" "useroren100") + +for user in "${users[@]}"; do + lavad keys add "$user" --keyring-backend test + lavad add-genesis-account "$user" 50000000000000ulava --keyring-backend test +done + +# add validators_allocation_pool for validators block rewards +# its total balance is 3% from the total tokens amount: 10^9 * 10^6 ulava +lavad add-genesis-account validators_rewards_allocation_pool 30000000000000ulava --module-account +if [ "$1" == "debug" ]; then + lavad add-genesis-account providers_rewards_allocation_pool 0ulava --module-account +else + lavad add-genesis-account providers_rewards_allocation_pool 30000000000000ulava --module-account +fi +lavad add-genesis-account iprpc_pool 0ulava --module-account +lavad gentx alice 10000000000000ulava --chain-id $chainID --keyring-backend test +lavad collect-gentxs +lavad start --pruning=nothing \ No newline at end of file diff --git a/scripts/test/unstake_100_providers.sh b/scripts/test/unstake_100_providers.sh new file mode 100755 index 0000000000..ff27bb7f33 --- /dev/null +++ b/scripts/test/unstake_100_providers.sh @@ -0,0 +1,17 @@ +#!/bin/bash +__dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source $__dir/../useful_commands.sh +. ${__dir}/vars/variables.sh +# Making sure old screens are not running +echo "current vote number $(latest_vote)" +killall screen +screen -wipe +GASPRICE="0.000000001ulava" + +for i in $(seq 1 100); do + users+=("useroren$i") +done + +for user in "${users[@]}"; do + lavad tx pairing unstake-provider ETH1 "$(operator_address)" --from $user -y --gas-adjustment "1.5" --gas "auto" --gas-prices "$GASPRICE" +done \ No newline at end of file diff --git a/utils/collcompat/collcompat.go b/utils/collcompat/collcompat.go new file mode 100644 index 0000000000..c2d4588166 --- /dev/null +++ b/utils/collcompat/collcompat.go @@ -0,0 +1,118 @@ +package utils + +import ( + "context" + + collcodec "cosmossdk.io/collections/codec" + "cosmossdk.io/core/store" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/gogo/protobuf/proto" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func NewKVStoreService(storeKey storetypes.StoreKey) store.KVStoreService { + return &kvStoreService{key: storeKey} +} + +type kvStoreService struct { + key storetypes.StoreKey +} + +func (k kvStoreService) OpenKVStore(ctx context.Context) store.KVStore { + return newKVStore(sdk.UnwrapSDKContext(ctx).KVStore(k.key)) +} + +// CoreKVStore is a wrapper of Core/Store kvstore interface +// Remove after https://github.com/cosmos/cosmos-sdk/issues/14714 is closed +type coreKVStore struct { + kvStore storetypes.KVStore +} + +// NewKVStore returns a wrapper of Core/Store kvstore interface +// Remove once store migrates to core/store kvstore interface +func newKVStore(store storetypes.KVStore) store.KVStore { + return coreKVStore{kvStore: store} +} + +// Get returns nil iff key doesn't exist. Errors on nil key. +func (store coreKVStore) Get(key []byte) ([]byte, error) { + return store.kvStore.Get(key), nil +} + +// Has checks if a key exists. Errors on nil key. +func (store coreKVStore) Has(key []byte) (bool, error) { + return store.kvStore.Has(key), nil +} + +// Set sets the key. Errors on nil key or value. +func (store coreKVStore) Set(key, value []byte) error { + store.kvStore.Set(key, value) + return nil +} + +// Delete deletes the key. Errors on nil key. +func (store coreKVStore) Delete(key []byte) error { + store.kvStore.Delete(key) + return nil +} + +// Iterator iterates over a domain of keys in ascending order. End is exclusive. +// Start must be less than end, or the Iterator is invalid. +// Iterator must be closed by caller. +// To iterate over entire domain, use store.Iterator(nil, nil) +// CONTRACT: No writes may happen within a domain while an iterator exists over it. +// Exceptionally allowed for cachekv.Store, safe to write in the modules. +func (store coreKVStore) Iterator(start, end []byte) (store.Iterator, error) { + return store.kvStore.Iterator(start, end), nil +} + +func (store coreKVStore) ReverseIterator(start, end []byte) (store.Iterator, error) { + return store.kvStore.ReverseIterator(start, end), nil +} + +type protoMessage[T any] interface { + *T + codec.ProtoMarshaler +} + +// ProtoValue inits a collections.ValueCodec for a generic gogo protobuf message. +func ProtoValue[T any, PT protoMessage[T]](cdc codec.BinaryCodec) collcodec.ValueCodec[T] { + c, ok := cdc.(codec.Codec) + if !ok { + return &collValue[T, PT]{} + } + return &collValue[T, PT]{c, proto.MessageName(PT(new(T)))} +} + +type collValue[T any, PT protoMessage[T]] struct { + cdc codec.Codec + messageName string +} + +func (c collValue[T, PT]) Encode(value T) ([]byte, error) { + return c.cdc.Marshal(PT(&value)) +} + +func (c collValue[T, PT]) Decode(b []byte) (value T, err error) { + err = c.cdc.Unmarshal(b, PT(&value)) + return value, err +} + +func (c collValue[T, PT]) EncodeJSON(value T) ([]byte, error) { + return c.cdc.MarshalJSON(PT(&value)) +} + +func (c collValue[T, PT]) DecodeJSON(b []byte) (value T, err error) { + err = c.cdc.UnmarshalJSON(b, PT(&value)) + return +} + +func (c collValue[T, PT]) Stringify(value T) string { + return PT(&value).String() +} + +func (c collValue[T, PT]) ValueType() string { + return "github.com/cosmos/gogoproto/" + c.messageName +} diff --git a/x/conflict/keeper/conflict.go b/x/conflict/keeper/conflict.go index 453dcf56b5..d9d218c528 100644 --- a/x/conflict/keeper/conflict.go +++ b/x/conflict/keeper/conflict.go @@ -103,7 +103,7 @@ func (k Keeper) ValidateResponseConflict(ctx sdk.Context, conflictData *types.Re if err != nil { return nil, fmt.Errorf("AccAddressFromHex %s provider: %w", print_st, err) } - stakeEntry, found := k.epochstorageKeeper.GetStakeEntryForProviderEpoch(ctx, chainID, providerAddress.String(), epochStart) + stakeEntry, found := k.epochstorageKeeper.GetStakeEntry(ctx, epochStart, chainID, providerAddress.String()) if !found { return nil, fmt.Errorf("did not find a stake entry for %s provider %s on epoch %d, chainID %s", print_st, providerAddress, epochStart, chainID) } diff --git a/x/conflict/keeper/msg_server_detection.go b/x/conflict/keeper/msg_server_detection.go index 2c4786373d..d17c0ce907 100644 --- a/x/conflict/keeper/msg_server_detection.go +++ b/x/conflict/keeper/msg_server_detection.go @@ -142,16 +142,13 @@ func (k msgServer) Detection(goCtx context.Context, msg *types.MsgDetection) (*t func (k Keeper) LotteryVoters(goCtx context.Context, epoch uint64, chainID string, exemptions []string) []string { ctx := sdk.UnwrapSDKContext(goCtx) - entries, err := k.epochstorageKeeper.GetStakeEntryForAllProvidersEpoch(ctx, chainID, epoch) - if err != nil { - return make([]string, 0) - } + entries := k.epochstorageKeeper.GetAllStakeEntriesForEpochChainId(ctx, epoch, chainID) freezeFilter := pairingfilters.FrozenProvidersFilter{} - frozenProviders := freezeFilter.Filter(ctx, *entries, epoch) // bool array -> true == not frozen + frozenProviders := freezeFilter.Filter(ctx, entries, epoch) // bool array -> true == not frozen voters := make([]string, 0) - for i, entry := range *entries { + for i, entry := range entries { if !slices.Contains(exemptions, entry.Address) && frozenProviders[i] { voters = append(voters, entry.Address) } diff --git a/x/conflict/keeper/vote.go b/x/conflict/keeper/vote.go index 63757e7967..461821e65e 100644 --- a/x/conflict/keeper/vote.go +++ b/x/conflict/keeper/vote.go @@ -89,7 +89,7 @@ func (k Keeper) HandleAndCloseVote(ctx sdk.Context, conflictVote types.ConflictV } for _, vote := range conflictVote.Votes { - entry, found := k.epochstorageKeeper.GetStakeEntryForProviderEpoch(ctx, conflictVote.ChainID, vote.Address, epochVoteStart) + entry, found := k.epochstorageKeeper.GetStakeEntry(ctx, epochVoteStart, conflictVote.ChainID, vote.Address) if !found { utils.LavaFormatWarning("failed to get stake entry for provider in voter list", fmt.Errorf("stake entry not found"), utils.Attribute{Key: "voteID", Value: conflictVote.Index}, diff --git a/x/conflict/types/expected_keepers.go b/x/conflict/types/expected_keepers.go index 3483a9edd1..215558e9be 100644 --- a/x/conflict/types/expected_keepers.go +++ b/x/conflict/types/expected_keepers.go @@ -26,11 +26,10 @@ type EpochstorageKeeper interface { BlocksToSave(ctx sdk.Context, block uint64) (res uint64, err error) GetEarliestEpochStart(ctx sdk.Context) uint64 GetEpochStartForBlock(ctx sdk.Context, block uint64) (epochStart, blockInEpoch uint64, err error) - GetStakeEntryForProviderEpoch(ctx sdk.Context, chainID string, selectedProvider string, epoch uint64) (entry epochstoragetypes.StakeEntry, found bool) - GetStakeEntryForAllProvidersEpoch(ctx sdk.Context, chainID string, epoch uint64) (entrys *[]epochstoragetypes.StakeEntry, err error) - ModifyStakeEntryCurrent(ctx sdk.Context, chainID string, stakeEntry epochstoragetypes.StakeEntry) - GetStakeEntryByAddressCurrent(ctx sdk.Context, chainID string, address string) (value epochstoragetypes.StakeEntry, found bool) + GetStakeEntryCurrent(ctx sdk.Context, chainID string, address string) (value epochstoragetypes.StakeEntry, found bool) PushFixatedParams(ctx sdk.Context, block, limit uint64) + GetStakeEntry(ctx sdk.Context, epoch uint64, chainID string, provider string) (val epochstoragetypes.StakeEntry, found bool) + GetAllStakeEntriesForEpochChainId(ctx sdk.Context, epoch uint64, chainID string) []epochstoragetypes.StakeEntry } type SpecKeeper interface { diff --git a/x/dualstaking/keeper/delegate.go b/x/dualstaking/keeper/delegate.go index de0e326752..d95ac248cf 100644 --- a/x/dualstaking/keeper/delegate.go +++ b/x/dualstaking/keeper/delegate.go @@ -176,7 +176,7 @@ func (k Keeper) decreaseDelegation(ctx sdk.Context, delegator, provider, chainID // modifyStakeEntryDelegation modifies the (epochstorage) stake-entry of the provider for a chain based on the action (increase or decrease). func (k Keeper) modifyStakeEntryDelegation(ctx sdk.Context, delegator, provider, chainID string, amount sdk.Coin, increase bool) (err error) { - stakeEntry, exists := k.epochstorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, provider) + stakeEntry, exists := k.epochstorageKeeper.GetStakeEntryCurrent(ctx, chainID, provider) if !exists || provider != stakeEntry.Address { if increase { return epochstoragetypes.ErrProviderNotStaked @@ -216,17 +216,9 @@ func (k Keeper) modifyStakeEntryDelegation(ctx sdk.Context, delegator, provider, } if stakeEntry.Stake.IsLT(k.GetParams(ctx).MinSelfDelegation) { - err = k.epochstorageKeeper.RemoveStakeEntryCurrent(ctx, chainID, stakeEntry.Vault) - if err != nil { - return utils.LavaFormatError("can't remove stake Entry after decreasing provider self delegation", err, - utils.Attribute{Key: "provider", Value: stakeEntry.Address}, - utils.Attribute{Key: "spec", Value: chainID}, - ) - } + k.epochstorageKeeper.RemoveStakeEntryCurrent(ctx, chainID, stakeEntry.Address) details["min_self_delegation"] = k.GetParams(ctx).MinSelfDelegation.String() utils.LogLavaEvent(ctx, k.Logger(ctx), types.UnstakeFromUnbond, details, "unstaking provider due to unbond that lowered its stake below min self delegation") - unstakeHoldBlocks := k.epochstorageKeeper.GetUnstakeHoldBlocks(ctx, stakeEntry.Chain) - k.epochstorageKeeper.AppendUnstakeEntry(ctx, stakeEntry, unstakeHoldBlocks) return nil } else if stakeEntry.EffectiveStake().LT(k.specKeeper.GetMinStake(ctx, chainID).Amount) { details["min_spec_stake"] = k.specKeeper.GetMinStake(ctx, chainID).String() @@ -236,7 +228,7 @@ func (k Keeper) modifyStakeEntryDelegation(ctx sdk.Context, delegator, provider, stakeEntry.UnFreeze(k.epochstorageKeeper.GetCurrentNextEpoch(ctx) + 1) } - k.epochstorageKeeper.ModifyStakeEntryCurrent(ctx, chainID, stakeEntry) + k.epochstorageKeeper.SetStakeEntryCurrent(ctx, stakeEntry) return nil } diff --git a/x/dualstaking/keeper/delegator_reward.go b/x/dualstaking/keeper/delegator_reward.go index 23dc6304bd..009491ccea 100644 --- a/x/dualstaking/keeper/delegator_reward.go +++ b/x/dualstaking/keeper/delegator_reward.go @@ -181,7 +181,7 @@ func (k Keeper) RewardProvidersAndDelegators(ctx sdk.Context, provider string, c utils.Attribute{Key: "block", Value: block}, ) } - stakeEntry, found := k.epochstorageKeeper.GetStakeEntryForProviderEpoch(ctx, chainID, provider, epoch) + stakeEntry, found := k.epochstorageKeeper.GetStakeEntry(ctx, epoch, chainID, provider) if !found { return zeroCoins, zeroCoins, err } diff --git a/x/dualstaking/keeper/helpers_test.go b/x/dualstaking/keeper/helpers_test.go index 88b7801148..31ab04597d 100644 --- a/x/dualstaking/keeper/helpers_test.go +++ b/x/dualstaking/keeper/helpers_test.go @@ -95,7 +95,7 @@ func (ts *tester) getStakeEntry(provider string, chainID string) epochstoragetyp epoch := ts.EpochStart() keeper := ts.Keepers.Epochstorage - stakeEntry, found := keeper.GetStakeEntryForProviderEpoch(ts.Ctx, chainID, provider, epoch) + stakeEntry, found := keeper.GetStakeEntry(ts.Ctx, epoch, chainID, provider) if !found { panic("getStakeEntry: no stake entry: " + provider + " " + chainID) } diff --git a/x/dualstaking/keeper/hooks_test.go b/x/dualstaking/keeper/hooks_test.go index 1ec8293fe4..a7000d6c50 100644 --- a/x/dualstaking/keeper/hooks_test.go +++ b/x/dualstaking/keeper/hooks_test.go @@ -124,7 +124,7 @@ func TestReDelegateToProvider(t *testing.T) { require.NoError(t, err) epoch := ts.EpochStart() - entry, found := ts.Keepers.Epochstorage.GetStakeEntryForProviderEpoch(ts.Ctx, ts.spec.Index, provider, epoch) + entry, found := ts.Keepers.Epochstorage.GetStakeEntry(ts.Ctx, epoch, ts.spec.Index, provider) require.True(t, found) require.Equal(t, amount, entry.Stake.Amount) @@ -155,7 +155,7 @@ func TestReDelegateToProvider(t *testing.T) { ts.AdvanceEpoch() epoch = ts.EpochStart() - entry, found = ts.Keepers.Epochstorage.GetStakeEntryForProviderEpoch(ts.Ctx, ts.spec.Index, provider, epoch) + entry, found = ts.Keepers.Epochstorage.GetStakeEntry(ts.Ctx, epoch, ts.spec.Index, provider) require.True(t, found) require.Equal(t, amount, entry.DelegateTotal.Amount) require.Equal(t, amount, entry.Stake.Amount) @@ -583,7 +583,7 @@ func TestUnbondValidatorButNotRemoveStakeEntry(t *testing.T) { require.Error(t, err) // checking that provider is not found - _, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + _, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.False(t, found) _, err = ts.QueryDualstakingProviderDelegators(provider, true) @@ -645,26 +645,10 @@ func TestUndelegateProvider(t *testing.T) { require.NoError(t, err) fmt.Println("Delegation of Provider before provider is removed", res2) - unstakeHoldBlocks := ts.Keepers.Epochstorage.UnstakeHoldBlocks(ts.Ctx, ts.BlockHeight()) - unstakeHoldBlocksStatic := ts.Keepers.Epochstorage.UnstakeHoldBlocksStatic(ts.Ctx, ts.BlockHeight()) - _, err = ts.TxPairingUnstakeProvider(providerAcct.GetVaultAddr(), ts.spec.Index) require.NoError(t, err) - ts.AdvanceBlocks(unstakeHoldBlocks) - - _, found := ts.Keepers.Epochstorage.UnstakeEntryByAddress(ts.Ctx, providerAcct.GetVaultAddr()) - require.True(t, found) - - ts.AdvanceBlocks(unstakeHoldBlocksStatic - unstakeHoldBlocks) - - // checking that provider can't be found - _, found = ts.Keepers.Epochstorage.UnstakeEntryByAddress(ts.Ctx, providerAcct.GetVaultAddr()) - require.False(t, found) - - ts.AdvanceEpoch() - - _, found = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + _, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.False(t, found) // delegation of the removed provider @@ -673,11 +657,13 @@ func TestUndelegateProvider(t *testing.T) { require.NoError(t, err) fmt.Println("Delegation of Provider after provider is removed", res2) + ts.AdvanceEpochUntilStale() + // stake provider again err = ts.StakeProvider(providerAcct.GetVaultAddr(), providerAcct.Addr.String(), ts.spec, sdk.NewIntFromUint64(1000).Int64()) require.NoError(t, err) - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) fmt.Println("Stake entry of re-staked provider", stakeEntry.String()) @@ -690,7 +676,7 @@ func TestUndelegateProvider(t *testing.T) { sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(1))) require.NoError(t, err) - stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) fmt.Println("Stake entry of re-staked provider after del1 9999 redelegation", stakeEntry.String()) diff --git a/x/dualstaking/keeper/migrations.go b/x/dualstaking/keeper/migrations.go index 505cf403ff..ca4564d49a 100644 --- a/x/dualstaking/keeper/migrations.go +++ b/x/dualstaking/keeper/migrations.go @@ -1,18 +1,12 @@ package keeper import ( - "encoding/json" - "fmt" - _ "embed" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/lavanet/lava/v2/utils" - commontypes "github.com/lavanet/lava/v2/utils/common/types" dualstakingv4 "github.com/lavanet/lava/v2/x/dualstaking/migrations/v4" dualstakingtypes "github.com/lavanet/lava/v2/x/dualstaking/types" - epochstoragetypes "github.com/lavanet/lava/v2/x/epochstorage/types" "github.com/lavanet/lava/v2/x/pairing/types" ) @@ -24,355 +18,6 @@ func NewMigrator(keeper Keeper) Migrator { return Migrator{keeper: keeper} } -// ConvertProviderStakeToSelfDelegation does: -// 1. zero out each provider stake and return their money -// 2. use that same money to make the providers self delegate -func (m Migrator) ConvertProviderStakeToSelfDelegation(ctx sdk.Context) error { - // get highest staked validator - validatorsByPower := m.keeper.stakingKeeper.GetBondedValidatorsByPower(ctx) - highestVal := validatorsByPower[0] - - // loop over all providers - chains := m.keeper.specKeeper.GetAllChainIDs(ctx) - for _, chainID := range chains { - storage, found := m.keeper.epochstorageKeeper.GetStakeStorageCurrent(ctx, chainID) - if found { - for _, entry := range storage.StakeEntries { - // return the providers all their coins - addr, err := sdk.AccAddressFromBech32(entry.Address) - if err != nil { - return err - } - - err = m.keeper.bankKeeper.MintCoins(ctx, types.ModuleName, []sdk.Coin{entry.Stake}) - if err != nil { - return err - } - - err = m.keeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, []sdk.Coin{entry.Stake}) - if err != nil { - utils.LavaFormatError("failed to send coins from module to account", err, - utils.Attribute{Key: "Account", Value: addr}, - ) - } - - // create self delegation, this will increase the stake entry, we need to fix that by reseting the stake before delegating - stake := entry.Stake - entry.Stake.Amount = sdk.ZeroInt() - m.keeper.epochstorageKeeper.ModifyStakeEntryCurrent(ctx, chainID, entry) - err = m.keeper.DelegateFull(ctx, entry.Address, highestVal.OperatorAddress, entry.Address, chainID, stake) - if err != nil { - return err - } - } - } - } - - moduleBalance := m.keeper.bankKeeper.GetBalance(ctx, m.keeper.accountKeeper.GetModuleAddress(types.ModuleName), m.keeper.stakingKeeper.BondDenom(ctx)) - if !moduleBalance.IsZero() { - err := m.keeper.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(moduleBalance)) - if err != nil { - return err - } - } - - return nil -} - -// HandleProviderDelegators does: -// 1. merge the deprecated bonded and not-bonded pool funds -// 2. return the providers' delegators money back from the merged pool -// 3. use the same money to delegate to both the original delegation's provider and highest staked validator -func (m Migrator) HandleProviderDelegators(ctx sdk.Context) error { - delegationsInds := m.keeper.delegationFS.GetAllEntryIndices(ctx) - nextEpoch := m.keeper.epochstorageKeeper.GetCurrentNextEpoch(ctx) - - // burn all coins from the pools - moduleBalance := m.keeper.bankKeeper.GetBalance(ctx, m.keeper.accountKeeper.GetModuleAddress(dualstakingtypes.BondedPoolName), m.keeper.stakingKeeper.BondDenom(ctx)) - if !moduleBalance.IsZero() { - err := m.keeper.bankKeeper.BurnCoins(ctx, dualstakingtypes.BondedPoolName, sdk.NewCoins(moduleBalance)) - if err != nil { - return err - } - } - - if !moduleBalance.IsZero() { - moduleBalance = m.keeper.bankKeeper.GetBalance(ctx, m.keeper.accountKeeper.GetModuleAddress(dualstakingtypes.NotBondedPoolName), m.keeper.stakingKeeper.BondDenom(ctx)) - err := m.keeper.bankKeeper.BurnCoins(ctx, dualstakingtypes.NotBondedPoolName, sdk.NewCoins(moduleBalance)) - if err != nil { - return err - } - } - - // give money back to delegators from the bonded pool - originalDelegations := []dualstakingtypes.Delegation{} - for _, ind := range delegationsInds { - // find the delegation and keep its original form - var d dualstakingtypes.Delegation - block, _, _, found := m.keeper.delegationFS.FindEntryDetailed(ctx, ind, nextEpoch, &d) - if !found { - continue - } - - if d.Delegator == d.Provider || d.Provider == commontypes.EMPTY_PROVIDER { - continue - } - - originalAmount := d.Amount - - // zero the delegation amount in the fixation store - d.Amount = sdk.NewCoin(m.keeper.stakingKeeper.BondDenom(ctx), sdk.ZeroInt()) - m.keeper.delegationFS.ModifyEntry(ctx, ind, block, &d) - - // give money back from the bonded pool - delegatorAddr, err := sdk.AccAddressFromBech32(d.Delegator) - if err != nil { - return err - } - - err = m.keeper.bankKeeper.MintCoins(ctx, types.ModuleName, []sdk.Coin{originalAmount}) - if err != nil { - return err - } - - err = m.keeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, delegatorAddr, sdk.Coins{originalAmount}) - if err != nil { - return err - } - - entry, found := m.keeper.epochstorageKeeper.GetStakeEntryByAddressCurrent(ctx, d.ChainID, d.Provider) - if !found { - continue - } - entry.DelegateTotal = entry.DelegateTotal.Sub(originalAmount) - m.keeper.epochstorageKeeper.ModifyStakeEntryCurrent(ctx, d.ChainID, entry) - - originalDelegations = append(originalDelegations, d) - } - - // get highest staked validator and delegate to it - validatorsByPower := m.keeper.stakingKeeper.GetBondedValidatorsByPower(ctx) - highestVal := validatorsByPower[0] - for _, d := range originalDelegations { - err := m.keeper.DelegateFull(ctx, d.Delegator, highestVal.OperatorAddress, d.Provider, d.ChainID, d.Amount) - if err != nil { - return err - } - } - - return nil -} - -// HandleValidatorsDelegators does: -// 1. get each validator's delegators -// 2. delegate the amount of their delegation to the empty provider (using the AfterDelegationModified hook) -func (m Migrator) HandleValidatorsDelegators(ctx sdk.Context) error { - // get all validators - validators := m.keeper.stakingKeeper.GetAllValidators(ctx) - - // for each validator+delegator, run the AfterDelegationModified to delegate to empty provider - for _, v := range validators { - delegations := m.keeper.stakingKeeper.GetValidatorDelegations(ctx, v.GetOperator()) - for _, d := range delegations { - err := m.keeper.Hooks().AfterDelegationModified(ctx, d.GetDelegatorAddr(), v.GetOperator()) - if err != nil { - return err - } - } - } - - return nil -} - -// VerifyDelegationsBalance gets all delegators (from both providers and validators) -// and verifies that each delegator has the same amount of delegations in both the provider -// and validator sides -func (m Migrator) VerifyDelegationsBalance(ctx sdk.Context) error { - delegationsInds := m.keeper.delegationFS.GetAllEntryIndices(ctx) - validators := m.keeper.stakingKeeper.GetAllValidators(ctx) - nextEpoch := m.keeper.epochstorageKeeper.GetCurrentNextEpoch(ctx) - - // get all the providers' delegators - var delegators []sdk.AccAddress - for _, ind := range delegationsInds { - var d dualstakingtypes.Delegation - found := m.keeper.delegationFS.FindEntry(ctx, ind, nextEpoch, &d) - if !found { - continue - } - delegatorAddr, err := sdk.AccAddressFromBech32(d.Delegator) - if err != nil { - return err - } - delegators = append(delegators, delegatorAddr) - } - - // get all the validators' delegators - for _, v := range validators { - delegations := m.keeper.stakingKeeper.GetValidatorDelegations(ctx, v.GetOperator()) - for _, d := range delegations { - delegatorAddr, err := sdk.AccAddressFromBech32(d.DelegatorAddress) - if err != nil { - return err - } - delegators = append(delegators, delegatorAddr) - } - } - - // verify delegations balance for each delegator - for _, d := range delegators { - diff, _, err := m.keeper.VerifyDelegatorBalance(ctx, d) - if err != nil { - return err - } - - if !diff.IsZero() { - return utils.LavaFormatError("delegations balance migration failed", fmt.Errorf("delegator not balanced"), - utils.Attribute{Key: "delegator", Value: d.String()}, - utils.Attribute{Key: "diff", Value: diff.String()}, - ) - } - } - - return nil -} - -// MigrateVersion1To2 implements store migration: Create a self delegation for all providers, Make providers-validators delegations balance -func (m Migrator) MigrateVersion1To2(ctx sdk.Context) error { - // first balance all validators - err := m.HandleValidatorsDelegators(ctx) - if err != nil { - return err - } - - // create providers self delegations - err = m.ConvertProviderStakeToSelfDelegation(ctx) - if err != nil { - return err - } - - // convert the rest of the delegations - err = m.HandleProviderDelegators(ctx) - if err != nil { - return err - } - - // verify the balance once again to make sure - err = m.VerifyDelegationsBalance(ctx) - if err != nil { - return err - } - - return nil -} - -// MigrateVersion2To3 implements store migration: Create a self delegation for all providers, Make providers-validators delegations balance -func (m Migrator) MigrateVersion2To3(ctx sdk.Context) error { - nextEpoch := m.keeper.epochstorageKeeper.GetCurrentNextEpoch(ctx) - chains := m.keeper.specKeeper.GetAllChainIDs(ctx) - OldStakeStorages := GetStakeStorages(ctx.ChainID()) - for _, chainID := range chains { - storage, found := m.keeper.epochstorageKeeper.GetStakeStorageCurrent(ctx, chainID) - if found { - providers := map[string]interface{}{} - stakeEntries := []epochstoragetypes.StakeEntry{} - - duplicated := 0 - missing := 0 - // remove duplicates - for _, entry := range storage.StakeEntries { - if _, ok := providers[entry.Address]; !ok { - d, found := m.keeper.GetDelegation(ctx, entry.Address, entry.Address, entry.Chain, nextEpoch) - if found { - delegations, err := m.keeper.GetProviderDelegators(ctx, entry.Address, nextEpoch) - if err == nil { - entry.DelegateTotal.Amount = sdk.ZeroInt() - for _, d := range delegations { - if d.Delegator != d.Provider && d.ChainID == chainID { - entry.DelegateTotal.Amount = entry.DelegateTotal.Amount.Add(d.Amount.Amount) - } - } - } else { - fmt.Println("didnt find delegations for:", entry.Address) - } - entry.Stake = d.Amount - stakeEntries = append(stakeEntries, entry) - } else { - fmt.Println("didnt find self delegation for:", entry.Address) - } - - providers[entry.Address] = struct{}{} - } else { - duplicated++ - } - } - - // add back the old ones if they were deleted - if len(OldStakeStorages) > 0 { - deletedEntriesToAdd := OldStakeStorages[chainID] - for _, entry := range deletedEntriesToAdd.StakeEntries { - if _, ok := providers[entry.Address]; !ok { - d, found := m.keeper.GetDelegation(ctx, entry.Address, entry.Address, entry.Chain, nextEpoch) - if found { - missing++ - delegations, err := m.keeper.GetProviderDelegators(ctx, entry.Address, nextEpoch) - if err == nil { - entry.DelegateTotal.Amount = sdk.ZeroInt() - for _, d := range delegations { - if d.Delegator != d.Provider && d.ChainID == chainID { - entry.DelegateTotal.Amount = entry.DelegateTotal.Amount.Add(d.Amount.Amount) - } - } - } - entry.Stake = d.Amount - stakeEntries = append(stakeEntries, entry) - } - } - } - } - - utils.LavaFormatInfo("Migrator for chain id providers", utils.LogAttr("chainID", chainID), - utils.LogAttr("duplicated", duplicated), - utils.LogAttr("missing", missing)) - storage.StakeEntries = stakeEntries - m.keeper.epochstorageKeeper.SetStakeStorageCurrent(ctx, storage.Index, storage) - } - } - return nil -} - -var ( - good_stakeStorage_lava_staging_4 []byte - good_stakeStorage_lava_testnet_2 []byte -) - -func GetStakeStorages(lavaChainID string) map[string]epochstoragetypes.StakeStorage { - var payload []byte - if lavaChainID == "lava-testnet-2" { - payload = good_stakeStorage_lava_testnet_2 - } else if lavaChainID == "lava-staging-4" { - payload = good_stakeStorage_lava_staging_4 - } - - var stakestorages []epochstoragetypes.StakeStorage - err := json.Unmarshal(payload, &stakestorages) - if err != nil { - utils.LavaFormatWarning("Could not unmarshal stakestorages", err, utils.LogAttr("chainID", lavaChainID), utils.LogAttr("PayloadLen", len(payload))) - } - - stakestoragesMap := map[string]epochstoragetypes.StakeStorage{} - for _, stakestorage := range stakestorages { - stakestoragesMap[stakestorage.Index] = stakestorage - } - return stakestoragesMap -} - -// MigrateVersion3To4 sets the DisableDualstakingHook flag to false -func (m Migrator) MigrateVersion3To4(ctx sdk.Context) error { - m.keeper.SetDisableDualstakingHook(ctx, false) - return nil -} - // MigrateVersion4To5 change the DelegatorReward object amount's field from sdk.Coin to sdk.Coins func (m Migrator) MigrateVersion4To5(ctx sdk.Context) error { delegatorRewards := m.GetAllDelegatorRewardV4(ctx) diff --git a/x/dualstaking/module.go b/x/dualstaking/module.go index f65a92b893..e71b104208 100644 --- a/x/dualstaking/module.go +++ b/x/dualstaking/module.go @@ -118,24 +118,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { migrator := keeper.NewMigrator(am.keeper) - // register v1 -> v2 migration - if err := cfg.RegisterMigration(types.ModuleName, 1, migrator.MigrateVersion1To2); err != nil { - // panic:ok: at start up, migration cannot proceed anyhow - panic(fmt.Errorf("%s: failed to register migration to v2: %w", types.ModuleName, err)) - } - - // register v2 -> v3 migration - if err := cfg.RegisterMigration(types.ModuleName, 2, migrator.MigrateVersion2To3); err != nil { - // panic:ok: at start up, migration cannot proceed anyhow - panic(fmt.Errorf("%s: failed to register migration to v3: %w", types.ModuleName, err)) - } - - // register v3 -> v4 migration - if err := cfg.RegisterMigration(types.ModuleName, 3, migrator.MigrateVersion3To4); err != nil { - // panic:ok: at start up, migration cannot proceed anyhow - panic(fmt.Errorf("%s: failed to register migration to v4: %w", types.ModuleName, err)) - } - // register v4 -> v5 migration if err := cfg.RegisterMigration(types.ModuleName, 4, migrator.MigrateVersion4To5); err != nil { // panic:ok: at start up, migration cannot proceed anyhow diff --git a/x/dualstaking/types/expected_keepers.go b/x/dualstaking/types/expected_keepers.go index 0ce6703669..b9804b0e63 100644 --- a/x/dualstaking/types/expected_keepers.go +++ b/x/dualstaking/types/expected_keepers.go @@ -32,19 +32,12 @@ type BankKeeper interface { } type EpochstorageKeeper interface { - GetStakeEntryByAddressCurrent(ctx sdk.Context, chainID string, address string) (value epochstoragetypes.StakeEntry, found bool) - ModifyStakeEntryCurrent(ctx sdk.Context, chainID string, stakeEntry epochstoragetypes.StakeEntry) - UnstakeHoldBlocks(ctx sdk.Context, block uint64) (res uint64) - UnstakeHoldBlocksStatic(ctx sdk.Context, block uint64) (res uint64) - GetStakeEntryForProviderEpoch(ctx sdk.Context, chainID string, selectedProvider string, epoch uint64) (entry epochstoragetypes.StakeEntry, found bool) + GetStakeEntryCurrent(ctx sdk.Context, chainID string, address string) (value epochstoragetypes.StakeEntry, found bool) + SetStakeEntryCurrent(ctx sdk.Context, stakeEntry epochstoragetypes.StakeEntry) GetEpochStartForBlock(ctx sdk.Context, block uint64) (epochStart, blockInEpoch uint64, err error) GetCurrentNextEpoch(ctx sdk.Context) (nextEpoch uint64) - GetStakeStorageCurrent(ctx sdk.Context, chainID string) (epochstoragetypes.StakeStorage, bool) - SetStakeStorageCurrent(ctx sdk.Context, chainID string, stakeStorage epochstoragetypes.StakeStorage) - RemoveStakeEntryCurrent(ctx sdk.Context, chainID string, address string) error - AppendUnstakeEntry(ctx sdk.Context, stakeEntry epochstoragetypes.StakeEntry, unstakeHoldBlocks uint64) - GetUnstakeHoldBlocks(ctx sdk.Context, chainID string) uint64 - UnstakeEntryByAddress(ctx sdk.Context, address string) (value epochstoragetypes.StakeEntry, found bool) + RemoveStakeEntryCurrent(ctx sdk.Context, chainID string, address string) + GetStakeEntry(ctx sdk.Context, epoch uint64, chainID string, provider string) (val epochstoragetypes.StakeEntry, found bool) // Methods imported from epochstorage should be defined here } diff --git a/x/epochstorage/README.md b/x/epochstorage/README.md index ee40abdf4b..cab73a26ac 100644 --- a/x/epochstorage/README.md +++ b/x/epochstorage/README.md @@ -13,8 +13,8 @@ Note that the module will make sure that any changes will be applied only in the * [Epoch](#epoch) * [EpochDetails](#epochdetails) * [FixatedParams](#fixatedparams) - * [StakeStorage](#stakeStorage) * [StakeEntry](#stakeentry) + * [StakeEntry Storage](#stakeentry-storage) * [Parameters](#parameters) * [Queries](#queries) * [Transactions](#transactions) @@ -63,28 +63,6 @@ type FixatedParams struct { This is done in the [BeginBlock method of the module](keeper/fixated_params.go) - -### StakeStorage - -StakeStorage is an object that is saved on the store per epoch. it contains the list of all the providers that are available in this epoch per chainID. - -```go -type StakeStorage struct { - Index string // index of the stake storage (epoch + chainid) - StakeEntries []StakeEntry // list of providers stake - EpochBlockHash []byte // the block hash of the of the epoch block (used as salt for pairing) -} -``` - -The index of the stakestorage is constructed from the epoch and chainID, for example: "100 ETH1" - -When a provider stakes itself to a chain (using the pairing module) it will be in the providers list of the next epoch. the stake storage of the next epoch (e.g. current stakestorage) is where all the changes are registered. - -When a new epoch starts, the module will create a copy of the current stake and save it as a specific epoch stake storage. this is done in the BeginBlock method of the module. - -Also, when a new epoch starts the epoch storage will delete any outdated stakestorage (determined by the param EpochsToSave). -Note that if a stakestorage does not exist (either if it was deleted or it is in the future), verify pairing and relay payments will fail for the requested epoch (look at pairing readme). - ### StakeEntry The stake entry is a struct that contains all the information of a provider. @@ -116,6 +94,14 @@ for more about [geolocation](../../proto/lavanet/lava/plans/plan.proto). For more information about delegation, go to dualstaking [README.md](../dualstaking/README.md). +#### StakeEntry Storage + +Stake entries are kept in two dedicated KV stores. One store keeps the current stake entries and the other keeps past stake entries (by epoch). + +The current stake entries store is updated when a provider stakes itself to a chain (using the pairing module). This will make it be in the providers list of the next epoch. + +When a new epoch starts, the epochstorage module will create a copy of the current stake entries and save it in the past stake entries store with their matching epoch. Then, every outdated stake entry is deleted (determined by the param EpochsToSave). + ### EndPoint Endpoint is a struct that describes how to connect and receive services from the provider for the specific interface and geolocation diff --git a/x/epochstorage/client/cli/query_fixated_params_test.go b/x/epochstorage/client/cli/query_fixated_params_test.go index 70d78e5c59..7f01f4d44f 100644 --- a/x/epochstorage/client/cli/query_fixated_params_test.go +++ b/x/epochstorage/client/cli/query_fixated_params_test.go @@ -152,7 +152,7 @@ func TestListFixatedParams(t *testing.T) { var resp types.QueryAllFixatedParamsResponse require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) require.NoError(t, err) - require.Equal(t, len(objs), int(resp.Pagination.Total)-4) + require.Equal(t, len(objs), int(resp.Pagination.Total)-2) require.ElementsMatch(t, nullify.Fill(objs), nullify.Fill(resp.FixatedParams), diff --git a/x/epochstorage/client/cli/query_stake_storage_test.go b/x/epochstorage/client/cli/query_stake_storage_test.go deleted file mode 100644 index 14780321c2..0000000000 --- a/x/epochstorage/client/cli/query_stake_storage_test.go +++ /dev/null @@ -1,162 +0,0 @@ -package cli_test - -import ( - "fmt" - "strconv" - "testing" - - tmcli "github.com/cometbft/cometbft/libs/cli" - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/lavanet/lava/v2/testutil/network" - "github.com/lavanet/lava/v2/testutil/nullify" - "github.com/lavanet/lava/v2/x/epochstorage/client/cli" - "github.com/lavanet/lava/v2/x/epochstorage/types" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -func networkWithStakeStorageObjects(t *testing.T, n int) (*network.Network, []types.StakeStorage) { - t.Helper() - cfg := network.DefaultConfig() - state := types.GenesisState{} - require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) - - for i := 0; i < n; i++ { - stakeStorage := types.StakeStorage{ - Index: strconv.Itoa(i), - } - nullify.Fill(&stakeStorage) - state.StakeStorageList = append(state.StakeStorageList, stakeStorage) - } - buf, err := cfg.Codec.MarshalJSON(&state) - require.NoError(t, err) - cfg.GenesisState[types.ModuleName] = buf - return network.New(t, cfg), state.StakeStorageList -} - -func TestShowStakeStorage(t *testing.T) { - net, objs := networkWithStakeStorageObjects(t, 2) - - ctx := net.Validators[0].ClientCtx - common := []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - } - for _, tc := range []struct { - desc string - idIndex string - - args []string - err error - obj types.StakeStorage - }{ - { - desc: "found", - idIndex: objs[0].Index, - - args: common, - obj: objs[0], - }, - { - desc: "not found", - idIndex: strconv.Itoa(100000), - - args: common, - err: status.Error(codes.InvalidArgument, "not found"), - }, - } { - tc := tc - t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.idIndex, - } - args = append(args, tc.args...) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowStakeStorage(), args) - if tc.err != nil { - stat, ok := status.FromError(tc.err) - require.True(t, ok) - require.ErrorIs(t, stat.Err(), tc.err) - } else { - require.NoError(t, err) - var resp types.QueryGetStakeStorageResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NotNil(t, resp.StakeStorage) - require.Equal(t, - nullify.Fill(&tc.obj), - nullify.Fill(&resp.StakeStorage), - ) - } - }) - } -} - -func TestListStakeStorage(t *testing.T) { - net, objs := networkWithStakeStorageObjects(t, 5) - - ctx := net.Validators[0].ClientCtx - request := func(next []byte, offset, limit uint64, total bool) []string { - args := []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - } - if next == nil { - args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) - } else { - args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) - } - args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) - if total { - args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) - } - return args - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(objs); i += step { - args := request(nil, uint64(i), uint64(step), false) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakeStorage(), args) - require.NoError(t, err) - var resp types.QueryAllStakeStorageResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.LessOrEqual(t, len(resp.StakeStorage), step) - require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.StakeStorage), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(objs); i += step { - args := request(next, 0, uint64(step), false) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakeStorage(), args) - require.NoError(t, err) - var resp types.QueryAllStakeStorageResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.LessOrEqual(t, len(resp.StakeStorage), step) - require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.StakeStorage), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - args := request(nil, 0, uint64(len(objs)), true) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakeStorage(), args) - require.NoError(t, err) - var resp types.QueryAllStakeStorageResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NoError(t, err) - require.Equal(t, len(objs), int(resp.Pagination.Total)) - require.ElementsMatch(t, - nullify.Fill(objs), - nullify.Fill(resp.StakeStorage), - ) - }) -} diff --git a/x/epochstorage/genesis.go b/x/epochstorage/genesis.go index 85cd86351a..02716bfd49 100644 --- a/x/epochstorage/genesis.go +++ b/x/epochstorage/genesis.go @@ -1,6 +1,9 @@ package epochstorage import ( + "strconv" + + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/lavanet/lava/v2/x/epochstorage/keeper" "github.com/lavanet/lava/v2/x/epochstorage/types" @@ -11,8 +14,19 @@ import ( func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { // Set all the stakeStorage for _, elem := range genState.StakeStorageList { - k.SetStakeStorage(ctx, elem) + for _, entry := range elem.StakeEntries { + if elem.Index != "" { + epoch, err := strconv.ParseUint(elem.Index, 10, 64) + if err != nil { + panic(errors.Wrapf(err, "failed InitGenesis of epochstorage")) + } + k.SetStakeEntry(ctx, epoch, entry) + } else { + k.SetStakeEntryCurrent(ctx, entry) + } + } } + // Set if defined if genState.EpochDetails != nil { k.SetEpochDetails(ctx, *genState.EpochDetails) @@ -30,7 +44,9 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) - genesis.StakeStorageList = k.GetAllStakeStorage(ctx) + // get all stake entries + genesis.StakeStorageList = k.GetAllStakeEntriesForGenesis(ctx) + // Get all epochDetails epochDetails, found := k.GetEpochDetails(ctx) if found { diff --git a/x/epochstorage/keeper/epoch_start.go b/x/epochstorage/keeper/epoch_start.go index b8a39f29ee..0ea2fdb764 100644 --- a/x/epochstorage/keeper/epoch_start.go +++ b/x/epochstorage/keeper/epoch_start.go @@ -1,13 +1,18 @@ package keeper import ( + "fmt" + "strconv" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/v2/utils" + "github.com/lavanet/lava/v2/x/epochstorage/types" ) // Function that calls all the functions that are supposed to run in epoch start func (k Keeper) EpochStart(ctx sdk.Context) { block := uint64(ctx.BlockHeight()) - + k.SetEpochHash(ctx) // save params for this epoch k.FixateParams(ctx, block) @@ -20,9 +25,96 @@ func (k Keeper) EpochStart(ctx sdk.Context) { k.SetEpochDetailsStart(ctx, block) - k.StoreCurrentEpochStakeStorage(ctx, block) + k.StoreCurrentStakeEntries(ctx, block) k.UpdateEarliestEpochstart(ctx) k.RemoveOldEpochData(ctx) } + +// StoreCurrentStakeEntries store the current stake entries in the epoch-prefixed stake entries store +func (k Keeper) StoreCurrentStakeEntries(ctx sdk.Context, epoch uint64) { + entries := k.GetAllStakeEntriesCurrent(ctx) + for _, entry := range entries { + k.SetStakeEntry(ctx, epoch, entry) + } +} + +func (k *Keeper) UpdateEarliestEpochstart(ctx sdk.Context) { + currentBlock := uint64(ctx.BlockHeight()) + earliestEpochBlock := k.GetEarliestEpochStart(ctx) + + // we take the epochs memory size at earliestEpochBlock, and not the current one + blocksToSaveAtEarliestEpoch, err := k.BlocksToSave(ctx, earliestEpochBlock) + if err != nil { + // panic:ok: critical, no recovery, avoid further corruption + utils.LavaFormatPanic("critical: failed to advance EarliestEpochstart", err, + utils.LogAttr("earliestEpochBlock", earliestEpochBlock), + utils.LogAttr("fixations", k.GetAllFixatedParams(ctx)), + ) + } + + if currentBlock <= blocksToSaveAtEarliestEpoch { + return + } + + lastBlockInMemory := currentBlock - blocksToSaveAtEarliestEpoch + + deletedEpochs := []uint64{} + for earliestEpochBlock < lastBlockInMemory { + deletedEpochs = append(deletedEpochs, earliestEpochBlock) + earliestEpochBlock, err = k.GetNextEpoch(ctx, earliestEpochBlock) + if err != nil { + // panic:ok: critical, no recovery, avoid further corruption + utils.LavaFormatPanic("critical: failed to advance EarliestEpochstart", err, + utils.LogAttr("earliestEpochBlock", earliestEpochBlock), + utils.LogAttr("fixations", k.GetAllFixatedParams(ctx)), + ) + } + } + + if len(deletedEpochs) == 0 { + return + } + + utils.LogLavaEvent(ctx, k.Logger(ctx), types.EarliestEpochEventName, + map[string]string{"block": strconv.FormatUint(earliestEpochBlock, 10)}, + "updated earliest epoch block") + + // now update the earliest epoch start + k.SetEarliestEpochStart(ctx, earliestEpochBlock, deletedEpochs) +} + +func (k Keeper) RemoveOldEpochData(ctx sdk.Context) { + for _, epoch := range k.GetDeletedEpochs(ctx) { + k.RemoveEpochHash(ctx, epoch) + k.RemoveAllStakeEntriesForEpoch(ctx, epoch) + } +} + +func (k Keeper) SetEpochHash(ctx sdk.Context) { + err := k.epochHashes.Set(ctx, uint64(ctx.BlockHeight()), ctx.HeaderHash()) + if err != nil { + panic(err) + } +} + +func (k Keeper) GetEpochHash(ctx sdk.Context, epoch uint64) []byte { + hash, err := k.epochHashes.Get(ctx, epoch) + if err != nil { + utils.LavaFormatError("GetEpochHash: epoch hash not found", fmt.Errorf("not found"), + utils.LogAttr("epoch", epoch), + utils.LogAttr("current_block", ctx.BlockHeight()), + ) + return []byte{} + } + + return hash +} + +func (k Keeper) RemoveEpochHash(ctx sdk.Context, epoch uint64) { + err := k.epochHashes.Remove(ctx, epoch) + if err != nil { + panic(err) + } +} diff --git a/x/epochstorage/keeper/grpc_query_stake_storage.go b/x/epochstorage/keeper/grpc_query_stake_storage.go index eedf1915dd..8ddb15bdbb 100644 --- a/x/epochstorage/keeper/grpc_query_stake_storage.go +++ b/x/epochstorage/keeper/grpc_query_stake_storage.go @@ -3,9 +3,7 @@ package keeper import ( "context" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" "github.com/lavanet/lava/v2/x/epochstorage/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -16,26 +14,10 @@ func (k Keeper) StakeStorageAll(c context.Context, req *types.QueryAllStakeStora return nil, status.Error(codes.InvalidArgument, "invalid request") } - var stakeStorages []types.StakeStorage ctx := sdk.UnwrapSDKContext(c) + stakeStorages := k.GetAllStakeEntriesForGenesis(ctx) - store := ctx.KVStore(k.storeKey) - stakeStorageStore := prefix.NewStore(store, types.KeyPrefix(types.StakeStorageKeyPrefix)) - - pageRes, err := query.Paginate(stakeStorageStore, req.Pagination, func(key, value []byte) error { - var stakeStorage types.StakeStorage - if err := k.cdc.Unmarshal(value, &stakeStorage); err != nil { - return err - } - - stakeStorages = append(stakeStorages, stakeStorage) - return nil - }) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryAllStakeStorageResponse{StakeStorage: stakeStorages, Pagination: pageRes}, nil + return &types.QueryAllStakeStorageResponse{StakeStorage: stakeStorages}, nil } func (k Keeper) StakeStorage(c context.Context, req *types.QueryGetStakeStorageRequest) (*types.QueryGetStakeStorageResponse, error) { @@ -44,13 +26,14 @@ func (k Keeper) StakeStorage(c context.Context, req *types.QueryGetStakeStorageR } ctx := sdk.UnwrapSDKContext(c) - val, found := k.GetStakeStorage( - ctx, - req.Index, - ) - if !found { + stakeEntries := k.GetAllStakeEntriesCurrentForChainId(ctx, req.Index) + if len(stakeEntries) == 0 { return nil, status.Error(codes.InvalidArgument, "not found") } + val := types.StakeStorage{ + Index: req.Index, + StakeEntries: stakeEntries, + } return &types.QueryGetStakeStorageResponse{StakeStorage: val}, nil } diff --git a/x/epochstorage/keeper/grpc_query_stake_storage_test.go b/x/epochstorage/keeper/grpc_query_stake_storage_test.go index a5829b3219..59c699a41d 100644 --- a/x/epochstorage/keeper/grpc_query_stake_storage_test.go +++ b/x/epochstorage/keeper/grpc_query_stake_storage_test.go @@ -5,19 +5,30 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - keepertest "github.com/lavanet/lava/v2/testutil/keeper" "github.com/lavanet/lava/v2/testutil/nullify" + "github.com/lavanet/lava/v2/x/epochstorage/keeper" "github.com/lavanet/lava/v2/x/epochstorage/types" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) // Prevent strconv unused error var _ = strconv.IntSize +func createNStakeStorage(k *keeper.Keeper, ctx sdk.Context, n int) []types.StakeStorage { + items := []types.StakeStorage{} + stakeEntries := createNStakeEntriesCurrent(k, ctx, n) + for _, entry := range stakeEntries { + items = append(items, types.StakeStorage{ + Index: entry.Address, + StakeEntries: []types.StakeEntry{entry}, + }) + } + return items +} + func TestStakeStorageQuerySingle(t *testing.T) { keeper, ctx := keepertest.EpochstorageKeeper(t) wctx := sdk.WrapSDKContext(ctx) @@ -68,59 +79,3 @@ func TestStakeStorageQuerySingle(t *testing.T) { }) } } - -func TestStakeStorageQueryPaginated(t *testing.T) { - keeper, ctx := keepertest.EpochstorageKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNStakeStorage(keeper, ctx, 5) - - request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllStakeStorageRequest { - return &types.QueryAllStakeStorageRequest{ - Pagination: &query.PageRequest{ - Key: next, - Offset: offset, - Limit: limit, - CountTotal: total, - }, - } - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(msgs); i += step { - resp, err := keeper.StakeStorageAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.StakeStorage), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakeStorage), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(msgs); i += step { - resp, err := keeper.StakeStorageAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.StakeStorage), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakeStorage), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - resp, err := keeper.StakeStorageAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) - require.ElementsMatch(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakeStorage), - ) - }) - t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.StakeStorageAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) - }) -} diff --git a/x/epochstorage/keeper/keeper.go b/x/epochstorage/keeper/keeper.go index 531fa419b9..3ba3df98a2 100644 --- a/x/epochstorage/keeper/keeper.go +++ b/x/epochstorage/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + "cosmossdk.io/collections" storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cometbft/cometbft/libs/log" @@ -11,6 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/lavanet/lava/v2/utils" + collcompat "github.com/lavanet/lava/v2/utils/collcompat" "github.com/lavanet/lava/v2/x/epochstorage/types" ) @@ -27,6 +29,11 @@ type ( stakingKeeper types.StakingKeeper fixationRegistries map[string]func(sdk.Context) any + + schema collections.Schema + stakeEntries *collections.IndexedMap[collections.Triple[uint64, string, collections.Pair[uint64, string]], types.StakeEntry, types.EpochChainIdProviderIndexes] + stakeEntriesCurrent *collections.IndexedMap[collections.Pair[string, string], types.StakeEntry, types.ChainIdVaultIndexes] + epochHashes collections.Map[uint64, []byte] } ) @@ -46,6 +53,8 @@ func NewKeeper( ps = ps.WithKeyTable(types.ParamKeyTable()) } + sb := collections.NewSchemaBuilder(collcompat.NewKVStoreService(storeKey)) + keeper := &Keeper{ cdc: cdc, storeKey: storeKey, @@ -57,12 +66,27 @@ func NewKeeper( stakingKeeper: stakingKeeper, fixationRegistries: make(map[string]func(sdk.Context) any), + + stakeEntries: collections.NewIndexedMap(sb, types.StakeEntriesPrefix, "stake_entries", + collections.TripleKeyCodec(collections.Uint64Key, collections.StringKey, + collections.PairKeyCodec(collections.Uint64Key, collections.StringKey)), + collcompat.ProtoValue[types.StakeEntry](cdc), types.NewEpochChainIdProviderIndexes(sb)), + + stakeEntriesCurrent: collections.NewIndexedMap(sb, types.StakeEntriesCurrentPrefix, "stake_entries_current", + collections.PairKeyCodec(collections.StringKey, collections.StringKey), + collcompat.ProtoValue[types.StakeEntry](cdc), types.NewChainIdVaultIndexes(sb)), + + epochHashes: collections.NewMap(sb, types.EpochHashesPrefix, "epoch_hashes", collections.Uint64Key, collections.BytesValue), } keeper.AddFixationRegistry(string(types.KeyEpochBlocks), func(ctx sdk.Context) any { return keeper.EpochBlocksRaw(ctx) }) keeper.AddFixationRegistry(string(types.KeyEpochsToSave), func(ctx sdk.Context) any { return keeper.EpochsToSaveRaw(ctx) }) - keeper.AddFixationRegistry(string(types.KeyUnstakeHoldBlocks), func(ctx sdk.Context) any { return keeper.UnstakeHoldBlocksRaw(ctx) }) - keeper.AddFixationRegistry(string(types.KeyUnstakeHoldBlocksStatic), func(ctx sdk.Context) any { return keeper.UnstakeHoldBlocksStaticRaw(ctx) }) + + schema, err := sb.Build() + if err != nil { + panic(err) + } + keeper.schema = schema return keeper } diff --git a/x/epochstorage/keeper/migrations.go b/x/epochstorage/keeper/migrations.go index 39b56942f5..4ae08b400e 100644 --- a/x/epochstorage/keeper/migrations.go +++ b/x/epochstorage/keeper/migrations.go @@ -1,15 +1,17 @@ package keeper import ( - "math" + "fmt" + "strconv" + "strings" + "unicode" + "cosmossdk.io/collections" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/lavanet/lava/v2/utils" "github.com/lavanet/lava/v2/x/epochstorage/types" v3 "github.com/lavanet/lava/v2/x/epochstorage/types/migrations/v3" - v4 "github.com/lavanet/lava/v2/x/epochstorage/types/migrations/v4" - v6 "github.com/lavanet/lava/v2/x/epochstorage/types/migrations/v6" ) type Migrator struct { @@ -20,160 +22,96 @@ func NewMigrator(keeper Keeper) Migrator { return Migrator{keeper: keeper} } -// Migrate2to3 implements store migration from v2 to v3: -// - refund all clients stake -// - migrate providers to a new key -func (m Migrator) Migrate2to3(ctx sdk.Context) error { - const ClientKey = "client" - const ProviderKey = "provider" - - storage := m.keeper.GetAllStakeStorage(ctx) - for _, storage := range storage { - // handle client keys - if storage.Index[:len(ClientKey)] == ClientKey { - m.keeper.RemoveStakeStorage(ctx, storage.Index) - } else if storage.Index[:len(ProviderKey)] == ProviderKey { // handle provider keys - if len(storage.Index) > len(ProviderKey) { - storage.Index = storage.Index[len(ProviderKey):] - m.keeper.SetStakeStorage(ctx, storage) - } - } - } - return nil -} +// Migrate7to8 transfers all the stake entries from the old stake storage to the new stake entries store +// StakeStorage is set to the stake entries store +// StakeStorageCurrent is set to the stake entries current store +// StakeStorageUnstake is deleted +func (m Migrator) Migrate7to8(ctx sdk.Context) error { + utils.LavaFormatDebug("migrate: epochstorage to move stake entries from stake storage") + k := m.keeper -// Migrate3to4 implements store migration from v3 to v4: -// set geolocation to int32 -func (m Migrator) Migrate3to4(ctx sdk.Context) error { - utils.LavaFormatDebug("migrate: epochstorage change geolocation from uint64 to int32") - - store := prefix.NewStore(ctx.KVStore(m.keeper.storeKey), v3.KeyPrefix(v3.StakeStorageKeyPrefix)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), v3.KeyPrefix(v3.StakeStorageKeyPrefix)) iterator := sdk.KVStorePrefixIterator(store, []byte{}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var stakeStorageV3 v3.StakeStorage - m.keeper.cdc.MustUnmarshal(iterator.Value(), &stakeStorageV3) + key := string(iterator.Key()) - stakeStorageV4 := v4.StakeStorage{ - Index: stakeStorageV3.Index, - EpochBlockHash: stakeStorageV3.EpochBlockHash, + // identify stake storage type: regular, current or unstake + if key == v3.StakeStorageKeyUnstakeConst { + store.Delete(iterator.Key()) + continue } - var stakeEntriesV4 []v4.StakeEntry - for _, stakeEntryV3 := range stakeStorageV3.StakeEntries { - stakeEntryV4 := v4.StakeEntry{ - Stake: stakeEntryV3.Stake, - Address: stakeEntryV3.Address, - StakeAppliedBlock: stakeEntryV3.StakeAppliedBlock, - Chain: stakeEntryV3.Chain, - Moniker: stakeEntryV3.Moniker, - } + epoch, err := extractEpochFromStakeStorageKey(key) + isCurrentStakeStorage := m.isCurrentStakeStorageKey(ctx, key) + if err != nil && !isCurrentStakeStorage { + panic(fmt.Errorf("stake storage with unidentified index %s", key)) + } - var geoInt32 int32 - if stakeEntryV3.Geolocation <= math.MaxInt32 { - geoInt32 = int32(stakeEntryV3.Geolocation) - } else { - geoInt32 = math.MaxInt32 - } + var stakeStorage types.StakeStorage + k.cdc.MustUnmarshal(iterator.Value(), &stakeStorage) - stakeEntryV4.Geolocation = geoInt32 - - var endpointsV4 []v4.Endpoint - for _, endpointV3 := range stakeEntryV3.Endpoints { - endpointV4 := v4.Endpoint{ - IPPORT: endpointV3.IPPORT, - Addons: endpointV3.Addons, - ApiInterfaces: endpointV3.ApiInterfaces, - Extensions: endpointV3.Extensions, - } - - var geoEndpInt32 int32 - if stakeEntryV3.Geolocation <= math.MaxInt32 { - geoEndpInt32 = int32(stakeEntryV3.Geolocation) - } else { - geoEndpInt32 = math.MaxInt32 - } - - endpointV4.Geolocation = geoEndpInt32 - endpointsV4 = append(endpointsV4, endpointV4) + for i, entry := range stakeStorage.StakeEntries { + if isCurrentStakeStorage { + k.SetStakeEntryCurrent(ctx, entry) + } else { + // we make sure that the stake entries order is the same as the previous version's order + k.SetStakeEntryForMigrator(ctx, epoch, entry, uint64(len(stakeStorage.StakeEntries)-i)) } + } - stakeEntryV4.Endpoints = endpointsV4 - - stakeEntriesV4 = append(stakeEntriesV4, stakeEntryV4) + if !isCurrentStakeStorage { + m.SetEpochHashForMigrator(ctx, epoch, stakeStorage.EpochBlockHash) } - stakeStorageV4.StakeEntries = stakeEntriesV4 store.Delete(iterator.Key()) - store.Set(iterator.Key(), m.keeper.cdc.MustMarshal(&stakeStorageV4)) } return nil } -// Migrate4to5 implements store migration from v4 to v5: -// - initialize DelegateTotal, DelegateLimit, DelegateCommission -func (m Migrator) Migrate4to5(ctx sdk.Context) error { - utils.LavaFormatDebug("migrate: epochstorage to include delegations") - - StakeStorages := m.keeper.GetAllStakeStorage(ctx) - for st := range StakeStorages { - for s := range StakeStorages[st].StakeEntries { - StakeStorages[st].StakeEntries[s].DelegateTotal = sdk.NewCoin(m.keeper.stakingKeeper.BondDenom(ctx), sdk.ZeroInt()) - StakeStorages[st].StakeEntries[s].DelegateLimit = sdk.NewCoin(m.keeper.stakingKeeper.BondDenom(ctx), sdk.ZeroInt()) - StakeStorages[st].StakeEntries[s].DelegateCommission = 100 - } - m.keeper.SetStakeStorage(ctx, StakeStorages[st]) +// Set stake entry +func (k Keeper) SetStakeEntryForMigrator(ctx sdk.Context, epoch uint64, stakeEntry types.StakeEntry, idx uint64) { + key := collections.Join3(epoch, stakeEntry.Chain, collections.Join(idx, stakeEntry.Address)) + err := k.stakeEntries.Set(ctx, key, stakeEntry) + if err != nil { + panic(err) } - - return nil } -// Migrate5to6 goes over all existing stake entries and populates the new vault address field with the stake entry address -func (m Migrator) Migrate5to6(ctx sdk.Context) error { - utils.LavaFormatDebug("migrate: epochstorage to include provider and vault addresses") - - store := prefix.NewStore(ctx.KVStore(m.keeper.storeKey), types.KeyPrefix(types.StakeStorageKeyPrefix)) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var stakeStorageV6 v6.StakeStorage - m.keeper.cdc.MustUnmarshal(iterator.Value(), &stakeStorageV6) - - for i := range stakeStorageV6.StakeEntries { - stakeStorageV6.StakeEntries[i].Vault = stakeStorageV6.StakeEntries[i].Address +// the legacy StakeStorage store used keys that were built like this: +// strconv.FormatUint(block, 10) + chainID +func extractEpochFromStakeStorageKey(key string) (uint64, error) { + number := "" + for _, char := range key { + if !unicode.IsDigit(char) { + break } - - store.Set(iterator.Key(), m.keeper.cdc.MustMarshal(&stakeStorageV6)) + number += string(char) } - - return nil + // Attempt conversion to uint64, return 0 and false if fails + parsedUint, err := strconv.ParseUint(number, 10, 64) + if err != nil { + return 0, err + } + return parsedUint, nil } -// Migrate6to7 goes over all existing stake entries and populates the new description field with current moniker -func (m Migrator) Migrate6to7(ctx sdk.Context) error { - utils.LavaFormatDebug("migrate: epochstorage to include detailed description") - - store := prefix.NewStore(ctx.KVStore(m.keeper.storeKey), types.KeyPrefix(types.StakeStorageKeyPrefix)) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var stakeStorageV7 types.StakeStorage - m.keeper.cdc.MustUnmarshal(iterator.Value(), &stakeStorageV7) - - for i := range stakeStorageV7.StakeEntries { - stakeStorageV7.StakeEntries[i].Description.Moniker = stakeStorageV7.StakeEntries[i].Moniker - stakeStorageV7.StakeEntries[i].Moniker = "" - } - - store.Set(iterator.Key(), m.keeper.cdc.MustMarshal(&stakeStorageV7)) +func (m Migrator) isCurrentStakeStorageKey(ctx sdk.Context, key string) bool { + // the legacy StakeStorage key (both regular and current) had a "/" which should be cut off + key, found := strings.CutSuffix(key, "/") + if !found { + return false } + _, found, _ = m.keeper.specKeeper.IsSpecFoundAndActive(ctx, key) + return found +} - return nil +func (m Migrator) SetEpochHashForMigrator(ctx sdk.Context, epoch uint64, hash []byte) { + err := m.keeper.epochHashes.Set(ctx, epoch, hash) + if err != nil { + panic(err) + } } diff --git a/x/epochstorage/keeper/params.go b/x/epochstorage/keeper/params.go index b9f39e1620..609a09fe8b 100644 --- a/x/epochstorage/keeper/params.go +++ b/x/epochstorage/keeper/params.go @@ -11,11 +11,9 @@ import ( // GetParams get all parameters as types.Params func (k Keeper) GetParams(ctx sdk.Context) types.Params { return types.NewParams( - k.UnstakeHoldBlocksRaw(ctx), k.EpochBlocksRaw(ctx), k.EpochsToSaveRaw(ctx), k.LatestParamChange(ctx), - k.UnstakeHoldBlocksStaticRaw(ctx), ) } @@ -24,37 +22,6 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramstore.SetParamSet(ctx, ¶ms) } -func (k Keeper) UnstakeHoldBlocks(ctx sdk.Context, block uint64) (res uint64) { - // Unstake Hold Blocks is always used for the latest, but we want to use the fixated - k.GetParamForBlock(ctx, string(types.KeyUnstakeHoldBlocks), block, &res) - return -} - -// UnstakeHoldBlocksRaw returns the UnstakeHoldBlocks param -func (k Keeper) UnstakeHoldBlocksRaw(ctx sdk.Context) (res uint64) { - // Unstake Hold Blocks is always used for the latest, but we want to use the fixated - k.paramstore.Get(ctx, types.KeyUnstakeHoldBlocks, &res) - return -} - -func (k Keeper) UnstakeHoldBlocksStatic(ctx sdk.Context, block uint64) (res uint64) { - // Unstake Hold Blocks is always used for the latest, but we want to use the fixated - k.GetParamForBlock(ctx, string(types.KeyUnstakeHoldBlocksStatic), block, &res) - return -} - -// UnstakeHoldBlocksRaw returns the UnstakeHoldBlocks param -func (k Keeper) UnstakeHoldBlocksStaticRaw(ctx sdk.Context) (res uint64) { - // Unstake Hold Blocks is always used for the latest, but we want to use the fixated - k.paramstore.Get(ctx, types.KeyUnstakeHoldBlocksStatic, &res) - return -} - -// UnstakeHoldBlocksRaw sets the UnstakeHoldBlocks param -func (k Keeper) SetUnstakeHoldBlocksStaticRaw(ctx sdk.Context, unstakeHoldBlocksStatic uint64) { - k.paramstore.Set(ctx, types.KeyUnstakeHoldBlocksStatic, unstakeHoldBlocksStatic) -} - // EpochBlocks returns the EpochBlocks fixated param func (k Keeper) EpochBlocks(ctx sdk.Context, block uint64) (res uint64, err error) { err = k.GetParamForBlock(ctx, string(types.KeyEpochBlocks), block, &res) diff --git a/x/epochstorage/keeper/params_test.go b/x/epochstorage/keeper/params_test.go index 4a3a803f09..fe8cb35223 100644 --- a/x/epochstorage/keeper/params_test.go +++ b/x/epochstorage/keeper/params_test.go @@ -15,8 +15,6 @@ func TestGetParams(t *testing.T) { k.SetParams(ctx, params) require.EqualValues(t, params, k.GetParams(ctx)) - require.EqualValues(t, params.UnstakeHoldBlocks, k.UnstakeHoldBlocksRaw(ctx)) - require.EqualValues(t, params.UnstakeHoldBlocksStatic, k.UnstakeHoldBlocksStaticRaw(ctx)) require.EqualValues(t, params.EpochBlocks, k.EpochBlocksRaw(ctx)) require.EqualValues(t, params.EpochsToSave, k.EpochsToSaveRaw(ctx)) } diff --git a/x/epochstorage/keeper/stake_entries.go b/x/epochstorage/keeper/stake_entries.go new file mode 100644 index 0000000000..cc8d0684d8 --- /dev/null +++ b/x/epochstorage/keeper/stake_entries.go @@ -0,0 +1,244 @@ +package keeper + +import ( + "fmt" + "sort" + "strconv" + + "cosmossdk.io/collections" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/v2/utils" + "github.com/lavanet/lava/v2/x/epochstorage/types" +) + +/* ########## StakeEntry ############ */ + +// GetStakeEntry gets a specific stake entry from the stake entries KV store +// Since the stake entries KV store's key includes the provider's stake (which is not known), we iterate over all +// the providers with the same epoch and chainID and compare the requested address to find the provider +func (k Keeper) GetStakeEntry(ctx sdk.Context, epoch uint64, chainID string, provider string) (types.StakeEntry, bool) { + pk, err := k.stakeEntries.Indexes.Index.MatchExact(ctx, collections.Join3(epoch, chainID, provider)) + if err != nil { + utils.LavaFormatWarning("GetStakeEntry: MatchExact with ref key failed", err, + utils.LogAttr("epoch", epoch), + utils.LogAttr("chain_id", chainID), + utils.LogAttr("provider", provider), + ) + return types.StakeEntry{}, false + } + + entry, err := k.stakeEntries.Get(ctx, pk) + if err != nil { + utils.LavaFormatError("GetStakeEntry: Get with primary key failed", err, + utils.LogAttr("epoch", epoch), + utils.LogAttr("chain_id", chainID), + utils.LogAttr("provider", provider), + ) + return types.StakeEntry{}, false + } + + return entry, true +} + +// Set stake entry +func (k Keeper) SetStakeEntry(ctx sdk.Context, epoch uint64, stakeEntry types.StakeEntry) { + stake := uint64(0) + if !stakeEntry.Stake.IsNil() && stakeEntry.Stake.Amount.IsUint64() { + stake = stakeEntry.Stake.Amount.Uint64() + } + key := collections.Join3(epoch, stakeEntry.Chain, collections.Join(stake, stakeEntry.Address)) + err := k.stakeEntries.Set(ctx, key, stakeEntry) + if err != nil { + panic(fmt.Errorf("SetStakeEntry: Failed to set entry with key %v, error: %w", key, err)) + } +} + +// RemoveAllStakeEntriesForEpoch removes all the stake entries of a specific epoch +func (k Keeper) RemoveAllStakeEntriesForEpoch(ctx sdk.Context, epoch uint64) { + rng := collections.NewPrefixedTripleRange[uint64, string, collections.Pair[uint64, string]](epoch) + iter, err := k.stakeEntries.Iterate(ctx, rng) + if err != nil { + panic(fmt.Errorf("RemoveAllStakeEntriesForEpoch: Failed to create iterator for epoch %d, error: %w", epoch, err)) + } + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + key, err := iter.Key() + if err != nil { + panic(fmt.Errorf("RemoveAllStakeEntriesForEpoch: Failed to get key from iterator for epoch %d, error: %w", epoch, err)) + } + + err = k.stakeEntries.Remove(ctx, key) + if err != nil { + panic(fmt.Errorf("RemoveAllStakeEntriesForEpoch: Failed to remove entry with key %v, error: %w", key, err)) + } + } +} + +// GetAllStakeEntries gets all the stake entries of a specific epoch +func (k Keeper) GetAllStakeEntriesForGenesis(ctx sdk.Context) []types.StakeStorage { + iter, err := k.stakeEntries.Iterate(ctx, nil) + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesForGenesis: Failed to create iterator, error: %w", err)) + } + defer iter.Close() + + storagesMap := map[uint64]types.StakeStorage{} + for ; iter.Valid(); iter.Next() { + key, err := iter.Key() + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesForGenesis: Failed to get key from iterator, error: %w", err)) + } + epoch := key.K1() + + entry, err := iter.Value() + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesForGenesis: Failed to get value from iterator for epoch %d, error: %w", epoch, err)) + } + if _, ok := storagesMap[epoch]; !ok { + storagesMap[epoch] = types.StakeStorage{ + Index: strconv.FormatUint(epoch, 10), + EpochBlockHash: k.GetEpochHash(ctx, epoch), + } + } + storage := storagesMap[epoch] + storage.StakeEntries = append(storage.StakeEntries, entry) + storagesMap[epoch] = storage + } + + var storages []types.StakeStorage + var keys []uint64 + for key := range storagesMap { + keys = append(keys, key) + } + sort.Slice(keys, func(i, j int) bool { + return keys[i] < keys[j] + }) + + for _, key := range keys { + storages = append(storages, storagesMap[key]) + } + + currentEntries := k.GetAllStakeEntriesCurrent(ctx) + storages = append(storages, types.StakeStorage{Index: "", StakeEntries: currentEntries}) // empty index for genesis + + return storages +} + +// GetAllStakeEntriesForEpoch gets all the stake entries of a specific epoch +func (k Keeper) GetAllStakeEntriesForEpoch(ctx sdk.Context, epoch uint64) []types.StakeEntry { + rng := collections.NewPrefixedTripleRange[uint64, string, collections.Pair[uint64, string]](epoch) + iter, err := k.stakeEntries.Iterate(ctx, rng) + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesForEpoch: Failed to create iterator for epoch %d, error: %w", epoch, err)) + } + defer iter.Close() + + entries, err := iter.Values() + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesForEpoch: Failed to get entries for epoch %d, error: %w", epoch, err)) + } + return entries +} + +// GetAllStakeEntriesForEpochChainId gets all the stake entries of a specific epoch and a specific chain +func (k Keeper) GetAllStakeEntriesForEpochChainId(ctx sdk.Context, epoch uint64, chainID string) []types.StakeEntry { + rng := collections.NewSuperPrefixedTripleRange[uint64, string, collections.Pair[uint64, string]](epoch, chainID) + iter, err := k.stakeEntries.Iterate(ctx, rng) + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesForEpochChainId: Failed to create iterator for epoch %d and chain ID %s, error: %w", epoch, chainID, err)) + } + defer iter.Close() + + entries, err := iter.Values() + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesForEpochChainId: Failed to get entries for epoch %d and chain ID %s, error: %w", epoch, chainID, err)) + } + return entries +} + +/* ########## Current StakeEntry ############ */ + +// GetStakeEntryCurrent returns a specific current stake entry (with both vault/provider) +func (k Keeper) GetStakeEntryCurrent(ctx sdk.Context, chainID string, provider string) (val types.StakeEntry, found bool) { + key := collections.Join(chainID, provider) + entry, err := k.stakeEntriesCurrent.Get(ctx, key) + if err == nil { + return entry, true + } + + // try to find the stake entry by the vault address + return k.GetStakeEntryCurrentForChainIdByVault(ctx, chainID, provider) +} + +// SetStakeEntryCurrent sets a current stake entry in the store +func (k Keeper) SetStakeEntryCurrent(ctx sdk.Context, stakeEntry types.StakeEntry) { + key := collections.Join(stakeEntry.Chain, stakeEntry.Address) + err := k.stakeEntriesCurrent.Set(ctx, key, stakeEntry) + if err != nil { + panic(fmt.Errorf("SetStakeEntryCurrent: Failed to set entry for key %v, error: %w", key, err)) + } +} + +// RemoveStakeEntryCurrent deletes a current stake entry from the store +func (k Keeper) RemoveStakeEntryCurrent(ctx sdk.Context, chainID string, provider string) { + key := collections.Join(chainID, provider) + err := k.stakeEntriesCurrent.Remove(ctx, key) + if err != nil { + panic(fmt.Errorf("RemoveStakeEntryCurrent: Failed to remove entry with key %v, error: %w", key, err)) + } +} + +// GetAllStakeEntriesCurrent gets all the current stake entries +func (k Keeper) GetAllStakeEntriesCurrent(ctx sdk.Context) []types.StakeEntry { + iter, err := k.stakeEntriesCurrent.Iterate(ctx, nil) + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesCurrent: Failed to create iterator, error: %w", err)) + } + defer iter.Close() + + entries, err := iter.Values() + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesCurrent: Failed to get entries, error: %w", err)) + } + return entries +} + +// GetAllStakeEntriesCurrentForChainId gets all the current stake entries for a specific chain +func (k Keeper) GetAllStakeEntriesCurrentForChainId(ctx sdk.Context, chainID string) []types.StakeEntry { + rng := collections.NewPrefixedPairRange[string, string](chainID) + iter, err := k.stakeEntriesCurrent.Iterate(ctx, rng) + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesCurrentForChainId: Failed to create iterator for chain ID %s, error: %w", chainID, err)) + } + defer iter.Close() + + entries, err := iter.Values() + if err != nil { + panic(fmt.Errorf("GetAllStakeEntriesCurrentForChainId: Failed to get entries for chain ID %s, error: %w", chainID, err)) + } + return entries +} + +// GetStakeEntryCurrentForChainIdByVault gets all the current stake entry for a specific chain by vault address +func (k Keeper) GetStakeEntryCurrentForChainIdByVault(ctx sdk.Context, chainID string, vault string) (val types.StakeEntry, found bool) { + pk, err := k.stakeEntriesCurrent.Indexes.Index.MatchExact(ctx, collections.Join(chainID, vault)) + if err != nil { + utils.LavaFormatWarning("GetStakeEntryCurrentForChainIdByVault: MatchExact with primary key failed", err, + utils.LogAttr("chain_id", chainID), + utils.LogAttr("vault", vault), + ) + return types.StakeEntry{}, false + } + + entry, err := k.stakeEntriesCurrent.Get(ctx, pk) + if err != nil { + utils.LavaFormatError("GetStakeEntryCurrentForChainIdByVault: Get with primary key failed", err, + utils.LogAttr("chain_id", chainID), + utils.LogAttr("vault", vault), + ) + return types.StakeEntry{}, false + } + + return entry, true +} diff --git a/x/epochstorage/keeper/stake_entries_test.go b/x/epochstorage/keeper/stake_entries_test.go new file mode 100644 index 0000000000..6ab51ad5a9 --- /dev/null +++ b/x/epochstorage/keeper/stake_entries_test.go @@ -0,0 +1,124 @@ +package keeper_test + +import ( + "strconv" + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/lavanet/lava/v2/testutil/keeper" + "github.com/lavanet/lava/v2/x/epochstorage/keeper" + "github.com/lavanet/lava/v2/x/epochstorage/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +/* ########## StakeEntry ############ */ + +func createNStakeEntries(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakeEntry { + items := make([]types.StakeEntry, n) + for i := range items { + items[i] = types.StakeEntry{ + Stake: sdk.NewCoin("token", math.NewInt(int64(i))), + Address: strconv.Itoa(i), + Chain: strconv.Itoa(i), + } + keeper.SetStakeEntry(ctx, uint64(i), items[i]) + } + return items +} + +func TestGetStakeEntry(t *testing.T) { + keeper, ctx := keepertest.EpochstorageKeeper(t) + items := createNStakeEntries(keeper, ctx, 10) + for i, item := range items { + entry, found := keeper.GetStakeEntry(ctx, uint64(i), strconv.Itoa(i), strconv.Itoa(i)) + require.True(t, found) + require.True(t, item.Stake.IsEqual(entry.Stake)) + } +} + +func TestRemoveAllStakeEntriesForEpoch(t *testing.T) { + keeper, ctx := keepertest.EpochstorageKeeper(t) + items := createNStakeEntries(keeper, ctx, 10) + epoch := uint64(1) + keeper.SetStakeEntry(ctx, epoch, types.StakeEntry{}) // set another stake entry on epoch=1 + keeper.RemoveAllStakeEntriesForEpoch(ctx, epoch) + for i := range items { + entries := keeper.GetAllStakeEntriesForEpoch(ctx, uint64(i)) + if i == 1 { + require.Len(t, entries, 0) // on epoch 1 there should be no entries + } else { + require.Len(t, entries, 1) // every other epoch is unaffected - there should be one entry + } + } +} + +func TestGetAllStakeEntriesForEpoch(t *testing.T) { + keeper, ctx := keepertest.EpochstorageKeeper(t) + items := createNStakeEntries(keeper, ctx, 10) + epoch := uint64(1) + keeper.SetStakeEntry(ctx, epoch, types.StakeEntry{}) // set another stake entry on epoch=1 + for i := range items { + entries := keeper.GetAllStakeEntriesForEpoch(ctx, uint64(i)) + if i == 1 { + require.Len(t, entries, 2) // on epoch 1 there should be two entries + } else { + require.Len(t, entries, 1) // every other epoch is unaffected - there should be one entry + } + } +} + +func TestGetAllStakeEntriesForEpochChainId(t *testing.T) { + keeper, ctx := keepertest.EpochstorageKeeper(t) + items := createNStakeEntries(keeper, ctx, 10) + epoch := uint64(1) + + // set two entries on epoch=1: one with the same chain as items, and another with a different chain + keeper.SetStakeEntry(ctx, epoch, types.StakeEntry{Chain: items[1].Chain}) + keeper.SetStakeEntry(ctx, epoch, types.StakeEntry{Chain: "otherChain"}) + + // there should be 3 entries on epoch=1: two of items[1].Chain and one of "otherChain" + entries := keeper.GetAllStakeEntriesForEpochChainId(ctx, epoch, items[1].Chain) + require.Len(t, entries, 2) + entries = keeper.GetAllStakeEntriesForEpochChainId(ctx, epoch, "otherChain") + require.Len(t, entries, 1) +} + +/* ########## Current StakeEntry ############ */ + +func createNStakeEntriesCurrent(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakeEntry { + items := make([]types.StakeEntry, n) + for i := range items { + items[i] = types.StakeEntry{ + Stake: sdk.NewCoin("token", math.NewInt(int64(i))), + Address: strconv.Itoa(i), + Vault: strconv.Itoa(i), + Chain: strconv.Itoa(i), + } + keeper.SetStakeEntryCurrent(ctx, items[i]) + } + return items +} + +func TestGetStakeEntryCurrent(t *testing.T) { + keeper, ctx := keepertest.EpochstorageKeeper(t) + items := createNStakeEntriesCurrent(keeper, ctx, 10) + for i, item := range items { + entry, found := keeper.GetStakeEntryCurrent(ctx, strconv.Itoa(i), strconv.Itoa(i)) + require.True(t, found) + require.True(t, item.Stake.IsEqual(entry.Stake)) + } +} + +func TestRemoveStakeEntryCurrent(t *testing.T) { + keeper, ctx := keepertest.EpochstorageKeeper(t) + items := createNStakeEntriesCurrent(keeper, ctx, 10) + for i := range items { + keeper.RemoveStakeEntryCurrent(ctx, strconv.Itoa(i), strconv.Itoa(i)) + _, found := keeper.GetStakeEntryCurrent(ctx, strconv.Itoa(i), strconv.Itoa(i)) + require.False(t, found) + } +} diff --git a/x/epochstorage/keeper/stake_storage.go b/x/epochstorage/keeper/stake_storage.go deleted file mode 100644 index e636900f4b..0000000000 --- a/x/epochstorage/keeper/stake_storage.go +++ /dev/null @@ -1,412 +0,0 @@ -package keeper - -import ( - "fmt" - "sort" - "strconv" - - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - legacyerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/lavanet/lava/v2/utils" - "github.com/lavanet/lava/v2/x/epochstorage/types" - spectypes "github.com/lavanet/lava/v2/x/spec/types" -) - -// SetStakeStorage set a specific stakeStorage in the store from its index -func (k Keeper) SetStakeStorage(ctx sdk.Context, stakeStorage types.StakeStorage) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakeStorageKeyPrefix)) - b := k.cdc.MustMarshal(&stakeStorage) - store.Set(types.StakeStorageKey( - stakeStorage.Index, - ), b) -} - -// GetStakeStorage returns a stakeStorage from its index -func (k Keeper) GetStakeStorage( - ctx sdk.Context, - index string, -) (val types.StakeStorage, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakeStorageKeyPrefix)) - - b := store.Get(types.StakeStorageKey( - index, - )) - if b == nil { - return val, false - } - - k.cdc.MustUnmarshal(b, &val) - return val, true -} - -// RemoveStakeStorage removes a stakeStorage from the store -func (k Keeper) RemoveStakeStorage( - ctx sdk.Context, - index string, -) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakeStorageKeyPrefix)) - store.Delete(types.StakeStorageKey( - index, - )) -} - -// GetAllStakeStorage returns all stakeStorage -func (k Keeper) GetAllStakeStorage(ctx sdk.Context) (list []types.StakeStorage) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakeStorageKeyPrefix)) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var val types.StakeStorage - k.cdc.MustUnmarshal(iterator.Value(), &val) - list = append(list, val) - } - - return -} - -func (k Keeper) RemoveOldEpochData(ctx sdk.Context) { - for _, block := range k.GetDeletedEpochs(ctx) { - allChainIDs := k.specKeeper.GetAllChainIDs(ctx) - for _, chainID := range allChainIDs { - k.RemoveStakeStorageByBlockAndChain(ctx, block, chainID) - } - } -} - -func (k *Keeper) UpdateEarliestEpochstart(ctx sdk.Context) { - currentBlock := uint64(ctx.BlockHeight()) - earliestEpochBlock := k.GetEarliestEpochStart(ctx) - - // we take the epochs memory size at earliestEpochBlock, and not the current one - blocksToSaveAtEarliestEpoch, err := k.BlocksToSave(ctx, earliestEpochBlock) - if err != nil { - // panic:ok: critical, no recovery, avoid further corruption - utils.LavaFormatPanic("critical: failed to advance EarliestEpochstart", err, - utils.LogAttr("earliestEpochBlock", earliestEpochBlock), - utils.LogAttr("fixations", k.GetAllFixatedParams(ctx)), - ) - } - - if currentBlock <= blocksToSaveAtEarliestEpoch { - return - } - - lastBlockInMemory := currentBlock - blocksToSaveAtEarliestEpoch - - deletedEpochs := []uint64{} - for earliestEpochBlock < lastBlockInMemory { - deletedEpochs = append(deletedEpochs, earliestEpochBlock) - earliestEpochBlock, err = k.GetNextEpoch(ctx, earliestEpochBlock) - if err != nil { - // panic:ok: critical, no recovery, avoid further corruption - utils.LavaFormatPanic("critical: failed to advance EarliestEpochstart", err, - utils.LogAttr("earliestEpochBlock", earliestEpochBlock), - utils.LogAttr("fixations", k.GetAllFixatedParams(ctx)), - ) - } - } - - if len(deletedEpochs) == 0 { - return - } - - utils.LogLavaEvent(ctx, k.Logger(ctx), types.EarliestEpochEventName, - map[string]string{"block": strconv.FormatUint(earliestEpochBlock, 10)}, - "updated earliest epoch block") - - // now update the earliest epoch start - k.SetEarliestEpochStart(ctx, earliestEpochBlock, deletedEpochs) -} - -func (k Keeper) StakeStorageKey(block uint64, chainID string) string { - return strconv.FormatUint(block, 10) + chainID -} - -func (k Keeper) RemoveStakeStorageByBlockAndChain(ctx sdk.Context, block uint64, chainID string) { - key := k.StakeStorageKey(block, chainID) - k.RemoveStakeStorage(ctx, key) -} - -// -------------------------------------------------- current staking list -------------------------------------------- - -func (k Keeper) stakeStorageKeyCurrent(chainID string) string { - return chainID -} - -// used to get the latest -func (k Keeper) GetStakeStorageCurrent(ctx sdk.Context, chainID string) (types.StakeStorage, bool) { - return k.GetStakeStorage(ctx, k.stakeStorageKeyCurrent(chainID)) -} - -func (k Keeper) SetStakeStorageCurrent(ctx sdk.Context, chainID string, stakeStorage types.StakeStorage) { - stakeStorage.Index = k.stakeStorageKeyCurrent(chainID) - k.SetStakeStorage(ctx, stakeStorage) -} - -func (k Keeper) GetStakeEntryByAddressCurrent(ctx sdk.Context, chainID string, address string) (types.StakeEntry, bool) { - if !utils.IsBech32Address(address) { - utils.LavaFormatWarning("cannot get stake entry of invalid address", fmt.Errorf("invalid address"), - utils.LogAttr("address", address), - ) - } - stakeStorage, found := k.GetStakeStorageCurrent(ctx, chainID) - if !found { - return types.StakeEntry{}, false - } - - return stakeStorage.GetStakeEntryByAddressFromStorage(address) -} - -func (k Keeper) RemoveStakeEntryCurrent(ctx sdk.Context, chainID string, address string) error { - if !utils.IsBech32Address(address) { - utils.LavaFormatWarning("cannot get stake entry of invalid address", fmt.Errorf("invalid address"), - utils.LogAttr("address", address), - ) - } - stakeStorage, found := k.GetStakeStorageCurrent(ctx, chainID) - if !found { - return legacyerrors.ErrNotFound - } - - for i, entry := range stakeStorage.StakeEntries { - if entry.IsAddressVaultOrProvider(address) { - stakeStorage.StakeEntries = append(stakeStorage.StakeEntries[:i], stakeStorage.StakeEntries[i+1:]...) - k.SetStakeStorageCurrent(ctx, chainID, stakeStorage) - return nil - } - } - - return legacyerrors.ErrNotFound -} - -func (k Keeper) AppendStakeEntryFromStorage(ctx sdk.Context, stakeStorageIndex string, stakeEntry types.StakeEntry, isUnstake bool) { - stakeStorage, found := k.GetStakeStorage(ctx, stakeStorageIndex) - var entries []types.StakeEntry - if !found { - entries = []types.StakeEntry{stakeEntry} - // create a new one - stakeStorage = types.StakeStorage{Index: stakeStorageIndex, StakeEntries: entries, EpochBlockHash: nil} - } else { - // the following code inserts stakeEntry into the existing entries by stake - entries = stakeStorage.StakeEntries - // sort func needs to return true if the inserted entry is less than the existing entry - sortFunc := func(i int) bool { - return stakeEntry.StakeAppliedBlock <= entries[i].StakeAppliedBlock - } - if !isUnstake { - sortFunc = func(i int) bool { - return stakeEntry.EffectiveStake().LT(entries[i].EffectiveStake()) - } - } - - // returns the smallest index in which the sort func is true - index := sort.Search(len(entries), sortFunc) - if index < len(entries) { - entries = append(entries[:index+1], entries[index:]...) - entries[index] = stakeEntry - } else { - // put in the end - entries = append(entries, stakeEntry) - } - } - stakeStorage.StakeEntries = entries - k.SetStakeStorage(ctx, stakeStorage) -} - -func (k Keeper) AppendStakeEntryCurrent(ctx sdk.Context, chainID string, stakeEntry types.StakeEntry) { - k.AppendStakeEntryFromStorage(ctx, k.stakeStorageKeyCurrent(chainID), stakeEntry, false) -} - -func (k Keeper) ModifyStakeEntryCurrentFromStorage(ctx sdk.Context, stakeStorage types.StakeStorage, stakeEntry types.StakeEntry) { - // TODO: more efficient: only create a new list once, after the second index is identified - // remove the given index, then store the new entry in the sorted list at the right place - entries := []types.StakeEntry{} - for i, entry := range stakeStorage.StakeEntries { - if entry.Address == stakeEntry.Address && entry.Vault == stakeEntry.Vault { - entries = append(entries, stakeStorage.StakeEntries[:i]...) - entries = append(entries, stakeStorage.StakeEntries[i+1:]...) - break - } - } - // the following code inserts stakeEntry into the existing entries by stake - // sort func needs to return true if the inserted entry is less than the existing entry - sortFunc := func(i int) bool { - return stakeEntry.EffectiveStake().LT(entries[i].EffectiveStake()) - } - // returns the smallest index in which the sort func is true - index := sort.Search(len(entries), sortFunc) - if index < len(entries) { - entries = append(entries[:index+1], entries[index:]...) - entries[index] = stakeEntry - } else { - entries = append(entries, stakeEntry) - } - stakeStorage.StakeEntries = entries - k.SetStakeStorage(ctx, stakeStorage) -} - -func (k Keeper) ModifyStakeEntryCurrent(ctx sdk.Context, chainID string, stakeEntry types.StakeEntry) { - // this stake storage entries are sorted by stake amount - stakeStorage, found := k.GetStakeStorageCurrent(ctx, chainID) - if !found { - // should not happen since caller is expected to validate chainID first; - // do nothing and return to avoid panic. - utils.LavaFormatError("critical: ModifyStakeEntryCurrent with unknown chain", legacyerrors.ErrNotFound, - utils.LogAttr("chainID", chainID), - utils.LogAttr("stakeAddr", stakeEntry.Address), - ) - return - } - k.ModifyStakeEntryCurrentFromStorage(ctx, stakeStorage, stakeEntry) -} - -// -------------------------------------------------- unstaking list -------------------------------------------- - -// used to get the unstaking entries -func (k Keeper) GetStakeStorageUnstake(ctx sdk.Context) (types.StakeStorage, bool) { - return k.GetStakeStorage(ctx, types.StakeStorageKeyUnstakeConst) -} - -func (k Keeper) SetStakeStorageUnstake(ctx sdk.Context, stakeStorage types.StakeStorage) { - stakeStorage.Index = types.StakeStorageKeyUnstakeConst - k.SetStakeStorage(ctx, stakeStorage) -} - -func (k Keeper) UnstakeEntryByAddress(ctx sdk.Context, address string) (value types.StakeEntry, found bool) { - if !utils.IsBech32Address(address) { - utils.LavaFormatWarning("cannot get stake entry of invalid address", fmt.Errorf("invalid address"), - utils.LogAttr("address", address), - ) - } - stakeStorage, found := k.GetStakeStorageUnstake(ctx) - if !found { - return types.StakeEntry{}, false - } - return stakeStorage.GetStakeEntryByAddressFromStorage(address) -} - -func (k Keeper) ModifyUnstakeEntry(ctx sdk.Context, stakeEntry types.StakeEntry) { - // this stake storage entries are sorted by stake amount - stakeStorage, found := k.GetStakeStorageUnstake(ctx) - if !found { - // should not happen since stake storage must always exist; do nothing to avoid panic - utils.LavaFormatError("critical: ModifyUnstakeEntry failed to get stakeStorage", legacyerrors.ErrNotFound, - utils.LogAttr("stakeAddr", stakeEntry.Address), - ) - return - } - k.ModifyStakeEntryCurrentFromStorage(ctx, stakeStorage, stakeEntry) -} - -func (k Keeper) AppendUnstakeEntry(ctx sdk.Context, stakeEntry types.StakeEntry, unstakeHoldBlocks uint64) { - // update unstake stakeAppliedBlock to the higher among params (unstakeholdblocks and blockstosave) - blockHeight := uint64(ctx.BlockHeight()) - stakeEntry.StakeAppliedBlock = blockHeight + unstakeHoldBlocks - k.AppendStakeEntryFromStorage(ctx, types.StakeStorageKeyUnstakeConst, stakeEntry, true) -} - -// Returns the unstaking Entry if its stakeAppliedBlock is lower than the provided block -func (k Keeper) PopUnstakeEntries(ctx sdk.Context, block uint64) (value []types.StakeEntry) { - stakeStorage, found := k.GetStakeStorageUnstake(ctx) - if !found { - // utils.LavaError(ctx, k.Logger(ctx), "emptyStakeStorage", map[string]string{"storageType": storageType}, "stakeStorageUnstake Empty!") - return nil - } - found_idx := -1 - // the unstaking is a sorted list so just chekcing until an entry stakeAppliedBlock is too big - for idx, entry := range stakeStorage.StakeEntries { - if entry.StakeAppliedBlock <= block { - // found an enrty that its stakeAppliedBlock is less equal to the wanted block number - value = append(value, entry) - // remove from the unstaking stakeStorage everything before this index - found_idx = idx - } else { - // no need to keep iterating the sorted list - break - } - } - if found_idx >= 0 { - stakeStorage.StakeEntries = stakeStorage.StakeEntries[found_idx+1:] - k.SetStakeStorageUnstake(ctx, stakeStorage) - return - } - return nil -} - -// ------------------------------------------------ - -// takes the current stake storage and puts it in epoch storage -func (k Keeper) StoreCurrentEpochStakeStorage(ctx sdk.Context, block uint64) { - allChainIDs := k.specKeeper.GetAllChainIDs(ctx) - for _, chainID := range allChainIDs { - tmpStorage, found := k.GetStakeStorageCurrent(ctx, chainID) - if !found { - // no storage for this spec yet - continue - } - newStorage := tmpStorage.Copy() - newStorage.Index = k.StakeStorageKey(block, chainID) - newStorage.EpochBlockHash = ctx.HeaderHash() // set the current block hash for pairing to work without accessing history - k.SetStakeStorage(ctx, newStorage) - } -} - -func (k Keeper) GetStakeStorageEpoch(ctx sdk.Context, block uint64, chainID string) (stakeStorage types.StakeStorage, found bool) { - key := k.StakeStorageKey(block, chainID) - return k.GetStakeStorage(ctx, key) -} - -func (k Keeper) GetStakeEntryForProviderEpoch(ctx sdk.Context, chainID string, address string, epoch uint64) (types.StakeEntry, bool) { - if !utils.IsBech32Address(address) { - utils.LavaFormatWarning("cannot get stake entry of invalid address", fmt.Errorf("invalid address"), - utils.LogAttr("address", address), - ) - } - stakeStorage, found := k.GetStakeStorageEpoch(ctx, epoch, chainID) - if !found { - return types.StakeEntry{}, false - } - return stakeStorage.GetStakeEntryByAddressFromStorage(address) -} - -func (k Keeper) GetStakeEntryForAllProvidersEpoch(ctx sdk.Context, chainID string, epoch uint64) (entrys *[]types.StakeEntry, err error) { - stakeStorage, found := k.GetStakeStorageEpoch(ctx, epoch, chainID) - if !found { - return nil, fmt.Errorf("could not find stakeStorage - epoch %d, chainID %s", epoch, chainID) - } - - return &stakeStorage.StakeEntries, nil -} - -func (k Keeper) GetEpochStakeEntries(ctx sdk.Context, block uint64, chainID string) (entries []types.StakeEntry, found bool, epochHash []byte) { - key := k.StakeStorageKey(block, chainID) - stakeStorage, found := k.GetStakeStorage(ctx, key) - if !found { - return nil, false, nil - } - return stakeStorage.StakeEntries, true, stakeStorage.EpochBlockHash -} - -func (k Keeper) GetUnstakeHoldBlocks(ctx sdk.Context, chainID string) uint64 { - _, found, providerType := k.specKeeper.IsSpecFoundAndActive(ctx, chainID) - if !found { - utils.LavaFormatError("critical: failed to get spec for chainID", - fmt.Errorf("unknown chainID"), - utils.Attribute{Key: "chainID", Value: chainID}, - ) - } - - // note: if spec was not found, the default choice is Spec_dynamic == 0 - - block := uint64(ctx.BlockHeight()) - if providerType == spectypes.Spec_static { - return k.UnstakeHoldBlocksStatic(ctx, block) - } else { - return k.UnstakeHoldBlocks(ctx, block) - } - - // NOT REACHED -} diff --git a/x/epochstorage/keeper/stake_storage_test.go b/x/epochstorage/keeper/stake_storage_test.go deleted file mode 100644 index 1e07c04298..0000000000 --- a/x/epochstorage/keeper/stake_storage_test.go +++ /dev/null @@ -1,138 +0,0 @@ -package keeper_test - -import ( - "strconv" - "strings" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - testkeeper "github.com/lavanet/lava/v2/testutil/keeper" - "github.com/lavanet/lava/v2/testutil/nullify" - "github.com/lavanet/lava/v2/x/epochstorage/keeper" - epochstoragetypes "github.com/lavanet/lava/v2/x/epochstorage/types" - "github.com/stretchr/testify/require" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -const ( - advanceFewEpochs = 4 - stakeStorageSlots = 10 -) - -func createNStakeStorage(keeper *keeper.Keeper, ctx sdk.Context, n int) []epochstoragetypes.StakeStorage { - items := make([]epochstoragetypes.StakeStorage, n) - for i := range items { - items[i].Index = strconv.Itoa(i) - - keeper.SetStakeStorage(ctx, items[i]) - } - return items -} - -func TestStakeStorageGet(t *testing.T) { - keeper, ctx := testkeeper.EpochstorageKeeper(t) - items := createNStakeStorage(keeper, ctx, 10) - for _, item := range items { - rst, found := keeper.GetStakeStorage(ctx, - item.Index, - ) - require.True(t, found) - require.Equal(t, - nullify.Fill(&item), - nullify.Fill(&rst), - ) - } -} - -func TestStakeStorageRemove(t *testing.T) { - keeper, ctx := testkeeper.EpochstorageKeeper(t) - items := createNStakeStorage(keeper, ctx, stakeStorageSlots) - for _, item := range items { - keeper.RemoveStakeStorage(ctx, - item.Index, - ) - _, found := keeper.GetStakeStorage(ctx, - item.Index, - ) - require.False(t, found) - } -} - -func removeAllEntriesBeforeBlock(keeper keeper.Keeper, ctx sdk.Context, block uint64, allChainID []string) { - allStorage := keeper.GetAllStakeStorage(ctx) - for _, chainId := range allChainID { - for _, entry := range allStorage { - if strings.Contains(entry.Index, chainId) { - storageBlock := entry.Index[:(len(entry.Index) - len(chainId))] - blockHeight, err := strconv.ParseUint(storageBlock, 10, 64) - if err != nil { - if storageBlock == "" { - // empty storageBlock means stake entry current, so skip it - continue - } - panic("failed to decode storage block: " + strconv.Itoa(int(block)) + - "chainID: " + chainId + "index: " + entry.Index) - } - if blockHeight < block { - keeper.RemoveStakeStorage(ctx, entry.Index) - } - } - } - } -} - -func TestStakeStorageRemoveAllPriorToBlock(t *testing.T) { - // keeper, ctx := keepertest.EpochstorageKeeper(t) - _, allkeepers, ctxx := testkeeper.InitAllKeepers(t) - - keeper := allkeepers.Epochstorage - ctx := sdk.UnwrapSDKContext(ctxx) - - items := make([]epochstoragetypes.StakeStorage, stakeStorageSlots) - chainID := "ETH1" - for i := 0; i < len(items); i++ { - items[i].Index = keeper.StakeStorageKey(uint64(i), chainID) - keeper.SetStakeStorage(ctx, items[i]) - } - - for i := 0; i < advanceFewEpochs; i++ { - testkeeper.AdvanceEpoch(ctxx, allkeepers) - } - - removeAllEntriesBeforeBlock(keeper, ctx, 10, []string{"OSMOSISETH1LAV1OSMOSIST"}) - allStorage := keeper.GetAllStakeStorage(ctx) - require.Equal(t, len(allStorage), stakeStorageSlots) // no entry was removed - - removeAllEntriesBeforeBlock(keeper, ctx, 10, []string{"OSMOSIS"}) - allStorage = keeper.GetAllStakeStorage(ctx) - require.Equal(t, len(allStorage), stakeStorageSlots) // no entry was removed - - removeAllEntriesBeforeBlock(keeper, ctx, 0, []string{chainID}) - allStorage = keeper.GetAllStakeStorage(ctx) - require.Equal(t, len(allStorage), stakeStorageSlots) // no entry was removed - - removeAllEntriesBeforeBlock(keeper, ctx, 9, []string{chainID}) - allStorage = keeper.GetAllStakeStorage(ctx) - require.Equal(t, len(allStorage), 1) // one provider - - removeAllEntriesBeforeBlock(keeper, ctx, 10, []string{chainID}) - allStorage = keeper.GetAllStakeStorage(ctx) - require.Equal(t, len(allStorage), 0) // zero entries left - - items[0].Index = strconv.FormatUint(uint64(10), 10) + "" - keeper.SetStakeStorage(ctx, items[0]) - removeAllEntriesBeforeBlock(keeper, ctx, 11, []string{""}) - allStorage = keeper.GetAllStakeStorage(ctx) - require.Equal(t, len(allStorage), 0) // zero entries left -} - -func TestStakeStorageGetAll(t *testing.T) { - keeper, ctx := testkeeper.EpochstorageKeeper(t) - items := createNStakeStorage(keeper, ctx, 10) - require.ElementsMatch(t, - nullify.Fill(items), - nullify.Fill(keeper.GetAllStakeStorage(ctx)), - ) -} diff --git a/x/epochstorage/module.go b/x/epochstorage/module.go index 61b009a4ae..3df27a6b84 100644 --- a/x/epochstorage/module.go +++ b/x/epochstorage/module.go @@ -130,31 +130,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { migrator := keeper.NewMigrator(am.keeper) - // register v2 -> v3 migration - if err := cfg.RegisterMigration(types.ModuleName, 2, migrator.Migrate2to3); err != nil { + // register v7 -> v8 migration + if err := cfg.RegisterMigration(types.ModuleName, 7, migrator.Migrate7to8); err != nil { // panic:ok: at start up, migration cannot proceed anyhow - panic(fmt.Errorf("%s: failed to register migration to v3: %w", types.ModuleName, err)) - } - // register v3 -> v4 migration - if err := cfg.RegisterMigration(types.ModuleName, 3, migrator.Migrate3to4); err != nil { - // panic:ok: at start up, migration cannot proceed anyhow - panic(fmt.Errorf("%s: failed to register migration to v4: %w", types.ModuleName, err)) - } - // register v4 -> v5 migration - if err := cfg.RegisterMigration(types.ModuleName, 4, migrator.Migrate4to5); err != nil { - // panic:ok: at start up, migration cannot proceed anyhow - panic(fmt.Errorf("%s: failed to register migration to v5: %w", types.ModuleName, err)) - } - // register v5 -> v6 migration - if err := cfg.RegisterMigration(types.ModuleName, 5, migrator.Migrate5to6); err != nil { - // panic:ok: at start up, migration cannot proceed anyhow - panic(fmt.Errorf("%s: failed to register migration to v6: %w", types.ModuleName, err)) - } - - // register v6 -> v7 migration - if err := cfg.RegisterMigration(types.ModuleName, 6, migrator.Migrate6to7); err != nil { - // panic:ok: at start up, migration cannot proceed anyhow - panic(fmt.Errorf("%s: failed to register migration to v7: %w", types.ModuleName, err)) + panic(fmt.Errorf("%s: failed to register migration to v8: %w", types.ModuleName, err)) } } @@ -180,7 +159,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 7 } +func (AppModule) ConsensusVersion() uint64 { return 8 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/epochstorage/types/genesis.go b/x/epochstorage/types/genesis.go index ab72171faf..180bce6ac6 100644 --- a/x/epochstorage/types/genesis.go +++ b/x/epochstorage/types/genesis.go @@ -25,11 +25,10 @@ func (gs GenesisState) Validate() error { stakeStorageIndexMap := make(map[string]struct{}) for _, elem := range gs.StakeStorageList { - index := string(StakeStorageKey(elem.Index)) - if _, ok := stakeStorageIndexMap[index]; ok { + if _, ok := stakeStorageIndexMap[elem.Index]; ok { return fmt.Errorf("duplicated index for stakeStorage") } - stakeStorageIndexMap[index] = struct{}{} + stakeStorageIndexMap[elem.Index] = struct{}{} } // Check for duplicated index in fixatedParams fixatedParamsIndexMap := make(map[string]struct{}) diff --git a/x/epochstorage/types/key_stake_storage.go b/x/epochstorage/types/key_stake_storage.go deleted file mode 100644 index bf87de822e..0000000000 --- a/x/epochstorage/types/key_stake_storage.go +++ /dev/null @@ -1,23 +0,0 @@ -package types - -import "encoding/binary" - -var _ binary.ByteOrder - -const ( - // StakeStorageKeyPrefix is the prefix to retrieve all StakeStorage - StakeStorageKeyPrefix = "StakeStorage/value/" -) - -// StakeStorageKey returns the store key to retrieve a StakeStorage from the index fields -func StakeStorageKey( - index string, -) []byte { - var key []byte - - indexBytes := []byte(index) - key = append(key, indexBytes...) - key = append(key, []byte("/")...) - - return key -} diff --git a/x/epochstorage/types/migrations/v3/keys.go b/x/epochstorage/types/migrations/v3/keys.go index 04373a6d26..a618f4a591 100644 --- a/x/epochstorage/types/migrations/v3/keys.go +++ b/x/epochstorage/types/migrations/v3/keys.go @@ -22,5 +22,6 @@ func KeyPrefix(p string) []byte { } const ( - EpochDetailsKey = "EpochDetails-value-" + EpochDetailsKey = "EpochDetails-value-" + StakeStorageKeyUnstakeConst = "Unstake" ) diff --git a/x/epochstorage/types/migrations/v4/endpoint.pb.go b/x/epochstorage/types/migrations/v4/endpoint.pb.go deleted file mode 100644 index 93263871ba..0000000000 --- a/x/epochstorage/types/migrations/v4/endpoint.pb.go +++ /dev/null @@ -1,522 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/endpoint.proto - -package v4 - -import ( - fmt "fmt" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Endpoint struct { - IPPORT string `protobuf:"bytes,1,opt,name=iPPORT,proto3" json:"iPPORT,omitempty"` - Geolocation int32 `protobuf:"varint,3,opt,name=geolocation,proto3" json:"geolocation,omitempty"` - Addons []string `protobuf:"bytes,4,rep,name=addons,proto3" json:"addons,omitempty"` - ApiInterfaces []string `protobuf:"bytes,5,rep,name=api_interfaces,json=apiInterfaces,proto3" json:"api_interfaces,omitempty"` - Extensions []string `protobuf:"bytes,6,rep,name=extensions,proto3" json:"extensions,omitempty"` -} - -func (m *Endpoint) Reset() { *m = Endpoint{} } -func (m *Endpoint) String() string { return proto.CompactTextString(m) } -func (*Endpoint) ProtoMessage() {} -func (*Endpoint) Descriptor() ([]byte, []int) { - return fileDescriptor_acb18a6b0d300ae9, []int{0} -} -func (m *Endpoint) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Endpoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_Endpoint.Merge(m, src) -} -func (m *Endpoint) XXX_Size() int { - return m.Size() -} -func (m *Endpoint) XXX_DiscardUnknown() { - xxx_messageInfo_Endpoint.DiscardUnknown(m) -} - -var xxx_messageInfo_Endpoint proto.InternalMessageInfo - -func (m *Endpoint) GetIPPORT() string { - if m != nil { - return m.IPPORT - } - return "" -} - -func (m *Endpoint) GetGeolocation() int32 { - if m != nil { - return m.Geolocation - } - return 0 -} - -func (m *Endpoint) GetAddons() []string { - if m != nil { - return m.Addons - } - return nil -} - -func (m *Endpoint) GetApiInterfaces() []string { - if m != nil { - return m.ApiInterfaces - } - return nil -} - -func (m *Endpoint) GetExtensions() []string { - if m != nil { - return m.Extensions - } - return nil -} - -func init() { - proto.RegisterType((*Endpoint)(nil), "lavanet.lava.epochstorage.EndpointV4") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/endpoint.proto", fileDescriptor_acb18a6b0d300ae9) -} - -var fileDescriptor_acb18a6b0d300ae9 = []byte{ - // 250 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xc8, 0x49, 0x2c, 0x4b, - 0xcc, 0x4b, 0x2d, 0xd1, 0x07, 0xd1, 0xfa, 0xa9, 0x05, 0xf9, 0xc9, 0x19, 0xc5, 0x25, 0xf9, 0x45, - 0x89, 0xe9, 0xa9, 0xfa, 0xa9, 0x79, 0x29, 0x05, 0xf9, 0x99, 0x79, 0x25, 0x7a, 0x05, 0x45, 0xf9, - 0x25, 0xf9, 0x42, 0x92, 0x50, 0x95, 0x7a, 0x20, 0x5a, 0x0f, 0x59, 0xa5, 0xd2, 0x4a, 0x46, 0x2e, - 0x0e, 0x57, 0xa8, 0x6a, 0x21, 0x31, 0x2e, 0xb6, 0xcc, 0x80, 0x00, 0xff, 0xa0, 0x10, 0x09, 0x46, - 0x05, 0x46, 0x0d, 0xce, 0x20, 0x28, 0x4f, 0x48, 0x81, 0x8b, 0x3b, 0x3d, 0x35, 0x3f, 0x27, 0x3f, - 0x39, 0xb1, 0x24, 0x33, 0x3f, 0x4f, 0x82, 0x59, 0x81, 0x51, 0x83, 0x35, 0x08, 0x59, 0x08, 0xa4, - 0x33, 0x31, 0x25, 0x25, 0x3f, 0xaf, 0x58, 0x82, 0x45, 0x81, 0x19, 0xa4, 0x13, 0xc2, 0x13, 0x52, - 0xe5, 0xe2, 0x4b, 0x2c, 0xc8, 0x8c, 0xcf, 0xcc, 0x2b, 0x49, 0x2d, 0x4a, 0x4b, 0x4c, 0x4e, 0x2d, - 0x96, 0x60, 0x05, 0xcb, 0xf3, 0x26, 0x16, 0x64, 0x7a, 0xc2, 0x05, 0x85, 0xe4, 0xb8, 0xb8, 0x52, - 0x2b, 0x4a, 0x52, 0xf3, 0x8a, 0x33, 0x41, 0x46, 0xb0, 0x81, 0x95, 0x20, 0x89, 0x78, 0xb1, 0x70, - 0x30, 0x09, 0x30, 0x3b, 0xb9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, - 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, - 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x4a, 0xa8, 0x54, 0xa0, - 0x86, 0x4b, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x54, 0x8c, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xf3, 0xac, 0x09, 0xa5, 0x41, 0x01, 0x00, 0x00, -} - -func (m *Endpoint) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Endpoint) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Endpoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Extensions) > 0 { - for iNdEx := len(m.Extensions) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Extensions[iNdEx]) - copy(dAtA[i:], m.Extensions[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.Extensions[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if len(m.ApiInterfaces) > 0 { - for iNdEx := len(m.ApiInterfaces) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ApiInterfaces[iNdEx]) - copy(dAtA[i:], m.ApiInterfaces[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.ApiInterfaces[iNdEx]))) - i-- - dAtA[i] = 0x2a - } - } - if len(m.Addons) > 0 { - for iNdEx := len(m.Addons) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Addons[iNdEx]) - copy(dAtA[i:], m.Addons[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.Addons[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if m.Geolocation != 0 { - i = encodeVarintEndpoint(dAtA, i, uint64(m.Geolocation)) - i-- - dAtA[i] = 0x18 - } - if len(m.IPPORT) > 0 { - i -= len(m.IPPORT) - copy(dAtA[i:], m.IPPORT) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.IPPORT))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintEndpoint(dAtA []byte, offset int, v uint64) int { - offset -= sovEndpoint(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Endpoint) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.IPPORT) - if l > 0 { - n += 1 + l + sovEndpoint(uint64(l)) - } - if m.Geolocation != 0 { - n += 1 + sovEndpoint(uint64(m.Geolocation)) - } - if len(m.Addons) > 0 { - for _, s := range m.Addons { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - if len(m.ApiInterfaces) > 0 { - for _, s := range m.ApiInterfaces { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - if len(m.Extensions) > 0 { - for _, s := range m.Extensions { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - return n -} - -func sovEndpoint(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozEndpoint(x uint64) (n int) { - return sovEndpoint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Endpoint) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Endpoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Endpoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IPPORT", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.IPPORT = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Geolocation", wireType) - } - m.Geolocation = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Geolocation |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addons", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addons = append(m.Addons, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApiInterfaces", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ApiInterfaces = append(m.ApiInterfaces, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Extensions", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Extensions = append(m.Extensions, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEndpoint(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEndpoint - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipEndpoint(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthEndpoint - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupEndpoint - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthEndpoint - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthEndpoint = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowEndpoint = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupEndpoint = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/migrations/v4/stake_entry.pb.go b/x/epochstorage/types/migrations/v4/stake_entry.pb.go deleted file mode 100644 index 9b24feb2c5..0000000000 --- a/x/epochstorage/types/migrations/v4/stake_entry.pb.go +++ /dev/null @@ -1,763 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/stake_entry.proto - -package v4 - -import ( - fmt "fmt" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type StakeEntry struct { - Stake types.Coin `protobuf:"bytes,1,opt,name=stake,proto3" json:"stake"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - StakeAppliedBlock uint64 `protobuf:"varint,3,opt,name=stake_applied_block,json=stakeAppliedBlock,proto3" json:"stake_applied_block,omitempty"` - Endpoints []Endpoint `protobuf:"bytes,4,rep,name=endpoints,proto3" json:"endpoints"` - Geolocation int32 `protobuf:"varint,5,opt,name=geolocation,proto3" json:"geolocation,omitempty"` - Chain string `protobuf:"bytes,6,opt,name=chain,proto3" json:"chain,omitempty"` - Moniker string `protobuf:"bytes,8,opt,name=moniker,proto3" json:"moniker,omitempty"` - DelegateTotal types.Coin `protobuf:"bytes,9,opt,name=delegate_total,json=delegateTotal,proto3" json:"delegate_total"` - DelegateLimit types.Coin `protobuf:"bytes,10,opt,name=delegate_limit,json=delegateLimit,proto3" json:"delegate_limit"` - DelegateCommission uint64 `protobuf:"varint,11,opt,name=delegate_commission,json=delegateCommission,proto3" json:"delegate_commission,omitempty"` -} - -func (m *StakeEntry) Reset() { *m = StakeEntry{} } -func (m *StakeEntry) String() string { return proto.CompactTextString(m) } -func (*StakeEntry) ProtoMessage() {} -func (*StakeEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_df6302d6b53c056e, []int{0} -} -func (m *StakeEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakeEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakeEntry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StakeEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakeEntry.Merge(m, src) -} -func (m *StakeEntry) XXX_Size() int { - return m.Size() -} -func (m *StakeEntry) XXX_DiscardUnknown() { - xxx_messageInfo_StakeEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_StakeEntry proto.InternalMessageInfo - -func (m *StakeEntry) GetStake() types.Coin { - if m != nil { - return m.Stake - } - return types.Coin{} -} - -func (m *StakeEntry) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *StakeEntry) GetStakeAppliedBlock() uint64 { - if m != nil { - return m.StakeAppliedBlock - } - return 0 -} - -func (m *StakeEntry) GetEndpoints() []Endpoint { - if m != nil { - return m.Endpoints - } - return nil -} - -func (m *StakeEntry) GetGeolocation() int32 { - if m != nil { - return m.Geolocation - } - return 0 -} - -func (m *StakeEntry) GetChain() string { - if m != nil { - return m.Chain - } - return "" -} - -func (m *StakeEntry) GetMoniker() string { - if m != nil { - return m.Moniker - } - return "" -} - -func (m *StakeEntry) GetDelegateTotal() types.Coin { - if m != nil { - return m.DelegateTotal - } - return types.Coin{} -} - -func (m *StakeEntry) GetDelegateLimit() types.Coin { - if m != nil { - return m.DelegateLimit - } - return types.Coin{} -} - -func (m *StakeEntry) GetDelegateCommission() uint64 { - if m != nil { - return m.DelegateCommission - } - return 0 -} - -func init() { - proto.RegisterType((*StakeEntry)(nil), "lavanet.lava.epochstorage.StakeEntryV4") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/stake_entry.proto", fileDescriptor_df6302d6b53c056e) -} - -var fileDescriptor_df6302d6b53c056e = []byte{ - // 422 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0xc1, 0x6e, 0x13, 0x31, - 0x10, 0xcd, 0x92, 0xa4, 0x4d, 0x1c, 0x81, 0xc0, 0xed, 0xc1, 0xed, 0x61, 0x59, 0xc1, 0x65, 0x25, - 0x90, 0xad, 0x16, 0xf1, 0x01, 0xa4, 0x6a, 0x91, 0x10, 0xa7, 0xc0, 0x89, 0x4b, 0xe4, 0xf5, 0x8e, - 0x36, 0x56, 0x76, 0x3d, 0xab, 0xb5, 0xa9, 0xe8, 0x5f, 0xf0, 0x59, 0x3d, 0xf6, 0xc8, 0x09, 0xa1, - 0xe4, 0x03, 0xf8, 0x05, 0xe4, 0xf5, 0x6e, 0x69, 0x0e, 0x91, 0xe0, 0x64, 0xcf, 0xbc, 0x79, 0x4f, - 0xef, 0x8d, 0x86, 0xbc, 0x2a, 0xe5, 0xb5, 0x34, 0xe0, 0x84, 0x7f, 0x05, 0xd4, 0xa8, 0x56, 0xd6, - 0x61, 0x23, 0x0b, 0x10, 0xd6, 0xc9, 0x35, 0x2c, 0xc1, 0xb8, 0xe6, 0x86, 0xd7, 0x0d, 0x3a, 0xa4, - 0x27, 0xdd, 0x30, 0xf7, 0x2f, 0x7f, 0x38, 0x7c, 0x9a, 0xee, 0xd7, 0x01, 0x93, 0xd7, 0xa8, 0x8d, - 0x0b, 0x22, 0xa7, 0xc7, 0x05, 0x16, 0xd8, 0x7e, 0x85, 0xff, 0x75, 0xdd, 0x58, 0xa1, 0xad, 0xd0, - 0x8a, 0x4c, 0x5a, 0x10, 0xd7, 0x67, 0x19, 0x38, 0x79, 0x26, 0x14, 0x6a, 0x13, 0xf0, 0x17, 0xbf, - 0x87, 0x84, 0x7c, 0xf2, 0x86, 0x2e, 0xbd, 0x1f, 0xfa, 0x96, 0x8c, 0x5b, 0x7b, 0x2c, 0x4a, 0xa2, - 0x74, 0x76, 0x7e, 0xc2, 0x03, 0x9d, 0x7b, 0x3a, 0xef, 0xe8, 0xfc, 0x02, 0xb5, 0x99, 0x8f, 0x6e, - 0x7f, 0x3e, 0x1f, 0x2c, 0xc2, 0x34, 0x65, 0xe4, 0x50, 0xe6, 0x79, 0x03, 0xd6, 0xb2, 0x47, 0x49, - 0x94, 0x4e, 0x17, 0x7d, 0x49, 0x39, 0x39, 0x0a, 0x79, 0x65, 0x5d, 0x97, 0x1a, 0xf2, 0x65, 0x56, - 0xa2, 0x5a, 0xb3, 0x61, 0x12, 0xa5, 0xa3, 0xc5, 0xb3, 0x16, 0x7a, 0x17, 0x90, 0xb9, 0x07, 0xe8, - 0x7b, 0x32, 0xed, 0x73, 0x59, 0x36, 0x4a, 0x86, 0xe9, 0xec, 0xfc, 0x25, 0xdf, 0xbb, 0x1e, 0x7e, - 0xd9, 0xcd, 0x76, 0x76, 0xfe, 0x72, 0x69, 0x42, 0x66, 0x05, 0x60, 0x89, 0x4a, 0x3a, 0x8d, 0x86, - 0x8d, 0x93, 0x28, 0x1d, 0x2f, 0x1e, 0xb6, 0xe8, 0x31, 0x19, 0xab, 0x95, 0xd4, 0x86, 0x1d, 0xb4, - 0x96, 0x43, 0xe1, 0xa3, 0x54, 0x68, 0xf4, 0x1a, 0x1a, 0x36, 0x09, 0x51, 0xba, 0x92, 0x5e, 0x91, - 0x27, 0x39, 0x94, 0x50, 0x48, 0x07, 0x4b, 0x87, 0x4e, 0x96, 0x6c, 0xfa, 0x6f, 0x4b, 0x7a, 0xdc, - 0xd3, 0x3e, 0x7b, 0xd6, 0x8e, 0x4e, 0xa9, 0x2b, 0xed, 0x18, 0xf9, 0x4f, 0x9d, 0x8f, 0x9e, 0x45, - 0x05, 0x39, 0xba, 0xd7, 0x51, 0x58, 0x55, 0xda, 0x5a, 0x9f, 0x74, 0xd6, 0xae, 0x96, 0xf6, 0xd0, - 0xc5, 0x3d, 0xf2, 0x61, 0x34, 0x39, 0x7c, 0x3a, 0x99, 0x5f, 0xdd, 0x6e, 0xe2, 0xe8, 0x6e, 0x13, - 0x47, 0xbf, 0x36, 0x71, 0xf4, 0x7d, 0x1b, 0x0f, 0xee, 0xb6, 0xf1, 0xe0, 0xc7, 0x36, 0x1e, 0x7c, - 0x79, 0x5d, 0x68, 0xb7, 0xfa, 0x9a, 0x71, 0x85, 0x95, 0xd8, 0x39, 0xbb, 0x6f, 0xbb, 0x87, 0xe7, - 0x6e, 0x6a, 0xb0, 0xd9, 0x41, 0x7b, 0x40, 0x6f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x45, - 0x2d, 0xb5, 0xea, 0x02, 0x00, 0x00, -} - -func (m *StakeEntry) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StakeEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakeEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.DelegateCommission != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.DelegateCommission)) - i-- - dAtA[i] = 0x58 - } - { - size, err := m.DelegateLimit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - { - size, err := m.DelegateTotal.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - if len(m.Moniker) > 0 { - i -= len(m.Moniker) - copy(dAtA[i:], m.Moniker) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Moniker))) - i-- - dAtA[i] = 0x42 - } - if len(m.Chain) > 0 { - i -= len(m.Chain) - copy(dAtA[i:], m.Chain) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Chain))) - i-- - dAtA[i] = 0x32 - } - if m.Geolocation != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.Geolocation)) - i-- - dAtA[i] = 0x28 - } - if len(m.Endpoints) > 0 { - for iNdEx := len(m.Endpoints) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Endpoints[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if m.StakeAppliedBlock != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.StakeAppliedBlock)) - i-- - dAtA[i] = 0x18 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Stake.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintStakeEntry(dAtA []byte, offset int, v uint64) int { - offset -= sovStakeEntry(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *StakeEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Stake.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - l = len(m.Address) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - if m.StakeAppliedBlock != 0 { - n += 1 + sovStakeEntry(uint64(m.StakeAppliedBlock)) - } - if len(m.Endpoints) > 0 { - for _, e := range m.Endpoints { - l = e.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - } - } - if m.Geolocation != 0 { - n += 1 + sovStakeEntry(uint64(m.Geolocation)) - } - l = len(m.Chain) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - l = len(m.Moniker) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - l = m.DelegateTotal.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - l = m.DelegateLimit.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - if m.DelegateCommission != 0 { - n += 1 + sovStakeEntry(uint64(m.DelegateCommission)) - } - return n -} - -func sovStakeEntry(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStakeEntry(x uint64) (n int) { - return sovStakeEntry(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *StakeEntry) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StakeEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakeEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stake", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Stake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StakeAppliedBlock", wireType) - } - m.StakeAppliedBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StakeAppliedBlock |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Endpoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Endpoints = append(m.Endpoints, Endpoint{}) - if err := m.Endpoints[len(m.Endpoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Geolocation", wireType) - } - m.Geolocation = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Geolocation |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Chain", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Chain = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Moniker = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateTotal", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DelegateTotal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateLimit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DelegateLimit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateCommission", wireType) - } - m.DelegateCommission = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DelegateCommission |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipStakeEntry(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStakeEntry - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStakeEntry(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthStakeEntry - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStakeEntry - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStakeEntry - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStakeEntry = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStakeEntry = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStakeEntry = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/migrations/v4/stake_storage.pb.go b/x/epochstorage/types/migrations/v4/stake_storage.pb.go deleted file mode 100644 index 431a10618b..0000000000 --- a/x/epochstorage/types/migrations/v4/stake_storage.pb.go +++ /dev/null @@ -1,438 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/stake_storage.proto - -package v4 - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type StakeStorage struct { - Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` - StakeEntries []StakeEntry `protobuf:"bytes,2,rep,name=stakeEntries,proto3" json:"stakeEntries"` - EpochBlockHash []byte `protobuf:"bytes,3,opt,name=epochBlockHash,proto3" json:"epochBlockHash,omitempty"` -} - -func (m *StakeStorage) Reset() { *m = StakeStorage{} } -func (m *StakeStorage) String() string { return proto.CompactTextString(m) } -func (*StakeStorage) ProtoMessage() {} -func (*StakeStorage) Descriptor() ([]byte, []int) { - return fileDescriptor_be7b78aecc265fd4, []int{0} -} -func (m *StakeStorage) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakeStorage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakeStorage.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StakeStorage) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakeStorage.Merge(m, src) -} -func (m *StakeStorage) XXX_Size() int { - return m.Size() -} -func (m *StakeStorage) XXX_DiscardUnknown() { - xxx_messageInfo_StakeStorage.DiscardUnknown(m) -} - -var xxx_messageInfo_StakeStorage proto.InternalMessageInfo - -func (m *StakeStorage) GetIndex() string { - if m != nil { - return m.Index - } - return "" -} - -func (m *StakeStorage) GetStakeEntries() []StakeEntry { - if m != nil { - return m.StakeEntries - } - return nil -} - -func (m *StakeStorage) GetEpochBlockHash() []byte { - if m != nil { - return m.EpochBlockHash - } - return nil -} - -func init() { - proto.RegisterType((*StakeStorage)(nil), "lavanet.lava.epochstorage.StakeStorageV4") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/stake_storage.proto", fileDescriptor_be7b78aecc265fd4) -} - -var fileDescriptor_be7b78aecc265fd4 = []byte{ - // 246 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xcd, 0x49, 0x2c, 0x4b, - 0xcc, 0x4b, 0x2d, 0xd1, 0x07, 0xd1, 0xfa, 0xa9, 0x05, 0xf9, 0xc9, 0x19, 0xc5, 0x25, 0xf9, 0x45, - 0x89, 0xe9, 0xa9, 0xfa, 0xc5, 0x25, 0x89, 0xd9, 0xa9, 0xf1, 0x50, 0x9e, 0x5e, 0x41, 0x51, 0x7e, - 0x49, 0xbe, 0x90, 0x24, 0x54, 0xb9, 0x1e, 0x88, 0xd6, 0x43, 0x56, 0x2e, 0xa5, 0x4d, 0xc8, 0xa4, - 0xd4, 0xbc, 0x92, 0xa2, 0x4a, 0x88, 0x39, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, - 0x88, 0x05, 0x11, 0x55, 0x9a, 0xcb, 0xc8, 0xc5, 0x13, 0x0c, 0x52, 0x1b, 0x0c, 0xd1, 0x28, 0x24, - 0xc2, 0xc5, 0x9a, 0x99, 0x97, 0x92, 0x5a, 0x21, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe1, - 0x08, 0xf9, 0x73, 0xf1, 0x80, 0x4d, 0x74, 0xcd, 0x2b, 0x29, 0xca, 0x4c, 0x2d, 0x96, 0x60, 0x52, - 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xd5, 0xc3, 0xe9, 0x36, 0xbd, 0x60, 0x98, 0xf2, 0x4a, 0x27, 0x96, - 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x50, 0x0c, 0x10, 0x52, 0xe3, 0xe2, 0x03, 0x2b, 0x77, 0xca, 0xc9, - 0x4f, 0xce, 0xf6, 0x48, 0x2c, 0xce, 0x90, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x09, 0x42, 0x13, 0x75, - 0x72, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, - 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x9d, 0xf4, 0xcc, 0x92, - 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x94, 0x70, 0xa8, 0x40, 0x0d, 0x89, 0x92, 0xca, - 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x77, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x64, 0x2d, - 0xbc, 0x7a, 0x7d, 0x01, 0x00, 0x00, -} - -func (m *StakeStorage) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StakeStorage) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakeStorage) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.EpochBlockHash) > 0 { - i -= len(m.EpochBlockHash) - copy(dAtA[i:], m.EpochBlockHash) - i = encodeVarintStakeStorage(dAtA, i, uint64(len(m.EpochBlockHash))) - i-- - dAtA[i] = 0x1a - } - if len(m.StakeEntries) > 0 { - for iNdEx := len(m.StakeEntries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StakeEntries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeStorage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Index) > 0 { - i -= len(m.Index) - copy(dAtA[i:], m.Index) - i = encodeVarintStakeStorage(dAtA, i, uint64(len(m.Index))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintStakeStorage(dAtA []byte, offset int, v uint64) int { - offset -= sovStakeStorage(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *StakeStorage) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Index) - if l > 0 { - n += 1 + l + sovStakeStorage(uint64(l)) - } - if len(m.StakeEntries) > 0 { - for _, e := range m.StakeEntries { - l = e.Size() - n += 1 + l + sovStakeStorage(uint64(l)) - } - } - l = len(m.EpochBlockHash) - if l > 0 { - n += 1 + l + sovStakeStorage(uint64(l)) - } - return n -} - -func sovStakeStorage(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStakeStorage(x uint64) (n int) { - return sovStakeStorage(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *StakeStorage) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StakeStorage: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakeStorage: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Index = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakeEntries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakeEntries = append(m.StakeEntries, StakeEntry{}) - if err := m.StakeEntries[len(m.StakeEntries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochBlockHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EpochBlockHash = append(m.EpochBlockHash[:0], dAtA[iNdEx:postIndex]...) - if m.EpochBlockHash == nil { - m.EpochBlockHash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStakeStorage(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStakeStorage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStakeStorage(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthStakeStorage - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStakeStorage - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStakeStorage - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStakeStorage = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStakeStorage = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStakeStorage = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/migrations/v5/endpoint.pb.go b/x/epochstorage/types/migrations/v5/endpoint.pb.go deleted file mode 100644 index b9ed97f2f7..0000000000 --- a/x/epochstorage/types/migrations/v5/endpoint.pb.go +++ /dev/null @@ -1,522 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/endpoint.proto - -package types - -import ( - fmt "fmt" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Endpoint struct { - IPPORT string `protobuf:"bytes,1,opt,name=iPPORT,proto3" json:"iPPORT,omitempty"` - Geolocation int32 `protobuf:"varint,3,opt,name=geolocation,proto3" json:"geolocation,omitempty"` - Addons []string `protobuf:"bytes,4,rep,name=addons,proto3" json:"addons,omitempty"` - ApiInterfaces []string `protobuf:"bytes,5,rep,name=api_interfaces,json=apiInterfaces,proto3" json:"api_interfaces,omitempty"` - Extensions []string `protobuf:"bytes,6,rep,name=extensions,proto3" json:"extensions,omitempty"` -} - -func (m *Endpoint) Reset() { *m = Endpoint{} } -func (m *Endpoint) String() string { return proto.CompactTextString(m) } -func (*Endpoint) ProtoMessage() {} -func (*Endpoint) Descriptor() ([]byte, []int) { - return fileDescriptor_acb18a6b0d300ae9, []int{0} -} -func (m *Endpoint) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Endpoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_Endpoint.Merge(m, src) -} -func (m *Endpoint) XXX_Size() int { - return m.Size() -} -func (m *Endpoint) XXX_DiscardUnknown() { - xxx_messageInfo_Endpoint.DiscardUnknown(m) -} - -var xxx_messageInfo_Endpoint proto.InternalMessageInfo - -func (m *Endpoint) GetIPPORT() string { - if m != nil { - return m.IPPORT - } - return "" -} - -func (m *Endpoint) GetGeolocation() int32 { - if m != nil { - return m.Geolocation - } - return 0 -} - -func (m *Endpoint) GetAddons() []string { - if m != nil { - return m.Addons - } - return nil -} - -func (m *Endpoint) GetApiInterfaces() []string { - if m != nil { - return m.ApiInterfaces - } - return nil -} - -func (m *Endpoint) GetExtensions() []string { - if m != nil { - return m.Extensions - } - return nil -} - -func init() { - proto.RegisterType((*Endpoint)(nil), "lavanet.lava.epochstorage.EndpointV5") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/endpoint.proto", fileDescriptor_acb18a6b0d300ae9) -} - -var fileDescriptor_acb18a6b0d300ae9 = []byte{ - // 250 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xc8, 0x49, 0x2c, 0x4b, - 0xcc, 0x4b, 0x2d, 0xd1, 0x07, 0xd1, 0xfa, 0xa9, 0x05, 0xf9, 0xc9, 0x19, 0xc5, 0x25, 0xf9, 0x45, - 0x89, 0xe9, 0xa9, 0xfa, 0xa9, 0x79, 0x29, 0x05, 0xf9, 0x99, 0x79, 0x25, 0x7a, 0x05, 0x45, 0xf9, - 0x25, 0xf9, 0x42, 0x92, 0x50, 0x95, 0x7a, 0x20, 0x5a, 0x0f, 0x59, 0xa5, 0xd2, 0x4a, 0x46, 0x2e, - 0x0e, 0x57, 0xa8, 0x6a, 0x21, 0x31, 0x2e, 0xb6, 0xcc, 0x80, 0x00, 0xff, 0xa0, 0x10, 0x09, 0x46, - 0x05, 0x46, 0x0d, 0xce, 0x20, 0x28, 0x4f, 0x48, 0x81, 0x8b, 0x3b, 0x3d, 0x35, 0x3f, 0x27, 0x3f, - 0x39, 0xb1, 0x24, 0x33, 0x3f, 0x4f, 0x82, 0x59, 0x81, 0x51, 0x83, 0x35, 0x08, 0x59, 0x08, 0xa4, - 0x33, 0x31, 0x25, 0x25, 0x3f, 0xaf, 0x58, 0x82, 0x45, 0x81, 0x19, 0xa4, 0x13, 0xc2, 0x13, 0x52, - 0xe5, 0xe2, 0x4b, 0x2c, 0xc8, 0x8c, 0xcf, 0xcc, 0x2b, 0x49, 0x2d, 0x4a, 0x4b, 0x4c, 0x4e, 0x2d, - 0x96, 0x60, 0x05, 0xcb, 0xf3, 0x26, 0x16, 0x64, 0x7a, 0xc2, 0x05, 0x85, 0xe4, 0xb8, 0xb8, 0x52, - 0x2b, 0x4a, 0x52, 0xf3, 0x8a, 0x33, 0x41, 0x46, 0xb0, 0x81, 0x95, 0x20, 0x89, 0x78, 0xb1, 0x70, - 0x30, 0x09, 0x30, 0x3b, 0xb9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, - 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, - 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x4a, 0xa8, 0x54, 0xa0, - 0x86, 0x4b, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x54, 0x8c, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xf3, 0xac, 0x09, 0xa5, 0x41, 0x01, 0x00, 0x00, -} - -func (m *Endpoint) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Endpoint) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Endpoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Extensions) > 0 { - for iNdEx := len(m.Extensions) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Extensions[iNdEx]) - copy(dAtA[i:], m.Extensions[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.Extensions[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if len(m.ApiInterfaces) > 0 { - for iNdEx := len(m.ApiInterfaces) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ApiInterfaces[iNdEx]) - copy(dAtA[i:], m.ApiInterfaces[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.ApiInterfaces[iNdEx]))) - i-- - dAtA[i] = 0x2a - } - } - if len(m.Addons) > 0 { - for iNdEx := len(m.Addons) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Addons[iNdEx]) - copy(dAtA[i:], m.Addons[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.Addons[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if m.Geolocation != 0 { - i = encodeVarintEndpoint(dAtA, i, uint64(m.Geolocation)) - i-- - dAtA[i] = 0x18 - } - if len(m.IPPORT) > 0 { - i -= len(m.IPPORT) - copy(dAtA[i:], m.IPPORT) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.IPPORT))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintEndpoint(dAtA []byte, offset int, v uint64) int { - offset -= sovEndpoint(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Endpoint) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.IPPORT) - if l > 0 { - n += 1 + l + sovEndpoint(uint64(l)) - } - if m.Geolocation != 0 { - n += 1 + sovEndpoint(uint64(m.Geolocation)) - } - if len(m.Addons) > 0 { - for _, s := range m.Addons { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - if len(m.ApiInterfaces) > 0 { - for _, s := range m.ApiInterfaces { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - if len(m.Extensions) > 0 { - for _, s := range m.Extensions { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - return n -} - -func sovEndpoint(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozEndpoint(x uint64) (n int) { - return sovEndpoint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Endpoint) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Endpoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Endpoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IPPORT", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.IPPORT = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Geolocation", wireType) - } - m.Geolocation = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Geolocation |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addons", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addons = append(m.Addons, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApiInterfaces", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ApiInterfaces = append(m.ApiInterfaces, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Extensions", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Extensions = append(m.Extensions, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEndpoint(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEndpoint - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipEndpoint(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthEndpoint - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupEndpoint - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthEndpoint - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthEndpoint = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowEndpoint = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupEndpoint = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/migrations/v5/stake_entry.pb.go b/x/epochstorage/types/migrations/v5/stake_entry.pb.go deleted file mode 100644 index d7e9806ed4..0000000000 --- a/x/epochstorage/types/migrations/v5/stake_entry.pb.go +++ /dev/null @@ -1,1055 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/stake_entry.proto - -package types - -import ( - fmt "fmt" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type StakeEntry struct { - Stake types.Coin `protobuf:"bytes,1,opt,name=stake,proto3" json:"stake"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - StakeAppliedBlock uint64 `protobuf:"varint,3,opt,name=stake_applied_block,json=stakeAppliedBlock,proto3" json:"stake_applied_block,omitempty"` - Endpoints []Endpoint `protobuf:"bytes,4,rep,name=endpoints,proto3" json:"endpoints"` - Geolocation int32 `protobuf:"varint,5,opt,name=geolocation,proto3" json:"geolocation,omitempty"` - Chain string `protobuf:"bytes,6,opt,name=chain,proto3" json:"chain,omitempty"` - Moniker string `protobuf:"bytes,8,opt,name=moniker,proto3" json:"moniker,omitempty"` - DelegateTotal types.Coin `protobuf:"bytes,9,opt,name=delegate_total,json=delegateTotal,proto3" json:"delegate_total"` - DelegateLimit types.Coin `protobuf:"bytes,10,opt,name=delegate_limit,json=delegateLimit,proto3" json:"delegate_limit"` - DelegateCommission uint64 `protobuf:"varint,11,opt,name=delegate_commission,json=delegateCommission,proto3" json:"delegate_commission,omitempty"` - LastChange uint64 `protobuf:"varint,12,opt,name=last_change,json=lastChange,proto3" json:"last_change,omitempty"` - BlockReport *BlockReport `protobuf:"bytes,13,opt,name=block_report,json=blockReport,proto3" json:"block_report,omitempty"` -} - -func (m *StakeEntry) Reset() { *m = StakeEntry{} } -func (m *StakeEntry) String() string { return proto.CompactTextString(m) } -func (*StakeEntry) ProtoMessage() {} -func (*StakeEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_df6302d6b53c056e, []int{0} -} -func (m *StakeEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakeEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakeEntry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StakeEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakeEntry.Merge(m, src) -} -func (m *StakeEntry) XXX_Size() int { - return m.Size() -} -func (m *StakeEntry) XXX_DiscardUnknown() { - xxx_messageInfo_StakeEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_StakeEntry proto.InternalMessageInfo - -func (m *StakeEntry) GetStake() types.Coin { - if m != nil { - return m.Stake - } - return types.Coin{} -} - -func (m *StakeEntry) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *StakeEntry) GetStakeAppliedBlock() uint64 { - if m != nil { - return m.StakeAppliedBlock - } - return 0 -} - -func (m *StakeEntry) GetEndpoints() []Endpoint { - if m != nil { - return m.Endpoints - } - return nil -} - -func (m *StakeEntry) GetGeolocation() int32 { - if m != nil { - return m.Geolocation - } - return 0 -} - -func (m *StakeEntry) GetChain() string { - if m != nil { - return m.Chain - } - return "" -} - -func (m *StakeEntry) GetMoniker() string { - if m != nil { - return m.Moniker - } - return "" -} - -func (m *StakeEntry) GetDelegateTotal() types.Coin { - if m != nil { - return m.DelegateTotal - } - return types.Coin{} -} - -func (m *StakeEntry) GetDelegateLimit() types.Coin { - if m != nil { - return m.DelegateLimit - } - return types.Coin{} -} - -func (m *StakeEntry) GetDelegateCommission() uint64 { - if m != nil { - return m.DelegateCommission - } - return 0 -} - -func (m *StakeEntry) GetLastChange() uint64 { - if m != nil { - return m.LastChange - } - return 0 -} - -func (m *StakeEntry) GetBlockReport() *BlockReport { - if m != nil { - return m.BlockReport - } - return nil -} - -// BlockReport holds the most up-to-date info regarding blocks of the provider -// It is set in the relay payment TX logic -// used by the consumer to calculate the provider's sync score -type BlockReport struct { - Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"` - LatestBlock uint64 `protobuf:"varint,2,opt,name=latest_block,json=latestBlock,proto3" json:"latest_block,omitempty"` -} - -func (m *BlockReport) Reset() { *m = BlockReport{} } -func (m *BlockReport) String() string { return proto.CompactTextString(m) } -func (*BlockReport) ProtoMessage() {} -func (*BlockReport) Descriptor() ([]byte, []int) { - return fileDescriptor_df6302d6b53c056e, []int{1} -} -func (m *BlockReport) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BlockReport) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BlockReport.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *BlockReport) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockReport.Merge(m, src) -} -func (m *BlockReport) XXX_Size() int { - return m.Size() -} -func (m *BlockReport) XXX_DiscardUnknown() { - xxx_messageInfo_BlockReport.DiscardUnknown(m) -} - -var xxx_messageInfo_BlockReport proto.InternalMessageInfo - -func (m *BlockReport) GetEpoch() uint64 { - if m != nil { - return m.Epoch - } - return 0 -} - -func (m *BlockReport) GetLatestBlock() uint64 { - if m != nil { - return m.LatestBlock - } - return 0 -} - -func init() { - proto.RegisterType((*StakeEntry)(nil), "lavanet.lava.epochstorage.StakeEntryV5") - proto.RegisterType((*BlockReport)(nil), "lavanet.lava.epochstorage.BlockReportV5") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/stake_entry.proto", fileDescriptor_df6302d6b53c056e) -} - -var fileDescriptor_df6302d6b53c056e = []byte{ - // 498 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0x6e, 0xb6, 0x74, 0x6b, 0x9d, 0x0e, 0x81, 0xb7, 0x83, 0xb7, 0x43, 0x16, 0x86, 0x84, 0x22, - 0x81, 0x1c, 0x6d, 0x88, 0x1f, 0x40, 0xab, 0x15, 0x81, 0x38, 0x05, 0x4e, 0x5c, 0x2a, 0x27, 0xb1, - 0x52, 0xab, 0x89, 0x5f, 0x14, 0x9b, 0x89, 0xfd, 0x0b, 0x7e, 0xd6, 0x8e, 0x3b, 0x22, 0x21, 0x21, - 0xd4, 0xfe, 0x11, 0x64, 0x3b, 0xdd, 0xda, 0xc3, 0x10, 0x3b, 0xd9, 0xef, 0x7d, 0xdf, 0xf7, 0xf4, - 0xbd, 0xe7, 0x67, 0xf4, 0xaa, 0x62, 0x57, 0x4c, 0x72, 0x9d, 0x98, 0x33, 0xe1, 0x0d, 0xe4, 0x73, - 0xa5, 0xa1, 0x65, 0x25, 0x4f, 0x94, 0x66, 0x0b, 0x3e, 0xe3, 0x52, 0xb7, 0xd7, 0xb4, 0x69, 0x41, - 0x03, 0x3e, 0xee, 0xc8, 0xd4, 0x9c, 0x74, 0x93, 0x7c, 0x12, 0x3f, 0x5c, 0x87, 0xcb, 0xa2, 0x01, - 0x21, 0xb5, 0x2b, 0x72, 0x72, 0x54, 0x42, 0x09, 0xf6, 0x9a, 0x98, 0x5b, 0x97, 0x0d, 0x73, 0x50, - 0x35, 0xa8, 0x24, 0x63, 0x8a, 0x27, 0x57, 0xe7, 0x19, 0xd7, 0xec, 0x3c, 0xc9, 0x41, 0x48, 0x87, - 0x9f, 0xfd, 0xf2, 0x11, 0xfa, 0x6c, 0x0c, 0x5d, 0x1a, 0x3f, 0xf8, 0x2d, 0xea, 0x5b, 0x7b, 0xc4, - 0x8b, 0xbc, 0x38, 0xb8, 0x38, 0xa6, 0x4e, 0x4e, 0x8d, 0x9c, 0x76, 0x72, 0x3a, 0x01, 0x21, 0xc7, - 0xfe, 0xcd, 0xef, 0xd3, 0x5e, 0xea, 0xd8, 0x98, 0xa0, 0x7d, 0x56, 0x14, 0x2d, 0x57, 0x8a, 0xec, - 0x44, 0x5e, 0x3c, 0x4c, 0xd7, 0x21, 0xa6, 0xe8, 0xd0, 0xf5, 0xcb, 0x9a, 0xa6, 0x12, 0xbc, 0x98, - 0x65, 0x15, 0xe4, 0x0b, 0xb2, 0x1b, 0x79, 0xb1, 0x9f, 0x3e, 0xb3, 0xd0, 0x3b, 0x87, 0x8c, 0x0d, - 0x80, 0xdf, 0xa3, 0xe1, 0xba, 0x2f, 0x45, 0xfc, 0x68, 0x37, 0x0e, 0x2e, 0x5e, 0xd0, 0x07, 0xc7, - 0x43, 0x2f, 0x3b, 0x6e, 0x67, 0xe7, 0x5e, 0x8b, 0x23, 0x14, 0x94, 0x1c, 0x2a, 0xc8, 0x99, 0x16, - 0x20, 0x49, 0x3f, 0xf2, 0xe2, 0x7e, 0xba, 0x99, 0xc2, 0x47, 0xa8, 0x9f, 0xcf, 0x99, 0x90, 0x64, - 0xcf, 0x5a, 0x76, 0x81, 0x69, 0xa5, 0x06, 0x29, 0x16, 0xbc, 0x25, 0x03, 0xd7, 0x4a, 0x17, 0xe2, - 0x29, 0x7a, 0x52, 0xf0, 0x8a, 0x97, 0x4c, 0xf3, 0x99, 0x06, 0xcd, 0x2a, 0x32, 0xfc, 0xbf, 0x21, - 0x1d, 0xac, 0x65, 0x5f, 0x8c, 0x6a, 0xab, 0x4e, 0x25, 0x6a, 0xa1, 0x09, 0x7a, 0x64, 0x9d, 0x4f, - 0x46, 0x85, 0x13, 0x74, 0x78, 0x57, 0x27, 0x87, 0xba, 0x16, 0x4a, 0x99, 0x4e, 0x03, 0x3b, 0x5a, - 0xbc, 0x86, 0x26, 0x77, 0x08, 0x3e, 0x45, 0x41, 0xc5, 0x94, 0x9e, 0xe5, 0x73, 0x26, 0x4b, 0x4e, - 0x46, 0x96, 0x88, 0x4c, 0x6a, 0x62, 0x33, 0xf8, 0x03, 0x1a, 0xd9, 0xe7, 0x99, 0xb5, 0xbc, 0x81, - 0x56, 0x93, 0x03, 0xeb, 0xeb, 0xe5, 0x3f, 0xe6, 0x6f, 0x1f, 0x2d, 0xb5, 0xec, 0x34, 0xc8, 0xee, - 0x83, 0x8f, 0xfe, 0x60, 0xff, 0xe9, 0xe0, 0x6c, 0x8a, 0x82, 0x0d, 0x86, 0x99, 0xb8, 0x55, 0xdb, - 0xed, 0xf2, 0x53, 0x17, 0xe0, 0xe7, 0x68, 0x54, 0x31, 0xcd, 0x95, 0xee, 0x76, 0x63, 0xc7, 0x82, - 0x81, 0xcb, 0x59, 0xf9, 0x78, 0x7a, 0xb3, 0x0c, 0xbd, 0xdb, 0x65, 0xe8, 0xfd, 0x59, 0x86, 0xde, - 0x8f, 0x55, 0xd8, 0xbb, 0x5d, 0x85, 0xbd, 0x9f, 0xab, 0xb0, 0xf7, 0xf5, 0x75, 0x29, 0xf4, 0xfc, - 0x5b, 0x46, 0x73, 0xa8, 0x93, 0xad, 0xaf, 0xf2, 0x7d, 0xfb, 0xb3, 0xe8, 0xeb, 0x86, 0xab, 0x6c, - 0xcf, 0x2e, 0xfd, 0x9b, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x58, 0x95, 0x4a, 0xd0, 0x9e, 0x03, - 0x00, 0x00, -} - -func (m *StakeEntry) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StakeEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakeEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.BlockReport != nil { - { - size, err := m.BlockReport.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a - } - if m.LastChange != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.LastChange)) - i-- - dAtA[i] = 0x60 - } - if m.DelegateCommission != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.DelegateCommission)) - i-- - dAtA[i] = 0x58 - } - { - size, err := m.DelegateLimit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - { - size, err := m.DelegateTotal.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - if len(m.Moniker) > 0 { - i -= len(m.Moniker) - copy(dAtA[i:], m.Moniker) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Moniker))) - i-- - dAtA[i] = 0x42 - } - if len(m.Chain) > 0 { - i -= len(m.Chain) - copy(dAtA[i:], m.Chain) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Chain))) - i-- - dAtA[i] = 0x32 - } - if m.Geolocation != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.Geolocation)) - i-- - dAtA[i] = 0x28 - } - if len(m.Endpoints) > 0 { - for iNdEx := len(m.Endpoints) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Endpoints[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if m.StakeAppliedBlock != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.StakeAppliedBlock)) - i-- - dAtA[i] = 0x18 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Stake.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *BlockReport) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BlockReport) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BlockReport) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.LatestBlock != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.LatestBlock)) - i-- - dAtA[i] = 0x10 - } - if m.Epoch != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.Epoch)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintStakeEntry(dAtA []byte, offset int, v uint64) int { - offset -= sovStakeEntry(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *StakeEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Stake.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - l = len(m.Address) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - if m.StakeAppliedBlock != 0 { - n += 1 + sovStakeEntry(uint64(m.StakeAppliedBlock)) - } - if len(m.Endpoints) > 0 { - for _, e := range m.Endpoints { - l = e.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - } - } - if m.Geolocation != 0 { - n += 1 + sovStakeEntry(uint64(m.Geolocation)) - } - l = len(m.Chain) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - l = len(m.Moniker) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - l = m.DelegateTotal.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - l = m.DelegateLimit.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - if m.DelegateCommission != 0 { - n += 1 + sovStakeEntry(uint64(m.DelegateCommission)) - } - if m.LastChange != 0 { - n += 1 + sovStakeEntry(uint64(m.LastChange)) - } - if m.BlockReport != nil { - l = m.BlockReport.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - } - return n -} - -func (m *BlockReport) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Epoch != 0 { - n += 1 + sovStakeEntry(uint64(m.Epoch)) - } - if m.LatestBlock != 0 { - n += 1 + sovStakeEntry(uint64(m.LatestBlock)) - } - return n -} - -func sovStakeEntry(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStakeEntry(x uint64) (n int) { - return sovStakeEntry(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *StakeEntry) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StakeEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakeEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stake", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Stake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StakeAppliedBlock", wireType) - } - m.StakeAppliedBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StakeAppliedBlock |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Endpoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Endpoints = append(m.Endpoints, Endpoint{}) - if err := m.Endpoints[len(m.Endpoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Geolocation", wireType) - } - m.Geolocation = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Geolocation |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Chain", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Chain = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Moniker = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateTotal", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DelegateTotal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateLimit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DelegateLimit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateCommission", wireType) - } - m.DelegateCommission = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DelegateCommission |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastChange", wireType) - } - m.LastChange = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastChange |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockReport", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.BlockReport == nil { - m.BlockReport = &BlockReport{} - } - if err := m.BlockReport.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStakeEntry(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStakeEntry - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BlockReport) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BlockReport: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockReport: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) - } - m.Epoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Epoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LatestBlock", wireType) - } - m.LatestBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LatestBlock |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipStakeEntry(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStakeEntry - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStakeEntry(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthStakeEntry - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStakeEntry - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStakeEntry - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStakeEntry = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStakeEntry = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStakeEntry = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/migrations/v5/stake_storage.pb.go b/x/epochstorage/types/migrations/v5/stake_storage.pb.go deleted file mode 100644 index dd257db346..0000000000 --- a/x/epochstorage/types/migrations/v5/stake_storage.pb.go +++ /dev/null @@ -1,438 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/stake_storage.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type StakeStorage struct { - Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` - StakeEntries []StakeEntry `protobuf:"bytes,2,rep,name=stakeEntries,proto3" json:"stakeEntries"` - EpochBlockHash []byte `protobuf:"bytes,3,opt,name=epochBlockHash,proto3" json:"epochBlockHash,omitempty"` -} - -func (m *StakeStorage) Reset() { *m = StakeStorage{} } -func (m *StakeStorage) String() string { return proto.CompactTextString(m) } -func (*StakeStorage) ProtoMessage() {} -func (*StakeStorage) Descriptor() ([]byte, []int) { - return fileDescriptor_be7b78aecc265fd4, []int{0} -} -func (m *StakeStorage) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakeStorage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakeStorage.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StakeStorage) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakeStorage.Merge(m, src) -} -func (m *StakeStorage) XXX_Size() int { - return m.Size() -} -func (m *StakeStorage) XXX_DiscardUnknown() { - xxx_messageInfo_StakeStorage.DiscardUnknown(m) -} - -var xxx_messageInfo_StakeStorage proto.InternalMessageInfo - -func (m *StakeStorage) GetIndex() string { - if m != nil { - return m.Index - } - return "" -} - -func (m *StakeStorage) GetStakeEntries() []StakeEntry { - if m != nil { - return m.StakeEntries - } - return nil -} - -func (m *StakeStorage) GetEpochBlockHash() []byte { - if m != nil { - return m.EpochBlockHash - } - return nil -} - -func init() { - proto.RegisterType((*StakeStorage)(nil), "lavanet.lava.epochstorage.StakeStorageV5") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/stake_storage.proto", fileDescriptor_be7b78aecc265fd4) -} - -var fileDescriptor_be7b78aecc265fd4 = []byte{ - // 246 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xcd, 0x49, 0x2c, 0x4b, - 0xcc, 0x4b, 0x2d, 0xd1, 0x07, 0xd1, 0xfa, 0xa9, 0x05, 0xf9, 0xc9, 0x19, 0xc5, 0x25, 0xf9, 0x45, - 0x89, 0xe9, 0xa9, 0xfa, 0xc5, 0x25, 0x89, 0xd9, 0xa9, 0xf1, 0x50, 0x9e, 0x5e, 0x41, 0x51, 0x7e, - 0x49, 0xbe, 0x90, 0x24, 0x54, 0xb9, 0x1e, 0x88, 0xd6, 0x43, 0x56, 0x2e, 0xa5, 0x4d, 0xc8, 0xa4, - 0xd4, 0xbc, 0x92, 0xa2, 0x4a, 0x88, 0x39, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, - 0x88, 0x05, 0x11, 0x55, 0x9a, 0xcb, 0xc8, 0xc5, 0x13, 0x0c, 0x52, 0x1b, 0x0c, 0xd1, 0x28, 0x24, - 0xc2, 0xc5, 0x9a, 0x99, 0x97, 0x92, 0x5a, 0x21, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe1, - 0x08, 0xf9, 0x73, 0xf1, 0x80, 0x4d, 0x74, 0xcd, 0x2b, 0x29, 0xca, 0x4c, 0x2d, 0x96, 0x60, 0x52, - 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xd5, 0xc3, 0xe9, 0x36, 0xbd, 0x60, 0x98, 0xf2, 0x4a, 0x27, 0x96, - 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x50, 0x0c, 0x10, 0x52, 0xe3, 0xe2, 0x03, 0x2b, 0x77, 0xca, 0xc9, - 0x4f, 0xce, 0xf6, 0x48, 0x2c, 0xce, 0x90, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x09, 0x42, 0x13, 0x75, - 0x72, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, - 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x9d, 0xf4, 0xcc, 0x92, - 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x94, 0x70, 0xa8, 0x40, 0x0d, 0x89, 0x92, 0xca, - 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x77, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x64, 0x2d, - 0xbc, 0x7a, 0x7d, 0x01, 0x00, 0x00, -} - -func (m *StakeStorage) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StakeStorage) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakeStorage) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.EpochBlockHash) > 0 { - i -= len(m.EpochBlockHash) - copy(dAtA[i:], m.EpochBlockHash) - i = encodeVarintStakeStorage(dAtA, i, uint64(len(m.EpochBlockHash))) - i-- - dAtA[i] = 0x1a - } - if len(m.StakeEntries) > 0 { - for iNdEx := len(m.StakeEntries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StakeEntries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeStorage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Index) > 0 { - i -= len(m.Index) - copy(dAtA[i:], m.Index) - i = encodeVarintStakeStorage(dAtA, i, uint64(len(m.Index))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintStakeStorage(dAtA []byte, offset int, v uint64) int { - offset -= sovStakeStorage(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *StakeStorage) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Index) - if l > 0 { - n += 1 + l + sovStakeStorage(uint64(l)) - } - if len(m.StakeEntries) > 0 { - for _, e := range m.StakeEntries { - l = e.Size() - n += 1 + l + sovStakeStorage(uint64(l)) - } - } - l = len(m.EpochBlockHash) - if l > 0 { - n += 1 + l + sovStakeStorage(uint64(l)) - } - return n -} - -func sovStakeStorage(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStakeStorage(x uint64) (n int) { - return sovStakeStorage(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *StakeStorage) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StakeStorage: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakeStorage: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Index = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakeEntries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakeEntries = append(m.StakeEntries, StakeEntry{}) - if err := m.StakeEntries[len(m.StakeEntries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochBlockHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EpochBlockHash = append(m.EpochBlockHash[:0], dAtA[iNdEx:postIndex]...) - if m.EpochBlockHash == nil { - m.EpochBlockHash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStakeStorage(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStakeStorage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStakeStorage(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthStakeStorage - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStakeStorage - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStakeStorage - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStakeStorage = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStakeStorage = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStakeStorage = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/migrations/v6/endpoint.pb.go b/x/epochstorage/types/migrations/v6/endpoint.pb.go deleted file mode 100644 index 576ee1e357..0000000000 --- a/x/epochstorage/types/migrations/v6/endpoint.pb.go +++ /dev/null @@ -1,522 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/endpoint.proto - -package types - -import ( - fmt "fmt" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Endpoint struct { - IPPORT string `protobuf:"bytes,1,opt,name=iPPORT,proto3" json:"iPPORT,omitempty"` - Geolocation int32 `protobuf:"varint,3,opt,name=geolocation,proto3" json:"geolocation,omitempty"` - Addons []string `protobuf:"bytes,4,rep,name=addons,proto3" json:"addons,omitempty"` - ApiInterfaces []string `protobuf:"bytes,5,rep,name=api_interfaces,json=apiInterfaces,proto3" json:"api_interfaces,omitempty"` - Extensions []string `protobuf:"bytes,6,rep,name=extensions,proto3" json:"extensions,omitempty"` -} - -func (m *Endpoint) Reset() { *m = Endpoint{} } -func (m *Endpoint) String() string { return proto.CompactTextString(m) } -func (*Endpoint) ProtoMessage() {} -func (*Endpoint) Descriptor() ([]byte, []int) { - return fileDescriptor_acb18a6b0d300ae9, []int{0} -} -func (m *Endpoint) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Endpoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_Endpoint.Merge(m, src) -} -func (m *Endpoint) XXX_Size() int { - return m.Size() -} -func (m *Endpoint) XXX_DiscardUnknown() { - xxx_messageInfo_Endpoint.DiscardUnknown(m) -} - -var xxx_messageInfo_Endpoint proto.InternalMessageInfo - -func (m *Endpoint) GetIPPORT() string { - if m != nil { - return m.IPPORT - } - return "" -} - -func (m *Endpoint) GetGeolocation() int32 { - if m != nil { - return m.Geolocation - } - return 0 -} - -func (m *Endpoint) GetAddons() []string { - if m != nil { - return m.Addons - } - return nil -} - -func (m *Endpoint) GetApiInterfaces() []string { - if m != nil { - return m.ApiInterfaces - } - return nil -} - -func (m *Endpoint) GetExtensions() []string { - if m != nil { - return m.Extensions - } - return nil -} - -func init() { - proto.RegisterType((*Endpoint)(nil), "lavanet.lava.epochstorage.EndpointV6") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/endpoint.proto", fileDescriptor_acb18a6b0d300ae9) -} - -var fileDescriptor_acb18a6b0d300ae9 = []byte{ - // 250 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xc8, 0x49, 0x2c, 0x4b, - 0xcc, 0x4b, 0x2d, 0xd1, 0x07, 0xd1, 0xfa, 0xa9, 0x05, 0xf9, 0xc9, 0x19, 0xc5, 0x25, 0xf9, 0x45, - 0x89, 0xe9, 0xa9, 0xfa, 0xa9, 0x79, 0x29, 0x05, 0xf9, 0x99, 0x79, 0x25, 0x7a, 0x05, 0x45, 0xf9, - 0x25, 0xf9, 0x42, 0x92, 0x50, 0x95, 0x7a, 0x20, 0x5a, 0x0f, 0x59, 0xa5, 0xd2, 0x4a, 0x46, 0x2e, - 0x0e, 0x57, 0xa8, 0x6a, 0x21, 0x31, 0x2e, 0xb6, 0xcc, 0x80, 0x00, 0xff, 0xa0, 0x10, 0x09, 0x46, - 0x05, 0x46, 0x0d, 0xce, 0x20, 0x28, 0x4f, 0x48, 0x81, 0x8b, 0x3b, 0x3d, 0x35, 0x3f, 0x27, 0x3f, - 0x39, 0xb1, 0x24, 0x33, 0x3f, 0x4f, 0x82, 0x59, 0x81, 0x51, 0x83, 0x35, 0x08, 0x59, 0x08, 0xa4, - 0x33, 0x31, 0x25, 0x25, 0x3f, 0xaf, 0x58, 0x82, 0x45, 0x81, 0x19, 0xa4, 0x13, 0xc2, 0x13, 0x52, - 0xe5, 0xe2, 0x4b, 0x2c, 0xc8, 0x8c, 0xcf, 0xcc, 0x2b, 0x49, 0x2d, 0x4a, 0x4b, 0x4c, 0x4e, 0x2d, - 0x96, 0x60, 0x05, 0xcb, 0xf3, 0x26, 0x16, 0x64, 0x7a, 0xc2, 0x05, 0x85, 0xe4, 0xb8, 0xb8, 0x52, - 0x2b, 0x4a, 0x52, 0xf3, 0x8a, 0x33, 0x41, 0x46, 0xb0, 0x81, 0x95, 0x20, 0x89, 0x78, 0xb1, 0x70, - 0x30, 0x09, 0x30, 0x3b, 0xb9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, - 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, - 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x4a, 0xa8, 0x54, 0xa0, - 0x86, 0x4b, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x54, 0x8c, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xf3, 0xac, 0x09, 0xa5, 0x41, 0x01, 0x00, 0x00, -} - -func (m *Endpoint) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Endpoint) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Endpoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Extensions) > 0 { - for iNdEx := len(m.Extensions) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Extensions[iNdEx]) - copy(dAtA[i:], m.Extensions[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.Extensions[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if len(m.ApiInterfaces) > 0 { - for iNdEx := len(m.ApiInterfaces) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ApiInterfaces[iNdEx]) - copy(dAtA[i:], m.ApiInterfaces[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.ApiInterfaces[iNdEx]))) - i-- - dAtA[i] = 0x2a - } - } - if len(m.Addons) > 0 { - for iNdEx := len(m.Addons) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Addons[iNdEx]) - copy(dAtA[i:], m.Addons[iNdEx]) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.Addons[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if m.Geolocation != 0 { - i = encodeVarintEndpoint(dAtA, i, uint64(m.Geolocation)) - i-- - dAtA[i] = 0x18 - } - if len(m.IPPORT) > 0 { - i -= len(m.IPPORT) - copy(dAtA[i:], m.IPPORT) - i = encodeVarintEndpoint(dAtA, i, uint64(len(m.IPPORT))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintEndpoint(dAtA []byte, offset int, v uint64) int { - offset -= sovEndpoint(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Endpoint) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.IPPORT) - if l > 0 { - n += 1 + l + sovEndpoint(uint64(l)) - } - if m.Geolocation != 0 { - n += 1 + sovEndpoint(uint64(m.Geolocation)) - } - if len(m.Addons) > 0 { - for _, s := range m.Addons { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - if len(m.ApiInterfaces) > 0 { - for _, s := range m.ApiInterfaces { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - if len(m.Extensions) > 0 { - for _, s := range m.Extensions { - l = len(s) - n += 1 + l + sovEndpoint(uint64(l)) - } - } - return n -} - -func sovEndpoint(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozEndpoint(x uint64) (n int) { - return sovEndpoint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Endpoint) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Endpoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Endpoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IPPORT", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.IPPORT = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Geolocation", wireType) - } - m.Geolocation = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Geolocation |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addons", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addons = append(m.Addons, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApiInterfaces", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ApiInterfaces = append(m.ApiInterfaces, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Extensions", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEndpoint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEndpoint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEndpoint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Extensions = append(m.Extensions, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEndpoint(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEndpoint - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipEndpoint(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEndpoint - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthEndpoint - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupEndpoint - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthEndpoint - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthEndpoint = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowEndpoint = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupEndpoint = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/migrations/v6/stake_entry.pb.go b/x/epochstorage/types/migrations/v6/stake_entry.pb.go deleted file mode 100644 index 1e807c5351..0000000000 --- a/x/epochstorage/types/migrations/v6/stake_entry.pb.go +++ /dev/null @@ -1,1106 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/stake_entry.proto - -package types - -import ( - fmt "fmt" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type StakeEntry struct { - Stake types.Coin `protobuf:"bytes,1,opt,name=stake,proto3" json:"stake"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - StakeAppliedBlock uint64 `protobuf:"varint,3,opt,name=stake_applied_block,json=stakeAppliedBlock,proto3" json:"stake_applied_block,omitempty"` - Endpoints []Endpoint `protobuf:"bytes,4,rep,name=endpoints,proto3" json:"endpoints"` - Geolocation int32 `protobuf:"varint,5,opt,name=geolocation,proto3" json:"geolocation,omitempty"` - Chain string `protobuf:"bytes,6,opt,name=chain,proto3" json:"chain,omitempty"` - Moniker string `protobuf:"bytes,8,opt,name=moniker,proto3" json:"moniker,omitempty"` - DelegateTotal types.Coin `protobuf:"bytes,9,opt,name=delegate_total,json=delegateTotal,proto3" json:"delegate_total"` - DelegateLimit types.Coin `protobuf:"bytes,10,opt,name=delegate_limit,json=delegateLimit,proto3" json:"delegate_limit"` - DelegateCommission uint64 `protobuf:"varint,11,opt,name=delegate_commission,json=delegateCommission,proto3" json:"delegate_commission,omitempty"` - LastChange uint64 `protobuf:"varint,12,opt,name=last_change,json=lastChange,proto3" json:"last_change,omitempty"` - BlockReport *BlockReport `protobuf:"bytes,13,opt,name=block_report,json=blockReport,proto3" json:"block_report,omitempty"` - Vault string `protobuf:"bytes,14,opt,name=vault,proto3" json:"vault,omitempty"` -} - -func (m *StakeEntry) Reset() { *m = StakeEntry{} } -func (m *StakeEntry) String() string { return proto.CompactTextString(m) } -func (*StakeEntry) ProtoMessage() {} -func (*StakeEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_df6302d6b53c056e, []int{0} -} -func (m *StakeEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakeEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakeEntry.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StakeEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakeEntry.Merge(m, src) -} -func (m *StakeEntry) XXX_Size() int { - return m.Size() -} -func (m *StakeEntry) XXX_DiscardUnknown() { - xxx_messageInfo_StakeEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_StakeEntry proto.InternalMessageInfo - -func (m *StakeEntry) GetStake() types.Coin { - if m != nil { - return m.Stake - } - return types.Coin{} -} - -func (m *StakeEntry) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *StakeEntry) GetStakeAppliedBlock() uint64 { - if m != nil { - return m.StakeAppliedBlock - } - return 0 -} - -func (m *StakeEntry) GetEndpoints() []Endpoint { - if m != nil { - return m.Endpoints - } - return nil -} - -func (m *StakeEntry) GetGeolocation() int32 { - if m != nil { - return m.Geolocation - } - return 0 -} - -func (m *StakeEntry) GetChain() string { - if m != nil { - return m.Chain - } - return "" -} - -func (m *StakeEntry) GetMoniker() string { - if m != nil { - return m.Moniker - } - return "" -} - -func (m *StakeEntry) GetDelegateTotal() types.Coin { - if m != nil { - return m.DelegateTotal - } - return types.Coin{} -} - -func (m *StakeEntry) GetDelegateLimit() types.Coin { - if m != nil { - return m.DelegateLimit - } - return types.Coin{} -} - -func (m *StakeEntry) GetDelegateCommission() uint64 { - if m != nil { - return m.DelegateCommission - } - return 0 -} - -func (m *StakeEntry) GetLastChange() uint64 { - if m != nil { - return m.LastChange - } - return 0 -} - -func (m *StakeEntry) GetBlockReport() *BlockReport { - if m != nil { - return m.BlockReport - } - return nil -} - -func (m *StakeEntry) GetVault() string { - if m != nil { - return m.Vault - } - return "" -} - -// BlockReport holds the most up-to-date info regarding blocks of the provider -// It is set in the relay payment TX logic -// used by the consumer to calculate the provider's sync score -type BlockReport struct { - Epoch uint64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"` - LatestBlock uint64 `protobuf:"varint,2,opt,name=latest_block,json=latestBlock,proto3" json:"latest_block,omitempty"` -} - -func (m *BlockReport) Reset() { *m = BlockReport{} } -func (m *BlockReport) String() string { return proto.CompactTextString(m) } -func (*BlockReport) ProtoMessage() {} -func (*BlockReport) Descriptor() ([]byte, []int) { - return fileDescriptor_df6302d6b53c056e, []int{1} -} -func (m *BlockReport) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BlockReport) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BlockReport.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *BlockReport) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockReport.Merge(m, src) -} -func (m *BlockReport) XXX_Size() int { - return m.Size() -} -func (m *BlockReport) XXX_DiscardUnknown() { - xxx_messageInfo_BlockReport.DiscardUnknown(m) -} - -var xxx_messageInfo_BlockReport proto.InternalMessageInfo - -func (m *BlockReport) GetEpoch() uint64 { - if m != nil { - return m.Epoch - } - return 0 -} - -func (m *BlockReport) GetLatestBlock() uint64 { - if m != nil { - return m.LatestBlock - } - return 0 -} - -func init() { - proto.RegisterType((*StakeEntry)(nil), "lavanet.lava.epochstorage.StakeEntryV6") - proto.RegisterType((*BlockReport)(nil), "lavanet.lava.epochstorage.BlockReportV6") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/stake_entry.proto", fileDescriptor_df6302d6b53c056e) -} - -var fileDescriptor_df6302d6b53c056e = []byte{ - // 510 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x6e, 0xdb, 0x3a, - 0x10, 0xb5, 0x12, 0x39, 0xb1, 0x29, 0x27, 0xf8, 0x9f, 0xc9, 0x82, 0xc9, 0x42, 0x51, 0x53, 0xa0, - 0x10, 0xd0, 0x82, 0x42, 0x52, 0xf4, 0x00, 0xb5, 0x11, 0x17, 0x2d, 0xba, 0x52, 0xbb, 0xea, 0xc6, - 0xa0, 0x24, 0x42, 0x26, 0x2c, 0x71, 0x04, 0x91, 0x31, 0x9a, 0x5b, 0xf4, 0x58, 0x59, 0x66, 0xd9, - 0x55, 0x51, 0xd8, 0x27, 0xe8, 0x0d, 0x0a, 0x92, 0x72, 0x12, 0x2f, 0x52, 0xb4, 0x2b, 0x72, 0xe6, - 0xbd, 0x37, 0x98, 0x79, 0xe4, 0xa0, 0x97, 0x15, 0x5b, 0x32, 0xc9, 0x75, 0x62, 0xce, 0x84, 0x37, - 0x90, 0xcf, 0x95, 0x86, 0x96, 0x95, 0x3c, 0x51, 0x9a, 0x2d, 0xf8, 0x8c, 0x4b, 0xdd, 0xde, 0xd0, - 0xa6, 0x05, 0x0d, 0xf8, 0xa4, 0x23, 0x53, 0x73, 0xd2, 0xc7, 0xe4, 0xd3, 0xf8, 0xe9, 0x3a, 0x5c, - 0x16, 0x0d, 0x08, 0xa9, 0x5d, 0x91, 0xd3, 0xe3, 0x12, 0x4a, 0xb0, 0xd7, 0xc4, 0xdc, 0xba, 0x6c, - 0x98, 0x83, 0xaa, 0x41, 0x25, 0x19, 0x53, 0x3c, 0x59, 0x5e, 0x64, 0x5c, 0xb3, 0x8b, 0x24, 0x07, - 0x21, 0x1d, 0x7e, 0xfe, 0xcb, 0x47, 0xe8, 0x93, 0x69, 0xe8, 0xca, 0xf4, 0x83, 0xdf, 0xa0, 0xbe, - 0x6d, 0x8f, 0x78, 0x91, 0x17, 0x07, 0x97, 0x27, 0xd4, 0xc9, 0xa9, 0x91, 0xd3, 0x4e, 0x4e, 0x27, - 0x20, 0xe4, 0xd8, 0xbf, 0xfd, 0x71, 0xd6, 0x4b, 0x1d, 0x1b, 0x13, 0xb4, 0xcf, 0x8a, 0xa2, 0xe5, - 0x4a, 0x91, 0x9d, 0xc8, 0x8b, 0x87, 0xe9, 0x26, 0xc4, 0x14, 0x1d, 0xb9, 0x79, 0x59, 0xd3, 0x54, - 0x82, 0x17, 0xb3, 0xac, 0x82, 0x7c, 0x41, 0x76, 0x23, 0x2f, 0xf6, 0xd3, 0xff, 0x2d, 0xf4, 0xd6, - 0x21, 0x63, 0x03, 0xe0, 0x77, 0x68, 0xb8, 0x99, 0x4b, 0x11, 0x3f, 0xda, 0x8d, 0x83, 0xcb, 0xe7, - 0xf4, 0x49, 0x7b, 0xe8, 0x55, 0xc7, 0xed, 0xda, 0x79, 0xd0, 0xe2, 0x08, 0x05, 0x25, 0x87, 0x0a, - 0x72, 0xa6, 0x05, 0x48, 0xd2, 0x8f, 0xbc, 0xb8, 0x9f, 0x3e, 0x4e, 0xe1, 0x63, 0xd4, 0xcf, 0xe7, - 0x4c, 0x48, 0xb2, 0x67, 0x5b, 0x76, 0x81, 0x19, 0xa5, 0x06, 0x29, 0x16, 0xbc, 0x25, 0x03, 0x37, - 0x4a, 0x17, 0xe2, 0x29, 0x3a, 0x2c, 0x78, 0xc5, 0x4b, 0xa6, 0xf9, 0x4c, 0x83, 0x66, 0x15, 0x19, - 0xfe, 0x9d, 0x49, 0x07, 0x1b, 0xd9, 0x67, 0xa3, 0xda, 0xaa, 0x53, 0x89, 0x5a, 0x68, 0x82, 0xfe, - 0xb1, 0xce, 0x47, 0xa3, 0xc2, 0x09, 0x3a, 0xba, 0xaf, 0x93, 0x43, 0x5d, 0x0b, 0xa5, 0xcc, 0xa4, - 0x81, 0xb5, 0x16, 0x6f, 0xa0, 0xc9, 0x3d, 0x82, 0xcf, 0x50, 0x50, 0x31, 0xa5, 0x67, 0xf9, 0x9c, - 0xc9, 0x92, 0x93, 0x91, 0x25, 0x22, 0x93, 0x9a, 0xd8, 0x0c, 0x7e, 0x8f, 0x46, 0xf6, 0x79, 0x66, - 0x2d, 0x6f, 0xa0, 0xd5, 0xe4, 0xc0, 0xf6, 0xf5, 0xe2, 0x0f, 0xfe, 0xdb, 0x47, 0x4b, 0x2d, 0x3b, - 0x0d, 0xb2, 0x87, 0xc0, 0x98, 0xbb, 0x64, 0xd7, 0x95, 0x26, 0x87, 0xce, 0x5c, 0x1b, 0x7c, 0xf0, - 0x07, 0xfb, 0xff, 0x0d, 0xce, 0xa7, 0x28, 0x18, 0x6f, 0x53, 0x6d, 0x4d, 0xfb, 0xe7, 0xfc, 0xd4, - 0x05, 0xf8, 0x19, 0x1a, 0x55, 0x4c, 0x73, 0xa5, 0xbb, 0x1f, 0xb3, 0x63, 0xc1, 0xc0, 0xe5, 0xac, - 0x7c, 0x3c, 0xbd, 0x5d, 0x85, 0xde, 0xdd, 0x2a, 0xf4, 0x7e, 0xae, 0x42, 0xef, 0xdb, 0x3a, 0xec, - 0xdd, 0xad, 0xc3, 0xde, 0xf7, 0x75, 0xd8, 0xfb, 0xf2, 0xaa, 0x14, 0x7a, 0x7e, 0x9d, 0xd1, 0x1c, - 0xea, 0x64, 0x6b, 0x81, 0xbe, 0x6e, 0xaf, 0x90, 0xbe, 0x69, 0xb8, 0xca, 0xf6, 0xec, 0x2a, 0xbc, - 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x25, 0xca, 0x07, 0xb4, 0x03, 0x00, 0x00, -} - -func (m *StakeEntry) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StakeEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakeEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Vault) > 0 { - i -= len(m.Vault) - copy(dAtA[i:], m.Vault) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Vault))) - i-- - dAtA[i] = 0x72 - } - if m.BlockReport != nil { - { - size, err := m.BlockReport.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a - } - if m.LastChange != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.LastChange)) - i-- - dAtA[i] = 0x60 - } - if m.DelegateCommission != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.DelegateCommission)) - i-- - dAtA[i] = 0x58 - } - { - size, err := m.DelegateLimit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - { - size, err := m.DelegateTotal.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - if len(m.Moniker) > 0 { - i -= len(m.Moniker) - copy(dAtA[i:], m.Moniker) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Moniker))) - i-- - dAtA[i] = 0x42 - } - if len(m.Chain) > 0 { - i -= len(m.Chain) - copy(dAtA[i:], m.Chain) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Chain))) - i-- - dAtA[i] = 0x32 - } - if m.Geolocation != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.Geolocation)) - i-- - dAtA[i] = 0x28 - } - if len(m.Endpoints) > 0 { - for iNdEx := len(m.Endpoints) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Endpoints[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if m.StakeAppliedBlock != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.StakeAppliedBlock)) - i-- - dAtA[i] = 0x18 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintStakeEntry(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Stake.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeEntry(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *BlockReport) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BlockReport) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BlockReport) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.LatestBlock != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.LatestBlock)) - i-- - dAtA[i] = 0x10 - } - if m.Epoch != 0 { - i = encodeVarintStakeEntry(dAtA, i, uint64(m.Epoch)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintStakeEntry(dAtA []byte, offset int, v uint64) int { - offset -= sovStakeEntry(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *StakeEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Stake.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - l = len(m.Address) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - if m.StakeAppliedBlock != 0 { - n += 1 + sovStakeEntry(uint64(m.StakeAppliedBlock)) - } - if len(m.Endpoints) > 0 { - for _, e := range m.Endpoints { - l = e.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - } - } - if m.Geolocation != 0 { - n += 1 + sovStakeEntry(uint64(m.Geolocation)) - } - l = len(m.Chain) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - l = len(m.Moniker) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - l = m.DelegateTotal.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - l = m.DelegateLimit.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - if m.DelegateCommission != 0 { - n += 1 + sovStakeEntry(uint64(m.DelegateCommission)) - } - if m.LastChange != 0 { - n += 1 + sovStakeEntry(uint64(m.LastChange)) - } - if m.BlockReport != nil { - l = m.BlockReport.Size() - n += 1 + l + sovStakeEntry(uint64(l)) - } - l = len(m.Vault) - if l > 0 { - n += 1 + l + sovStakeEntry(uint64(l)) - } - return n -} - -func (m *BlockReport) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Epoch != 0 { - n += 1 + sovStakeEntry(uint64(m.Epoch)) - } - if m.LatestBlock != 0 { - n += 1 + sovStakeEntry(uint64(m.LatestBlock)) - } - return n -} - -func sovStakeEntry(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStakeEntry(x uint64) (n int) { - return sovStakeEntry(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *StakeEntry) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StakeEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakeEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Stake", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Stake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StakeAppliedBlock", wireType) - } - m.StakeAppliedBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StakeAppliedBlock |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Endpoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Endpoints = append(m.Endpoints, Endpoint{}) - if err := m.Endpoints[len(m.Endpoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Geolocation", wireType) - } - m.Geolocation = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Geolocation |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Chain", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Chain = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Moniker = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateTotal", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DelegateTotal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateLimit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DelegateLimit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegateCommission", wireType) - } - m.DelegateCommission = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DelegateCommission |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastChange", wireType) - } - m.LastChange = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastChange |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockReport", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.BlockReport == nil { - m.BlockReport = &BlockReport{} - } - if err := m.BlockReport.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Vault", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeEntry - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeEntry - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Vault = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStakeEntry(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStakeEntry - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BlockReport) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BlockReport: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockReport: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) - } - m.Epoch = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Epoch |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LatestBlock", wireType) - } - m.LatestBlock = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LatestBlock |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipStakeEntry(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStakeEntry - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStakeEntry(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeEntry - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthStakeEntry - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStakeEntry - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStakeEntry - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStakeEntry = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStakeEntry = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStakeEntry = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/migrations/v6/stake_storage.pb.go b/x/epochstorage/types/migrations/v6/stake_storage.pb.go deleted file mode 100644 index 3e68d424ab..0000000000 --- a/x/epochstorage/types/migrations/v6/stake_storage.pb.go +++ /dev/null @@ -1,438 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/stake_storage.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type StakeStorage struct { - Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` - StakeEntries []StakeEntry `protobuf:"bytes,2,rep,name=stakeEntries,proto3" json:"stakeEntries"` - EpochBlockHash []byte `protobuf:"bytes,3,opt,name=epochBlockHash,proto3" json:"epochBlockHash,omitempty"` -} - -func (m *StakeStorage) Reset() { *m = StakeStorage{} } -func (m *StakeStorage) String() string { return proto.CompactTextString(m) } -func (*StakeStorage) ProtoMessage() {} -func (*StakeStorage) Descriptor() ([]byte, []int) { - return fileDescriptor_be7b78aecc265fd4, []int{0} -} -func (m *StakeStorage) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StakeStorage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StakeStorage.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StakeStorage) XXX_Merge(src proto.Message) { - xxx_messageInfo_StakeStorage.Merge(m, src) -} -func (m *StakeStorage) XXX_Size() int { - return m.Size() -} -func (m *StakeStorage) XXX_DiscardUnknown() { - xxx_messageInfo_StakeStorage.DiscardUnknown(m) -} - -var xxx_messageInfo_StakeStorage proto.InternalMessageInfo - -func (m *StakeStorage) GetIndex() string { - if m != nil { - return m.Index - } - return "" -} - -func (m *StakeStorage) GetStakeEntries() []StakeEntry { - if m != nil { - return m.StakeEntries - } - return nil -} - -func (m *StakeStorage) GetEpochBlockHash() []byte { - if m != nil { - return m.EpochBlockHash - } - return nil -} - -func init() { - proto.RegisterType((*StakeStorage)(nil), "lavanet.lava.epochstorage.StakeStorageV6") -} - -func init() { - proto.RegisterFile("lavanet/lava/epochstorage/stake_storage.proto", fileDescriptor_be7b78aecc265fd4) -} - -var fileDescriptor_be7b78aecc265fd4 = []byte{ - // 246 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xcd, 0x49, 0x2c, 0x4b, - 0xcc, 0x4b, 0x2d, 0xd1, 0x07, 0xd1, 0xfa, 0xa9, 0x05, 0xf9, 0xc9, 0x19, 0xc5, 0x25, 0xf9, 0x45, - 0x89, 0xe9, 0xa9, 0xfa, 0xc5, 0x25, 0x89, 0xd9, 0xa9, 0xf1, 0x50, 0x9e, 0x5e, 0x41, 0x51, 0x7e, - 0x49, 0xbe, 0x90, 0x24, 0x54, 0xb9, 0x1e, 0x88, 0xd6, 0x43, 0x56, 0x2e, 0xa5, 0x4d, 0xc8, 0xa4, - 0xd4, 0xbc, 0x92, 0xa2, 0x4a, 0x88, 0x39, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0xa6, 0x3e, - 0x88, 0x05, 0x11, 0x55, 0x9a, 0xcb, 0xc8, 0xc5, 0x13, 0x0c, 0x52, 0x1b, 0x0c, 0xd1, 0x28, 0x24, - 0xc2, 0xc5, 0x9a, 0x99, 0x97, 0x92, 0x5a, 0x21, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe1, - 0x08, 0xf9, 0x73, 0xf1, 0x80, 0x4d, 0x74, 0xcd, 0x2b, 0x29, 0xca, 0x4c, 0x2d, 0x96, 0x60, 0x52, - 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xd5, 0xc3, 0xe9, 0x36, 0xbd, 0x60, 0x98, 0xf2, 0x4a, 0x27, 0x96, - 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x50, 0x0c, 0x10, 0x52, 0xe3, 0xe2, 0x03, 0x2b, 0x77, 0xca, 0xc9, - 0x4f, 0xce, 0xf6, 0x48, 0x2c, 0xce, 0x90, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x09, 0x42, 0x13, 0x75, - 0x72, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, - 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x9d, 0xf4, 0xcc, 0x92, - 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x94, 0x70, 0xa8, 0x40, 0x0d, 0x89, 0x92, 0xca, - 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x77, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x64, 0x2d, - 0xbc, 0x7a, 0x7d, 0x01, 0x00, 0x00, -} - -func (m *StakeStorage) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StakeStorage) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StakeStorage) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.EpochBlockHash) > 0 { - i -= len(m.EpochBlockHash) - copy(dAtA[i:], m.EpochBlockHash) - i = encodeVarintStakeStorage(dAtA, i, uint64(len(m.EpochBlockHash))) - i-- - dAtA[i] = 0x1a - } - if len(m.StakeEntries) > 0 { - for iNdEx := len(m.StakeEntries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StakeEntries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStakeStorage(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Index) > 0 { - i -= len(m.Index) - copy(dAtA[i:], m.Index) - i = encodeVarintStakeStorage(dAtA, i, uint64(len(m.Index))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintStakeStorage(dAtA []byte, offset int, v uint64) int { - offset -= sovStakeStorage(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *StakeStorage) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Index) - if l > 0 { - n += 1 + l + sovStakeStorage(uint64(l)) - } - if len(m.StakeEntries) > 0 { - for _, e := range m.StakeEntries { - l = e.Size() - n += 1 + l + sovStakeStorage(uint64(l)) - } - } - l = len(m.EpochBlockHash) - if l > 0 { - n += 1 + l + sovStakeStorage(uint64(l)) - } - return n -} - -func sovStakeStorage(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStakeStorage(x uint64) (n int) { - return sovStakeStorage(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *StakeStorage) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StakeStorage: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StakeStorage: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Index = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakeEntries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakeEntries = append(m.StakeEntries, StakeEntry{}) - if err := m.StakeEntries[len(m.StakeEntries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochBlockHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthStakeStorage - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthStakeStorage - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EpochBlockHash = append(m.EpochBlockHash[:0], dAtA[iNdEx:postIndex]...) - if m.EpochBlockHash == nil { - m.EpochBlockHash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStakeStorage(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStakeStorage - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStakeStorage(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowStakeStorage - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthStakeStorage - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStakeStorage - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStakeStorage - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStakeStorage = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStakeStorage = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStakeStorage = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/epochstorage/types/params.go b/x/epochstorage/types/params.go index 3acf9439db..f6c42e3381 100644 --- a/x/epochstorage/types/params.go +++ b/x/epochstorage/types/params.go @@ -9,11 +9,6 @@ import ( var _ paramtypes.ParamSet = (*Params)(nil) -var ( - KeyUnstakeHoldBlocks = []byte("UnstakeHoldBlocks") - DefaultUnstakeHoldBlocks uint64 = 210 -) - var ( KeyEpochBlocks = []byte("EpochBlocks") DefaultEpochBlocks uint64 = 20 @@ -29,11 +24,6 @@ var ( DefaultLatestParamChange uint64 = 0 ) -var ( - KeyUnstakeHoldBlocksStatic = []byte("UnstakeHoldBlocksStatic") - DefaultUnstakeHoldBlocksStatic uint64 = 400 -) - // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) @@ -41,49 +31,37 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams( - unstakeHoldBlocks uint64, epochBlocks uint64, epochsToSave uint64, latestParamChange uint64, - unstakeHoldBlocksStatic uint64, ) Params { return Params{ - UnstakeHoldBlocks: unstakeHoldBlocks, - EpochBlocks: epochBlocks, - EpochsToSave: epochsToSave, - LatestParamChange: latestParamChange, - UnstakeHoldBlocksStatic: unstakeHoldBlocksStatic, + EpochBlocks: epochBlocks, + EpochsToSave: epochsToSave, + LatestParamChange: latestParamChange, } } // DefaultParams returns a default set of parameters func DefaultParams() Params { return NewParams( - DefaultUnstakeHoldBlocks, DefaultEpochBlocks, DefaultEpochsToSave, DefaultLatestParamChange, - DefaultUnstakeHoldBlocksStatic, ) } // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyUnstakeHoldBlocks, &p.UnstakeHoldBlocks, validateUnstakeHoldBlocks), paramtypes.NewParamSetPair(KeyEpochBlocks, &p.EpochBlocks, validateEpochBlocks), paramtypes.NewParamSetPair(KeyEpochsToSave, &p.EpochsToSave, validateEpochsToSave), paramtypes.NewParamSetPair(KeyLatestParamChange, &p.LatestParamChange, validateLatestParamChange), - paramtypes.NewParamSetPair(KeyUnstakeHoldBlocksStatic, &p.UnstakeHoldBlocksStatic, validateUnstakeHoldBlocksStatic), } } // Validate validates the set of params func (p Params) Validate() error { - if err := validateUnstakeHoldBlocks(p.UnstakeHoldBlocks); err != nil { - return err - } - if err := validateEpochBlocks(p.EpochBlocks); err != nil { return err } @@ -92,14 +70,6 @@ func (p Params) Validate() error { return err } - if err := validateUnstakeHoldBlocksStatic(p.UnstakeHoldBlocksStatic); err != nil { - return err - } - - if err := validateBlocksParams(p.UnstakeHoldBlocks, p.UnstakeHoldBlocksStatic, p.EpochBlocks*p.EpochsToSave); err != nil { - return err - } - return nil } @@ -109,19 +79,6 @@ func (p Params) String() string { return string(out) } -// validateUnstakeHoldBlocks validates the UnstakeHoldBlocks param -func validateUnstakeHoldBlocks(v interface{}) error { - unstakeHoldBlocks, ok := v.(uint64) - if !ok { - return fmt.Errorf("invalid parameter type: %T", v) - } - - // TODO implement validation - _ = unstakeHoldBlocks - - return nil -} - // validateEpochBlocks validates the EpochBlocks param func validateEpochBlocks(v interface{}) error { epochBlocks, ok := v.(uint64) @@ -159,25 +116,3 @@ func validateLatestParamChange(v interface{}) error { return nil } - -// validateUnstakeHoldBlocks validates the UnstakeHoldBlocks param -func validateUnstakeHoldBlocksStatic(v interface{}) error { - unstakeHoldBlocks, ok := v.(uint64) - if !ok { - return fmt.Errorf("invalid parameter type: %T", v) - } - - // TODO implement validation - _ = unstakeHoldBlocks - - return nil -} - -// validateUnstakeHoldBlocks validates the UnstakeHoldBlocks param -func validateBlocksParams(unstakeHoldBlocks, unstakeHoldBlocksStatic, blocksToSave uint64) error { - if !(unstakeHoldBlocksStatic > unstakeHoldBlocks && unstakeHoldBlocks > blocksToSave) { - return fmt.Errorf("parameters do not follow the rule of: unstakeHoldBlocksStatic > unstakeHoldBlocks > blocksToSave") - } - - return nil -} diff --git a/x/epochstorage/types/params.pb.go b/x/epochstorage/types/params.pb.go index 9e27d108e5..e9068a9939 100644 --- a/x/epochstorage/types/params.pb.go +++ b/x/epochstorage/types/params.pb.go @@ -25,11 +25,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - UnstakeHoldBlocks uint64 `protobuf:"varint,1,opt,name=unstakeHoldBlocks,proto3" json:"unstakeHoldBlocks,omitempty" yaml:"unstake_hold_blocks"` - EpochBlocks uint64 `protobuf:"varint,2,opt,name=epochBlocks,proto3" json:"epochBlocks,omitempty" yaml:"epoch_blocks"` - EpochsToSave uint64 `protobuf:"varint,3,opt,name=epochsToSave,proto3" json:"epochsToSave,omitempty" yaml:"epochs_to_save"` - LatestParamChange uint64 `protobuf:"varint,4,opt,name=latestParamChange,proto3" json:"latestParamChange,omitempty" yaml:"latest_param_change"` - UnstakeHoldBlocksStatic uint64 `protobuf:"varint,5,opt,name=unstakeHoldBlocksStatic,proto3" json:"unstakeHoldBlocksStatic,omitempty" yaml:"unstake_hold_blocks_static"` + EpochBlocks uint64 `protobuf:"varint,2,opt,name=epochBlocks,proto3" json:"epochBlocks,omitempty" yaml:"epoch_blocks"` + EpochsToSave uint64 `protobuf:"varint,3,opt,name=epochsToSave,proto3" json:"epochsToSave,omitempty" yaml:"epochs_to_save"` + LatestParamChange uint64 `protobuf:"varint,4,opt,name=latestParamChange,proto3" json:"latestParamChange,omitempty" yaml:"latest_param_change"` } func (m *Params) Reset() { *m = Params{} } @@ -64,13 +62,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetUnstakeHoldBlocks() uint64 { - if m != nil { - return m.UnstakeHoldBlocks - } - return 0 -} - func (m *Params) GetEpochBlocks() uint64 { if m != nil { return m.EpochBlocks @@ -92,13 +83,6 @@ func (m *Params) GetLatestParamChange() uint64 { return 0 } -func (m *Params) GetUnstakeHoldBlocksStatic() uint64 { - if m != nil { - return m.UnstakeHoldBlocksStatic - } - return 0 -} - func init() { proto.RegisterType((*Params)(nil), "lavanet.lava.epochstorage.Params") } @@ -108,29 +92,26 @@ func init() { } var fileDescriptor_09513f4cf6e403e6 = []byte{ - // 341 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x31, 0x4f, 0xf2, 0x40, - 0x18, 0xc7, 0xdb, 0x17, 0x5e, 0x86, 0xea, 0x62, 0xd5, 0x50, 0x18, 0xae, 0xda, 0x44, 0xe3, 0xd4, - 0x4b, 0x74, 0x92, 0xc4, 0x05, 0x17, 0x4d, 0x1c, 0x4c, 0x71, 0x72, 0xb9, 0x1c, 0xe5, 0xd2, 0x12, - 0x0e, 0x9e, 0x86, 0x3b, 0x1a, 0xf9, 0x00, 0xee, 0x8e, 0x8e, 0x7e, 0x1c, 0x47, 0x46, 0xa7, 0xc6, - 0xc0, 0x37, 0xe8, 0x27, 0x30, 0x7d, 0x4a, 0x0c, 0xd8, 0x30, 0x5d, 0x93, 0xfe, 0xfe, 0xbf, 0xf6, - 0xff, 0xdc, 0x63, 0x9d, 0x4b, 0x9e, 0xf2, 0x89, 0xd0, 0xb4, 0x38, 0xa9, 0x48, 0x20, 0x8c, 0x95, - 0x86, 0x29, 0x8f, 0x04, 0x4d, 0xf8, 0x94, 0x8f, 0x95, 0x9f, 0x4c, 0x41, 0x83, 0xdd, 0x5a, 0x73, - 0x7e, 0x71, 0xfa, 0x9b, 0x5c, 0xfb, 0x28, 0x82, 0x08, 0x90, 0xa2, 0xc5, 0x53, 0x19, 0xf0, 0x5e, - 0x6b, 0x56, 0xe3, 0x11, 0x0d, 0xf6, 0x83, 0x75, 0x30, 0x9b, 0x28, 0xcd, 0x47, 0xe2, 0x0e, 0xe4, - 0xa0, 0x2b, 0x21, 0x1c, 0x29, 0xc7, 0x3c, 0x31, 0x2f, 0xea, 0x5d, 0x92, 0x67, 0x6e, 0x7b, 0xce, - 0xc7, 0xb2, 0xe3, 0xad, 0x11, 0x16, 0x83, 0x1c, 0xb0, 0x3e, 0x42, 0x5e, 0x50, 0x0d, 0xda, 0xd7, - 0xd6, 0x1e, 0x7e, 0x7e, 0xed, 0xf9, 0x87, 0x9e, 0x66, 0x9e, 0xb9, 0x87, 0xa5, 0x07, 0x5f, 0xfe, - 0x0a, 0x36, 0x59, 0xfb, 0xc6, 0xda, 0x2f, 0xff, 0xfc, 0x09, 0x7a, 0x3c, 0x15, 0x4e, 0x0d, 0xb3, - 0xad, 0x3c, 0x73, 0x8f, 0x37, 0xb2, 0x8a, 0x69, 0x60, 0x8a, 0xa7, 0xc2, 0x0b, 0xb6, 0xf0, 0xa2, - 0x87, 0xe4, 0x5a, 0x28, 0x8d, 0xbd, 0x6e, 0x63, 0x3e, 0x89, 0x84, 0x53, 0xff, 0xdb, 0xa3, 0x44, - 0x18, 0x4e, 0x8f, 0x85, 0x08, 0x79, 0x41, 0x35, 0x68, 0x33, 0xab, 0x59, 0x29, 0xd7, 0xd3, 0x5c, - 0x0f, 0x43, 0xe7, 0x3f, 0x3a, 0xcf, 0xf2, 0xcc, 0x3d, 0xdd, 0x39, 0x1b, 0xa6, 0x90, 0xf5, 0x82, - 0x5d, 0x96, 0x4e, 0xfd, 0xfd, 0xc3, 0x35, 0xba, 0xf7, 0x9f, 0x4b, 0x62, 0x2e, 0x96, 0xc4, 0xfc, - 0x5e, 0x12, 0xf3, 0x6d, 0x45, 0x8c, 0xc5, 0x8a, 0x18, 0x5f, 0x2b, 0x62, 0x3c, 0xd3, 0x68, 0xa8, - 0xe3, 0x59, 0xdf, 0x0f, 0x61, 0x4c, 0xb7, 0xb6, 0x20, 0xbd, 0xa4, 0x2f, 0xdb, 0xab, 0xa0, 0xe7, - 0x89, 0x50, 0xfd, 0x06, 0xde, 0xec, 0xd5, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x47, 0x4f, 0x74, - 0x80, 0x34, 0x02, 0x00, 0x00, + // 290 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0x49, 0x2c, 0x4b, + 0xcc, 0x4b, 0x2d, 0xd1, 0x07, 0xd1, 0xfa, 0xa9, 0x05, 0xf9, 0xc9, 0x19, 0xc5, 0x25, 0xf9, 0x45, + 0x89, 0xe9, 0xa9, 0xfa, 0x05, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, + 0x42, 0x92, 0x50, 0x75, 0x7a, 0x20, 0x5a, 0x0f, 0x59, 0x9d, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, + 0x58, 0x95, 0x3e, 0x88, 0x05, 0xd1, 0xa0, 0xf4, 0x88, 0x91, 0x8b, 0x2d, 0x00, 0x6c, 0x82, 0x90, + 0x25, 0x17, 0x37, 0x58, 0x83, 0x53, 0x4e, 0x7e, 0x72, 0x76, 0xb1, 0x04, 0x93, 0x02, 0xa3, 0x06, + 0x8b, 0x93, 0xf8, 0xa7, 0x7b, 0xf2, 0xc2, 0x95, 0x89, 0xb9, 0x39, 0x56, 0x4a, 0x60, 0xc9, 0xf8, + 0x24, 0xb0, 0xac, 0x52, 0x10, 0xb2, 0x5a, 0x21, 0x5b, 0x2e, 0x1e, 0x88, 0x5d, 0x21, 0xf9, 0xc1, + 0x89, 0x65, 0xa9, 0x12, 0xcc, 0x60, 0xbd, 0x92, 0x9f, 0xee, 0xc9, 0x8b, 0x22, 0xe9, 0x2d, 0x8e, + 0x2f, 0xc9, 0x8f, 0x2f, 0x4e, 0x2c, 0x4b, 0x55, 0x0a, 0x42, 0x51, 0x2e, 0xe4, 0xc3, 0x25, 0x98, + 0x93, 0x58, 0x92, 0x5a, 0x5c, 0x02, 0x76, 0x89, 0x73, 0x46, 0x62, 0x5e, 0x7a, 0xaa, 0x04, 0x0b, + 0xd8, 0x0c, 0xb9, 0x4f, 0xf7, 0xe4, 0xa5, 0x20, 0x66, 0x40, 0x94, 0xc4, 0x83, 0xfd, 0x1b, 0x9f, + 0x0c, 0x56, 0xa4, 0x14, 0x84, 0xa9, 0xd1, 0x8a, 0x65, 0xc6, 0x02, 0x79, 0x06, 0x2f, 0x16, 0x0e, + 0x46, 0x01, 0x26, 0x2f, 0x16, 0x0e, 0x56, 0x01, 0x36, 0x27, 0xcf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, + 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, + 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, + 0xd5, 0x47, 0x09, 0xe2, 0x32, 0x23, 0xfd, 0x0a, 0xd4, 0x70, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, + 0x62, 0x03, 0x07, 0x9b, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x9a, 0x9c, 0xe6, 0x8e, 0x91, 0x01, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -153,11 +134,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.UnstakeHoldBlocksStatic != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.UnstakeHoldBlocksStatic)) - i-- - dAtA[i] = 0x28 - } if m.LatestParamChange != 0 { i = encodeVarintParams(dAtA, i, uint64(m.LatestParamChange)) i-- @@ -173,11 +149,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if m.UnstakeHoldBlocks != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.UnstakeHoldBlocks)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } @@ -198,9 +169,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - if m.UnstakeHoldBlocks != 0 { - n += 1 + sovParams(uint64(m.UnstakeHoldBlocks)) - } if m.EpochBlocks != 0 { n += 1 + sovParams(uint64(m.EpochBlocks)) } @@ -210,9 +178,6 @@ func (m *Params) Size() (n int) { if m.LatestParamChange != 0 { n += 1 + sovParams(uint64(m.LatestParamChange)) } - if m.UnstakeHoldBlocksStatic != 0 { - n += 1 + sovParams(uint64(m.UnstakeHoldBlocksStatic)) - } return n } @@ -251,25 +216,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UnstakeHoldBlocks", wireType) - } - m.UnstakeHoldBlocks = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UnstakeHoldBlocks |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EpochBlocks", wireType) @@ -327,25 +273,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UnstakeHoldBlocksStatic", wireType) - } - m.UnstakeHoldBlocksStatic = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UnstakeHoldBlocksStatic |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/epochstorage/types/stake_entries.go b/x/epochstorage/types/stake_entries.go new file mode 100644 index 0000000000..18e34282c8 --- /dev/null +++ b/x/epochstorage/types/stake_entries.go @@ -0,0 +1,114 @@ +package types + +import ( + "fmt" + + regmath "math" + + "cosmossdk.io/collections" + "cosmossdk.io/collections/indexes" + "cosmossdk.io/math" + "github.com/lavanet/lava/v2/utils" +) + +var ( + StakeEntriesPrefix = collections.NewPrefix([]byte("StakeEntries/")) + StakeEntriesCurrentPrefix = collections.NewPrefix([]byte("StakeEntriesCurrent/")) + EpochChainIdProviderIndexesPrefix = collections.NewPrefix([]byte("EpochChainIdProviderIndexes/")) + ChainIdVaultIndexesPrefix = collections.NewPrefix([]byte("ChainIdVaultIndexes/")) + EpochHashesPrefix = collections.NewPrefix([]byte("EpochHash/")) +) + +// EpochChainIdProviderIndexes defines a secondary unique index for the keeper's stakeEntries indexed map +// Normally, a stake entry can be accessed with the primary key: [epoch, chainID, stake, address] +// The new set of indexes, EpochChainIdProviderIndexes, allows accessing the stake entries with [epoch, chainID, address] +type EpochChainIdProviderIndexes struct { + Index *indexes.Unique[collections.Triple[uint64, string, string], collections.Triple[uint64, string, collections.Pair[uint64, string]], StakeEntry] +} + +func (e EpochChainIdProviderIndexes) IndexesList() []collections.Index[collections.Triple[uint64, string, collections.Pair[uint64, string]], StakeEntry] { + return []collections.Index[collections.Triple[uint64, string, collections.Pair[uint64, string]], StakeEntry]{e.Index} +} + +func NewEpochChainIdProviderIndexes(sb *collections.SchemaBuilder) EpochChainIdProviderIndexes { + return EpochChainIdProviderIndexes{ + Index: indexes.NewUnique(sb, EpochChainIdProviderIndexesPrefix, "stake_entry_by_epoch_chain_address", + collections.TripleKeyCodec(collections.Uint64Key, collections.StringKey, collections.StringKey), + collections.TripleKeyCodec(collections.Uint64Key, collections.StringKey, + collections.PairKeyCodec(collections.Uint64Key, collections.StringKey)), + func(pk collections.Triple[uint64, string, collections.Pair[uint64, string]], _ StakeEntry) (collections.Triple[uint64, string, string], error) { + return collections.Join3(pk.K1(), pk.K2(), pk.K3().K2()), nil + }, + ), + } +} + +// ChainIdVaultIndexes defines a secondary unique index for the keeper's stakeEntriesCurrent indexed map +// Normally, a current stake entry can be accessed with the primary key: [chainID, address] +// The new set of indexes, ChainIdVaultIndexes, allows accessing the stake entries with [chainID, vault] +type ChainIdVaultIndexes struct { + Index *indexes.Unique[collections.Pair[string, string], collections.Pair[string, string], StakeEntry] +} + +func (c ChainIdVaultIndexes) IndexesList() []collections.Index[collections.Pair[string, string], StakeEntry] { + return []collections.Index[collections.Pair[string, string], StakeEntry]{c.Index} +} + +func NewChainIdVaultIndexes(sb *collections.SchemaBuilder) ChainIdVaultIndexes { + return ChainIdVaultIndexes{ + Index: indexes.NewUnique(sb, ChainIdVaultIndexesPrefix, "stake_entry_current_by_chain_vault", + collections.PairKeyCodec(collections.StringKey, collections.StringKey), + collections.PairKeyCodec(collections.StringKey, collections.StringKey), + func(pk collections.Pair[string, string], entry StakeEntry) (collections.Pair[string, string], error) { + if entry.Vault == "" { + return collections.Pair[string, string]{}, + utils.LavaFormatError("NewChainIdVaultIndexes: cannot create new ChainIdVault index", + fmt.Errorf("empty vault address"), + utils.LogAttr("provider", entry.Address), + utils.LogAttr("chain_id", entry.Chain), + ) + } + return collections.Join(pk.K1(), entry.Vault), nil + }, + ), + } +} + +// StakeEntry methods + +func (se StakeEntry) EffectiveStake() math.Int { + effective := se.Stake.Amount + if se.DelegateLimit.Amount.LT(se.DelegateTotal.Amount) { + effective = effective.Add(se.DelegateLimit.Amount) + } else { + effective = effective.Add(se.DelegateTotal.Amount) + } + return effective +} + +// Frozen provider block const +const FROZEN_BLOCK = regmath.MaxInt64 + +func (stakeEntry *StakeEntry) Freeze() { + stakeEntry.StakeAppliedBlock = FROZEN_BLOCK +} + +func (stakeEntry *StakeEntry) UnFreeze(currentBlock uint64) { + stakeEntry.StakeAppliedBlock = currentBlock +} + +func (stakeEntry *StakeEntry) IsFrozen() bool { + return stakeEntry.StakeAppliedBlock == FROZEN_BLOCK +} + +func (stakeEntry *StakeEntry) IsJailed(time int64) bool { + return stakeEntry.JailEndTime > time +} + +func (stakeEntry *StakeEntry) IsAddressVaultAndNotProvider(address string) bool { + return address != stakeEntry.Address && address == stakeEntry.Vault +} + +func (stakeEntry *StakeEntry) IsAddressVaultOrProvider(address string) bool { + return address == stakeEntry.Address || address == stakeEntry.Vault +} diff --git a/x/epochstorage/types/stake_entry.go b/x/epochstorage/types/stake_entry.go deleted file mode 100644 index dad926835c..0000000000 --- a/x/epochstorage/types/stake_entry.go +++ /dev/null @@ -1,46 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: lavanet/lava/epochstorage/stake_entry.proto - -package types - -import ( - "cosmossdk.io/math" - regmath "math" -) - -func (se StakeEntry) EffectiveStake() math.Int { - effective := se.Stake.Amount - if se.DelegateLimit.Amount.LT(se.DelegateTotal.Amount) { - effective = effective.Add(se.DelegateLimit.Amount) - } else { - effective = effective.Add(se.DelegateTotal.Amount) - } - return effective -} - -// Frozen provider block const -const FROZEN_BLOCK = regmath.MaxInt64 - -func (stakeEntry *StakeEntry) Freeze() { - stakeEntry.StakeAppliedBlock = FROZEN_BLOCK -} - -func (stakeEntry *StakeEntry) UnFreeze(currentBlock uint64) { - stakeEntry.StakeAppliedBlock = currentBlock -} - -func (stakeEntry *StakeEntry) IsFrozen() bool { - return stakeEntry.StakeAppliedBlock == FROZEN_BLOCK -} - -func (stakeEntry *StakeEntry) IsJailed(time int64) bool { - return stakeEntry.JailEndTime > time -} - -func (stakeEntry *StakeEntry) IsAddressVaultAndNotProvider(address string) bool { - return address != stakeEntry.Address && address == stakeEntry.Vault -} - -func (stakeEntry *StakeEntry) IsAddressVaultOrProvider(address string) bool { - return address == stakeEntry.Address || address == stakeEntry.Vault -} \ No newline at end of file diff --git a/x/epochstorage/types/stake_storage.go b/x/epochstorage/types/stake_storage.go deleted file mode 100644 index 58b8a3a93f..0000000000 --- a/x/epochstorage/types/stake_storage.go +++ /dev/null @@ -1,36 +0,0 @@ -package types - -import ( - fmt "fmt" - - "github.com/lavanet/lava/v2/utils" -) - -func (ss StakeStorage) GetStakeEntryByAddressFromStorage(address string) (StakeEntry, bool) { - if !utils.IsBech32Address(address) { - utils.LavaFormatWarning("address is not Bech32", fmt.Errorf("invalid address"), - utils.LogAttr("address", address), - ) - return StakeEntry{}, false - } - - for _, entry := range ss.StakeEntries { - if !utils.IsBech32Address(entry.Address) || !utils.IsBech32Address(entry.Vault) { - // this should not happen; to avoid panic we simply skip this one (thus - // freeze the situation so it can be investigated and orderly resolved). - utils.LavaFormatError("critical: invalid account address inside StakeStorage", fmt.Errorf("invalid address"), - utils.LogAttr("provider", entry.Address), - utils.LogAttr("vault", entry.Vault), - utils.LogAttr("chainID", entry.Chain), - ) - continue - } - - if entry.IsAddressVaultOrProvider(address) { - // found the right entry - return entry, true - } - } - - return StakeEntry{}, false -} diff --git a/x/pairing/keeper/cu_tracker_test.go b/x/pairing/keeper/cu_tracker_test.go index fd39467668..7911ce154e 100644 --- a/x/pairing/keeper/cu_tracker_test.go +++ b/x/pairing/keeper/cu_tracker_test.go @@ -145,11 +145,11 @@ func TestTrackedCuWithDelegations(t *testing.T) { providerAcct, provider := ts.GetAccount(common.PROVIDER, 0) // change the provider's delegation limit and commission - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(testStake)) stakeEntry.DelegateCommission = 0 - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() // delegate testStake/2 (with commission=0) -> provider should get 66% of the reward @@ -486,11 +486,11 @@ func TestProviderMonthlyPayoutQuery(t *testing.T) { ts.AdvanceEpoch() // change the provider's delegation limit and commission - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(testStake)) stakeEntry.DelegateCommission = 0 - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() // delegate testStake/2 (with commission=0) -> provider should get 66% of the reward @@ -606,11 +606,11 @@ func TestProviderMonthlyPayoutQueryWithContributor(t *testing.T) { ts.AdvanceEpoch() // change the provider's delegation limit and commission - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(testStake)) stakeEntry.DelegateCommission = 0 - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() // delegate testStake/2 (with commission=0) -> provider should get 66% of the reward diff --git a/x/pairing/keeper/delegator_rewards_test.go b/x/pairing/keeper/delegator_rewards_test.go index 4486c7fc30..dc5bd640ec 100644 --- a/x/pairing/keeper/delegator_rewards_test.go +++ b/x/pairing/keeper/delegator_rewards_test.go @@ -99,13 +99,13 @@ func TestProviderDelegatorsRewards(t *testing.T) { ts.AdvanceEpoch() // apply delegations // change delegation traits of stake entry and get the modified one - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(tt.limit*testStake/100)) stakeEntry.DelegateCommission = tt.commission - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() - stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) // check that there are two delegators @@ -216,15 +216,15 @@ func TestDelegationLimitAffectingProviderReward(t *testing.T) { require.NoError(t, err) ts.AdvanceEpoch() // apply delegations - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) // modify the stake entry to have a delegation limit higher than the total delegations stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(2*testStake)) stakeEntry.DelegateCommission = 50 - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() - stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) res, err := ts.QueryDualstakingProviderDelegators(provider, false) @@ -236,7 +236,7 @@ func TestDelegationLimitAffectingProviderReward(t *testing.T) { // modify the stake entry to have a delegation limit lower than the total delegations stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(testStake)) - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() relayPaymentMessage = sendRelay(ts, provider, clientAcc, []string{ts.spec.Index}) @@ -263,16 +263,16 @@ func TestProviderRewardWithCommission(t *testing.T) { require.NoError(t, err) ts.AdvanceEpoch() // apply delegations - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) // ** provider's commission is 100% ** // stakeEntry.DelegateCommission = 100 stakeEntry.DelegateLimit = delegationAmount1 - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() - stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) res, err := ts.QueryDualstakingProviderDelegators(provider, false) @@ -301,7 +301,7 @@ func TestProviderRewardWithCommission(t *testing.T) { // ** provider's commission is 0% ** // stakeEntry.DelegateCommission = 0 - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() // the expected reward for the provider with 0% commission is half of the total rewards @@ -484,11 +484,11 @@ func TestVaultProviderDelegatorRewardsQuery(t *testing.T) { } func makeProviderCommissionZero(ts *tester, chainID string, provider string) { - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, chainID, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, chainID, provider) require.True(ts.T, found) stakeEntry.DelegateCommission = 0 stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(testStake)) - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, stakeEntry.Chain, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() } @@ -547,10 +547,10 @@ func TestDelegationFirstMonthPairing(t *testing.T) { _, delegator := ts.GetAccount(common.CONSUMER, 1) // increase delegation limit of stake entry - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(10*testStake)) - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() // delegate and check the delegation's timestamp is equal than nowPlusMonthTime @@ -589,10 +589,10 @@ func TestDelegationFirstMonthReward(t *testing.T) { _, delegator := ts.GetAccount(common.CONSUMER, 1) // increase delegation limit and zero commission of stake entry - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(10*testStake)) - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() makeProviderCommissionZero(ts, ts.spec.Index, provider) @@ -640,15 +640,15 @@ func TestRedelegationFirstMonthReward(t *testing.T) { _, delegator := ts.GetAccount(common.CONSUMER, 1) // increase delegation limit and zero commission of both stake entries - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(10*testStake)) - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() - stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider1) + stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider1) require.True(t, found) stakeEntry.DelegateLimit = sdk.NewCoin(ts.TokenDenom(), sdk.NewInt(10*testStake)) - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() makeProviderCommissionZero(ts, ts.spec.Index, provider1) makeProviderCommissionZero(ts, ts.spec.Index, provider) diff --git a/x/pairing/keeper/epoch_cu.go b/x/pairing/keeper/epoch_cu.go index 1a848c0f3a..c5f1d3dc24 100644 --- a/x/pairing/keeper/epoch_cu.go +++ b/x/pairing/keeper/epoch_cu.go @@ -36,7 +36,7 @@ func (k Keeper) IsUniqueEpochSessionExists(ctx sdk.Context, epoch uint64, provid // RemoveAllUniqueEpochSession removes all the UniqueEpochSession objects from the store for a specific epoch func (k Keeper) RemoveAllUniqueEpochSession(ctx sdk.Context, epoch uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.UniqueEpochSessionKeyPrefix()) - iterator := sdk.KVStorePrefixIterator(store, types.EncodeBlock(epoch)) + iterator := sdk.KVStorePrefixIterator(store, utils.Serialize(epoch)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { store.Delete(iterator.Key()) @@ -47,7 +47,7 @@ func (k Keeper) RemoveAllUniqueEpochSession(ctx sdk.Context, epoch uint64) { func (k Keeper) GetAllUniqueEpochSessionForEpoch(ctx sdk.Context, epoch uint64) []string { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.UniqueEpochSessionKeyPrefix()) - iterator := sdk.KVStorePrefixIterator(store, types.EncodeBlock(epoch)) // Get an iterator with no prefix to iterate over all keys + iterator := sdk.KVStorePrefixIterator(store, utils.Serialize(epoch)) // Get an iterator with no prefix to iterate over all keys defer iterator.Close() var keys []string @@ -105,7 +105,7 @@ func (k Keeper) GetProviderEpochCu(ctx sdk.Context, epoch uint64, provider strin // RemoveProviderEpochCu removes a ProviderEpochCu from the store func (k Keeper) RemoveAllProviderEpochCu(ctx sdk.Context, epoch uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ProviderEpochCuKeyPrefix()) - iterator := sdk.KVStorePrefixIterator(store, types.EncodeBlock(epoch)) + iterator := sdk.KVStorePrefixIterator(store, utils.Serialize(epoch)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { store.Delete(iterator.Key()) @@ -167,7 +167,7 @@ func (k Keeper) RemoveProviderEpochComplainerCu(ctx sdk.Context, epoch uint64, p // RemoveProviderEpochComplainerCu removes a ProviderEpochCu from the store func (k Keeper) RemoveAllProviderEpochComplainerCu(ctx sdk.Context, epoch uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ProviderEpochComplainerCuKeyPrefix()) - iterator := sdk.KVStorePrefixIterator(store, types.EncodeBlock(epoch)) + iterator := sdk.KVStorePrefixIterator(store, utils.Serialize(epoch)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { store.Delete(iterator.Key()) @@ -230,7 +230,7 @@ func (k Keeper) RemoveProviderConsumerEpochCu(ctx sdk.Context, epoch uint64, pro func (k Keeper) GetAllProviderConsumerEpochCu(ctx sdk.Context, epoch uint64) []types.ProviderConsumerEpochCuGenesis { providerConsumerEpochCus := []types.ProviderConsumerEpochCuGenesis{} store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ProviderConsumerEpochCuKeyPrefix()) - iterator := sdk.KVStorePrefixIterator(store, types.EncodeBlock(epoch)) + iterator := sdk.KVStorePrefixIterator(store, utils.Serialize(epoch)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { epoch, provider, project, chainID, err := types.DecodeProviderConsumerEpochCuKey(string(iterator.Key())) diff --git a/x/pairing/keeper/filters/filter.go b/x/pairing/keeper/filters/filter.go index 8a1481f11f..b7689c46d5 100644 --- a/x/pairing/keeper/filters/filter.go +++ b/x/pairing/keeper/filters/filter.go @@ -83,7 +83,10 @@ func SetupScores(ctx sdk.Context, filters []Filter, providers []epochstoragetype // create providerScore array with all possible providers providerScores := []*pairingscores.PairingScore{} - for j := 0; j < len(providers); j++ { + // currently, the providers are sorted by stake with increasing order + // the pairing mechanism works best if we iterate over the largest stake + // providers first, so we iterate in reverse order + for j := len(providers) - 1; j >= 0; j-- { result := true slotFiltering := map[int]struct{}{} // for mix filters // check provider for each filter diff --git a/x/pairing/keeper/grpc_query_provider.go b/x/pairing/keeper/grpc_query_provider.go index 84a2ccc5c9..086b843023 100644 --- a/x/pairing/keeper/grpc_query_provider.go +++ b/x/pairing/keeper/grpc_query_provider.go @@ -24,7 +24,7 @@ func (k Keeper) Provider(goCtx context.Context, req *types.QueryProviderRequest) stakeEntries := []epochstoragetypes.StakeEntry{} for _, chain := range chains { - stakeEntry, found := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chain, req.Address) + stakeEntry, found := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chain, req.Address) if !found { continue } diff --git a/x/pairing/keeper/grpc_query_providers.go b/x/pairing/keeper/grpc_query_providers.go index 7462a70c24..ccdb4fec87 100644 --- a/x/pairing/keeper/grpc_query_providers.go +++ b/x/pairing/keeper/grpc_query_providers.go @@ -17,22 +17,16 @@ func (k Keeper) Providers(goCtx context.Context, req *types.QueryProvidersReques ctx := sdk.UnwrapSDKContext(goCtx) - stakeStorage, found := k.epochStorageKeeper.GetStakeStorageCurrent(ctx, req.ChainID) - if !found { - stakeStorage = epochstoragetypes.StakeStorage{} - } - - stakeEntries := stakeStorage.GetStakeEntries() - for i := range stakeEntries { - stakeEntries[i].Moniker = stakeEntries[i].Description.Moniker - } + stakeEntries := k.epochStorageKeeper.GetAllStakeEntriesCurrentForChainId(ctx, req.ChainID) if !req.ShowFrozen { stakeEntriesNoFrozen := []epochstoragetypes.StakeEntry{} - for _, stakeEntry := range stakeEntries { + for i := range stakeEntries { + stakeEntries[i].Moniker = stakeEntries[i].Description.Moniker + // show providers with valid stakeAppliedBlock (frozen providers have stakeAppliedBlock = MaxUint64) - if stakeEntry.GetStakeAppliedBlock() <= uint64(ctx.BlockHeight()) { - stakeEntriesNoFrozen = append(stakeEntriesNoFrozen, stakeEntry) + if stakeEntries[i].GetStakeAppliedBlock() <= uint64(ctx.BlockHeight()) { + stakeEntriesNoFrozen = append(stakeEntriesNoFrozen, stakeEntries[i]) } } stakeEntries = stakeEntriesNoFrozen diff --git a/x/pairing/keeper/grpc_query_static_providers_list.go b/x/pairing/keeper/grpc_query_static_providers_list.go index c25c014867..68cb318a20 100644 --- a/x/pairing/keeper/grpc_query_static_providers_list.go +++ b/x/pairing/keeper/grpc_query_static_providers_list.go @@ -28,11 +28,7 @@ func (k Keeper) StaticProvidersList(goCtx context.Context, req *types.QueryStati } epoch := k.epochStorageKeeper.GetEpochStart(ctx) - stakes, found, _ := k.epochStorageKeeper.GetEpochStakeEntries(ctx, epoch, req.GetChainID()) - - if !found { - return &types.QueryStaticProvidersListResponse{}, nil - } + stakes := k.epochStorageKeeper.GetAllStakeEntriesForEpochChainId(ctx, epoch, req.ChainID) finalProviders := []epochstoragetypes.StakeEntry{} for _, stake := range stakes { diff --git a/x/pairing/keeper/keeper.go b/x/pairing/keeper/keeper.go index 994e527a87..0ba76fcd42 100644 --- a/x/pairing/keeper/keeper.go +++ b/x/pairing/keeper/keeper.go @@ -109,8 +109,6 @@ func (k Keeper) BeginBlock(ctx sdk.Context) { if k.epochStorageKeeper.IsEpochStart(ctx) { // remove old session payments k.RemoveOldEpochPayments(ctx) - // unstake any unstaking providers - k.CheckUnstakingForCommit(ctx) // unstake/jail unresponsive providers k.PunishUnresponsiveProviders(ctx, types.EPOCHS_NUM_TO_CHECK_CU_FOR_UNRESPONSIVE_PROVIDER, diff --git a/x/pairing/keeper/msg_server_freeze.go b/x/pairing/keeper/msg_server_freeze.go index 87c6bfe04a..9e343e863a 100644 --- a/x/pairing/keeper/msg_server_freeze.go +++ b/x/pairing/keeper/msg_server_freeze.go @@ -34,14 +34,14 @@ func (k Keeper) FreezeProvider(ctx sdk.Context, provider string, chainIDs []stri } for _, chainId := range chainIDs { - stakeEntry, found := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainId, provider) + stakeEntry, found := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainId, provider) if !found { return utils.LavaFormatWarning("Freeze_cant_get_stake_entry", types.FreezeStakeEntryNotFoundError, []utils.Attribute{{Key: "chainID", Value: chainId}, {Key: "providerAddress", Value: provider}}...) } // freeze the provider by making the StakeAppliedBlock be max. This will remove the provider from the pairing list in the next epoch stakeEntry.Freeze() - k.epochStorageKeeper.ModifyStakeEntryCurrent(ctx, chainId, stakeEntry) + k.epochStorageKeeper.SetStakeEntryCurrent(ctx, stakeEntry) } utils.LogLavaEvent(ctx, ctx.Logger(), "freeze_provider", map[string]string{"providerAddress": provider, "chainIDs": strings.Join(chainIDs, ","), "freezeRequestBlock": strconv.FormatInt(ctx.BlockHeight(), 10), "freezeReason": reason}, "Provider Freeze") diff --git a/x/pairing/keeper/msg_server_relay_payment.go b/x/pairing/keeper/msg_server_relay_payment.go index 9933b18a46..017057c1f2 100644 --- a/x/pairing/keeper/msg_server_relay_payment.go +++ b/x/pairing/keeper/msg_server_relay_payment.go @@ -332,13 +332,13 @@ func (k msgServer) RelayPayment(goCtx context.Context, msg *types.MsgRelayPaymen } func (k msgServer) setStakeEntryBlockReport(ctx sdk.Context, providerAddr string, chainID string, latestBlock uint64) { - stakeEntry, found := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, providerAddr) + stakeEntry, found := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainID, providerAddr) if found { stakeEntry.BlockReport = &epochstoragetypes.BlockReport{ Epoch: k.epochStorageKeeper.GetEpochStart(ctx), LatestBlock: latestBlock, } - k.epochStorageKeeper.ModifyStakeEntryCurrent(ctx, chainID, stakeEntry) + k.epochStorageKeeper.SetStakeEntryCurrent(ctx, stakeEntry) } } diff --git a/x/pairing/keeper/msg_server_relay_payment_gov_test.go b/x/pairing/keeper/msg_server_relay_payment_gov_test.go index 0d9d15e1ab..f1b4499bfb 100644 --- a/x/pairing/keeper/msg_server_relay_payment_gov_test.go +++ b/x/pairing/keeper/msg_server_relay_payment_gov_test.go @@ -497,10 +497,6 @@ func TestStakePaymentUnstake(t *testing.T) { paramVal = "\"" + strconv.FormatUint(10, 10) + "\"" err = ts.TxProposalChangeParam(epochstoragetypes.ModuleName, paramKey, paramVal) require.NoError(t, err) - paramKey = string(epochstoragetypes.KeyUnstakeHoldBlocks) - paramVal = "\"" + strconv.FormatUint(210, 10) + "\"" - err = ts.TxProposalChangeParam(epochstoragetypes.ModuleName, paramKey, paramVal) - require.NoError(t, err) // Advance an epoch to apply EpochBlocks change ts.AdvanceEpoch() // blockHeight = 20 diff --git a/x/pairing/keeper/msg_server_relay_payment_test.go b/x/pairing/keeper/msg_server_relay_payment_test.go index 15c1076728..576ae4d5f0 100644 --- a/x/pairing/keeper/msg_server_relay_payment_test.go +++ b/x/pairing/keeper/msg_server_relay_payment_test.go @@ -166,9 +166,7 @@ func TestRelayPaymentNotUnstakingProviderForUnresponsivenessIfNoEpochInformation require.NoError(t, err) // test that the provider was not unstaked - _, unStakeStoragefound := ts.Keepers.Epochstorage.UnstakeEntryByAddress(ts.Ctx, provider2) - require.False(t, unStakeStoragefound) - _, stakeStorageFound := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Name, provider2) + _, stakeStorageFound := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Name, provider2) require.True(t, stakeStorageFound) } @@ -270,9 +268,7 @@ func TestRelayPaymentNotUnstakingProviderForUnresponsivenessBecauseOfServices(t require.NoError(t, err) // test that the provider was not unstaked. - _, unStakeStoragefound := ts.Keepers.Epochstorage.UnstakeEntryByAddress(ts.Ctx, provider2) - require.False(t, unStakeStoragefound) - _, stakeStorageFound := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Name, provider2) + _, stakeStorageFound := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Name, provider2) require.True(t, stakeStorageFound) } diff --git a/x/pairing/keeper/msg_server_stake_provider_test.go b/x/pairing/keeper/msg_server_stake_provider_test.go index 8261cc89f6..ecdee17001 100644 --- a/x/pairing/keeper/msg_server_stake_provider_test.go +++ b/x/pairing/keeper/msg_server_stake_provider_test.go @@ -27,7 +27,7 @@ func TestModifyStakeProviderWithDescription(t *testing.T) { providerAcct, providerAddr := ts.GetAccount(common.PROVIDER, 0) // Get the stake entry and check the provider is staked - stakeEntry, foundProvider := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, providerAddr) + stakeEntry, foundProvider := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, providerAddr) require.True(t, foundProvider) require.True(t, stakeEntry.Description.Equal(common.MockDescription())) @@ -38,7 +38,7 @@ func TestModifyStakeProviderWithDescription(t *testing.T) { ts.AdvanceEpoch() // Get the stake entry and check the provider is staked - stakeEntry, foundProvider = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, providerAddr) + stakeEntry, foundProvider = ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, providerAddr) require.True(t, foundProvider) require.True(t, stakeEntry.Description.Equal(dNew)) } @@ -661,7 +661,7 @@ func TestStakeEndpoints(t *testing.T) { if play.success { require.NoError(t, err) - providerEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, providerAddr) + providerEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, providerAddr) require.True(t, found) addons := 0 extensions := 0 @@ -720,7 +720,7 @@ func TestStakeProviderLimits(t *testing.T) { return } require.NoError(t, err) - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, addr) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, addr) require.True(t, found) require.Equal(t, tt.isFrozen, stakeEntry.IsFrozen()) }) @@ -743,7 +743,7 @@ func TestUnfreezeWithDelegations(t *testing.T) { providerAcc, provider := ts.AddAccount(common.PROVIDER, 1, minSelfDelegation.Amount.Int64()+1) err := ts.StakeProviderExtra(providerAcc.GetVaultAddr(), provider, ts.spec, minSelfDelegation.Amount.Int64()+1, nil, 0, "", "", "", "", "") require.NoError(t, err) - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) require.True(t, stakeEntry.IsFrozen()) require.Equal(t, minSelfDelegation.Amount.AddRaw(1), stakeEntry.EffectiveStake()) @@ -753,10 +753,10 @@ func TestUnfreezeWithDelegations(t *testing.T) { require.Error(t, err) // increase delegation limit of stake entry from 0 to MinStakeProvider + 100 - stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) stakeEntry.DelegateLimit = ts.spec.MinStakeProvider.AddAmount(math.NewInt(100)) - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() // add delegator and delegate to provider so its effective stake is MinStakeProvider+MinSelfDelegation+1 @@ -765,7 +765,7 @@ func TestUnfreezeWithDelegations(t *testing.T) { _, err = ts.TxDualstakingDelegate(consumer, provider, ts.spec.Index, ts.spec.MinStakeProvider) require.NoError(t, err) ts.AdvanceEpoch() // apply delegation - stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, provider) + stakeEntry, found = ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, provider) require.True(t, found) require.True(t, stakeEntry.IsFrozen()) require.Equal(t, ts.spec.MinStakeProvider.Add(minSelfDelegation).Amount.AddRaw(1), stakeEntry.EffectiveStake()) @@ -881,7 +881,7 @@ func TestVaultProviderNewStakeEntry(t *testing.T) { require.Equal(t, providerBefore, providerAfter) // stake entry - _, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, tt.spec.Index, tt.provider.String()) + _, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, tt.spec.Index, tt.provider.String()) require.True(t, found) // should be found because provider is registered in a vaild stake entry // delegations @@ -900,7 +900,7 @@ func TestVaultProviderNewStakeEntry(t *testing.T) { } // stake entry - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, tt.spec.Index, tt.provider.String()) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, tt.spec.Index, tt.provider.String()) require.True(t, found) require.Equal(t, testStake, stakeEntry.Stake.Amount.Int64()) require.Equal(t, int64(0), stakeEntry.DelegateTotal.Amount.Int64()) @@ -960,7 +960,7 @@ func TestVaultProviderExistingStakeEntry(t *testing.T) { require.Equal(t, beforeProvider, afterProvider) // stake entry - _, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, tt.spec.Index, tt.provider.String()) + _, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, tt.spec.Index, tt.provider.String()) require.True(t, found) // should be found because provider is registered in a vaild stake entry // delegations @@ -979,7 +979,7 @@ func TestVaultProviderExistingStakeEntry(t *testing.T) { } // stake entry - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, tt.spec.Index, tt.provider.String()) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, tt.spec.Index, tt.provider.String()) require.True(t, found) require.Equal(t, testStake+100, stakeEntry.Stake.Amount.Int64()) require.Equal(t, int64(0), stakeEntry.DelegateTotal.Amount.Int64()) @@ -1011,7 +1011,7 @@ func TestVaultProviderModifyStakeEntry(t *testing.T) { vault := acc.GetVaultAddr() valAcc, _ := ts.GetAccount(common.VALIDATOR, 0) - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, acc.Addr.String()) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, acc.Addr.String()) require.True(t, found) // consts for stake entry changes @@ -1100,7 +1100,7 @@ func TestVaultProviderModifyStakeEntry(t *testing.T) { } // reset stake entry - ts.Keepers.Epochstorage.ModifyStakeEntryCurrent(ts.Ctx, ts.spec.Index, stakeEntry) + ts.Keepers.Epochstorage.SetStakeEntryCurrent(ts.Ctx, stakeEntry) ts.AdvanceEpoch() }) } @@ -1215,7 +1215,7 @@ func TestDelegatorAfterProviderUnstakeAndStake(t *testing.T) { // apple should be able to unbond. After this, banana has one delegation: orange->banana err = ts.StakeProvider(orange, banana, ts.spec, testBalance/4) require.NoError(t, err) - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, orange) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, orange) require.True(t, found) require.NotZero(t, stakeEntry.DelegateTotal.Amount.Int64()) @@ -1233,7 +1233,7 @@ func TestDelegatorAfterProviderUnstakeAndStake(t *testing.T) { // apple should be able to unbond. After this, banana has no delegations err = ts.StakeProvider(banana, orange, ts.spec, testBalance/4) require.NoError(t, err) - stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Index, banana) + stakeEntry, found := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Index, banana) require.True(t, found) require.Zero(t, stakeEntry.DelegateTotal.Amount.Int64()) diff --git a/x/pairing/keeper/msg_server_stake_unstake_gov_test.go b/x/pairing/keeper/msg_server_stake_unstake_gov_test.go index f0445cf82a..aa519df090 100644 --- a/x/pairing/keeper/msg_server_stake_unstake_gov_test.go +++ b/x/pairing/keeper/msg_server_stake_unstake_gov_test.go @@ -4,7 +4,6 @@ import ( "strconv" "testing" - "github.com/lavanet/lava/v2/testutil/common" epochstoragetypes "github.com/lavanet/lava/v2/x/epochstorage/types" "github.com/stretchr/testify/require" ) @@ -49,19 +48,18 @@ func TestStakeGovEpochBlocksDecrease(t *testing.T) { // define tests tests := []struct { - name string - epoch uint64 - shouldBeStaked bool + name string + epoch uint64 }{ - {"ShouldntBeStaked", epochShouldntBeStaked, true}, // 11 blocks have passed since the stake - not enough blocks - {"ShouldBeStaked", epochShouldBeStaked, true}, // 21 blocks have passed - enough blocks + {"ShouldntBeStaked", epochShouldntBeStaked}, // 11 blocks have passed since the stake - not enough blocks + {"ShouldBeStaked", epochShouldBeStaked}, // 21 blocks have passed - enough blocks } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // check if the provider/client are staked - _, foundProvider, _ := ts.Keepers.Epochstorage.GetEpochStakeEntries(ts.Ctx, tt.epoch, ts.spec.GetIndex()) - require.Equal(t, tt.shouldBeStaked, foundProvider) + entries := ts.Keepers.Epochstorage.GetAllStakeEntriesForEpoch(ts.Ctx, tt.epoch) + require.Len(t, entries, 1) }) } } @@ -118,106 +116,12 @@ func TestStakeGovEpochBlocksIncrease(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // check if the provider/client are staked - _, found, _ := ts.Keepers.Epochstorage.GetEpochStakeEntries(ts.Ctx, tt.epoch, ts.spec.GetIndex()) - require.Equal(t, tt.shouldBeStaked, found) + entries := ts.Keepers.Epochstorage.GetAllStakeEntriesForEpoch(ts.Ctx, tt.epoch) + if tt.shouldBeStaked { + require.Len(t, entries, 1) + } else { + require.Len(t, entries, 0) + } }) } } - -// Test that if UnstakeHoldBlocks decreases then the provider gets the funds back only by the original -// value (return_funds_block = next_epoch(current_block + max(UnstakeHoldBlocks, BlocksToSave))) -func TestUnstakeGovUnstakeHoldBlocksDecrease(t *testing.T) { - ts := newTester(t) - ts.setupForPayments(1, 0, 0) // 1 provider, 0 client, default providers-to-pair - - providerAcct, _ := ts.GetAccount(common.PROVIDER, 0) - - // make sure EpochBlocks default value is 20 and UnstakeHoldBlocks is 210 - paramKey := string(epochstoragetypes.KeyEpochBlocks) - paramVal := "\"" + strconv.FormatUint(20, 10) + "\"" - err := ts.TxProposalChangeParam(epochstoragetypes.ModuleName, paramKey, paramVal) - require.NoError(t, err) - - paramKey = string(epochstoragetypes.KeyUnstakeHoldBlocks) - paramVal = "\"" + strconv.FormatUint(210, 10) + "\"" - err = ts.TxProposalChangeParam(epochstoragetypes.ModuleName, paramKey, paramVal) - require.NoError(t, err) - - // Advance an epoch to apply the changes - ts.AdvanceEpoch() // blockHeight = 20 - - // change the UnstakeHoldBlocks parameter to 60 - paramKey = string(epochstoragetypes.KeyUnstakeHoldBlocks) - paramVal = "\"" + strconv.FormatUint(60, 10) + "\"" - err = ts.TxProposalChangeParam(epochstoragetypes.ModuleName, paramKey, paramVal) - require.NoError(t, err) - - // Advance to blockHeight = 39, one block before the UnstakeHoldBlocks change apply - ts.AdvanceBlocks(19) - - // Unstake the provider: - // should get the funds on block #260 (39+210 = 249 -> next epoch start in 260) - _, err = ts.TxPairingUnstakeProvider(providerAcct.GetVaultAddr(), ts.spec.Index) - require.NoError(t, err) - - // Advance a block to complete the epoch and apply UnstakeHoldBlocks change to 60 - // if the unstaking refers to 60 (wrongly, since they unstaked before the change applied), - // they are supposed to get the funds back on block #240 (39+200(=BlockToSave) = 240 -> - // this is a start of a new epoch) - ts.AdvanceBlock() // blockHeight = 40 - - // Advance 10 epochs to get to block #240. At this point, they shouldn't get their funds back - ts.AdvanceEpochs(10) - - // Advance another epoch to block #260. Now they should get their funds back - ts.AdvanceEpoch() // blockHeight = 260 -} - -// Test that if the UnstakeHoldBlocks param increases make then the provider gets the funds back only -// by the original value (return_funds_block = next_epoch(current_block + max(UnstakeHoldBlocks, BlocksToSave))) -func TestUnstakeGovUnstakeHoldBlocksIncrease(t *testing.T) { - ts := newTester(t) - ts.setupForPayments(1, 0, 0) // 1 provider, 0 client, default providers-to-pair - - providerAcct, _ := ts.GetAccount(common.PROVIDER, 0) - - // make sure EpochBlocks default value is 20 and UnstakeHoldBlocks is 210 - paramKey := string(epochstoragetypes.KeyEpochBlocks) - paramVal := "\"" + strconv.FormatUint(20, 10) + "\"" - err := ts.TxProposalChangeParam(epochstoragetypes.ModuleName, paramKey, paramVal) - require.NoError(t, err) - - paramKey = string(epochstoragetypes.KeyUnstakeHoldBlocks) - paramVal = "\"" + strconv.FormatUint(210, 10) + "\"" - err = ts.TxProposalChangeParam(epochstoragetypes.ModuleName, paramKey, paramVal) - require.NoError(t, err) - - // Advance an epoch to apply the changes. - ts.AdvanceEpoch() // blockHeight = 20 - - // change the UnstakeHoldBlocks parameter to 280 - paramKey = string(epochstoragetypes.KeyUnstakeHoldBlocks) - paramVal = "\"" + strconv.FormatUint(280, 10) + "\"" - err = ts.TxProposalChangeParam(epochstoragetypes.ModuleName, paramKey, paramVal) - require.NoError(t, err) - - // Advance to blockHeight = 39, one block before the UnstakeHoldBlocks change apply - ts.AdvanceBlocks(19) - - // Unstake the provider: - // should get the funds back on block #260 (39+210 = 249 -> next epoch start in 260) - _, err = ts.TxPairingUnstakeProvider(providerAcct.GetVaultAddr(), ts.spec.Index) - require.NoError(t, err) - - // Advance a block to complete the epoch and apply UnstakeHoldBlocks change to 280 - // if the unstaking refers to 280 (wrongly, since they unstaked before the change applied), - // they are supposed to get the funds back on block #320 (40+280 = 320 -> - // this is a start of a new epoch) - ts.AdvanceBlock() // blockHeight = 40 - - // Advance 11 epochs to get to block #260. At this point, they should get their funds back - ts.AdvanceEpochs(11) - - // Advance 3 more epoch to block #320. Now they definitely should get their funds back - ts.AdvanceEpochs(14) -} diff --git a/x/pairing/keeper/msg_server_unfreeze.go b/x/pairing/keeper/msg_server_unfreeze.go index 14a654df0c..35bbda74cd 100644 --- a/x/pairing/keeper/msg_server_unfreeze.go +++ b/x/pairing/keeper/msg_server_unfreeze.go @@ -15,7 +15,7 @@ func (k msgServer) UnfreezeProvider(goCtx context.Context, msg *types.MsgUnfreez unfreezeBlock := k.epochStorageKeeper.GetCurrentNextEpoch(ctx) + 1 unfrozen_chains := []string{} for _, chainId := range msg.GetChainIds() { - stakeEntry, found := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainId, msg.Creator) + stakeEntry, found := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainId, msg.Creator) if !found { return nil, utils.LavaFormatWarning("Unfreeze_cant_get_stake_entry", types.FreezeStakeEntryNotFoundError, []utils.Attribute{{Key: "chainID", Value: chainId}, {Key: "providerAddress", Value: msg.GetCreator()}}...) } @@ -49,7 +49,7 @@ func (k msgServer) UnfreezeProvider(goCtx context.Context, msg *types.MsgUnfreez stakeEntry.UnFreeze(unfreezeBlock) stakeEntry.JailEndTime = 0 stakeEntry.Jails = 0 - k.epochStorageKeeper.ModifyStakeEntryCurrent(ctx, chainId, stakeEntry) + k.epochStorageKeeper.SetStakeEntryCurrent(ctx, stakeEntry) unfrozen_chains = append(unfrozen_chains, chainId) } utils.LogLavaEvent(ctx, ctx.Logger(), "unfreeze_provider", map[string]string{"providerAddress": msg.GetCreator(), "chainIDs": strings.Join(unfrozen_chains, ",")}, "Provider Unfreeze") diff --git a/x/pairing/keeper/msg_server_unstake_provider_test.go b/x/pairing/keeper/msg_server_unstake_provider_test.go index a7ca917f73..e58960b196 100644 --- a/x/pairing/keeper/msg_server_unstake_provider_test.go +++ b/x/pairing/keeper/msg_server_unstake_provider_test.go @@ -4,42 +4,9 @@ import ( "testing" "github.com/lavanet/lava/v2/testutil/common" - spectypes "github.com/lavanet/lava/v2/x/spec/types" "github.com/stretchr/testify/require" ) -func TestUnstakeStaticProvider(t *testing.T) { - ts := newTester(t) - - // will overwrite the default "mock" spec - ts.spec.ProvidersTypes = spectypes.Spec_static - ts.AddSpec("mock", ts.spec) - - balance := 5 * ts.spec.MinStakeProvider.Amount.Int64() - providerAcct, provider := ts.AddAccount(common.PROVIDER, 0, balance) - - err := ts.StakeProvider(providerAcct.GetVaultAddr(), provider, ts.spec, balance/2) - require.NoError(t, err) - - ts.AdvanceEpoch() - - unstakeHoldBlocks := ts.Keepers.Epochstorage.UnstakeHoldBlocks(ts.Ctx, ts.BlockHeight()) - unstakeHoldBlocksStatic := ts.Keepers.Epochstorage.UnstakeHoldBlocksStatic(ts.Ctx, ts.BlockHeight()) - - _, err = ts.TxPairingUnstakeProvider(providerAcct.GetVaultAddr(), ts.spec.Index) - require.NoError(t, err) - - ts.AdvanceBlocks(unstakeHoldBlocks) - - _, found := ts.Keepers.Epochstorage.UnstakeEntryByAddress(ts.Ctx, provider) - require.True(t, found) - - ts.AdvanceBlocks(unstakeHoldBlocksStatic - unstakeHoldBlocks) - - _, found = ts.Keepers.Epochstorage.UnstakeEntryByAddress(ts.Ctx, provider) - require.False(t, found) -} - // TestVaultProviderUnstake tests that only the vault address can unstake. // Scenarios: // 1. unstake with vault -> should work diff --git a/x/pairing/keeper/pairing.go b/x/pairing/keeper/pairing.go index 6f132556e1..9d1732d98f 100644 --- a/x/pairing/keeper/pairing.go +++ b/x/pairing/keeper/pairing.go @@ -121,10 +121,11 @@ func (k Keeper) getPairingForClient(ctx sdk.Context, chainID string, block uint6 if err != nil { return nil, 0, nil, fmt.Errorf("invalid pairing data: %s", err) } - stakeEntries, found, epochHash := k.epochStorageKeeper.GetEpochStakeEntries(ctx, epoch, chainID) - if !found { + stakeEntries := k.epochStorageKeeper.GetAllStakeEntriesForEpochChainId(ctx, epoch, chainID) + if len(stakeEntries) == 0 { return nil, 0, nil, fmt.Errorf("did not find providers for pairing: epoch:%d, chainID: %s", block, chainID) } + epochHash := k.epochStorageKeeper.GetEpochHash(ctx, epoch) if providersType == spectypes.Spec_static { frozenFilter := pairingfilters.FrozenProvidersFilter{} diff --git a/x/pairing/keeper/pairing_test.go b/x/pairing/keeper/pairing_test.go index bbec8a799b..74165525af 100644 --- a/x/pairing/keeper/pairing_test.go +++ b/x/pairing/keeper/pairing_test.go @@ -517,9 +517,8 @@ func TestAddonPairing(t *testing.T) { err = ts.addProviderEndpoints(2, optionalSupportingEndpoints) // this errors out require.Error(t, err) - stakeStorage, found := ts.Keepers.Epochstorage.GetStakeStorageCurrent(ts.Ctx, ts.spec.Index) - require.True(t, found) - require.Len(t, stakeStorage.StakeEntries, 12) + entries := ts.Keepers.Epochstorage.GetAllStakeEntriesCurrentForChainId(ts.Ctx, ts.spec.Index) + require.Len(t, entries, 12) for _, tt := range templates { t.Run(tt.name, func(t *testing.T) { @@ -1967,9 +1966,8 @@ func TestExtensionAndAddonPairing(t *testing.T) { err = ts.addProviderEndpoints(2, optionalExtSupportingEndpoints) // this errors as it doesnt implement mandatory require.Error(t, err) - stakeStorage, found := ts.Keepers.Epochstorage.GetStakeStorageCurrent(ts.Ctx, ts.spec.Index) - require.True(t, found) - require.Len(t, stakeStorage.StakeEntries, 26) // one for stub and 25 others + entries := ts.Keepers.Epochstorage.GetAllStakeEntriesCurrentForChainId(ts.Ctx, ts.spec.Index) + require.Len(t, entries, 26) // one for stub and 25 others for _, tt := range templates { t.Run(tt.name, func(t *testing.T) { diff --git a/x/pairing/keeper/staking.go b/x/pairing/keeper/staking.go index cf6c2d8983..5cfab4fb38 100644 --- a/x/pairing/keeper/staking.go +++ b/x/pairing/keeper/staking.go @@ -78,7 +78,7 @@ func (k Keeper) StakeNewEntry(ctx sdk.Context, validator, creator, chainID strin // new staking takes effect from the next block stakeAppliedBlock := uint64(ctx.BlockHeight()) + 1 - existingEntry, entryExists := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, creator) + existingEntry, entryExists := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainID, creator) if entryExists { // modify the entry (check who's modifying - vault/provider) isProvider := false @@ -166,7 +166,7 @@ func (k Keeper) StakeNewEntry(ctx sdk.Context, validator, creator, chainID strin existingEntry.DelegateLimit = delegationLimit existingEntry.LastChange = uint64(ctx.BlockTime().UTC().Unix()) - k.epochStorageKeeper.ModifyStakeEntryCurrent(ctx, chainID, existingEntry) + k.epochStorageKeeper.SetStakeEntryCurrent(ctx, existingEntry) if amount.Amount.GT(existingEntry.Stake.Amount) { // delegate the difference @@ -203,7 +203,7 @@ func (k Keeper) StakeNewEntry(ctx sdk.Context, validator, creator, chainID strin // check that the configured provider is not used by another vault (when the provider and creator (vault) addresses are not equal) if provider != creator { - providerStakeEntry, entryExists := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, provider) + providerStakeEntry, entryExists := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainID, provider) if entryExists { return utils.LavaFormatWarning("configured provider exists", fmt.Errorf("new provider not staked"), utils.LogAttr("provider", provider), @@ -263,7 +263,7 @@ func (k Keeper) StakeNewEntry(ctx sdk.Context, validator, creator, chainID strin LastChange: uint64(ctx.BlockTime().UTC().Unix()), } - k.epochStorageKeeper.AppendStakeEntryCurrent(ctx, chainID, stakeEntry) + k.epochStorageKeeper.SetStakeEntryCurrent(ctx, stakeEntry) err = k.dualstakingKeeper.DelegateFull(ctx, stakeEntry.Vault, validator, stakeEntry.Address, chainID, amount) if err != nil { @@ -345,7 +345,7 @@ func (k Keeper) validateGeoLocationAndApiInterfaces(endpoints []epochstoragetype } func (k Keeper) GetStakeEntry(ctx sdk.Context, chainID string, provider string) (epochstoragetypes.StakeEntry, error) { - stakeEntry, found := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, provider) + stakeEntry, found := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainID, provider) if !found { return epochstoragetypes.StakeEntry{}, utils.LavaFormatWarning("provider not staked on chain", fmt.Errorf("cannot get stake entry"), utils.Attribute{Key: "chainID", Value: chainID}, diff --git a/x/pairing/keeper/unresponsive_provider.go b/x/pairing/keeper/unresponsive_provider.go index f83df2e870..d34a2da4de 100644 --- a/x/pairing/keeper/unresponsive_provider.go +++ b/x/pairing/keeper/unresponsive_provider.go @@ -53,10 +53,9 @@ func (k Keeper) PunishUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUF return } - // Get the current stake storages (from all chains). - // Stake storages contain a list of stake entries (each for a different chain). - providerStakeStorageList := k.getCurrentProviderStakeStorageList(ctx) - if len(providerStakeStorageList) == 0 { + // Get the current stake entries (from all chains). + currentStakeEntries := k.epochStorageKeeper.GetAllStakeEntriesCurrent(ctx) + if len(currentStakeEntries) == 0 { // no provider is staked -> no one to punish return } @@ -78,21 +77,15 @@ func (k Keeper) PunishUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUF } } - ProviderChainID := func(provider, chainID string) string { - return provider + " " + chainID - } - // check all supported providers from all geolocations prior to making decisions existingProviders := map[string]uint64{} - stakeEntries := map[string]epochstoragetypes.StakeEntry{} - for _, providerStakeStorage := range providerStakeStorageList { - providerStakeEntriesForChain := providerStakeStorage.GetStakeEntries() - // count providers per geolocation - for _, providerStakeEntry := range providerStakeEntriesForChain { - if !providerStakeEntry.IsFrozen() { - existingProviders[providerStakeEntry.GetChain()]++ - } - stakeEntries[ProviderChainID(providerStakeEntry.Address, providerStakeEntry.Chain)] = providerStakeEntry + currentStakeEntriesMap := map[string]epochstoragetypes.StakeEntry{} + + // count providers per geolocation + for _, entry := range currentStakeEntries { + if !entry.IsFrozen() { + existingProviders[entry.GetChain()]++ + currentStakeEntriesMap[stakeEntriesMapKey(entry.Chain, entry.Address)] = entry } } @@ -102,7 +95,8 @@ func (k Keeper) PunishUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUF pecsDetailed := k.GetAllProviderEpochComplainerCuStore(ctx) complainedProviders := map[string]map[uint64]types.ProviderEpochComplainerCu{} // map[provider chainID]map[epoch]ProviderEpochComplainerCu for _, pec := range pecsDetailed { - entry, ok := stakeEntries[ProviderChainID(pec.Provider, pec.ChainId)] + key := stakeEntriesMapKey(pec.ChainId, pec.Provider) + entry, ok := currentStakeEntriesMap[key] if ok { if minHistoryBlock < entry.StakeAppliedBlock && entry.Jails == 0 { // this staked provider has too short history (either since staking @@ -113,8 +107,6 @@ func (k Keeper) PunishUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUF continue } - key := ProviderChainID(pec.Provider, pec.ChainId) - if _, ok := complainedProviders[key]; !ok { complainedProviders[key] = map[uint64]types.ProviderEpochComplainerCu{pec.Epoch: pec.ProviderEpochComplainerCu} keys = append(keys, key) @@ -133,8 +125,8 @@ func (k Keeper) PunishUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUF // go over all the providers, count the complainers CU and punish providers for _, key := range keys { components := strings.Split(key, " ") - provider := components[0] - chainID := components[1] + chainID := components[0] + provider := components[1] // update the CU count for this provider in providerCuCounterForUnreponsivenessMap epochs, complaintCU, servicedCU, err := k.countCuForUnresponsiveness(ctx, provider, chainID, minPaymentBlock, epochsNumToCheckCUForUnresponsiveProvider, epochsNumToCheckCUForComplainers, complainedProviders[key]) if err != nil { @@ -146,7 +138,7 @@ func (k Keeper) PunishUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUF // providerPaymentStorageKeyList is not empty -> provider should be punished if len(epochs) != 0 && existingProviders[chainID] > minProviders { - entry, ok := stakeEntries[key] + entry, ok := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainID, provider) if !ok { utils.LavaFormatError("Jail_cant_get_stake_entry", types.FreezeStakeEntryNotFoundError, []utils.Attribute{{Key: "chainID", Value: chainID}, {Key: "providerAddress", Value: provider}}...) continue @@ -162,6 +154,10 @@ func (k Keeper) PunishUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUF } } +func stakeEntriesMapKey(chainID string, address string) string { + return chainID + " " + address +} + // getBlockEpochsAgo returns the block numEpochs back from the given blockHeight func (k Keeper) getBlockEpochsAgo(ctx sdk.Context, blockHeight, numEpochs uint64) (uint64, error) { for counter := 0; counter < int(numEpochs); counter++ { @@ -222,25 +218,6 @@ func (k Keeper) countCuForUnresponsiveness(ctx sdk.Context, provider, chainId st return nil, complainersCu, servicedCu, nil } -// Function that return the current stake storage for all chains -func (k Keeper) getCurrentProviderStakeStorageList(ctx sdk.Context) []epochstoragetypes.StakeStorage { - var stakeStorageList []epochstoragetypes.StakeStorage - - // get all chain IDs - chainIdList := k.specKeeper.GetAllChainIDs(ctx) - - // go over all chain IDs and keep their stake storage. If there is no stake storage for a specific chain, continue to the next one - for _, chainID := range chainIdList { - stakeStorage, found := k.epochStorageKeeper.GetStakeStorageCurrent(ctx, chainID) - if !found { - continue - } - stakeStorageList = append(stakeStorageList, stakeStorage) - } - - return stakeStorageList -} - // Function that punishes providers. Current punishment is freeze func (k Keeper) punishUnresponsiveProvider(ctx sdk.Context, epochs []uint64, stakeEntry epochstoragetypes.StakeEntry, complaintCU uint64, servicedCU uint64) error { // if last jail was more than 24H ago, reset the jails counter @@ -275,7 +252,7 @@ func (k Keeper) punishUnresponsiveProvider(ctx sdk.Context, epochs []uint64, sta utils.LogLavaEvent(ctx, k.Logger(ctx), types.ProviderTemporaryJailedEventName, details, "Unresponsive provider was jailed due to unresponsiveness") } - k.epochStorageKeeper.ModifyStakeEntryCurrent(ctx, stakeEntry.Chain, stakeEntry) + k.epochStorageKeeper.SetStakeEntryCurrent(ctx, stakeEntry) // reset the provider's complainer CU (so he won't get punished for the same complaints twice) k.resetComplainersCU(ctx, epochs, stakeEntry.Address, stakeEntry.Chain) diff --git a/x/pairing/keeper/unresponsive_provider_test.go b/x/pairing/keeper/unresponsive_provider_test.go index 47e2e0ef8f..62a8d75d86 100644 --- a/x/pairing/keeper/unresponsive_provider_test.go +++ b/x/pairing/keeper/unresponsive_provider_test.go @@ -14,7 +14,7 @@ import ( ) func (ts *tester) checkProviderJailed(provider string, shouldFreeze bool) { - stakeEntry, stakeStorageFound := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Name, provider) + stakeEntry, stakeStorageFound := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Name, provider) require.True(ts.T, stakeStorageFound) require.Equal(ts.T, shouldFreeze, stakeEntry.IsJailed(ts.Ctx.BlockTime().UTC().Unix())) if shouldFreeze { @@ -34,9 +34,7 @@ func (ts *tester) checkComplainerReset(provider string, epoch uint64) { } func (ts *tester) checkProviderStaked(provider string) { - _, unstakeStoragefound := ts.Keepers.Epochstorage.UnstakeEntryByAddress(ts.Ctx, provider) - require.False(ts.T, unstakeStoragefound) - _, stakeStorageFound := ts.Keepers.Epochstorage.GetStakeEntryByAddressCurrent(ts.Ctx, ts.spec.Name, provider) + _, stakeStorageFound := ts.Keepers.Epochstorage.GetStakeEntryCurrent(ts.Ctx, ts.spec.Name, provider) require.True(ts.T, stakeStorageFound) } diff --git a/x/pairing/keeper/unstaking.go b/x/pairing/keeper/unstaking.go index ef096c60e6..8caa313f38 100644 --- a/x/pairing/keeper/unstaking.go +++ b/x/pairing/keeper/unstaking.go @@ -28,7 +28,7 @@ func (k Keeper) UnstakeEntry(ctx sdk.Context, validator, chainID, creator, unsta ) } - existingEntry, entryExists := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, creator) + existingEntry, entryExists := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainID, creator) if !entryExists { return utils.LavaFormatWarning("can't unstake Entry, stake entry not found for address", fmt.Errorf("stake entry not found"), utils.Attribute{Key: "provider", Value: creator}, @@ -45,6 +45,7 @@ func (k Keeper) UnstakeEntry(ctx sdk.Context, validator, chainID, creator, unsta ) } + // the stake entry is removed inside UnbondFull err := k.dualstakingKeeper.UnbondFull(ctx, existingEntry.Vault, validator, existingEntry.Address, existingEntry.GetChain(), existingEntry.Stake, true) if err != nil { return utils.LavaFormatWarning("can't unbond self delegation", err, @@ -53,18 +54,6 @@ func (k Keeper) UnstakeEntry(ctx sdk.Context, validator, chainID, creator, unsta ) } - // index might have changed in the unbond - _, found = k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, existingEntry.Address) - if found { - err = k.epochStorageKeeper.RemoveStakeEntryCurrent(ctx, chainID, creator) - if err != nil { - return utils.LavaFormatWarning("can't remove stake Entry, stake entry not found", err, - utils.Attribute{Key: "provider", Value: creator}, - utils.Attribute{Key: "spec", Value: chainID}, - ) - } - } - details := map[string]string{ "address": existingEntry.GetAddress(), "chainID": existingEntry.GetChain(), @@ -75,16 +64,9 @@ func (k Keeper) UnstakeEntry(ctx sdk.Context, validator, chainID, creator, unsta } utils.LogLavaEvent(ctx, logger, types.ProviderUnstakeEventName, details, unstakeDescription) - unstakeHoldBlocks := k.epochStorageKeeper.GetUnstakeHoldBlocks(ctx, existingEntry.Chain) - k.epochStorageKeeper.AppendUnstakeEntry(ctx, existingEntry, unstakeHoldBlocks) return nil } -func (k Keeper) CheckUnstakingForCommit(ctx sdk.Context) { - // this pops all the entries that had their deadline pass - k.epochStorageKeeper.PopUnstakeEntries(ctx, uint64(ctx.BlockHeight())) -} - func (k Keeper) UnstakeEntryForce(ctx sdk.Context, chainID, provider, unstakeDescription string) error { providerAddr, err := sdk.AccAddressFromBech32(provider) if err != nil { @@ -93,7 +75,7 @@ func (k Keeper) UnstakeEntryForce(ctx sdk.Context, chainID, provider, unstakeDes ) } - existingEntry, entryExists := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, provider) + existingEntry, entryExists := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainID, provider) if !entryExists { return utils.LavaFormatWarning("can't unstake Entry, stake entry not found for address", fmt.Errorf("stake entry not found"), utils.Attribute{Key: "provider", Value: provider}, @@ -123,14 +105,8 @@ func (k Keeper) UnstakeEntryForce(ctx sdk.Context, chainID, provider, unstakeDes } if totalAmount.IsZero() { - existingEntry, _ := k.epochStorageKeeper.GetStakeEntryByAddressCurrent(ctx, chainID, provider) - err = k.epochStorageKeeper.RemoveStakeEntryCurrent(ctx, chainID, provider) - if err != nil { - return utils.LavaFormatWarning("can't remove stake Entry, stake entry not found", err, - utils.Attribute{Key: "provider", Value: provider}, - utils.Attribute{Key: "spec", Value: chainID}, - ) - } + existingEntry, _ := k.epochStorageKeeper.GetStakeEntryCurrent(ctx, chainID, provider) + k.epochStorageKeeper.RemoveStakeEntryCurrent(ctx, chainID, existingEntry.Address) details := map[string]string{ "address": existingEntry.GetAddress(), @@ -142,8 +118,6 @@ func (k Keeper) UnstakeEntryForce(ctx sdk.Context, chainID, provider, unstakeDes } utils.LogLavaEvent(ctx, k.Logger(ctx), types.ProviderUnstakeEventName, details, unstakeDescription) - unstakeHoldBlocks := k.epochStorageKeeper.GetUnstakeHoldBlocks(ctx, existingEntry.Chain) - k.epochStorageKeeper.AppendUnstakeEntry(ctx, existingEntry, unstakeHoldBlocks) return nil } } diff --git a/x/pairing/types/epoch_cu.go b/x/pairing/types/epoch_cu.go index f9442a7939..470c8ea3f5 100644 --- a/x/pairing/types/epoch_cu.go +++ b/x/pairing/types/epoch_cu.go @@ -1,10 +1,11 @@ package types import ( - "encoding/binary" "fmt" "strconv" "strings" + + "github.com/lavanet/lava/v2/utils" ) const ( @@ -14,26 +15,16 @@ const ( ProviderConsumerEpochCuPrefix = "ProviderConsumerEpochCu/" ) -func EncodeBlock(block uint64) []byte { - encodedKey := make([]byte, 8) - binary.BigEndian.PutUint64(encodedKey[0:8], block) - return encodedKey -} - -func DecodeBlock(encodedKey []byte) uint64 { - return binary.BigEndian.Uint64(encodedKey[0:8]) -} - func UniqueEpochSessionKey(epoch uint64, provider string, chainID string, project string, sessionID uint64) []byte { - return append(EncodeBlock(epoch), []byte(strings.Join([]string{provider, chainID, project, strconv.FormatUint(sessionID, 10)}, " "))...) + return append(utils.Serialize(epoch), []byte(strings.Join([]string{provider, chainID, project, strconv.FormatUint(sessionID, 10)}, " "))...) } func ProviderEpochCuKey(epoch uint64, provider string, chainID string) []byte { - return append(EncodeBlock(epoch), []byte(strings.Join([]string{provider, chainID}, " "))...) + return append(utils.Serialize(epoch), []byte(strings.Join([]string{provider, chainID}, " "))...) } func ProviderConsumerEpochCuKey(epoch uint64, provider string, project string, chainID string) []byte { - return append(EncodeBlock(epoch), []byte(strings.Join([]string{provider, project, chainID}, " "))...) + return append(utils.Serialize(epoch), []byte(strings.Join([]string{provider, project, chainID}, " "))...) } func DecodeUniqueEpochSessionKey(key string) (epoch uint64, provider string, chainID string, project string, sessionID uint64, err error) { @@ -45,7 +36,7 @@ func DecodeUniqueEpochSessionKey(key string) (epoch uint64, provider string, cha if len(split) != 4 { return 0, "", "", "", 0, fmt.Errorf("invalid UniqueEpochSession key: bad structure. key: %s", key) } - epoch = DecodeBlock([]byte(key[:8])) + utils.Deserialize([]byte(key[:8]), &epoch) sessionID, err = strconv.ParseUint(split[3], 10, 64) if err != nil { return 0, "", "", "", 0, fmt.Errorf("invalid UniqueEpochSession key: bad session ID. key: %s", key) @@ -61,7 +52,7 @@ func DecodeProviderEpochCuKey(key string) (epoch uint64, provider string, chainI if len(split) != 2 { return 0, "", "", fmt.Errorf("invalid ProviderEpochCu key: bad structure. key: %s", key) } - epoch = DecodeBlock([]byte(key[:8])) + utils.Deserialize([]byte(key[:8]), &epoch) return epoch, split[0], split[1], nil } @@ -73,7 +64,8 @@ func DecodeProviderConsumerEpochCuKey(key string) (epoch uint64, provider string if len(split) != 3 { return 0, "", "", "", fmt.Errorf("invalid ProviderConsumerEpochCu key: bad structure. key: %s", key) } - epoch = DecodeBlock([]byte(key[:8])) + + utils.Deserialize([]byte(key[:8]), &epoch) return epoch, split[0], split[1], split[2], nil } diff --git a/x/pairing/types/expected_keepers.go b/x/pairing/types/expected_keepers.go index 17b0dd0f0c..5daea548e7 100644 --- a/x/pairing/types/expected_keepers.go +++ b/x/pairing/types/expected_keepers.go @@ -35,31 +35,24 @@ type EpochstorageKeeper interface { GetParamForBlock(ctx sdk.Context, fixationKey string, block uint64, param any) error GetEpochStart(ctx sdk.Context) uint64 GetEarliestEpochStart(ctx sdk.Context) uint64 - UnstakeHoldBlocks(ctx sdk.Context, block uint64) (res uint64) - UnstakeHoldBlocksStatic(ctx sdk.Context, block uint64) (res uint64) IsEpochStart(ctx sdk.Context) (res bool) BlocksToSave(ctx sdk.Context, block uint64) (res uint64, erro error) BlocksToSaveRaw(ctx sdk.Context) (res uint64) GetEpochStartForBlock(ctx sdk.Context, block uint64) (epochStart, blockInEpoch uint64, err error) GetPreviousEpochStartForBlock(ctx sdk.Context, block uint64) (previousEpochStart uint64, erro error) - PopUnstakeEntries(ctx sdk.Context, block uint64) (value []epochstoragetypes.StakeEntry) - AppendUnstakeEntry(ctx sdk.Context, stakeEntry epochstoragetypes.StakeEntry, unstakeHoldBlocks uint64) - ModifyUnstakeEntry(ctx sdk.Context, stakeEntry epochstoragetypes.StakeEntry) - GetStakeStorageUnstake(ctx sdk.Context) (epochstoragetypes.StakeStorage, bool) - ModifyStakeEntryCurrent(ctx sdk.Context, chainID string, stakeEntry epochstoragetypes.StakeEntry) - AppendStakeEntryCurrent(ctx sdk.Context, chainID string, stakeEntry epochstoragetypes.StakeEntry) - RemoveStakeEntryCurrent(ctx sdk.Context, chainID string, address string) error - GetStakeEntryByAddressCurrent(ctx sdk.Context, chainID string, address string) (epochstoragetypes.StakeEntry, bool) - UnstakeEntryByAddress(ctx sdk.Context, address string) (value epochstoragetypes.StakeEntry, found bool) - GetStakeStorageCurrent(ctx sdk.Context, chainID string) (value epochstoragetypes.StakeStorage, found bool) - GetEpochStakeEntries(ctx sdk.Context, block uint64, chainID string) (entries []epochstoragetypes.StakeEntry, found bool, epochHash []byte) GetNextEpoch(ctx sdk.Context, block uint64) (nextEpoch uint64, erro error) GetCurrentNextEpoch(ctx sdk.Context) (nextEpoch uint64) AddFixationRegistry(fixationKey string, getParamFunction func(sdk.Context) any) GetDeletedEpochs(ctx sdk.Context) []uint64 EpochBlocks(ctx sdk.Context, block uint64) (res uint64, err error) EpochBlocksRaw(ctx sdk.Context) (res uint64) - GetUnstakeHoldBlocks(ctx sdk.Context, chainID string) uint64 + GetStakeEntryCurrent(ctx sdk.Context, chainID string, provider string) (val epochstoragetypes.StakeEntry, found bool) + GetAllStakeEntriesCurrentForChainId(ctx sdk.Context, chainID string) []epochstoragetypes.StakeEntry + GetAllStakeEntriesForEpochChainId(ctx sdk.Context, epoch uint64, chainID string) []epochstoragetypes.StakeEntry + SetStakeEntryCurrent(ctx sdk.Context, stakeEntry epochstoragetypes.StakeEntry) + GetAllStakeEntriesCurrent(ctx sdk.Context) []epochstoragetypes.StakeEntry + RemoveStakeEntryCurrent(ctx sdk.Context, chainID string, provider string) + GetEpochHash(ctx sdk.Context, epoch uint64) []byte } type AccountKeeper interface { diff --git a/x/rewards/keeper/grpc_query_iprpc_provider_reward.go b/x/rewards/keeper/grpc_query_iprpc_provider_reward.go index 6081b669f1..497c664584 100644 --- a/x/rewards/keeper/grpc_query_iprpc_provider_reward.go +++ b/x/rewards/keeper/grpc_query_iprpc_provider_reward.go @@ -32,7 +32,7 @@ func (k Keeper) IprpcProviderRewardEstimation(goCtx context.Context, req *types. providerIprpcCu := uint64(0) totalIprpcCu := uint64(0) - stakeEntry, found := k.epochstorage.GetStakeEntryByAddressCurrent(ctx, specFund.Spec, req.Provider) + stakeEntry, found := k.epochstorage.GetStakeEntryCurrent(ctx, specFund.Spec, req.Provider) if !found { continue } diff --git a/x/rewards/keeper/providers.go b/x/rewards/keeper/providers.go index f8c1f91a81..5e921734f2 100644 --- a/x/rewards/keeper/providers.go +++ b/x/rewards/keeper/providers.go @@ -139,12 +139,9 @@ func (k Keeper) specEmissionParts(ctx sdk.Context) (emissions []types.SpecEmissi continue } - stakeStorage, found := k.epochstorage.GetStakeStorageCurrent(ctx, chainID) - if !found { - continue - } + stakeEntries := k.epochstorage.GetAllStakeEntriesCurrentForChainId(ctx, chainID) chainStake[chainID] = sdk.ZeroDec() - for _, entry := range stakeStorage.StakeEntries { + for _, entry := range stakeEntries { chainStake[chainID] = chainStake[chainID].Add(sdk.NewDecFromInt(entry.EffectiveStake())) } diff --git a/x/rewards/types/expected_keepers.go b/x/rewards/types/expected_keepers.go index 31db754123..a1cb0221f6 100644 --- a/x/rewards/types/expected_keepers.go +++ b/x/rewards/types/expected_keepers.go @@ -38,8 +38,8 @@ type TimerStoreKeeper interface { } type EpochstorageKeeper interface { - GetStakeStorageCurrent(ctx sdk.Context, chainID string) (epochstoragetypes.StakeStorage, bool) - GetStakeEntryByAddressCurrent(ctx sdk.Context, chainID string, address string) (epochstoragetypes.StakeEntry, bool) + GetStakeEntryCurrent(ctx sdk.Context, chainID string, address string) (epochstoragetypes.StakeEntry, bool) + GetAllStakeEntriesCurrentForChainId(ctx sdk.Context, chainID string) []epochstoragetypes.StakeEntry } type DowntimeKeeper interface { diff --git a/x/subscription/types/expected_keepers.go b/x/subscription/types/expected_keepers.go index 116884fc47..cfe316d684 100644 --- a/x/subscription/types/expected_keepers.go +++ b/x/subscription/types/expected_keepers.go @@ -32,7 +32,7 @@ type EpochstorageKeeper interface { IsEpochStart(ctx sdk.Context) bool GetNextEpoch(ctx sdk.Context, block uint64) (nextEpoch uint64, erro error) GetCurrentNextEpoch(ctx sdk.Context) (nextEpoch uint64) - GetStakeEntryByAddressCurrent(ctx sdk.Context, chainID string, address string) (epochstoragetypes.StakeEntry, bool) + GetStakeEntryCurrent(ctx sdk.Context, chainID string, address string) (epochstoragetypes.StakeEntry, bool) // Methods imported from epochstorage should be defined here }