diff --git a/CHANGELOG.md b/CHANGELOG.md index c0e564eca36c..25800d8001b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## [v0.46.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.7) - 2022-12-13 + ### Features * (client) [#14051](https://github.com/cosmos/cosmos-sdk/pull/14051) Add `--grpc` client option. @@ -50,6 +52,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### State Machine Breaking +* (x/gov) [#14214](https://github.com/cosmos/cosmos-sdk/pull/14214) Fix gov v0.46 migration to v1 votes. + * Also provide a helper function `govv046.Migrate_V0466_To_V0467` for migrating a chain already on v0.46 with versions <=v0.46.6 to the latest v0.46.7 correct state. * (x/group) [#14071](https://github.com/cosmos/cosmos-sdk/pull/14071) Don't re-tally proposal after voting period end if they have been marked as ACCEPTED or REJECTED. ### API Breaking Changes diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9d1711e20caa..cabe154c0b82 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,16 +1,24 @@ -# Cosmos SDK v0.46.6 Release Notes +# Cosmos SDK v0.46.7 Release Notes -This release introduces small bug fixes and improvements. +This release introduces bug fixes and improvements. Notably, the upgrade to Tendermint [v0.34.24](https://github.com/tendermint/tendermint/releases/tag/v0.34.24). Please read the release notes of [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) if you are upgrading from `<=0.46.4`. -Please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md) for an exhaustive list of changes. +A critical vulnerability has been fixed in the group module. For safety, `v0.46.5` and `v0.46.6` are retracted, even though chains not using the group module are not affected. When using the group module, please upgrade immediately to `v0.46.7`. -Full Commit History: https://github.com/cosmos/cosmos-sdk/compare/v0.46.5...v0.46.6 +An issue has been discovered in the gov module's votes migration. It does not impact proposals and votes tallying, but the gRPC queries on votes are incorrect. This issue is fixed in `v0.46.7`, however: +- if your chain is already on v0.46 using `<= v0.46.6`, a **coordinated upgrade** to v0.46.7 is required. You can use the helper function `govv046.Migrate_V046_6_To_V046_7` for migrating a chain **already on v0.46 with versions <=v0.46.6** to the latest v0.46.7 correct state. +- if your chain is on a previous version <= v0.45, then simply use v0.46.7 when upgrading to v0.46. -**NOTE**: The changes mentioned in `v0.46.3` are **still** required: +**NOTE**: The changes mentioned in `v0.46.3` are no longer required. The following replace directive can be removed from the chains. ```go -# Chains must add the following to their go.mod for the application: +# Can be deleted from go.mod replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 ``` + +Instead, `github.com/confio/ics23/go` must be **bumped to `v0.9.0`**. + +Please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md) for an exhaustive list of changes. + +Full Commit History: https://github.com/cosmos/cosmos-sdk/compare/v0.46.6...v0.46.7 diff --git a/contrib/images/simd-env/Dockerfile b/contrib/images/simd-env/Dockerfile index 4c39c6407761..0d3565375837 100644 --- a/contrib/images/simd-env/Dockerfile +++ b/contrib/images/simd-env/Dockerfile @@ -7,7 +7,6 @@ COPY go.mod go.sum /work/ COPY db/go.mod db/go.sum /work/db/ COPY errors/go.mod errors/go.sum /work/errors/ COPY math/go.mod math/go.sum /work/math/ -COPY ./ics23/go/go.mod /work/ics23/go/go.mod RUN go mod download COPY ./ /work diff --git a/go.mod b/go.mod index 318487fe4c25..af7a597cccc2 100644 --- a/go.mod +++ b/go.mod @@ -13,13 +13,13 @@ require ( github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e github.com/cockroachdb/apd/v2 v2.0.2 github.com/coinbase/rosetta-sdk-go v0.7.9 - github.com/confio/ics23/go v0.7.0 - github.com/cosmos/btcutil v1.0.4 + github.com/confio/ics23/go v0.9.0 + github.com/cosmos/btcutil v1.0.5 github.com/cosmos/cosmos-proto v1.0.0-alpha7 github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl v0.19.4 - github.com/cosmos/ledger-cosmos-go v0.11.1 + github.com/cosmos/ledger-cosmos-go v0.12.1 github.com/gogo/gateway v1.1.0 github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 @@ -47,13 +47,13 @@ require ( github.com/spf13/cobra v1.6.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.13.0 - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.8.1 github.com/tendermint/btcd v0.1.1 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.16.0 github.com/tendermint/tendermint v0.34.24 github.com/tendermint/tm-db v0.6.7 - golang.org/x/crypto v0.1.0 + golang.org/x/crypto v0.2.0 golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a google.golang.org/grpc v1.50.1 @@ -77,7 +77,6 @@ require ( github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect - github.com/cosmos/ledger-go v0.9.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/danieljoos/wincred v1.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -140,13 +139,14 @@ require ( github.com/subosito/gotenv v1.4.1 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/ulikunitz/xz v0.5.8 // indirect - github.com/zondax/hid v0.9.0 // indirect + github.com/zondax/hid v0.9.1 // indirect + github.com/zondax/ledger-go v0.14.0 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.23.0 // indirect - golang.org/x/net v0.1.0 // indirect + golang.org/x/net v0.2.0 // indirect golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 // indirect - golang.org/x/sys v0.1.0 // indirect - golang.org/x/term v0.1.0 // indirect + golang.org/x/sys v0.2.0 // indirect + golang.org/x/term v0.2.0 // indirect golang.org/x/text v0.4.0 // indirect golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect google.golang.org/api v0.93.0 // indirect @@ -159,9 +159,6 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 - // vendor ics23 - github.com/confio/ics23/go => ./ics23/go - // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 @@ -171,6 +168,8 @@ replace ( ) retract ( + // subject to a bug in the group module and gov module migration + [v0.46.5, v0.46.6] // subject to the dragonberry vulnerability // and/or the bank coin metadata migration issue [v0.46.0, v0.46.4] diff --git a/go.sum b/go.sum index 07d7539027cd..1a250e71fa80 100644 --- a/go.sum +++ b/go.sum @@ -147,18 +147,17 @@ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= -github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= @@ -215,6 +214,8 @@ github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= +github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= +github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= @@ -226,8 +227,8 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= -github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= +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-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 h1:6YvzjQtc+cDwCe9XwYPPa8zFCxNG79N7vmCjpK+vGOg= @@ -241,10 +242,8 @@ github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok= github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8= -github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= -github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= -github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= -github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= +github.com/cosmos/ledger-cosmos-go v0.12.1 h1:sMBxza5p/rNK/06nBSNmsI/WDqI0pVJFVNihy1Y984w= +github.com/cosmos/ledger-cosmos-go v0.12.1/go.mod h1:dhO6kj+Y+AHIOgAe4L9HL/6NDdyyth4q238I9yFpD2g= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -262,6 +261,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= @@ -924,8 +924,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -934,8 +935,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= @@ -989,8 +991,10 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= -github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= +github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.0 h1:dlMC7aO8Wss1CxBq2I96kZ69Nh1ligzbs8UWOtq/AsA= +github.com/zondax/ledger-go v0.14.0/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= @@ -1037,8 +1041,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE= +golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= 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= @@ -1144,8 +1148,8 @@ golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1283,13 +1287,13 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/ics23/.gitignore b/ics23/.gitignore deleted file mode 100644 index 22d0d82f8095..000000000000 --- a/ics23/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendor diff --git a/ics23/go/Makefile b/ics23/go/Makefile deleted file mode 100644 index aebfcb20d751..000000000000 --- a/ics23/go/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -.PHONY: protoc test - -# make sure we turn on go modules -export GO111MODULE := on - -# PROTOC_FLAGS := -I=.. -I=./vendor -I=$(GOPATH)/src -PROTOC_FLAGS := -I=.. -I=$(GOPATH)/src - -test: - go test . - -protoc: -# @go mod vendor - protoc --gocosmos_out=plugins=interfacetype+grpc,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. $(PROTOC_FLAGS) ../proofs.proto - -install-proto-dep: - @echo "Installing protoc-gen-gocosmos..." - @go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos - - diff --git a/ics23/go/compress.go b/ics23/go/compress.go deleted file mode 100644 index ebe3275e3897..000000000000 --- a/ics23/go/compress.go +++ /dev/null @@ -1,157 +0,0 @@ -package ics23 - -// IsCompressed returns true if the proof was compressed -func IsCompressed(proof *CommitmentProof) bool { - return proof.GetCompressed() != nil -} - -// Compress will return a CompressedBatchProof if the input is BatchProof -// Otherwise it will return the input. -// This is safe to call multiple times (idempotent) -func Compress(proof *CommitmentProof) *CommitmentProof { - batch := proof.GetBatch() - if batch == nil { - return proof - } - return &CommitmentProof{ - Proof: &CommitmentProof_Compressed{ - Compressed: compress(batch), - }, - } -} - -// Decompress will return a BatchProof if the input is CompressedBatchProof -// Otherwise it will return the input. -// This is safe to call multiple times (idempotent) -func Decompress(proof *CommitmentProof) *CommitmentProof { - comp := proof.GetCompressed() - if comp != nil { - return &CommitmentProof{ - Proof: &CommitmentProof_Batch{ - Batch: decompress(comp), - }, - } - } - return proof -} - -func compress(batch *BatchProof) *CompressedBatchProof { - var centries []*CompressedBatchEntry - var lookup []*InnerOp - registry := make(map[string]int32) - - for _, entry := range batch.Entries { - centry := compressEntry(entry, &lookup, registry) - centries = append(centries, centry) - } - - return &CompressedBatchProof{ - Entries: centries, - LookupInners: lookup, - } -} - -func compressEntry(entry *BatchEntry, lookup *[]*InnerOp, registry map[string]int32) *CompressedBatchEntry { - if exist := entry.GetExist(); exist != nil { - return &CompressedBatchEntry{ - Proof: &CompressedBatchEntry_Exist{ - Exist: compressExist(exist, lookup, registry), - }, - } - } - - non := entry.GetNonexist() - return &CompressedBatchEntry{ - Proof: &CompressedBatchEntry_Nonexist{ - Nonexist: &CompressedNonExistenceProof{ - Key: non.Key, - Left: compressExist(non.Left, lookup, registry), - Right: compressExist(non.Right, lookup, registry), - }, - }, - } -} - -func compressExist(exist *ExistenceProof, lookup *[]*InnerOp, registry map[string]int32) *CompressedExistenceProof { - if exist == nil { - return nil - } - res := &CompressedExistenceProof{ - Key: exist.Key, - Value: exist.Value, - Leaf: exist.Leaf, - Path: make([]int32, len(exist.Path)), - } - for i, step := range exist.Path { - res.Path[i] = compressStep(step, lookup, registry) - } - return res -} - -func compressStep(step *InnerOp, lookup *[]*InnerOp, registry map[string]int32) int32 { - bz, err := step.Marshal() - if err != nil { - panic(err) - } - sig := string(bz) - - // load from cache if there - if num, ok := registry[sig]; ok { - return num - } - - // create new step if not there - num := int32(len(*lookup)) - *lookup = append(*lookup, step) - registry[sig] = num - return num -} - -func decompress(comp *CompressedBatchProof) *BatchProof { - lookup := comp.LookupInners - - var entries []*BatchEntry - - for _, centry := range comp.Entries { - entry := decompressEntry(centry, lookup) - entries = append(entries, entry) - } - - return &BatchProof{ - Entries: entries, - } -} - -// TendermintSpec constrains the format from proofs-tendermint (crypto/merkle SimpleProof) -var TendermintSpec = &ProofSpec{ - LeafSpec: &LeafOp{ - Prefix: []byte{0}, - PrehashKey: HashOp_NO_HASH, - Hash: HashOp_SHA256, - PrehashValue: HashOp_SHA256, - Length: LengthOp_VAR_PROTO, - }, - InnerSpec: &InnerSpec{ - ChildOrder: []int32{0, 1}, - MinPrefixLength: 1, - MaxPrefixLength: 1, - ChildSize: 32, // (no length byte) - Hash: HashOp_SHA256, - }, -} - -func decompressExist(exist *CompressedExistenceProof, lookup []*InnerOp) *ExistenceProof { - if exist == nil { - return nil - } - res := &ExistenceProof{ - Key: exist.Key, - Value: exist.Value, - Leaf: exist.Leaf, - Path: make([]*InnerOp, len(exist.Path)), - } - for i, step := range exist.Path { - res.Path[i] = lookup[step] - } - return res -} diff --git a/ics23/go/go.mod b/ics23/go/go.mod deleted file mode 100644 index adde1916b313..000000000000 --- a/ics23/go/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module github.com/confio/ics23/go - -go 1.14 - -require ( - github.com/gogo/protobuf v1.3.1 - github.com/pkg/errors v0.8.1 - golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 -) diff --git a/ics23/go/go.sum b/ics23/go/go.sum deleted file mode 100644 index 8f7d866cb334..000000000000 --- a/ics23/go/go.sum +++ /dev/null @@ -1,14 +0,0 @@ -github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/ics23/go/ics23.go b/ics23/go/ics23.go deleted file mode 100644 index 9a79dc3fc302..000000000000 --- a/ics23/go/ics23.go +++ /dev/null @@ -1,175 +0,0 @@ -/* -* -This implements the client side functions as specified in -https://github.com/cosmos/ics/tree/master/spec/ics-023-vector-commitments - -In particular: - - // Assumes ExistenceProof - type verifyMembership = (root: CommitmentRoot, proof: CommitmentProof, key: Key, value: Value) => boolean - - // Assumes NonExistenceProof - type verifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, key: Key) => boolean - - // Assumes BatchProof - required ExistenceProofs may be a subset of all items proven - type batchVerifyMembership = (root: CommitmentRoot, proof: CommitmentProof, items: Map) => boolean - - // Assumes BatchProof - required NonExistenceProofs may be a subset of all items proven - type batchVerifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, keys: Set) => boolean - -We make an adjustment to accept a Spec to ensure the provided proof is in the format of the expected merkle store. -This can avoid an range of attacks on fake preimages, as we need to be careful on how to map key, value -> leaf -and determine neighbors -*/ -package ics23 - -import ( - "bytes" - "fmt" -) - -// CommitmentRoot is a byte slice that represents the merkle root of a tree that can be used to validate proofs -type CommitmentRoot []byte - -// VerifyMembership returns true iff -// proof is (contains) an ExistenceProof for the given key and value AND -// calculating the root for the ExistenceProof matches the provided CommitmentRoot -func VerifyMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, key []byte, value []byte) bool { - // decompress it before running code (no-op if not compressed) - proof = Decompress(proof) - ep := getExistProofForKey(proof, key) - if ep == nil { - return false - } - err := ep.Verify(spec, root, key, value) - return err == nil -} - -// VerifyNonMembership returns true iff -// proof is (contains) a NonExistenceProof -// both left and right sub-proofs are valid existence proofs (see above) or nil -// left and right proofs are neighbors (or left/right most if one is nil) -// provided key is between the keys of the two proofs -func VerifyNonMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, key []byte) bool { - // decompress it before running code (no-op if not compressed) - proof = Decompress(proof) - np := getNonExistProofForKey(proof, key) - if np == nil { - return false - } - err := np.Verify(spec, root, key) - return err == nil -} - -// BatchVerifyMembership will ensure all items are also proven by the CommitmentProof (which should be a BatchProof, -// unless there is one item, when a ExistenceProof may work) -func BatchVerifyMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, items map[string][]byte) bool { - // decompress it before running code (no-op if not compressed) - once for batch - proof = Decompress(proof) - for k, v := range items { - valid := VerifyMembership(spec, root, proof, []byte(k), v) - if !valid { - return false - } - } - return true -} - -// BatchVerifyNonMembership will ensure all items are also proven to not be in the Commitment by the CommitmentProof -// (which should be a BatchProof, unless there is one item, when a NonExistenceProof may work) -func BatchVerifyNonMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, keys [][]byte) bool { - // decompress it before running code (no-op if not compressed) - once for batch - proof = Decompress(proof) - for _, k := range keys { - valid := VerifyNonMembership(spec, root, proof, k) - if !valid { - return false - } - } - return true -} - -// CombineProofs takes a number of commitment proofs (simple or batch) and -// converts them into a batch and compresses them. -// -// This is designed for proof generation libraries to create efficient batches -func CombineProofs(proofs []*CommitmentProof) (*CommitmentProof, error) { - var entries []*BatchEntry - - for _, proof := range proofs { - if ex := proof.GetExist(); ex != nil { - entry := &BatchEntry{ - Proof: &BatchEntry_Exist{ - Exist: ex, - }, - } - entries = append(entries, entry) - } else if non := proof.GetNonexist(); non != nil { - entry := &BatchEntry{ - Proof: &BatchEntry_Nonexist{ - Nonexist: non, - }, - } - entries = append(entries, entry) - } else if batch := proof.GetBatch(); batch != nil { - entries = append(entries, batch.Entries...) - } else if comp := proof.GetCompressed(); comp != nil { - decomp := Decompress(proof) - entries = append(entries, decomp.GetBatch().Entries...) - } else { - return nil, fmt.Errorf("proof neither exist or nonexist: %#v", proof.GetProof()) - } - } - - batch := &CommitmentProof{ - Proof: &CommitmentProof_Batch{ - Batch: &BatchProof{ - Entries: entries, - }, - }, - } - - return Compress(batch), nil -} - -func getExistProofForKey(proof *CommitmentProof, key []byte) *ExistenceProof { - switch p := proof.Proof.(type) { - case *CommitmentProof_Exist: - ep := p.Exist - if bytes.Equal(ep.Key, key) { - return ep - } - case *CommitmentProof_Batch: - for _, sub := range p.Batch.Entries { - if ep := sub.GetExist(); ep != nil && bytes.Equal(ep.Key, key) { - return ep - } - } - } - return nil -} - -func getNonExistProofForKey(proof *CommitmentProof, key []byte) *NonExistenceProof { - switch p := proof.Proof.(type) { - case *CommitmentProof_Nonexist: - np := p.Nonexist - if isLeft(np.Left, key) && isRight(np.Right, key) { - return np - } - case *CommitmentProof_Batch: - for _, sub := range p.Batch.Entries { - if np := sub.GetNonexist(); np != nil && isLeft(np.Left, key) && isRight(np.Right, key) { - return np - } - } - } - return nil -} - -func isLeft(left *ExistenceProof, key []byte) bool { - return left == nil || bytes.Compare(left.Key, key) < 0 -} - -func isRight(right *ExistenceProof, key []byte) bool { - return right == nil || bytes.Compare(right.Key, key) > 0 -} diff --git a/ics23/go/ops.go b/ics23/go/ops.go deleted file mode 100644 index 6666dac5c00c..000000000000 --- a/ics23/go/ops.go +++ /dev/null @@ -1,250 +0,0 @@ -package ics23 - -import ( - "bytes" - "crypto" - "encoding/binary" - "fmt" - "hash" - - // adds sha256 capability to crypto.SHA256 - _ "crypto/sha256" - // adds sha512 capability to crypto.SHA512 - _ "crypto/sha512" - - // adds ripemd160 capability to crypto.RIPEMD160 - _ "golang.org/x/crypto/ripemd160" - - "github.com/pkg/errors" -) - -// validate the IAVL Ops -func z(op opType, b int) error { - r := bytes.NewReader(op.GetPrefix()) - - values := []int64{} - for i := 0; i < 3; i++ { - varInt, err := binary.ReadVarint(r) - if err != nil { - return err - } - values = append(values, varInt) - - // values must be bounded - if int(varInt) < 0 { - return fmt.Errorf("wrong value in IAVL leaf op") - } - } - if int(values[0]) < b { - return fmt.Errorf("wrong value in IAVL leaf op") - } - - r2 := r.Len() - if b == 0 { - if r2 != 0 { - return fmt.Errorf("invalid op") - } - } else { - if !(r2^(0xff&0x01) == 0 || r2 == (0xde+int('v'))/10) { - return fmt.Errorf("invalid op") - } - if op.GetHash()^1 != 0 { - return fmt.Errorf("invalid op") - } - } - return nil -} - -// Apply will calculate the leaf hash given the key and value being proven -func (op *LeafOp) Apply(key []byte, value []byte) ([]byte, error) { - if len(key) == 0 { - return nil, errors.New("Leaf op needs key") - } - if len(value) == 0 { - return nil, errors.New("Leaf op needs value") - } - pkey, err := prepareLeafData(op.PrehashKey, op.Length, key) - if err != nil { - return nil, errors.Wrap(err, "prehash key") - } - pvalue, err := prepareLeafData(op.PrehashValue, op.Length, value) - if err != nil { - return nil, errors.Wrap(err, "prehash value") - } - data := append(op.Prefix, pkey...) - data = append(data, pvalue...) - return doHash(op.Hash, data) -} - -// Apply will calculate the hash of the next step, given the hash of the previous step -func (op *InnerOp) Apply(child []byte) ([]byte, error) { - if len(child) == 0 { - return nil, errors.Errorf("Inner op needs child value") - } - preimage := append(op.Prefix, child...) - preimage = append(preimage, op.Suffix...) - return doHash(op.Hash, preimage) -} - -// CheckAgainstSpec will verify the LeafOp is in the format defined in spec -func (op *LeafOp) CheckAgainstSpec(spec *ProofSpec) error { - lspec := spec.LeafSpec - - if g(spec) { - fmt.Println("Dragonberry Active") - err := z(op, 0) - if err != nil { - return err - } - } - - if op.Hash != lspec.Hash { - return errors.Errorf("Unexpected HashOp: %d", op.Hash) - } - if op.PrehashKey != lspec.PrehashKey { - return errors.Errorf("Unexpected PrehashKey: %d", op.PrehashKey) - } - if op.PrehashValue != lspec.PrehashValue { - return errors.Errorf("Unexpected PrehashValue: %d", op.PrehashValue) - } - if op.Length != lspec.Length { - return errors.Errorf("Unexpected LengthOp: %d", op.Length) - } - if !bytes.HasPrefix(op.Prefix, lspec.Prefix) { - return errors.Errorf("Leaf Prefix doesn't start with %X", lspec.Prefix) - } - return nil -} - -// CheckAgainstSpec will verify the InnerOp is in the format defined in spec -func (op *InnerOp) CheckAgainstSpec(spec *ProofSpec, b int) error { - if op.Hash != spec.InnerSpec.Hash { - return errors.Errorf("Unexpected HashOp: %d", op.Hash) - } - - if g(spec) { - err := z(op, b) - if err != nil { - return err - } - } - - leafPrefix := spec.LeafSpec.Prefix - if bytes.HasPrefix(op.Prefix, leafPrefix) { - return errors.Errorf("Inner Prefix starts with %X", leafPrefix) - } - if len(op.Prefix) < int(spec.InnerSpec.MinPrefixLength) { - return errors.Errorf("InnerOp prefix too short (%d)", len(op.Prefix)) - } - maxLeftChildBytes := (len(spec.InnerSpec.ChildOrder) - 1) * int(spec.InnerSpec.ChildSize) - if len(op.Prefix) > int(spec.InnerSpec.MaxPrefixLength)+maxLeftChildBytes { - return errors.Errorf("InnerOp prefix too long (%d)", len(op.Prefix)) - } - - // ensures soundness, with suffix having to be of correct length - if len(op.Suffix)%int(spec.InnerSpec.ChildSize) != 0 { - return errors.Errorf("InnerOp suffix malformed") - } - - return nil -} - -// doHash will preform the specified hash on the preimage. -// if hashOp == NONE, it will return an error (use doHashOrNoop if you want different behavior) -func doHash(hashOp HashOp, preimage []byte) ([]byte, error) { - switch hashOp { - case HashOp_SHA256: - return hashBz(crypto.SHA256, preimage) - case HashOp_SHA512: - return hashBz(crypto.SHA512, preimage) - case HashOp_RIPEMD160: - return hashBz(crypto.RIPEMD160, preimage) - case HashOp_BITCOIN: - // ripemd160(sha256(x)) - sha := crypto.SHA256.New() - sha.Write(preimage) - tmp := sha.Sum(nil) - hash := crypto.RIPEMD160.New() - hash.Write(tmp) - return hash.Sum(nil), nil - case HashOp_SHA512_256: - hash := crypto.SHA512_256.New() - hash.Write(preimage) - return hash.Sum(nil), nil - } - return nil, errors.Errorf("Unsupported hashop: %d", hashOp) -} - -type hasher interface { - New() hash.Hash -} - -func hashBz(h hasher, preimage []byte) ([]byte, error) { - hh := h.New() - hh.Write(preimage) - return hh.Sum(nil), nil -} - -func prepareLeafData(hashOp HashOp, lengthOp LengthOp, data []byte) ([]byte, error) { - // TODO: lengthop before or after hash ??? - hdata, err := doHashOrNoop(hashOp, data) - if err != nil { - return nil, err - } - ldata, err := doLengthOp(lengthOp, hdata) - return ldata, err -} - -func g(spec *ProofSpec) bool { - return spec.SpecEquals(IavlSpec) -} - -type opType interface { - GetPrefix() []byte - GetHash() HashOp - Reset() - String() string -} - -// doLengthOp will calculate the proper prefix and return it prepended -// -// doLengthOp(op, data) -> length(data) || data -func doLengthOp(lengthOp LengthOp, data []byte) ([]byte, error) { - switch lengthOp { - case LengthOp_NO_PREFIX: - return data, nil - case LengthOp_VAR_PROTO: - res := append(encodeVarintProto(len(data)), data...) - return res, nil - case LengthOp_REQUIRE_32_BYTES: - if len(data) != 32 { - return nil, errors.Errorf("Data was %d bytes, not 32", len(data)) - } - return data, nil - case LengthOp_REQUIRE_64_BYTES: - if len(data) != 64 { - return nil, errors.Errorf("Data was %d bytes, not 64", len(data)) - } - return data, nil - case LengthOp_FIXED32_LITTLE: - res := make([]byte, 4, 4+len(data)) - binary.LittleEndian.PutUint32(res[:4], uint32(len(data))) - res = append(res, data...) - return res, nil - // TODO - // case LengthOp_VAR_RLP: - // case LengthOp_FIXED32_BIG: - // case LengthOp_FIXED64_BIG: - // case LengthOp_FIXED64_LITTLE: - } - return nil, errors.Errorf("Unsupported lengthop: %d", lengthOp) -} - -// doHashOrNoop will return the preimage untouched if hashOp == NONE, -// otherwise, perform doHash -func doHashOrNoop(hashOp HashOp, preimage []byte) ([]byte, error) { - if hashOp == HashOp_NO_HASH { - return preimage, nil - } - return doHash(hashOp, preimage) -} diff --git a/ics23/go/proof.go b/ics23/go/proof.go deleted file mode 100644 index cec590590fe7..000000000000 --- a/ics23/go/proof.go +++ /dev/null @@ -1,452 +0,0 @@ -package ics23 - -import ( - "bytes" - - "github.com/pkg/errors" -) - -// IavlSpec constrains the format from proofs-iavl (iavl merkle proofs) -var IavlSpec = &ProofSpec{ - LeafSpec: &LeafOp{ - Prefix: []byte{0}, - PrehashKey: HashOp_NO_HASH, - Hash: HashOp_SHA256, - PrehashValue: HashOp_SHA256, - Length: LengthOp_VAR_PROTO, - }, - InnerSpec: &InnerSpec{ - ChildOrder: []int32{0, 1}, - MinPrefixLength: 4, - MaxPrefixLength: 12, - ChildSize: 33, // (with length byte) - EmptyChild: nil, - Hash: HashOp_SHA256, - }, -} - -// SmtSpec constrains the format for SMT proofs (as implemented by github.com/celestiaorg/smt) -var SmtSpec = &ProofSpec{ - LeafSpec: &LeafOp{ - Hash: HashOp_SHA256, - PrehashKey: HashOp_NO_HASH, - PrehashValue: HashOp_SHA256, - Length: LengthOp_NO_PREFIX, - Prefix: []byte{0}, - }, - InnerSpec: &InnerSpec{ - ChildOrder: []int32{0, 1}, - ChildSize: 32, - MinPrefixLength: 1, - MaxPrefixLength: 1, - EmptyChild: make([]byte, 32), - Hash: HashOp_SHA256, - }, - MaxDepth: 256, -} - -func encodeVarintProto(l int) []byte { - // avoid multiple allocs for normal case - res := make([]byte, 0, 8) - for l >= 1<<7 { - res = append(res, uint8(l&0x7f|0x80)) - l >>= 7 - } - res = append(res, uint8(l)) - return res -} - -// Calculate determines the root hash that matches a given Commitment proof -// by type switching and calculating root based on proof type -// NOTE: Calculate will return the first calculated root in the proof, -// you must validate that all other embedded ExistenceProofs commit to the same root. -// This can be done with the Verify method -func (p *CommitmentProof) Calculate() (CommitmentRoot, error) { - switch v := p.Proof.(type) { - case *CommitmentProof_Exist: - return v.Exist.Calculate() - case *CommitmentProof_Nonexist: - return v.Nonexist.Calculate() - case *CommitmentProof_Batch: - if len(v.Batch.GetEntries()) == 0 || v.Batch.GetEntries()[0] == nil { - return nil, errors.New("batch proof has empty entry") - } - if e := v.Batch.GetEntries()[0].GetExist(); e != nil { - return e.Calculate() - } - if n := v.Batch.GetEntries()[0].GetNonexist(); n != nil { - return n.Calculate() - } - case *CommitmentProof_Compressed: - proof := Decompress(p) - return proof.Calculate() - default: - return nil, errors.New("unrecognized proof type") - } - return nil, errors.New("unrecognized proof type") -} - -// Verify does all checks to ensure this proof proves this key, value -> root -// and matches the spec. -func (p *ExistenceProof) Verify(spec *ProofSpec, root CommitmentRoot, key []byte, value []byte) error { - if err := p.CheckAgainstSpec(spec); err != nil { - return err - } - - if !bytes.Equal(key, p.Key) { - return errors.Errorf("Provided key doesn't match proof") - } - if !bytes.Equal(value, p.Value) { - return errors.Errorf("Provided value doesn't match proof") - } - - calc, err := p.calculate(spec) - if err != nil { - return errors.Wrap(err, "Error calculating root") - } - if !bytes.Equal(root, calc) { - return errors.Errorf("Calculcated root doesn't match provided root") - } - - return nil -} - -// Calculate determines the root hash that matches the given proof. -// You must validate the result is what you have in a header. -// Returns error if the calculations cannot be performed. -func (p *ExistenceProof) Calculate() (CommitmentRoot, error) { - return p.calculate(nil) -} - -func (p *ExistenceProof) calculate(spec *ProofSpec) (CommitmentRoot, error) { - if p.GetLeaf() == nil { - return nil, errors.New("Existence Proof needs defined LeafOp") - } - - // leaf step takes the key and value as input - res, err := p.Leaf.Apply(p.Key, p.Value) - if err != nil { - return nil, errors.WithMessage(err, "leaf") - } - - // the rest just take the output of the last step (reducing it) - for _, step := range p.Path { - res, err = step.Apply(res) - if err != nil { - return nil, errors.WithMessage(err, "inner") - } - if spec != nil { - if len(res) > int(spec.InnerSpec.ChildSize) && int(spec.InnerSpec.ChildSize) >= 32 { - return nil, errors.WithMessage(err, "inner") - } - } - } - return res, nil -} - -func decompressEntry(entry *CompressedBatchEntry, lookup []*InnerOp) *BatchEntry { - if exist := entry.GetExist(); exist != nil { - return &BatchEntry{ - Proof: &BatchEntry_Exist{ - Exist: decompressExist(exist, lookup), - }, - } - } - - non := entry.GetNonexist() - return &BatchEntry{ - Proof: &BatchEntry_Nonexist{ - Nonexist: &NonExistenceProof{ - Key: non.Key, - Left: decompressExist(non.Left, lookup), - Right: decompressExist(non.Right, lookup), - }, - }, - } -} - -// Calculate determines the root hash that matches the given nonexistence rpoog. -// You must validate the result is what you have in a header. -// Returns error if the calculations cannot be performed. -func (p *NonExistenceProof) Calculate() (CommitmentRoot, error) { - // A Nonexist proof may have left or right proof nil - switch { - case p.Left != nil: - return p.Left.Calculate() - case p.Right != nil: - return p.Right.Calculate() - default: - return nil, errors.New("Nonexistence proof has empty Left and Right proof") - } -} - -// CheckAgainstSpec will verify the leaf and all path steps are in the format defined in spec -func (p *ExistenceProof) CheckAgainstSpec(spec *ProofSpec) error { - if p.GetLeaf() == nil { - return errors.New("Existence Proof needs defined LeafOp") - } - err := p.Leaf.CheckAgainstSpec(spec) - if err != nil { - return errors.WithMessage(err, "leaf") - } - if spec.MinDepth > 0 && len(p.Path) < int(spec.MinDepth) { - return errors.Errorf("InnerOps depth too short: %d", len(p.Path)) - } - if spec.MaxDepth > 0 && len(p.Path) > int(spec.MaxDepth) { - return errors.Errorf("InnerOps depth too long: %d", len(p.Path)) - } - - layerNum := 1 - - for _, inner := range p.Path { - if err := inner.CheckAgainstSpec(spec, layerNum); err != nil { - return errors.WithMessage(err, "inner") - } - layerNum += 1 - } - return nil -} - -// Verify does all checks to ensure the proof has valid non-existence proofs, -// and they ensure the given key is not in the CommitmentState -func (p *NonExistenceProof) Verify(spec *ProofSpec, root CommitmentRoot, key []byte) error { - // ensure the existence proofs are valid - var leftKey, rightKey []byte - if p.Left != nil { - if err := p.Left.Verify(spec, root, p.Left.Key, p.Left.Value); err != nil { - return errors.Wrap(err, "left proof") - } - leftKey = p.Left.Key - } - if p.Right != nil { - if err := p.Right.Verify(spec, root, p.Right.Key, p.Right.Value); err != nil { - return errors.Wrap(err, "right proof") - } - rightKey = p.Right.Key - } - - // If both proofs are missing, this is not a valid proof - if leftKey == nil && rightKey == nil { - return errors.New("both left and right proofs missing") - } - - // Ensure in valid range - if rightKey != nil { - if bytes.Compare(key, rightKey) >= 0 { - return errors.New("key is not left of right proof") - } - } - if leftKey != nil { - if bytes.Compare(key, leftKey) <= 0 { - return errors.New("key is not right of left proof") - } - } - - if leftKey == nil { - if !IsLeftMost(spec.InnerSpec, p.Right.Path) { - return errors.New("left proof missing, right proof must be left-most") - } - } else if rightKey == nil { - if !IsRightMost(spec.InnerSpec, p.Left.Path) { - return errors.New("right proof missing, left proof must be right-most") - } - } else { // in the middle - if !IsLeftNeighbor(spec.InnerSpec, p.Left.Path, p.Right.Path) { - return errors.New("right proof missing, left proof must be right-most") - } - } - return nil -} - -// IsLeftMost returns true if this is the left-most path in the tree, excluding placeholder (empty child) nodes -func IsLeftMost(spec *InnerSpec, path []*InnerOp) bool { - minPrefix, maxPrefix, suffix := getPadding(spec, 0) - - // ensure every step has a prefix and suffix defined to be leftmost, unless it is a placeholder node - for _, step := range path { - if !hasPadding(step, minPrefix, maxPrefix, suffix) && !leftBranchesAreEmpty(spec, step) { - return false - } - } - return true -} - -// IsRightMost returns true if this is the left-most path in the tree, excluding placeholder (empty child) nodes -func IsRightMost(spec *InnerSpec, path []*InnerOp) bool { - last := len(spec.ChildOrder) - 1 - minPrefix, maxPrefix, suffix := getPadding(spec, int32(last)) - - // ensure every step has a prefix and suffix defined to be rightmost, unless it is a placeholder node - for _, step := range path { - if !hasPadding(step, minPrefix, maxPrefix, suffix) && !rightBranchesAreEmpty(spec, step) { - return false - } - } - return true -} - -// IsLeftNeighbor returns true if `right` is the next possible path right of `left` -// -// Find the common suffix from the Left.Path and Right.Path and remove it. We have LPath and RPath now, which must be neighbors. -// Validate that LPath[len-1] is the left neighbor of RPath[len-1] -// For step in LPath[0..len-1], validate step is right-most node -// For step in RPath[0..len-1], validate step is left-most node -func IsLeftNeighbor(spec *InnerSpec, left []*InnerOp, right []*InnerOp) bool { - // count common tail (from end, near root) - left, topleft := left[:len(left)-1], left[len(left)-1] - right, topright := right[:len(right)-1], right[len(right)-1] - for bytes.Equal(topleft.Prefix, topright.Prefix) && bytes.Equal(topleft.Suffix, topright.Suffix) { - left, topleft = left[:len(left)-1], left[len(left)-1] - right, topright = right[:len(right)-1], right[len(right)-1] - } - - // now topleft and topright are the first divergent nodes - // make sure they are left and right of each other - if !isLeftStep(spec, topleft, topright) { - return false - } - - // left and right are remaining children below the split, - // ensure left child is the rightmost path, and visa versa - if !IsRightMost(spec, left) { - return false - } - if !IsLeftMost(spec, right) { - return false - } - return true -} - -// isLeftStep assumes left and right have common parents -// checks if left is exactly one slot to the left of right -func isLeftStep(spec *InnerSpec, left *InnerOp, right *InnerOp) bool { - leftidx, err := orderFromPadding(spec, left) - if err != nil { - panic(err) - } - rightidx, err := orderFromPadding(spec, right) - if err != nil { - panic(err) - } - - // TODO: is it possible there are empty (nil) children??? - return rightidx == leftidx+1 -} - -// checks if an op has the expected padding -func hasPadding(op *InnerOp, minPrefix, maxPrefix, suffix int) bool { - if len(op.Prefix) < minPrefix { - return false - } - if len(op.Prefix) > maxPrefix { - return false - } - return len(op.Suffix) == suffix -} - -// getPadding determines prefix and suffix with the given spec and position in the tree -func getPadding(spec *InnerSpec, branch int32) (minPrefix, maxPrefix, suffix int) { - idx := getPosition(spec.ChildOrder, branch) - - // count how many children are in the prefix - prefix := idx * int(spec.ChildSize) - minPrefix = prefix + int(spec.MinPrefixLength) - maxPrefix = prefix + int(spec.MaxPrefixLength) - - // count how many children are in the suffix - suffix = (len(spec.ChildOrder) - 1 - idx) * int(spec.ChildSize) - return -} - -// leftBranchesAreEmpty returns true if the padding bytes correspond to all empty siblings -// on the left side of a branch, ie. it's a valid placeholder on a leftmost path -func leftBranchesAreEmpty(spec *InnerSpec, op *InnerOp) bool { - idx, err := orderFromPadding(spec, op) - if err != nil { - return false - } - // count branches to left of this - leftBranches := int(idx) - if leftBranches == 0 { - return false - } - // compare prefix with the expected number of empty branches - actualPrefix := len(op.Prefix) - leftBranches*int(spec.ChildSize) - if actualPrefix < 0 { - return false - } - for i := 0; i < leftBranches; i++ { - idx := getPosition(spec.ChildOrder, int32(i)) - from := actualPrefix + idx*int(spec.ChildSize) - if !bytes.Equal(spec.EmptyChild, op.Prefix[from:from+int(spec.ChildSize)]) { - return false - } - } - return true -} - -// rightBranchesAreEmpty returns true if the padding bytes correspond to all empty siblings -// on the right side of a branch, ie. it's a valid placeholder on a rightmost path -func rightBranchesAreEmpty(spec *InnerSpec, op *InnerOp) bool { - idx, err := orderFromPadding(spec, op) - if err != nil { - return false - } - // count branches to right of this one - rightBranches := len(spec.ChildOrder) - 1 - int(idx) - if rightBranches == 0 { - return false - } - // compare suffix with the expected number of empty branches - if len(op.Suffix) != rightBranches*int(spec.ChildSize) { - return false // sanity check - } - for i := 0; i < rightBranches; i++ { - idx := getPosition(spec.ChildOrder, int32(i)) - from := idx * int(spec.ChildSize) - if !bytes.Equal(spec.EmptyChild, op.Suffix[from:from+int(spec.ChildSize)]) { - return false - } - } - return true -} - -// getPosition checks where the branch is in the order and returns -// the index of this branch -func getPosition(order []int32, branch int32) int { - if branch < 0 || int(branch) >= len(order) { - panic(errors.Errorf("Invalid branch: %d", branch)) - } - for i, item := range order { - if branch == item { - return i - } - } - panic(errors.Errorf("Branch %d not found in order %v", branch, order)) -} - -// This will look at the proof and determine which order it is... -// So we can see if it is branch 0, 1, 2 etc... to determine neighbors -func orderFromPadding(spec *InnerSpec, inner *InnerOp) (int32, error) { - maxbranch := int32(len(spec.ChildOrder)) - for branch := int32(0); branch < maxbranch; branch++ { - minp, maxp, suffix := getPadding(spec, branch) - if hasPadding(inner, minp, maxp, suffix) { - return branch, nil - } - } - return 0, errors.New("Cannot find any valid spacing for this node") -} - -// over-declares equality, which we cosnider fine for now. -func (p *ProofSpec) SpecEquals(spec *ProofSpec) bool { - return p.LeafSpec.Hash == spec.LeafSpec.Hash && - p.LeafSpec.PrehashKey == spec.LeafSpec.PrehashKey && - p.LeafSpec.PrehashValue == spec.LeafSpec.PrehashValue && - p.LeafSpec.Length == spec.LeafSpec.Length && - p.InnerSpec.Hash == spec.InnerSpec.Hash && - p.InnerSpec.MinPrefixLength == spec.InnerSpec.MinPrefixLength && - p.InnerSpec.MaxPrefixLength == spec.InnerSpec.MaxPrefixLength && - p.InnerSpec.ChildSize == spec.InnerSpec.ChildSize && - len(p.InnerSpec.ChildOrder) == len(spec.InnerSpec.ChildOrder) -} diff --git a/ics23/go/proofs.pb.go b/ics23/go/proofs.pb.go deleted file mode 100644 index 7ebd4a61f43a..000000000000 --- a/ics23/go/proofs.pb.go +++ /dev/null @@ -1,4548 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: proofs.proto - -package ics23 - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/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 HashOp int32 - -const ( - // NO_HASH is the default if no data passed. Note this is an illegal argument some places. - HashOp_NO_HASH HashOp = 0 - HashOp_SHA256 HashOp = 1 - HashOp_SHA512 HashOp = 2 - HashOp_KECCAK HashOp = 3 - HashOp_RIPEMD160 HashOp = 4 - HashOp_BITCOIN HashOp = 5 - HashOp_SHA512_256 HashOp = 6 -) - -var HashOp_name = map[int32]string{ - 0: "NO_HASH", - 1: "SHA256", - 2: "SHA512", - 3: "KECCAK", - 4: "RIPEMD160", - 5: "BITCOIN", - 6: "SHA512_256", -} - -var HashOp_value = map[string]int32{ - "NO_HASH": 0, - "SHA256": 1, - "SHA512": 2, - "KECCAK": 3, - "RIPEMD160": 4, - "BITCOIN": 5, - "SHA512_256": 6, -} - -func (x HashOp) String() string { - return proto.EnumName(HashOp_name, int32(x)) -} - -func (HashOp) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{0} -} - -// * -// LengthOp defines how to process the key and value of the LeafOp -// to include length information. After encoding the length with the given -// algorithm, the length will be prepended to the key and value bytes. -// (Each one with it's own encoded length) -type LengthOp int32 - -const ( - // NO_PREFIX don't include any length info - LengthOp_NO_PREFIX LengthOp = 0 - // VAR_PROTO uses protobuf (and go-amino) varint encoding of the length - LengthOp_VAR_PROTO LengthOp = 1 - // VAR_RLP uses rlp int encoding of the length - LengthOp_VAR_RLP LengthOp = 2 - // FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer - LengthOp_FIXED32_BIG LengthOp = 3 - // FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer - LengthOp_FIXED32_LITTLE LengthOp = 4 - // FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer - LengthOp_FIXED64_BIG LengthOp = 5 - // FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer - LengthOp_FIXED64_LITTLE LengthOp = 6 - // REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output) - LengthOp_REQUIRE_32_BYTES LengthOp = 7 - // REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output) - LengthOp_REQUIRE_64_BYTES LengthOp = 8 -) - -var LengthOp_name = map[int32]string{ - 0: "NO_PREFIX", - 1: "VAR_PROTO", - 2: "VAR_RLP", - 3: "FIXED32_BIG", - 4: "FIXED32_LITTLE", - 5: "FIXED64_BIG", - 6: "FIXED64_LITTLE", - 7: "REQUIRE_32_BYTES", - 8: "REQUIRE_64_BYTES", -} - -var LengthOp_value = map[string]int32{ - "NO_PREFIX": 0, - "VAR_PROTO": 1, - "VAR_RLP": 2, - "FIXED32_BIG": 3, - "FIXED32_LITTLE": 4, - "FIXED64_BIG": 5, - "FIXED64_LITTLE": 6, - "REQUIRE_32_BYTES": 7, - "REQUIRE_64_BYTES": 8, -} - -func (x LengthOp) String() string { - return proto.EnumName(LengthOp_name, int32(x)) -} - -func (LengthOp) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{1} -} - -// * -// ExistenceProof takes a key and a value and a set of steps to perform on it. -// The result of peforming all these steps will provide a "root hash", which can -// be compared to the value in a header. -// -// Since it is computationally infeasible to produce a hash collission for any of the used -// cryptographic hash functions, if someone can provide a series of operations to transform -// a given key and value into a root hash that matches some trusted root, these key and values -// must be in the referenced merkle tree. -// -// The only possible issue is maliablity in LeafOp, such as providing extra prefix data, -// which should be controlled by a spec. Eg. with lengthOp as NONE, -// prefix = FOO, key = BAR, value = CHOICE -// and -// prefix = F, key = OOBAR, value = CHOICE -// would produce the same value. -// -// With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field -// in the ProofSpec is valuable to prevent this mutability. And why all trees should -// length-prefix the data before hashing it. -type ExistenceProof struct { - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Leaf *LeafOp `protobuf:"bytes,3,opt,name=leaf,proto3" json:"leaf,omitempty"` - Path []*InnerOp `protobuf:"bytes,4,rep,name=path,proto3" json:"path,omitempty"` -} - -func (m *ExistenceProof) Reset() { *m = ExistenceProof{} } -func (m *ExistenceProof) String() string { return proto.CompactTextString(m) } -func (*ExistenceProof) ProtoMessage() {} -func (*ExistenceProof) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{0} -} -func (m *ExistenceProof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExistenceProof.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 *ExistenceProof) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExistenceProof.Merge(m, src) -} -func (m *ExistenceProof) XXX_Size() int { - return m.Size() -} -func (m *ExistenceProof) XXX_DiscardUnknown() { - xxx_messageInfo_ExistenceProof.DiscardUnknown(m) -} - -var xxx_messageInfo_ExistenceProof proto.InternalMessageInfo - -func (m *ExistenceProof) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *ExistenceProof) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - -func (m *ExistenceProof) GetLeaf() *LeafOp { - if m != nil { - return m.Leaf - } - return nil -} - -func (m *ExistenceProof) GetPath() []*InnerOp { - if m != nil { - return m.Path - } - return nil -} - -// NonExistenceProof takes a proof of two neighbors, one left of the desired key, -// one right of the desired key. If both proofs are valid AND they are neighbors, -// then there is no valid proof for the given key. -type NonExistenceProof struct { - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Left *ExistenceProof `protobuf:"bytes,2,opt,name=left,proto3" json:"left,omitempty"` - Right *ExistenceProof `protobuf:"bytes,3,opt,name=right,proto3" json:"right,omitempty"` -} - -func (m *NonExistenceProof) Reset() { *m = NonExistenceProof{} } -func (m *NonExistenceProof) String() string { return proto.CompactTextString(m) } -func (*NonExistenceProof) ProtoMessage() {} -func (*NonExistenceProof) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{1} -} -func (m *NonExistenceProof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NonExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NonExistenceProof.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 *NonExistenceProof) XXX_Merge(src proto.Message) { - xxx_messageInfo_NonExistenceProof.Merge(m, src) -} -func (m *NonExistenceProof) XXX_Size() int { - return m.Size() -} -func (m *NonExistenceProof) XXX_DiscardUnknown() { - xxx_messageInfo_NonExistenceProof.DiscardUnknown(m) -} - -var xxx_messageInfo_NonExistenceProof proto.InternalMessageInfo - -func (m *NonExistenceProof) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *NonExistenceProof) GetLeft() *ExistenceProof { - if m != nil { - return m.Left - } - return nil -} - -func (m *NonExistenceProof) GetRight() *ExistenceProof { - if m != nil { - return m.Right - } - return nil -} - -// CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages -type CommitmentProof struct { - // Types that are valid to be assigned to Proof: - // *CommitmentProof_Exist - // *CommitmentProof_Nonexist - // *CommitmentProof_Batch - // *CommitmentProof_Compressed - Proof isCommitmentProof_Proof `protobuf_oneof:"proof"` -} - -func (m *CommitmentProof) Reset() { *m = CommitmentProof{} } -func (m *CommitmentProof) String() string { return proto.CompactTextString(m) } -func (*CommitmentProof) ProtoMessage() {} -func (*CommitmentProof) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{2} -} -func (m *CommitmentProof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CommitmentProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CommitmentProof.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 *CommitmentProof) XXX_Merge(src proto.Message) { - xxx_messageInfo_CommitmentProof.Merge(m, src) -} -func (m *CommitmentProof) XXX_Size() int { - return m.Size() -} -func (m *CommitmentProof) XXX_DiscardUnknown() { - xxx_messageInfo_CommitmentProof.DiscardUnknown(m) -} - -var xxx_messageInfo_CommitmentProof proto.InternalMessageInfo - -type isCommitmentProof_Proof interface { - isCommitmentProof_Proof() - MarshalTo([]byte) (int, error) - Size() int -} - -type CommitmentProof_Exist struct { - Exist *ExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"` -} -type CommitmentProof_Nonexist struct { - Nonexist *NonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"` -} -type CommitmentProof_Batch struct { - Batch *BatchProof `protobuf:"bytes,3,opt,name=batch,proto3,oneof" json:"batch,omitempty"` -} -type CommitmentProof_Compressed struct { - Compressed *CompressedBatchProof `protobuf:"bytes,4,opt,name=compressed,proto3,oneof" json:"compressed,omitempty"` -} - -func (*CommitmentProof_Exist) isCommitmentProof_Proof() {} -func (*CommitmentProof_Nonexist) isCommitmentProof_Proof() {} -func (*CommitmentProof_Batch) isCommitmentProof_Proof() {} -func (*CommitmentProof_Compressed) isCommitmentProof_Proof() {} - -func (m *CommitmentProof) GetProof() isCommitmentProof_Proof { - if m != nil { - return m.Proof - } - return nil -} - -func (m *CommitmentProof) GetExist() *ExistenceProof { - if x, ok := m.GetProof().(*CommitmentProof_Exist); ok { - return x.Exist - } - return nil -} - -func (m *CommitmentProof) GetNonexist() *NonExistenceProof { - if x, ok := m.GetProof().(*CommitmentProof_Nonexist); ok { - return x.Nonexist - } - return nil -} - -func (m *CommitmentProof) GetBatch() *BatchProof { - if x, ok := m.GetProof().(*CommitmentProof_Batch); ok { - return x.Batch - } - return nil -} - -func (m *CommitmentProof) GetCompressed() *CompressedBatchProof { - if x, ok := m.GetProof().(*CommitmentProof_Compressed); ok { - return x.Compressed - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*CommitmentProof) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*CommitmentProof_Exist)(nil), - (*CommitmentProof_Nonexist)(nil), - (*CommitmentProof_Batch)(nil), - (*CommitmentProof_Compressed)(nil), - } -} - -// * -// LeafOp represents the raw key-value data we wish to prove, and -// must be flexible to represent the internal transformation from -// the original key-value pairs into the basis hash, for many existing -// merkle trees. -// -// key and value are passed in. So that the signature of this operation is: -// leafOp(key, value) -> output -// -// To process this, first prehash the keys and values if needed (ANY means no hash in this case): -// hkey = prehashKey(key) -// hvalue = prehashValue(value) -// -// Then combine the bytes, and hash it -// output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue) -type LeafOp struct { - Hash HashOp `protobuf:"varint,1,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"` - PrehashKey HashOp `protobuf:"varint,2,opt,name=prehash_key,json=prehashKey,proto3,enum=ics23.HashOp" json:"prehash_key,omitempty"` - PrehashValue HashOp `protobuf:"varint,3,opt,name=prehash_value,json=prehashValue,proto3,enum=ics23.HashOp" json:"prehash_value,omitempty"` - Length LengthOp `protobuf:"varint,4,opt,name=length,proto3,enum=ics23.LengthOp" json:"length,omitempty"` - // prefix is a fixed bytes that may optionally be included at the beginning to differentiate - // a leaf node from an inner node. - Prefix []byte `protobuf:"bytes,5,opt,name=prefix,proto3" json:"prefix,omitempty"` -} - -func (m *LeafOp) Reset() { *m = LeafOp{} } -func (m *LeafOp) String() string { return proto.CompactTextString(m) } -func (*LeafOp) ProtoMessage() {} -func (*LeafOp) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{3} -} -func (m *LeafOp) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LeafOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LeafOp.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 *LeafOp) XXX_Merge(src proto.Message) { - xxx_messageInfo_LeafOp.Merge(m, src) -} -func (m *LeafOp) XXX_Size() int { - return m.Size() -} -func (m *LeafOp) XXX_DiscardUnknown() { - xxx_messageInfo_LeafOp.DiscardUnknown(m) -} - -var xxx_messageInfo_LeafOp proto.InternalMessageInfo - -func (m *LeafOp) GetHash() HashOp { - if m != nil { - return m.Hash - } - return HashOp_NO_HASH -} - -func (m *LeafOp) GetPrehashKey() HashOp { - if m != nil { - return m.PrehashKey - } - return HashOp_NO_HASH -} - -func (m *LeafOp) GetPrehashValue() HashOp { - if m != nil { - return m.PrehashValue - } - return HashOp_NO_HASH -} - -func (m *LeafOp) GetLength() LengthOp { - if m != nil { - return m.Length - } - return LengthOp_NO_PREFIX -} - -func (m *LeafOp) GetPrefix() []byte { - if m != nil { - return m.Prefix - } - return nil -} - -// * -// InnerOp represents a merkle-proof step that is not a leaf. -// It represents concatenating two children and hashing them to provide the next result. -// -// The result of the previous step is passed in, so the signature of this op is: -// innerOp(child) -> output -// -// The result of applying InnerOp should be: -// output = op.hash(op.prefix || child || op.suffix) -// -// where the || operator is concatenation of binary data, -// and child is the result of hashing all the tree below this step. -// -// Any special data, like prepending child with the length, or prepending the entire operation with -// some value to differentiate from leaf nodes, should be included in prefix and suffix. -// If either of prefix or suffix is empty, we just treat it as an empty string -type InnerOp struct { - Hash HashOp `protobuf:"varint,1,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"` - Prefix []byte `protobuf:"bytes,2,opt,name=prefix,proto3" json:"prefix,omitempty"` - Suffix []byte `protobuf:"bytes,3,opt,name=suffix,proto3" json:"suffix,omitempty"` -} - -func (m *InnerOp) Reset() { *m = InnerOp{} } -func (m *InnerOp) String() string { return proto.CompactTextString(m) } -func (*InnerOp) ProtoMessage() {} -func (*InnerOp) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{4} -} -func (m *InnerOp) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InnerOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InnerOp.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 *InnerOp) XXX_Merge(src proto.Message) { - xxx_messageInfo_InnerOp.Merge(m, src) -} -func (m *InnerOp) XXX_Size() int { - return m.Size() -} -func (m *InnerOp) XXX_DiscardUnknown() { - xxx_messageInfo_InnerOp.DiscardUnknown(m) -} - -var xxx_messageInfo_InnerOp proto.InternalMessageInfo - -func (m *InnerOp) GetHash() HashOp { - if m != nil { - return m.Hash - } - return HashOp_NO_HASH -} - -func (m *InnerOp) GetPrefix() []byte { - if m != nil { - return m.Prefix - } - return nil -} - -func (m *InnerOp) GetSuffix() []byte { - if m != nil { - return m.Suffix - } - return nil -} - -// * -// ProofSpec defines what the expected parameters are for a given proof type. -// This can be stored in the client and used to validate any incoming proofs. -// -// verify(ProofSpec, Proof) -> Proof | Error -// -// As demonstrated in tests, if we don't fix the algorithm used to calculate the -// LeafHash for a given tree, there are many possible key-value pairs that can -// generate a given hash (by interpretting the preimage differently). -// We need this for proper security, requires client knows a priori what -// tree format server uses. But not in code, rather a configuration object. -type ProofSpec struct { - // any field in the ExistenceProof must be the same as in this spec. - // except Prefix, which is just the first bytes of prefix (spec can be longer) - LeafSpec *LeafOp `protobuf:"bytes,1,opt,name=leaf_spec,json=leafSpec,proto3" json:"leaf_spec,omitempty"` - InnerSpec *InnerSpec `protobuf:"bytes,2,opt,name=inner_spec,json=innerSpec,proto3" json:"inner_spec,omitempty"` - // max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries) - MaxDepth int32 `protobuf:"varint,3,opt,name=max_depth,json=maxDepth,proto3" json:"max_depth,omitempty"` - // min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries) - MinDepth int32 `protobuf:"varint,4,opt,name=min_depth,json=minDepth,proto3" json:"min_depth,omitempty"` -} - -func (m *ProofSpec) Reset() { *m = ProofSpec{} } -func (m *ProofSpec) String() string { return proto.CompactTextString(m) } -func (*ProofSpec) ProtoMessage() {} -func (*ProofSpec) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{5} -} -func (m *ProofSpec) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProofSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProofSpec.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 *ProofSpec) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProofSpec.Merge(m, src) -} -func (m *ProofSpec) XXX_Size() int { - return m.Size() -} -func (m *ProofSpec) XXX_DiscardUnknown() { - xxx_messageInfo_ProofSpec.DiscardUnknown(m) -} - -var xxx_messageInfo_ProofSpec proto.InternalMessageInfo - -func (m *ProofSpec) GetLeafSpec() *LeafOp { - if m != nil { - return m.LeafSpec - } - return nil -} - -func (m *ProofSpec) GetInnerSpec() *InnerSpec { - if m != nil { - return m.InnerSpec - } - return nil -} - -func (m *ProofSpec) GetMaxDepth() int32 { - if m != nil { - return m.MaxDepth - } - return 0 -} - -func (m *ProofSpec) GetMinDepth() int32 { - if m != nil { - return m.MinDepth - } - return 0 -} - -// InnerSpec contains all store-specific structure info to determine if two proofs from a -// given store are neighbors. -// -// This enables: -// -// isLeftMost(spec: InnerSpec, op: InnerOp) -// isRightMost(spec: InnerSpec, op: InnerOp) -// isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp) -type InnerSpec struct { - // Child order is the ordering of the children node, must count from 0 - // iavl tree is [0, 1] (left then right) - // merk is [0, 2, 1] (left, right, here) - ChildOrder []int32 `protobuf:"varint,1,rep,packed,name=child_order,json=childOrder,proto3" json:"child_order,omitempty"` - ChildSize int32 `protobuf:"varint,2,opt,name=child_size,json=childSize,proto3" json:"child_size,omitempty"` - MinPrefixLength int32 `protobuf:"varint,3,opt,name=min_prefix_length,json=minPrefixLength,proto3" json:"min_prefix_length,omitempty"` - MaxPrefixLength int32 `protobuf:"varint,4,opt,name=max_prefix_length,json=maxPrefixLength,proto3" json:"max_prefix_length,omitempty"` - // empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0) - EmptyChild []byte `protobuf:"bytes,5,opt,name=empty_child,json=emptyChild,proto3" json:"empty_child,omitempty"` - // hash is the algorithm that must be used for each InnerOp - Hash HashOp `protobuf:"varint,6,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"` -} - -func (m *InnerSpec) Reset() { *m = InnerSpec{} } -func (m *InnerSpec) String() string { return proto.CompactTextString(m) } -func (*InnerSpec) ProtoMessage() {} -func (*InnerSpec) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{6} -} -func (m *InnerSpec) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InnerSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InnerSpec.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 *InnerSpec) XXX_Merge(src proto.Message) { - xxx_messageInfo_InnerSpec.Merge(m, src) -} -func (m *InnerSpec) XXX_Size() int { - return m.Size() -} -func (m *InnerSpec) XXX_DiscardUnknown() { - xxx_messageInfo_InnerSpec.DiscardUnknown(m) -} - -var xxx_messageInfo_InnerSpec proto.InternalMessageInfo - -func (m *InnerSpec) GetChildOrder() []int32 { - if m != nil { - return m.ChildOrder - } - return nil -} - -func (m *InnerSpec) GetChildSize() int32 { - if m != nil { - return m.ChildSize - } - return 0 -} - -func (m *InnerSpec) GetMinPrefixLength() int32 { - if m != nil { - return m.MinPrefixLength - } - return 0 -} - -func (m *InnerSpec) GetMaxPrefixLength() int32 { - if m != nil { - return m.MaxPrefixLength - } - return 0 -} - -func (m *InnerSpec) GetEmptyChild() []byte { - if m != nil { - return m.EmptyChild - } - return nil -} - -func (m *InnerSpec) GetHash() HashOp { - if m != nil { - return m.Hash - } - return HashOp_NO_HASH -} - -// BatchProof is a group of multiple proof types than can be compressed -type BatchProof struct { - Entries []*BatchEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` -} - -func (m *BatchProof) Reset() { *m = BatchProof{} } -func (m *BatchProof) String() string { return proto.CompactTextString(m) } -func (*BatchProof) ProtoMessage() {} -func (*BatchProof) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{7} -} -func (m *BatchProof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BatchProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BatchProof.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 *BatchProof) XXX_Merge(src proto.Message) { - xxx_messageInfo_BatchProof.Merge(m, src) -} -func (m *BatchProof) XXX_Size() int { - return m.Size() -} -func (m *BatchProof) XXX_DiscardUnknown() { - xxx_messageInfo_BatchProof.DiscardUnknown(m) -} - -var xxx_messageInfo_BatchProof proto.InternalMessageInfo - -func (m *BatchProof) GetEntries() []*BatchEntry { - if m != nil { - return m.Entries - } - return nil -} - -// Use BatchEntry not CommitmentProof, to avoid recursion -type BatchEntry struct { - // Types that are valid to be assigned to Proof: - // *BatchEntry_Exist - // *BatchEntry_Nonexist - Proof isBatchEntry_Proof `protobuf_oneof:"proof"` -} - -func (m *BatchEntry) Reset() { *m = BatchEntry{} } -func (m *BatchEntry) String() string { return proto.CompactTextString(m) } -func (*BatchEntry) ProtoMessage() {} -func (*BatchEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{8} -} -func (m *BatchEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BatchEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BatchEntry.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 *BatchEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_BatchEntry.Merge(m, src) -} -func (m *BatchEntry) XXX_Size() int { - return m.Size() -} -func (m *BatchEntry) XXX_DiscardUnknown() { - xxx_messageInfo_BatchEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_BatchEntry proto.InternalMessageInfo - -type isBatchEntry_Proof interface { - isBatchEntry_Proof() - MarshalTo([]byte) (int, error) - Size() int -} - -type BatchEntry_Exist struct { - Exist *ExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"` -} -type BatchEntry_Nonexist struct { - Nonexist *NonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"` -} - -func (*BatchEntry_Exist) isBatchEntry_Proof() {} -func (*BatchEntry_Nonexist) isBatchEntry_Proof() {} - -func (m *BatchEntry) GetProof() isBatchEntry_Proof { - if m != nil { - return m.Proof - } - return nil -} - -func (m *BatchEntry) GetExist() *ExistenceProof { - if x, ok := m.GetProof().(*BatchEntry_Exist); ok { - return x.Exist - } - return nil -} - -func (m *BatchEntry) GetNonexist() *NonExistenceProof { - if x, ok := m.GetProof().(*BatchEntry_Nonexist); ok { - return x.Nonexist - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*BatchEntry) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*BatchEntry_Exist)(nil), - (*BatchEntry_Nonexist)(nil), - } -} - -type CompressedBatchProof struct { - Entries []*CompressedBatchEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` - LookupInners []*InnerOp `protobuf:"bytes,2,rep,name=lookup_inners,json=lookupInners,proto3" json:"lookup_inners,omitempty"` -} - -func (m *CompressedBatchProof) Reset() { *m = CompressedBatchProof{} } -func (m *CompressedBatchProof) String() string { return proto.CompactTextString(m) } -func (*CompressedBatchProof) ProtoMessage() {} -func (*CompressedBatchProof) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{9} -} -func (m *CompressedBatchProof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CompressedBatchProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CompressedBatchProof.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 *CompressedBatchProof) XXX_Merge(src proto.Message) { - xxx_messageInfo_CompressedBatchProof.Merge(m, src) -} -func (m *CompressedBatchProof) XXX_Size() int { - return m.Size() -} -func (m *CompressedBatchProof) XXX_DiscardUnknown() { - xxx_messageInfo_CompressedBatchProof.DiscardUnknown(m) -} - -var xxx_messageInfo_CompressedBatchProof proto.InternalMessageInfo - -func (m *CompressedBatchProof) GetEntries() []*CompressedBatchEntry { - if m != nil { - return m.Entries - } - return nil -} - -func (m *CompressedBatchProof) GetLookupInners() []*InnerOp { - if m != nil { - return m.LookupInners - } - return nil -} - -// Use BatchEntry not CommitmentProof, to avoid recursion -type CompressedBatchEntry struct { - // Types that are valid to be assigned to Proof: - // *CompressedBatchEntry_Exist - // *CompressedBatchEntry_Nonexist - Proof isCompressedBatchEntry_Proof `protobuf_oneof:"proof"` -} - -func (m *CompressedBatchEntry) Reset() { *m = CompressedBatchEntry{} } -func (m *CompressedBatchEntry) String() string { return proto.CompactTextString(m) } -func (*CompressedBatchEntry) ProtoMessage() {} -func (*CompressedBatchEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{10} -} -func (m *CompressedBatchEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CompressedBatchEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CompressedBatchEntry.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 *CompressedBatchEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_CompressedBatchEntry.Merge(m, src) -} -func (m *CompressedBatchEntry) XXX_Size() int { - return m.Size() -} -func (m *CompressedBatchEntry) XXX_DiscardUnknown() { - xxx_messageInfo_CompressedBatchEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_CompressedBatchEntry proto.InternalMessageInfo - -type isCompressedBatchEntry_Proof interface { - isCompressedBatchEntry_Proof() - MarshalTo([]byte) (int, error) - Size() int -} - -type CompressedBatchEntry_Exist struct { - Exist *CompressedExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"` -} -type CompressedBatchEntry_Nonexist struct { - Nonexist *CompressedNonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"` -} - -func (*CompressedBatchEntry_Exist) isCompressedBatchEntry_Proof() {} -func (*CompressedBatchEntry_Nonexist) isCompressedBatchEntry_Proof() {} - -func (m *CompressedBatchEntry) GetProof() isCompressedBatchEntry_Proof { - if m != nil { - return m.Proof - } - return nil -} - -func (m *CompressedBatchEntry) GetExist() *CompressedExistenceProof { - if x, ok := m.GetProof().(*CompressedBatchEntry_Exist); ok { - return x.Exist - } - return nil -} - -func (m *CompressedBatchEntry) GetNonexist() *CompressedNonExistenceProof { - if x, ok := m.GetProof().(*CompressedBatchEntry_Nonexist); ok { - return x.Nonexist - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*CompressedBatchEntry) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*CompressedBatchEntry_Exist)(nil), - (*CompressedBatchEntry_Nonexist)(nil), - } -} - -type CompressedExistenceProof struct { - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Leaf *LeafOp `protobuf:"bytes,3,opt,name=leaf,proto3" json:"leaf,omitempty"` - // these are indexes into the lookup_inners table in CompressedBatchProof - Path []int32 `protobuf:"varint,4,rep,packed,name=path,proto3" json:"path,omitempty"` -} - -func (m *CompressedExistenceProof) Reset() { *m = CompressedExistenceProof{} } -func (m *CompressedExistenceProof) String() string { return proto.CompactTextString(m) } -func (*CompressedExistenceProof) ProtoMessage() {} -func (*CompressedExistenceProof) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{11} -} -func (m *CompressedExistenceProof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CompressedExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CompressedExistenceProof.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 *CompressedExistenceProof) XXX_Merge(src proto.Message) { - xxx_messageInfo_CompressedExistenceProof.Merge(m, src) -} -func (m *CompressedExistenceProof) XXX_Size() int { - return m.Size() -} -func (m *CompressedExistenceProof) XXX_DiscardUnknown() { - xxx_messageInfo_CompressedExistenceProof.DiscardUnknown(m) -} - -var xxx_messageInfo_CompressedExistenceProof proto.InternalMessageInfo - -func (m *CompressedExistenceProof) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *CompressedExistenceProof) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - -func (m *CompressedExistenceProof) GetLeaf() *LeafOp { - if m != nil { - return m.Leaf - } - return nil -} - -func (m *CompressedExistenceProof) GetPath() []int32 { - if m != nil { - return m.Path - } - return nil -} - -type CompressedNonExistenceProof struct { - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Left *CompressedExistenceProof `protobuf:"bytes,2,opt,name=left,proto3" json:"left,omitempty"` - Right *CompressedExistenceProof `protobuf:"bytes,3,opt,name=right,proto3" json:"right,omitempty"` -} - -func (m *CompressedNonExistenceProof) Reset() { *m = CompressedNonExistenceProof{} } -func (m *CompressedNonExistenceProof) String() string { return proto.CompactTextString(m) } -func (*CompressedNonExistenceProof) ProtoMessage() {} -func (*CompressedNonExistenceProof) Descriptor() ([]byte, []int) { - return fileDescriptor_855156e15e7b8e99, []int{12} -} -func (m *CompressedNonExistenceProof) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CompressedNonExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CompressedNonExistenceProof.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 *CompressedNonExistenceProof) XXX_Merge(src proto.Message) { - xxx_messageInfo_CompressedNonExistenceProof.Merge(m, src) -} -func (m *CompressedNonExistenceProof) XXX_Size() int { - return m.Size() -} -func (m *CompressedNonExistenceProof) XXX_DiscardUnknown() { - xxx_messageInfo_CompressedNonExistenceProof.DiscardUnknown(m) -} - -var xxx_messageInfo_CompressedNonExistenceProof proto.InternalMessageInfo - -func (m *CompressedNonExistenceProof) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *CompressedNonExistenceProof) GetLeft() *CompressedExistenceProof { - if m != nil { - return m.Left - } - return nil -} - -func (m *CompressedNonExistenceProof) GetRight() *CompressedExistenceProof { - if m != nil { - return m.Right - } - return nil -} - -func init() { - proto.RegisterEnum("ics23.HashOp", HashOp_name, HashOp_value) - proto.RegisterEnum("ics23.LengthOp", LengthOp_name, LengthOp_value) - proto.RegisterType((*ExistenceProof)(nil), "ics23.ExistenceProof") - proto.RegisterType((*NonExistenceProof)(nil), "ics23.NonExistenceProof") - proto.RegisterType((*CommitmentProof)(nil), "ics23.CommitmentProof") - proto.RegisterType((*LeafOp)(nil), "ics23.LeafOp") - proto.RegisterType((*InnerOp)(nil), "ics23.InnerOp") - proto.RegisterType((*ProofSpec)(nil), "ics23.ProofSpec") - proto.RegisterType((*InnerSpec)(nil), "ics23.InnerSpec") - proto.RegisterType((*BatchProof)(nil), "ics23.BatchProof") - proto.RegisterType((*BatchEntry)(nil), "ics23.BatchEntry") - proto.RegisterType((*CompressedBatchProof)(nil), "ics23.CompressedBatchProof") - proto.RegisterType((*CompressedBatchEntry)(nil), "ics23.CompressedBatchEntry") - proto.RegisterType((*CompressedExistenceProof)(nil), "ics23.CompressedExistenceProof") - proto.RegisterType((*CompressedNonExistenceProof)(nil), "ics23.CompressedNonExistenceProof") -} - -func init() { proto.RegisterFile("proofs.proto", fileDescriptor_855156e15e7b8e99) } - -var fileDescriptor_855156e15e7b8e99 = []byte{ - // 940 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4b, 0x6f, 0xe3, 0x54, - 0x14, 0xce, 0x4d, 0x62, 0x27, 0x39, 0x69, 0x53, 0xf7, 0xaa, 0x20, 0x4b, 0x15, 0x69, 0xf1, 0x86, - 0x4e, 0x47, 0x14, 0x26, 0x99, 0x06, 0xb1, 0x40, 0xa2, 0x49, 0x3d, 0xc4, 0x6a, 0x69, 0xc2, 0x4d, - 0x18, 0x0d, 0x12, 0x92, 0xe5, 0x49, 0x6f, 0x26, 0xd6, 0x24, 0xb6, 0x65, 0xbb, 0x28, 0x19, 0x81, - 0x90, 0xf8, 0x05, 0xac, 0x61, 0xc7, 0x96, 0x3f, 0xc2, 0xb2, 0x4b, 0x96, 0xa8, 0x5d, 0xb0, 0xe0, - 0x4f, 0xa0, 0xfb, 0x88, 0x9b, 0x27, 0xed, 0x02, 0xcd, 0xee, 0x9e, 0xef, 0x7c, 0xe7, 0x71, 0xcf, - 0xc3, 0xd7, 0xb0, 0x11, 0x84, 0xbe, 0xdf, 0x8f, 0x8e, 0x82, 0xd0, 0x8f, 0x7d, 0xac, 0xb8, 0xbd, - 0xa8, 0x52, 0x35, 0x7e, 0x84, 0x92, 0x39, 0x76, 0xa3, 0x98, 0x7a, 0x3d, 0xda, 0x66, 0x7a, 0xac, - 0x41, 0xe6, 0x35, 0x9d, 0xe8, 0x68, 0x1f, 0x1d, 0x6c, 0x10, 0x76, 0xc4, 0x3b, 0xa0, 0x7c, 0xe7, - 0x0c, 0xaf, 0xa8, 0x9e, 0xe6, 0x98, 0x10, 0xf0, 0xfb, 0x90, 0x1d, 0x52, 0xa7, 0xaf, 0x67, 0xf6, - 0xd1, 0x41, 0xb1, 0xb2, 0x79, 0xc4, 0xfd, 0x1d, 0x9d, 0x53, 0xa7, 0xdf, 0x0a, 0x08, 0x57, 0x61, - 0x03, 0xb2, 0x81, 0x13, 0x0f, 0xf4, 0xec, 0x7e, 0xe6, 0xa0, 0x58, 0x29, 0x49, 0x8a, 0xe5, 0x79, - 0x34, 0x64, 0x1c, 0xa6, 0x33, 0x7e, 0x80, 0xed, 0x0b, 0xdf, 0xbb, 0x37, 0x87, 0x47, 0x2c, 0x5a, - 0x3f, 0xe6, 0x29, 0x14, 0x2b, 0xef, 0x48, 0x57, 0xf3, 0x66, 0x84, 0x53, 0xf0, 0x63, 0x50, 0x42, - 0xf7, 0xd5, 0x20, 0x96, 0x99, 0xad, 0xe1, 0x0a, 0x8e, 0xf1, 0x0f, 0x82, 0xad, 0x86, 0x3f, 0x1a, - 0xb9, 0xf1, 0x88, 0x7a, 0xb1, 0x88, 0xfe, 0x21, 0x28, 0x94, 0x91, 0x79, 0xfc, 0x75, 0x0e, 0x9a, - 0x29, 0x22, 0x58, 0xb8, 0x06, 0x79, 0xcf, 0xf7, 0x84, 0x85, 0x48, 0x4f, 0x97, 0x16, 0x4b, 0x17, - 0x6b, 0xa6, 0x48, 0xc2, 0xc5, 0x8f, 0x40, 0x79, 0xe9, 0xc4, 0xbd, 0x81, 0xcc, 0x73, 0x5b, 0x1a, - 0xd5, 0x19, 0x96, 0x84, 0xe0, 0x0c, 0xfc, 0x19, 0x40, 0xcf, 0x1f, 0x05, 0x21, 0x8d, 0x22, 0x7a, - 0xa9, 0x67, 0x39, 0x7f, 0x57, 0xf2, 0x1b, 0x89, 0x62, 0xce, 0x72, 0xc6, 0xa0, 0x9e, 0x03, 0x85, - 0xf7, 0xde, 0xb8, 0x46, 0xa0, 0x8a, 0x0e, 0xb1, 0xf6, 0x0d, 0x9c, 0x68, 0xc0, 0xef, 0x58, 0x4a, - 0xda, 0xd7, 0x74, 0xa2, 0x01, 0x6b, 0x0d, 0x53, 0xe1, 0x23, 0x28, 0x06, 0x21, 0x65, 0x47, 0x9b, - 0x75, 0x23, 0xbd, 0x8a, 0x09, 0x92, 0x71, 0x46, 0x27, 0xb8, 0x02, 0x9b, 0x53, 0xbe, 0x98, 0x97, - 0xcc, 0x2a, 0x8b, 0x0d, 0xc9, 0x79, 0xce, 0xa7, 0xe8, 0x03, 0x50, 0x87, 0xd4, 0x7b, 0xc5, 0x87, - 0x84, 0x91, 0xb7, 0x92, 0x39, 0x62, 0x60, 0x2b, 0x20, 0x52, 0x8d, 0xdf, 0x05, 0x35, 0x08, 0x69, - 0xdf, 0x1d, 0xeb, 0x0a, 0x9f, 0x0a, 0x29, 0x19, 0xdf, 0x42, 0x4e, 0x0e, 0xd4, 0x43, 0xae, 0x74, - 0xe7, 0x25, 0x3d, 0xeb, 0x85, 0xe1, 0xd1, 0x55, 0x9f, 0xe1, 0x19, 0x81, 0x0b, 0xc9, 0xf8, 0x0d, - 0x41, 0x81, 0x57, 0xb4, 0x13, 0xd0, 0x1e, 0x3e, 0x84, 0x02, 0x9b, 0x6b, 0x3b, 0x0a, 0x68, 0x4f, - 0x0e, 0xc7, 0xc2, 0xdc, 0xe7, 0x99, 0x9e, 0x73, 0x3f, 0x02, 0x70, 0x59, 0x5e, 0x82, 0x2c, 0xe6, - 0x42, 0x9b, 0xdd, 0x00, 0xc6, 0x22, 0x05, 0x77, 0x7a, 0xc4, 0xbb, 0x50, 0x18, 0x39, 0x63, 0xfb, - 0x92, 0x06, 0xb1, 0x18, 0x09, 0x85, 0xe4, 0x47, 0xce, 0xf8, 0x94, 0xc9, 0x5c, 0xe9, 0x7a, 0x52, - 0x99, 0x95, 0x4a, 0xd7, 0xe3, 0x4a, 0xe3, 0x6f, 0x04, 0x85, 0xc4, 0x25, 0xde, 0x83, 0x62, 0x6f, - 0xe0, 0x0e, 0x2f, 0x6d, 0x3f, 0xbc, 0xa4, 0xa1, 0x8e, 0xf6, 0x33, 0x07, 0x0a, 0x01, 0x0e, 0xb5, - 0x18, 0x82, 0xdf, 0x03, 0x21, 0xd9, 0x91, 0xfb, 0x46, 0xec, 0xb4, 0x42, 0x0a, 0x1c, 0xe9, 0xb8, - 0x6f, 0x28, 0x3e, 0x84, 0x6d, 0x16, 0x4a, 0x14, 0xc6, 0x96, 0xcd, 0x11, 0xf9, 0x6c, 0x8d, 0x5c, - 0xaf, 0xcd, 0x71, 0xd1, 0x1e, 0xce, 0x75, 0xc6, 0x0b, 0xdc, 0xac, 0xe4, 0x3a, 0xe3, 0x39, 0xee, - 0x1e, 0x14, 0xe9, 0x28, 0x88, 0x27, 0x36, 0x0f, 0x25, 0xbb, 0x08, 0x1c, 0x6a, 0x30, 0x24, 0x69, - 0x9f, 0xba, 0xb6, 0x7d, 0xc6, 0xa7, 0x00, 0x77, 0x43, 0x8e, 0x1f, 0x43, 0x8e, 0x7a, 0x71, 0xe8, - 0xd2, 0x88, 0xdf, 0x72, 0x61, 0x85, 0x4c, 0x2f, 0x0e, 0x27, 0x64, 0xca, 0x30, 0xbe, 0x97, 0xa6, - 0x1c, 0x7e, 0x4b, 0x2b, 0x7e, 0xb7, 0x78, 0x3f, 0x21, 0xd8, 0x59, 0xb5, 0xa8, 0xf8, 0x78, 0xf1, - 0x0e, 0x6b, 0xd6, 0x7a, 0xfe, 0x36, 0xb8, 0x0a, 0x9b, 0x43, 0xdf, 0x7f, 0x7d, 0x15, 0xd8, 0x7c, - 0x80, 0x22, 0x3d, 0xbd, 0xf2, 0x13, 0xbb, 0x21, 0x48, 0x5c, 0x8c, 0x8c, 0x5f, 0x96, 0x93, 0x10, - 0xd5, 0xf8, 0x64, 0xbe, 0x1a, 0x7b, 0x4b, 0x29, 0xac, 0xab, 0xcb, 0xe7, 0x4b, 0x75, 0x31, 0x96, - 0x6c, 0x1f, 0x58, 0xa1, 0x09, 0xe8, 0xeb, 0xe2, 0xfd, 0x9f, 0x4f, 0x12, 0x9e, 0x79, 0x92, 0x14, - 0xf9, 0x04, 0xfd, 0x8a, 0x60, 0xf7, 0x3f, 0xf2, 0x5d, 0x11, 0xbe, 0x3a, 0xf7, 0x1a, 0xdd, 0x57, - 0x2f, 0xf9, 0x2e, 0x1d, 0xcf, 0xbf, 0x4b, 0xf7, 0x5a, 0x09, 0xf6, 0x21, 0x05, 0x55, 0xec, 0x00, - 0x2e, 0x42, 0xee, 0xa2, 0x65, 0x37, 0x4f, 0x3a, 0x4d, 0x2d, 0x85, 0x01, 0xd4, 0x4e, 0xf3, 0xa4, - 0x72, 0x5c, 0xd3, 0x90, 0x3c, 0x1f, 0x3f, 0xa9, 0x68, 0x69, 0x76, 0x3e, 0x33, 0x1b, 0x8d, 0x93, - 0x33, 0x2d, 0x83, 0x37, 0xa1, 0x40, 0xac, 0xb6, 0xf9, 0xe5, 0xe9, 0x93, 0xda, 0xc7, 0x5a, 0x96, - 0xd9, 0xd7, 0xad, 0x6e, 0xa3, 0x65, 0x5d, 0x68, 0x0a, 0x2e, 0x01, 0x08, 0x1b, 0x9b, 0xf9, 0x50, - 0x0f, 0x7f, 0x47, 0x90, 0x9f, 0x7e, 0x74, 0x99, 0xe1, 0x45, 0xcb, 0x6e, 0x13, 0xf3, 0x99, 0xf5, - 0x42, 0x4b, 0x31, 0xf1, 0xf9, 0x09, 0xb1, 0xdb, 0xa4, 0xd5, 0x6d, 0x69, 0x88, 0xf9, 0x61, 0x22, - 0x39, 0x6f, 0x6b, 0x69, 0xbc, 0x05, 0xc5, 0x67, 0xd6, 0x0b, 0xf3, 0xb4, 0x5a, 0xb1, 0xeb, 0xd6, - 0x17, 0x5a, 0x06, 0x63, 0x28, 0x4d, 0x81, 0x73, 0xab, 0xdb, 0x3d, 0x37, 0xb5, 0x6c, 0x42, 0xaa, - 0x3d, 0xe5, 0x24, 0x25, 0x21, 0xd5, 0x9e, 0x4e, 0x49, 0x2a, 0xde, 0x01, 0x8d, 0x98, 0x5f, 0x7d, - 0x6d, 0x11, 0xd3, 0x66, 0xce, 0xbe, 0xe9, 0x9a, 0x1d, 0x2d, 0x37, 0x8b, 0x32, 0x6b, 0x8e, 0xe6, - 0xeb, 0xfa, 0x1f, 0x37, 0x65, 0x74, 0x7d, 0x53, 0x46, 0x7f, 0xdd, 0x94, 0xd1, 0xcf, 0xb7, 0xe5, - 0xd4, 0xf5, 0x6d, 0x39, 0xf5, 0xe7, 0x6d, 0x39, 0xf5, 0x52, 0xe5, 0xbf, 0x37, 0xd5, 0x7f, 0x03, - 0x00, 0x00, 0xff, 0xff, 0xd4, 0x7d, 0x87, 0x8f, 0xee, 0x08, 0x00, 0x00, -} - -func (m *ExistenceProof) 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 *ExistenceProof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Path) > 0 { - for iNdEx := len(m.Path) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Path[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if m.Leaf != nil { - { - size, err := m.Leaf.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *NonExistenceProof) 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 *NonExistenceProof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NonExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Right != nil { - { - size, err := m.Right.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.Left != nil { - { - size, err := m.Left.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *CommitmentProof) 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 *CommitmentProof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CommitmentProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Proof != nil { - { - size := m.Proof.Size() - i -= size - if _, err := m.Proof.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *CommitmentProof_Exist) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CommitmentProof_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Exist != nil { - { - size, err := m.Exist.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *CommitmentProof_Nonexist) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CommitmentProof_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Nonexist != nil { - { - size, err := m.Nonexist.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *CommitmentProof_Batch) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CommitmentProof_Batch) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Batch != nil { - { - size, err := m.Batch.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} -func (m *CommitmentProof_Compressed) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CommitmentProof_Compressed) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Compressed != nil { - { - size, err := m.Compressed.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} -func (m *LeafOp) 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 *LeafOp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LeafOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Prefix) > 0 { - i -= len(m.Prefix) - copy(dAtA[i:], m.Prefix) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Prefix))) - i-- - dAtA[i] = 0x2a - } - if m.Length != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.Length)) - i-- - dAtA[i] = 0x20 - } - if m.PrehashValue != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.PrehashValue)) - i-- - dAtA[i] = 0x18 - } - if m.PrehashKey != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.PrehashKey)) - i-- - dAtA[i] = 0x10 - } - if m.Hash != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.Hash)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *InnerOp) 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 *InnerOp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InnerOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Suffix) > 0 { - i -= len(m.Suffix) - copy(dAtA[i:], m.Suffix) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Suffix))) - i-- - dAtA[i] = 0x1a - } - if len(m.Prefix) > 0 { - i -= len(m.Prefix) - copy(dAtA[i:], m.Prefix) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Prefix))) - i-- - dAtA[i] = 0x12 - } - if m.Hash != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.Hash)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ProofSpec) 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 *ProofSpec) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProofSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.MinDepth != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.MinDepth)) - i-- - dAtA[i] = 0x20 - } - if m.MaxDepth != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.MaxDepth)) - i-- - dAtA[i] = 0x18 - } - if m.InnerSpec != nil { - { - size, err := m.InnerSpec.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.LeafSpec != nil { - { - size, err := m.LeafSpec.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *InnerSpec) 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 *InnerSpec) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InnerSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Hash != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.Hash)) - i-- - dAtA[i] = 0x30 - } - if len(m.EmptyChild) > 0 { - i -= len(m.EmptyChild) - copy(dAtA[i:], m.EmptyChild) - i = encodeVarintProofs(dAtA, i, uint64(len(m.EmptyChild))) - i-- - dAtA[i] = 0x2a - } - if m.MaxPrefixLength != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.MaxPrefixLength)) - i-- - dAtA[i] = 0x20 - } - if m.MinPrefixLength != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.MinPrefixLength)) - i-- - dAtA[i] = 0x18 - } - if m.ChildSize != 0 { - i = encodeVarintProofs(dAtA, i, uint64(m.ChildSize)) - i-- - dAtA[i] = 0x10 - } - if len(m.ChildOrder) > 0 { - dAtA11 := make([]byte, len(m.ChildOrder)*10) - var j10 int - for _, num1 := range m.ChildOrder { - num := uint64(num1) - for num >= 1<<7 { - dAtA11[j10] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j10++ - } - dAtA11[j10] = uint8(num) - j10++ - } - i -= j10 - copy(dAtA[i:], dAtA11[:j10]) - i = encodeVarintProofs(dAtA, i, uint64(j10)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *BatchProof) 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 *BatchProof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BatchProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Entries) > 0 { - for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *BatchEntry) 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 *BatchEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BatchEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Proof != nil { - { - size := m.Proof.Size() - i -= size - if _, err := m.Proof.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *BatchEntry_Exist) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BatchEntry_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Exist != nil { - { - size, err := m.Exist.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *BatchEntry_Nonexist) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BatchEntry_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Nonexist != nil { - { - size, err := m.Nonexist.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *CompressedBatchProof) 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 *CompressedBatchProof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CompressedBatchProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.LookupInners) > 0 { - for iNdEx := len(m.LookupInners) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LookupInners[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Entries) > 0 { - for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *CompressedBatchEntry) 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 *CompressedBatchEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CompressedBatchEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Proof != nil { - { - size := m.Proof.Size() - i -= size - if _, err := m.Proof.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *CompressedBatchEntry_Exist) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CompressedBatchEntry_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Exist != nil { - { - size, err := m.Exist.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *CompressedBatchEntry_Nonexist) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CompressedBatchEntry_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Nonexist != nil { - { - size, err := m.Nonexist.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *CompressedExistenceProof) 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 *CompressedExistenceProof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CompressedExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Path) > 0 { - dAtA17 := make([]byte, len(m.Path)*10) - var j16 int - for _, num1 := range m.Path { - num := uint64(num1) - for num >= 1<<7 { - dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j16++ - } - dAtA17[j16] = uint8(num) - j16++ - } - i -= j16 - copy(dAtA[i:], dAtA17[:j16]) - i = encodeVarintProofs(dAtA, i, uint64(j16)) - i-- - dAtA[i] = 0x22 - } - if m.Leaf != nil { - { - size, err := m.Leaf.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *CompressedNonExistenceProof) 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 *CompressedNonExistenceProof) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CompressedNonExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Right != nil { - { - size, err := m.Right.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.Left != nil { - { - size, err := m.Left.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProofs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintProofs(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintProofs(dAtA []byte, offset int, v uint64) int { - offset -= sovProofs(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ExistenceProof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - if m.Leaf != nil { - l = m.Leaf.Size() - n += 1 + l + sovProofs(uint64(l)) - } - if len(m.Path) > 0 { - for _, e := range m.Path { - l = e.Size() - n += 1 + l + sovProofs(uint64(l)) - } - } - return n -} - -func (m *NonExistenceProof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - if m.Left != nil { - l = m.Left.Size() - n += 1 + l + sovProofs(uint64(l)) - } - if m.Right != nil { - l = m.Right.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} - -func (m *CommitmentProof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Proof != nil { - n += m.Proof.Size() - } - return n -} - -func (m *CommitmentProof_Exist) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Exist != nil { - l = m.Exist.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} -func (m *CommitmentProof_Nonexist) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Nonexist != nil { - l = m.Nonexist.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} -func (m *CommitmentProof_Batch) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Batch != nil { - l = m.Batch.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} -func (m *CommitmentProof_Compressed) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Compressed != nil { - l = m.Compressed.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} -func (m *LeafOp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Hash != 0 { - n += 1 + sovProofs(uint64(m.Hash)) - } - if m.PrehashKey != 0 { - n += 1 + sovProofs(uint64(m.PrehashKey)) - } - if m.PrehashValue != 0 { - n += 1 + sovProofs(uint64(m.PrehashValue)) - } - if m.Length != 0 { - n += 1 + sovProofs(uint64(m.Length)) - } - l = len(m.Prefix) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - return n -} - -func (m *InnerOp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Hash != 0 { - n += 1 + sovProofs(uint64(m.Hash)) - } - l = len(m.Prefix) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - l = len(m.Suffix) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - return n -} - -func (m *ProofSpec) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.LeafSpec != nil { - l = m.LeafSpec.Size() - n += 1 + l + sovProofs(uint64(l)) - } - if m.InnerSpec != nil { - l = m.InnerSpec.Size() - n += 1 + l + sovProofs(uint64(l)) - } - if m.MaxDepth != 0 { - n += 1 + sovProofs(uint64(m.MaxDepth)) - } - if m.MinDepth != 0 { - n += 1 + sovProofs(uint64(m.MinDepth)) - } - return n -} - -func (m *InnerSpec) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ChildOrder) > 0 { - l = 0 - for _, e := range m.ChildOrder { - l += sovProofs(uint64(e)) - } - n += 1 + sovProofs(uint64(l)) + l - } - if m.ChildSize != 0 { - n += 1 + sovProofs(uint64(m.ChildSize)) - } - if m.MinPrefixLength != 0 { - n += 1 + sovProofs(uint64(m.MinPrefixLength)) - } - if m.MaxPrefixLength != 0 { - n += 1 + sovProofs(uint64(m.MaxPrefixLength)) - } - l = len(m.EmptyChild) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - if m.Hash != 0 { - n += 1 + sovProofs(uint64(m.Hash)) - } - return n -} - -func (m *BatchProof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Entries) > 0 { - for _, e := range m.Entries { - l = e.Size() - n += 1 + l + sovProofs(uint64(l)) - } - } - return n -} - -func (m *BatchEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Proof != nil { - n += m.Proof.Size() - } - return n -} - -func (m *BatchEntry_Exist) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Exist != nil { - l = m.Exist.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} -func (m *BatchEntry_Nonexist) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Nonexist != nil { - l = m.Nonexist.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} -func (m *CompressedBatchProof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Entries) > 0 { - for _, e := range m.Entries { - l = e.Size() - n += 1 + l + sovProofs(uint64(l)) - } - } - if len(m.LookupInners) > 0 { - for _, e := range m.LookupInners { - l = e.Size() - n += 1 + l + sovProofs(uint64(l)) - } - } - return n -} - -func (m *CompressedBatchEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Proof != nil { - n += m.Proof.Size() - } - return n -} - -func (m *CompressedBatchEntry_Exist) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Exist != nil { - l = m.Exist.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} -func (m *CompressedBatchEntry_Nonexist) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Nonexist != nil { - l = m.Nonexist.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} -func (m *CompressedExistenceProof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - if m.Leaf != nil { - l = m.Leaf.Size() - n += 1 + l + sovProofs(uint64(l)) - } - if len(m.Path) > 0 { - l = 0 - for _, e := range m.Path { - l += sovProofs(uint64(e)) - } - n += 1 + sovProofs(uint64(l)) + l - } - return n -} - -func (m *CompressedNonExistenceProof) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovProofs(uint64(l)) - } - if m.Left != nil { - l = m.Left.Size() - n += 1 + l + sovProofs(uint64(l)) - } - if m.Right != nil { - l = m.Right.Size() - n += 1 + l + sovProofs(uint64(l)) - } - return n -} - -func sovProofs(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozProofs(x uint64) (n int) { - return sovProofs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ExistenceProof) 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 ErrIntOverflowProofs - } - 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: ExistenceProof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExistenceProof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Leaf", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Leaf == nil { - m.Leaf = &LeafOp{} - } - if err := m.Leaf.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Path = append(m.Path, &InnerOp{}) - if err := m.Path[len(m.Path)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *NonExistenceProof) 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 ErrIntOverflowProofs - } - 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: NonExistenceProof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NonExistenceProof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Left", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Left == nil { - m.Left = &ExistenceProof{} - } - if err := m.Left.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Right", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Right == nil { - m.Right = &ExistenceProof{} - } - if err := m.Right.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CommitmentProof) 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 ErrIntOverflowProofs - } - 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: CommitmentProof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CommitmentProof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Exist", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ExistenceProof{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Proof = &CommitmentProof_Exist{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonexist", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &NonExistenceProof{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Proof = &CommitmentProof_Nonexist{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Batch", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &BatchProof{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Proof = &CommitmentProof_Batch{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Compressed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &CompressedBatchProof{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Proof = &CommitmentProof_Compressed{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LeafOp) 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 ErrIntOverflowProofs - } - 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: LeafOp: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LeafOp: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - m.Hash = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Hash |= HashOp(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PrehashKey", wireType) - } - m.PrehashKey = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PrehashKey |= HashOp(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PrehashValue", wireType) - } - m.PrehashValue = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PrehashValue |= HashOp(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Length", wireType) - } - m.Length = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Length |= LengthOp(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Prefix = append(m.Prefix[:0], dAtA[iNdEx:postIndex]...) - if m.Prefix == nil { - m.Prefix = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InnerOp) 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 ErrIntOverflowProofs - } - 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: InnerOp: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InnerOp: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - m.Hash = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Hash |= HashOp(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Prefix = append(m.Prefix[:0], dAtA[iNdEx:postIndex]...) - if m.Prefix == nil { - m.Prefix = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Suffix", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Suffix = append(m.Suffix[:0], dAtA[iNdEx:postIndex]...) - if m.Suffix == nil { - m.Suffix = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ProofSpec) 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 ErrIntOverflowProofs - } - 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: ProofSpec: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProofSpec: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LeafSpec", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.LeafSpec == nil { - m.LeafSpec = &LeafOp{} - } - if err := m.LeafSpec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InnerSpec", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.InnerSpec == nil { - m.InnerSpec = &InnerSpec{} - } - if err := m.InnerSpec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxDepth", wireType) - } - m.MaxDepth = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxDepth |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinDepth", wireType) - } - m.MinDepth = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinDepth |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InnerSpec) 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 ErrIntOverflowProofs - } - 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: InnerSpec: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InnerSpec: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType == 0 { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ChildOrder = append(m.ChildOrder, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.ChildOrder) == 0 { - m.ChildOrder = make([]int32, 0, elementCount) - } - for iNdEx < postIndex { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ChildOrder = append(m.ChildOrder, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field ChildOrder", wireType) - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ChildSize", wireType) - } - m.ChildSize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ChildSize |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinPrefixLength", wireType) - } - m.MinPrefixLength = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MinPrefixLength |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxPrefixLength", wireType) - } - m.MaxPrefixLength = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxPrefixLength |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EmptyChild", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EmptyChild = append(m.EmptyChild[:0], dAtA[iNdEx:postIndex]...) - if m.EmptyChild == nil { - m.EmptyChild = []byte{} - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - m.Hash = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Hash |= HashOp(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BatchProof) 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 ErrIntOverflowProofs - } - 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: BatchProof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BatchProof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Entries = append(m.Entries, &BatchEntry{}) - if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BatchEntry) 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 ErrIntOverflowProofs - } - 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: BatchEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BatchEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Exist", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ExistenceProof{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Proof = &BatchEntry_Exist{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonexist", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &NonExistenceProof{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Proof = &BatchEntry_Nonexist{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CompressedBatchProof) 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 ErrIntOverflowProofs - } - 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: CompressedBatchProof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CompressedBatchProof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Entries = append(m.Entries, &CompressedBatchEntry{}) - if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LookupInners", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LookupInners = append(m.LookupInners, &InnerOp{}) - if err := m.LookupInners[len(m.LookupInners)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CompressedBatchEntry) 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 ErrIntOverflowProofs - } - 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: CompressedBatchEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CompressedBatchEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Exist", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &CompressedExistenceProof{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Proof = &CompressedBatchEntry_Exist{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonexist", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &CompressedNonExistenceProof{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Proof = &CompressedBatchEntry_Nonexist{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CompressedExistenceProof) 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 ErrIntOverflowProofs - } - 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: CompressedExistenceProof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CompressedExistenceProof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Leaf", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Leaf == nil { - m.Leaf = &LeafOp{} - } - if err := m.Leaf.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType == 0 { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Path = append(m.Path, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.Path) == 0 { - m.Path = make([]int32, 0, elementCount) - } - for iNdEx < postIndex { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Path = append(m.Path, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CompressedNonExistenceProof) 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 ErrIntOverflowProofs - } - 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: CompressedNonExistenceProof: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CompressedNonExistenceProof: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Left", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Left == nil { - m.Left = &CompressedExistenceProof{} - } - if err := m.Left.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Right", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProofs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProofs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProofs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Right == nil { - m.Right = &CompressedExistenceProof{} - } - if err := m.Right.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProofs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProofs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipProofs(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, ErrIntOverflowProofs - } - 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, ErrIntOverflowProofs - } - 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, ErrIntOverflowProofs - } - 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, ErrInvalidLengthProofs - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupProofs - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthProofs - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthProofs = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowProofs = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupProofs = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/gov/migrations/v046/json_test.go b/x/gov/migrations/v046/json_test.go index 518161b9e8b5..bd4330d46063 100644 --- a/x/gov/migrations/v046/json_test.go +++ b/x/gov/migrations/v046/json_test.go @@ -19,6 +19,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) +var voter = sdk.MustAccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") + func TestMigrateJSON(t *testing.T) { encodingConfig := simapp.MakeTestEncodingConfig() clientCtx := client.Context{}. diff --git a/x/gov/migrations/v046/store.go b/x/gov/migrations/v046/store.go index c0ad36dfb4b7..9fbcf9f3413d 100644 --- a/x/gov/migrations/v046/store.go +++ b/x/gov/migrations/v046/store.go @@ -6,7 +6,8 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" v042 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) // migrateProposals migrates all legacy proposals into MsgExecLegacyContent @@ -18,7 +19,7 @@ func migrateProposals(store sdk.KVStore, cdc codec.BinaryCodec) error { defer iter.Close() for ; iter.Valid(); iter.Next() { - var oldProp v1beta1.Proposal + var oldProp govv1beta1.Proposal err := cdc.Unmarshal(iter.Value(), &oldProp) if err != nil { return err @@ -40,12 +41,69 @@ func migrateProposals(store sdk.KVStore, cdc codec.BinaryCodec) error { return nil } -// MigrateStore performs in-place store migrations from v0.43 to v0.46. The +// migrateVotes migrates all v1beta1 weighted votes (with sdk.Dec as weight) +// to v1 weighted votes (with string as weight) +func migrateVotes(store sdk.KVStore, cdc codec.BinaryCodec) error { + votesStore := prefix.NewStore(store, v042.VotesKeyPrefix) + + iter := votesStore.Iterator(nil, nil) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var oldVote govv1beta1.Vote + err := cdc.Unmarshal(iter.Value(), &oldVote) + if err != nil { + return err + } + + newVote := govv1.Vote{ + ProposalId: oldVote.ProposalId, + Voter: oldVote.Voter, + } + newOptions := make([]*govv1.WeightedVoteOption, len(oldVote.Options)) + for i, o := range oldVote.Options { + newOptions[i] = &govv1.WeightedVoteOption{ + Option: govv1.VoteOption(o.Option), + Weight: o.Weight.String(), // Convert to decimal string + } + } + newVote.Options = newOptions + bz, err := cdc.Marshal(&newVote) + if err != nil { + return err + } + + // Set new value on store. + votesStore.Set(iter.Key(), bz) + } + + return nil +} + +// MigrateStore performs in-place store migrations from v2 (v0.43) to v3 (v0.46). The // migration includes: // // - Migrate proposals to be Msg-based. func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { store := ctx.KVStore(storeKey) + if err := migrateVotes(store, cdc); err != nil { + return err + } + return migrateProposals(store, cdc) } + +// Migrate_V046_4_To_V046_5 is a helper function to migrate chains from <=v0.46.6 +// to v0.46.7 ONLY. +// +// IMPORTANT: Please do not use this function if you are upgrading to v0.46 +// from <=v0.45. +// +// This function migrates the store in-place by fixing the gov votes weight to +// be stored as decimals strings (instead of the sdk.Dec BigInt representation). +// +// The store is expected to be the gov store, and not any prefixed substore. +func Migrate_V046_6_To_V046_7(store sdk.KVStore, cdc codec.BinaryCodec) error { + return migrateVotes(store, cdc) +} diff --git a/x/gov/migrations/v046/store_test.go b/x/gov/migrations/v046/store_test.go index a9318f9390a9..4d3e50e68de1 100644 --- a/x/gov/migrations/v046/store_test.go +++ b/x/gov/migrations/v046/store_test.go @@ -39,6 +39,15 @@ func TestMigrateStore(t *testing.T) { store.Set(v042gov.ProposalKey(prop1.ProposalId), prop1Bz) store.Set(v042gov.ProposalKey(prop2.ProposalId), prop2Bz) + // Vote on prop 1 + options := []v1beta1.WeightedVoteOption{ + {Option: v1beta1.OptionNo, Weight: sdk.MustNewDecFromStr("0.3")}, + {Option: v1beta1.OptionYes, Weight: sdk.MustNewDecFromStr("0.7")}, + } + vote1 := v1beta1.NewVote(1, voter, options) + vote1Bz := cdc.MustMarshal(&vote1) + store.Set(v042gov.VoteKey(1, voter), vote1Bz) + // Run migrations. err = v046gov.MigrateStore(ctx, govKey, cdc) require.NoError(t, err) @@ -52,6 +61,14 @@ func TestMigrateStore(t *testing.T) { err = cdc.Unmarshal(store.Get(v042gov.ProposalKey(prop2.ProposalId)), &newProp2) require.NoError(t, err) compareProps(t, prop2, newProp2) + + var newVote1 v1.Vote + err = cdc.Unmarshal(store.Get(v042gov.VoteKey(prop1.ProposalId, voter)), &newVote1) + require.NoError(t, err) + // Without the votes migration, we would have 300000000000000000 in state, + // because of how sdk.Dec stores itself in state. + require.Equal(t, "0.300000000000000000", newVote1.Options[0].Weight) + require.Equal(t, "0.700000000000000000", newVote1.Options[1].Weight) } func compareProps(t *testing.T, oldProp v1beta1.Proposal, newProp v1.Proposal) {