diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1b427152..3e9d810b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: "1.20" + go-version: "1.21" # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/golangci_lint.yml b/.github/workflows/golangci_lint.yml index 8bf57462..9ea6d315 100644 --- a/.github/workflows/golangci_lint.yml +++ b/.github/workflows/golangci_lint.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: "1.20" + go-version: "1.21" check-latest: true - uses: technote-space/get-diff-action@v6.1.2 id: git_diff diff --git a/.github/workflows/release_binary.yml b/.github/workflows/release_binary.yml index 3c0e3892..e99d6468 100644 --- a/.github/workflows/release_binary.yml +++ b/.github/workflows/release_binary.yml @@ -21,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' check-latest: true - name: release dry run diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ec5e16e..334125e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' check-latest: true - uses: actions/checkout@v4 - uses: technote-space/get-diff-action@v6.1.2 diff --git a/go.mod b/go.mod index bcd28a26..90dab20c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Lorenzo-Protocol/lorenzo/v2 -go 1.20 +go 1.21 require ( cosmossdk.io/errors v1.0.1 @@ -32,7 +32,6 @@ require ( require ( cosmossdk.io/core v0.5.1 - github.com/armon/go-metrics v0.4.1 github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/btcsuite/btcd/btcutil v1.1.5 github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 @@ -41,6 +40,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 + golang.org/x/crypto v0.21.0 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 ) @@ -59,6 +59,7 @@ require ( github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect + github.com/armon/go-metrics v0.4.1 // indirect github.com/aws/aws-sdk-go v1.44.203 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect @@ -209,7 +210,6 @@ require ( go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect diff --git a/go.sum b/go.sum index d6f989d5..7bae49ca 100644 --- a/go.sum +++ b/go.sum @@ -215,6 +215,7 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3 github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= @@ -225,7 +226,9 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go github.com/Lorenzo-Protocol/ethermint v0.22.0-lorenzo-4 h1:uMybTuWsBk+JuzNPDp+WdKyDM0U87TzEJgYR7sLzfMg= github.com/Lorenzo-Protocol/ethermint v0.22.0-lorenzo-4/go.mod h1:JEhGmVj5rZX5bTfOqh3nltE2N6+qMI4HVNV2vW6PpOQ= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -238,6 +241,7 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:eSYp2T6f0apnuW8TzhV3f6Aff2SE8Dwio++U4ha4yEM= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= +github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= @@ -321,6 +325,7 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= +github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA= @@ -368,6 +373,7 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ= +github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -392,6 +398,7 @@ github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSM github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -473,7 +480,9 @@ github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/ github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf h1:Yt+4K30SdjOkRoRRm3vYNQgR+/ZIy0RmeUDZo7Y8zeQ= github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= @@ -502,6 +511,7 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go. github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= +github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew= github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= @@ -514,9 +524,11 @@ github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlK github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= @@ -536,6 +548,7 @@ github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= @@ -573,6 +586,7 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= @@ -669,12 +683,14 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -991,6 +1007,7 @@ github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -1002,16 +1019,22 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= +github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= +github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= +github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= +github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -1022,6 +1045,7 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= +github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= @@ -1042,6 +1066,7 @@ github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1137,6 +1162,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -1235,6 +1261,7 @@ github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y= +github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= @@ -1245,6 +1272,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1280,6 +1308,7 @@ go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znn go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -1349,6 +1378,7 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1661,6 +1691,7 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1951,6 +1982,7 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/proto/lorenzo/bnblightclient/v1/client.proto b/proto/lorenzo/bnblightclient/v1/client.proto new file mode 100644 index 00000000..0ac6acf2 --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/client.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; + +message Header { + option (gogoproto.goproto_getters) = false; + + // header defines the bnb header bytes + bytes raw_header = 1; + // parent_hash defines the previous bnb header hash + bytes parent_hash = 2; + // hash defines the bnb header hash + bytes hash = 3; + // number defines the block number + uint64 number = 4; + // receipt_root defines the receipts merkle root hash + bytes receipt_root = 5; +} \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/genesis.proto b/proto/lorenzo/bnblightclient/v1/genesis.proto new file mode 100644 index 00000000..5727ca57 --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/genesis.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "lorenzo/bnblightclient/v1/client.proto"; +import "lorenzo/bnblightclient/v1/params.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; + +// GenesisState defines the bnb light client state +message GenesisState { + // params defines the bnb light client parameters + lorenzo.bnblightclient.v1.Params params = 1; + // headers defines the bnb light client headers + repeated lorenzo.bnblightclient.v1.Header headers = 2; + // events defines the bnb chain generated events + repeated EvmEvent events = 3; +} + +message EvmEvent { + // block_number defines the block number + uint64 block_number = 1; + // contract defines the contract + bytes contract = 2; + // index defines the unique identifier of the event + uint64 identifier = 3; +} \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/params.proto b/proto/lorenzo/bnblightclient/v1/params.proto new file mode 100644 index 00000000..3134b0b0 --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/params.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.equal) = true; + + // the stake plan hub contract address + string stake_plan_hub_address = 1; + // event_name defines the event name + string event_name = 2; + // the maximum number of bnb block headers to retain + uint64 retained_blocks = 3; + // list of people who can upload bnb block header information + repeated string allow_list = 4; + // chain_id defines the bnb chain id + uint32 chain_id = 5; +} \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/query.proto b/proto/lorenzo/bnblightclient/v1/query.proto new file mode 100644 index 00000000..fcbe0049 --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/query.proto @@ -0,0 +1,74 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "lorenzo/bnblightclient/v1/client.proto"; +import "lorenzo/bnblightclient/v1/params.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; + +// Query defines the gRPC querier service. +service Query { + // Params queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/params"; + } + + // Header returns the header in bnb chain by number + rpc Header(QueryHeaderRequest) returns (QueryHeaderResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/header/{number}"; + } + + // HeaderByHash returns the header in bnb chain by hash + rpc HeaderByHash(QueryHeaderByHashRequest) + returns (QueryHeaderByHashResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/header/{hash}/hash"; + } + + // LatestHeader returns the latest header in bnb chain + rpc LatestHeader(QueryLatestHeaderRequest) + returns (QueryLatestHeaderResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/latest_header"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + lorenzo.bnblightclient.v1.Params params = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryHeaderRequest is the request type for the Query/Header RPC method. +message QueryHeaderRequest { uint64 number = 1; } + +// QueryParamsResponse is the response type for the Query/Header RPC method. +message QueryHeaderResponse { + // params holds all the parameters of this module. + lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = true ]; +} + +// QueryHeaderByHashRequest is the request type for the Query/HeaderByHash RPC +// method. +message QueryHeaderByHashRequest { bytes hash = 1; } + +// QueryHeaderByHashResponse is the response type for the Query/HeaderByHash RPC +// method. +message QueryHeaderByHashResponse { + // params holds all the parameters of this module. + lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = true ]; +} + +// QueryLatestHeaderRequest is the request type for the Query/LatestHeader +// RPC method. +message QueryLatestHeaderRequest {} + +// QueryLatestHeaderResponse is the response type for the Query/LatestHeader +// RPC method. +message QueryLatestHeaderResponse { + // header holds the bnb light client header. + lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/tx.proto b/proto/lorenzo/bnblightclient/v1/tx.proto new file mode 100644 index 00000000..b4af189c --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/tx.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; +import "lorenzo/bnblightclient/v1/client.proto"; +import "lorenzo/bnblightclient/v1/params.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; + +// Msg defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // UploadHeaders adds a batch of headers to the bnb light client chain + rpc UploadHeaders(MsgUploadHeaders) returns (MsgUploadHeadersResponse) {}; + + // UpdateParams defines a method for updating bnb light client module + // parameters. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // UpdateHeader defines a method for updating bnb light client header. + rpc UpdateHeader(MsgUpdateHeader) returns (MsgUpdateHeaderResponse); +} + +// MsgUploadHeaders defines the message for multiple incoming header bytes +message MsgUploadHeaders { + option (cosmos.msg.v1.signer) = "signer"; + + repeated lorenzo.bnblightclient.v1.Header headers = 1; + string signer = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} +// MsgUploadHeadersResponse defines the response for the UploadHeaders transaction +message MsgUploadHeadersResponse {} + +// MsgUpdateHeader defines the message for updating bnb light client header. +message MsgUpdateHeader { + option (cosmos.msg.v1.signer) = "signer"; + + lorenzo.bnblightclient.v1.Header header = 1; + string signer = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} +// MsgUpdateHeaderResponse defines the response for the UpdateHeader +// transaction +message MsgUpdateHeaderResponse {} + +// MsgUpdateParams defines a message for updating fee module parameters. +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + // just FYI: cosmos.AddressString marks that this field should use type alias + // for AddressString instead of string, but the functionality is not yet + // implemented in cosmos-proto + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // params defines the bnb light client parameters. + // + // NOTE: All parameters must be supplied. + lorenzo.bnblightclient.v1.Params params = 2 [ (gogoproto.nullable) = false ]; +} + +// MsgUpdateParamsResponse is the response to the MsgUpdateParams message. +message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/proto/lorenzo/btcstaking/v1/staking_record.proto b/proto/lorenzo/btcstaking/v1/staking_record.proto index c3f394a8..745f521b 100644 --- a/proto/lorenzo/btcstaking/v1/staking_record.proto +++ b/proto/lorenzo/btcstaking/v1/staking_record.proto @@ -1,10 +1,7 @@ syntax = "proto3"; package lorenzo.btcstaking.v1; -import "cosmos/msg/v1/msg.proto"; -import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -// import "cosmos/staking/v1beta1/staking.proto"; option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/btcstaking/types"; @@ -16,3 +13,20 @@ message BTCStakingRecord { string agent_btc_addr = 5; uint32 chain_id = 6; } + +// BTCBStakingRecord defines the message for btcb staking record +message BTCBStakingRecord { + // tx_hash defines the tx hash + bytes tx_hash = 1; + // event_idx defines the event index + uint64 event_idx = 2; + // receiver_addr defines the receiver address + string receiver_addr = 3; + // amount defines the stBTC amount + string amount = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + // chain_id defines the chain id + uint32 chain_id = 5; +} diff --git a/proto/lorenzo/btcstaking/v1/tx.proto b/proto/lorenzo/btcstaking/v1/tx.proto index e13d39d2..7ef2aec8 100644 --- a/proto/lorenzo/btcstaking/v1/tx.proto +++ b/proto/lorenzo/btcstaking/v1/tx.proto @@ -16,6 +16,9 @@ service Msg { rpc CreateBTCStaking(MsgCreateBTCStaking) returns (MsgCreateBTCStakingResponse); + rpc CreateBTCStakingFromBNB(MsgCreateBTCStakingFromBNB) + returns (MsgCreateBTCStakingFromBNBResponse); + rpc Burn(MsgBurnRequest) returns (MsgBurnResponse); rpc AddReceiver(MsgAddReceiver) returns (MsgAddReceiverResponse); @@ -59,6 +62,16 @@ message MsgCreateBTCStaking { message MsgCreateBTCStakingResponse {} +message MsgCreateBTCStakingFromBNB { + option (cosmos.msg.v1.signer) = "signer"; + + string signer = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + bytes receipt = 2; + bytes proof = 3; +} + +message MsgCreateBTCStakingFromBNBResponse {} + message MsgBurnRequest { option (cosmos.msg.v1.signer) = "signer"; string signer = 1; diff --git a/x/bnblightclient/client/cli/query.go b/x/bnblightclient/client/cli/query.go new file mode 100644 index 00000000..0a64ee78 --- /dev/null +++ b/x/bnblightclient/client/cli/query.go @@ -0,0 +1,135 @@ +package cli + +import ( + "context" + "fmt" + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/ethereum/go-ethereum/common" + "github.com/spf13/cobra" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" +) + +// GetQueryCmd returns the cli query commands for bnblightclient module +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdQueryHeader()) + cmd.AddCommand(CmdQueryHeaderHash()) + cmd.AddCommand(CmdQueryLatestHeader()) + return cmd +} + +// CmdQueryParams returns a new Cobra command for showing the parameters of the bnblightclient module. +// +// No parameters. +// Returns *cobra.Command. +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "query the parameters of the fee module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// CmdQueryHeader returns a new Cobra command for querying the header of the bnblightclient module by number. +// +// It takes no parameters and returns a pointer to a Cobra command. +func CmdQueryHeader() *cobra.Command { + cmd := &cobra.Command{ + Use: "header", + Short: "query the header of the bnblightclient module by number", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + number, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("invalid number: %s, error: %s", args[0], err.Error()) + } + + res, err := queryClient.Header(context.Background(), &types.QueryHeaderRequest{Number: number}) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// CmdQueryHeaderHash queries the header of the bnblightclient module by hash. +// +// It takes exact 1 argument. +// Returns an error. +func CmdQueryHeaderHash() *cobra.Command { + cmd := &cobra.Command{ + Use: "header-hash", + Short: "query the header of the bnblightclient module by hash", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.HeaderByHash( + context.Background(), + &types.QueryHeaderByHashRequest{Hash: common.FromHex(args[0])}, + ) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// CmdQueryLatestHeader returns a new Cobra command for querying the latest header of the bnblightclient module. +// +// It takes exact 1 argument. +// Returns an error. +func CmdQueryLatestHeader() *cobra.Command { + cmd := &cobra.Command{ + Use: "latest-header", + Short: "query the latest header of the bnblightclient module", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.LatestHeader( + context.Background(), + &types.QueryLatestHeaderRequest{}, + ) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/bnblightclient/client/cli/tx.go b/x/bnblightclient/client/cli/tx.go new file mode 100644 index 00000000..00946a0f --- /dev/null +++ b/x/bnblightclient/client/cli/tx.go @@ -0,0 +1,120 @@ +package cli + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" +) + +// GetTxCmd returns the transaction commands for bnblightclient module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand(CmdTxUploadHeaders()) + cmd.AddCommand(CmdTxUpdateHeader()) + return cmd +} + +// CmdTxUploadHeaders creates a cobra.Command to upload BNB light client headers. +// +// It takes a single argument, which is the path to a JSON file containing the headers. +// The function reads the content of the file, unmarshals it into a slice of types.Header, +// and creates a MsgUploadHeaders message with the signer and the headers. +// +// The function returns an error if there is any issue reading the file or unmarshaling +// the content. +// +// The function also returns an error if there is any issue generating or broadcasting +// the transaction. +// +// The function returns a pointer to a cobra.Command. +func CmdTxUploadHeaders() *cobra.Command { + cmd := &cobra.Command{ + Use: "upload-headers [headers-file]", + Short: "upload bnb light client header", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + content, err := os.ReadFile(args[0]) + if err != nil { + return err + } + + var headers []*types.Header + if err := json.Unmarshal(content, &headers); err != nil { + return err + } + + msg := types.MsgUploadHeaders{ + Signer: clientCtx.GetFromAddress().String(), + Headers: headers, + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// CmdTxUpdateHeader creates a cobra.Command to update the BNB light client header. +// +// It takes a single argument, which is the path to a JSON file containing the header. +// The function reads the content of the file, unmarshals it into a types.Header struct, +// and creates a MsgUpdateHeader message with the signer and the header. +// +// The function returns an error if there is any issue reading the file or unmarshaling +// the content. +// +// The function also returns an error if there is any issue generating or broadcasting +// the transaction. +// +// The function returns a pointer to a cobra.Command. +func CmdTxUpdateHeader() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-header [header-file]", + Short: "update bnb light client header", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + content, err := os.ReadFile(args[0]) + if err != nil { + return err + } + + var header types.Header + if err := json.Unmarshal(content, &header); err != nil { + return err + } + + msg := types.MsgUpdateHeader{ + Signer: clientCtx.GetFromAddress().String(), + Header: &header, + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/bnblightclient/keeper/genesis.go b/x/bnblightclient/keeper/genesis.go new file mode 100644 index 00000000..533c595a --- /dev/null +++ b/x/bnblightclient/keeper/genesis.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "slices" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis +// state. +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + if err := genState.Validate(); err != nil { + panic(err) + } + + if err := k.SetParams(ctx, genState.Params); err != nil { + panic(err) + } + + slices.SortFunc(genState.Headers, func(a, b *types.Header) int { + return int(a.Number - b.Number) + }) + for _, header := range genState.Headers { + k.setHeader(ctx, header) + } + k.setLatestNumber(ctx, genState.Headers[len(genState.Headers)-1].Number) + + for _, record := range genState.Events { + k.setEvmEvent(ctx, genState.Params.ChainId, record) + } +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return &types.GenesisState{ + Params: k.GetParams(ctx), + Headers: k.GetAllHeaders(ctx), + Events: k.GetAllEvmEvents(ctx), + } +} diff --git a/x/bnblightclient/keeper/grpc_query.go b/x/bnblightclient/keeper/grpc_query.go new file mode 100644 index 00000000..deb79c29 --- /dev/null +++ b/x/bnblightclient/keeper/grpc_query.go @@ -0,0 +1,61 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" +) + +var _ types.QueryServer = Querier{} + +// Querier defines a wrapper around the x/bnblightclient keeper providing gRPC method +type Querier struct { + k Keeper +} + +// NewQuerierImpl returns an implementation of the captains QueryServer interface. +func NewQuerierImpl(k Keeper) types.QueryServer { + return &Querier{k} +} + +// Header implements types.QueryServer. +func (q Querier) Header(goCtx context.Context, req *types.QueryHeaderRequest) (*types.QueryHeaderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + header, found := q.k.GetHeader(ctx, req.Number) + if !found { + return nil, errorsmod.Wrapf(types.ErrHeaderNotFound, "header %d not found", req.Number) + } + return &types.QueryHeaderResponse{Header: header}, nil +} + +// HeaderByHash implements types.QueryServer. +func (q Querier) HeaderByHash(goCtx context.Context, req *types.QueryHeaderByHashRequest) (*types.QueryHeaderByHashResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + header, found := q.k.GetHeaderByHash(ctx, req.Hash) + if !found { + return nil, errorsmod.Wrapf(types.ErrHeaderNotFound, "header %x not found", req.Hash) + } + return &types.QueryHeaderByHashResponse{Header: header}, nil +} + +// LatestHeader implements types.QueryServer. +func (q Querier) LatestHeader(goCtx context.Context, req *types.QueryLatestHeaderRequest) (*types.QueryLatestHeaderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + header, found := q.k.GetLatestHeader(ctx) + if !found { + return nil, errorsmod.Wrap(types.ErrHeaderNotFound, "latested header not found") + } + return &types.QueryLatestHeaderResponse{Header: *header}, nil +} + +// Params implements types.QueryServer. +func (q Querier) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + params := q.k.GetParams(ctx) + return &types.QueryParamsResponse{Params: *params}, nil +} diff --git a/x/bnblightclient/keeper/header.go b/x/bnblightclient/keeper/header.go new file mode 100644 index 00000000..ea77cf30 --- /dev/null +++ b/x/bnblightclient/keeper/header.go @@ -0,0 +1,178 @@ +package keeper + +import ( + "slices" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" +) + +// UploadHeaders adds a batch of headers to the bnb light client chain +func (k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { + slices.SortFunc(headers, func(a, b *types.Header) int { + return int(a.Number - b.Number) + }) + + vHeader := headers + latestedHeader, exist := k.GetLatestHeader(ctx) + if exist { + vHeader = append([]*types.Header{latestedHeader}, headers...) + } + + // verify headers + if err := types.VeryHeaders(vHeader); err != nil { + return err + } + + for _, header := range headers { + k.setHeader(ctx, header) + } + k.setLatestNumber(ctx, headers[len(headers)-1].Number) + k.prune(ctx) + return nil +} + +// UpdateHeader updates the header in the Keeper. +// +// Parameters: +// - ctx: the context object. +// - header: the header to be updated. +// +// Returns: +// - error: an error if the header update fails. +func (k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { + if err := types.VeryHeaders([]*types.Header{header}); err != nil { + return err + } + + if !k.HasHeader(ctx, header.Number) { + return errorsmod.Wrapf(types.ErrHeaderNotFound, "header %d not found, cannot update", header.Number) + } + + k.setHeader(ctx, header) + return nil +} + +// GetLatestHeader retrieves the latest header from the store. +// +// Parameters: +// - ctx: the context object +// +// Returns: +// - types.Header: the latest header +// - bool: true if the header was found, false otherwise +func (k Keeper) GetLatestHeader(ctx sdk.Context) (*types.Header, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyLatestHeaderNumber()) + if bz == nil { + return nil, false + } + + number := sdk.BigEndianToUint64(bz) + return k.GetHeader(ctx, number) +} + +// GetLatestNumber retrieves the latest number from the store. +// +// Parameters: +// - ctx: the context object +// +// Returns: +// - uint64: the latest number +func (k Keeper) GetLatestNumber(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyLatestHeaderNumber()) + if bz == nil { + return 0 + } + return sdk.BigEndianToUint64(bz) +} + +// GetHeader retrieves the header for a specific number from the store. +// +// Parameters: +// - ctx: the context object +// - number: the number of the header to retrieve +// +// Returns: +// - types.Header: the header object +// - bool: true if the header was found, false otherwise +func (k Keeper) GetHeader(ctx sdk.Context, number uint64) (*types.Header, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyHeader(number)) + if bz == nil { + return nil, false + } + var header types.Header + k.cdc.MustUnmarshal(bz, &header) + return &header, true +} + +// GetAllHeaders retrieves all headers from the store. +// +// Parameters: +// - ctx: the context object +// +// Returns: +// - headers: a slice of Header objects +func (k Keeper) GetAllHeaders(ctx sdk.Context) (headers []*types.Header) { + store := ctx.KVStore(k.storeKey) + + it := sdk.KVStorePrefixIterator(store, types.KeyPrefixHeader) + defer it.Close() //nolint:errcheck + + for ; it.Valid(); it.Next() { + var header types.Header + k.cdc.MustUnmarshal(it.Value(), &header) + headers = append(headers, &header) + } + return +} + +// GetHeaderByHash retrieves a header from the store based on its hash. +// +// Parameters: +// - ctx: the context object +// - hash: the hash of the header to retrieve +// +// Returns: +// - *types.Header: the header object, or nil if not found +// - bool: true if the header was found, false otherwise +func (k Keeper) GetHeaderByHash(ctx sdk.Context, hash []byte) (*types.Header, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyHeaderHash(hash)) + if bz == nil { + return nil, false + } + + number := sdk.BigEndianToUint64(bz) + return k.GetHeader(ctx, number) +} + +// HasHeader checks if a header with the given number exists in the store. +// +// Parameters: +// - ctx: the context object +// - number: the number of the header to check +// Return type: bool +func (k Keeper) HasHeader(ctx sdk.Context, number uint64) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.KeyHeader(number)) +} + +func (k Keeper) setHeader(ctx sdk.Context, header *types.Header) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(header) + store.Set(types.KeyHeader(header.Number), bz) + + numberBz := sdk.Uint64ToBigEndian(header.Number) + store.Set(types.KeyHeaderHash(header.Hash), numberBz) +} + +func (k Keeper) setLatestNumber(ctx sdk.Context, number uint64) { + store := ctx.KVStore(k.storeKey) + bz := sdk.Uint64ToBigEndian(number) + store.Set(types.KeyLatestHeaderNumber(), bz) +} diff --git a/x/bnblightclient/keeper/keeper.go b/x/bnblightclient/keeper/keeper.go new file mode 100644 index 00000000..05fd98ff --- /dev/null +++ b/x/bnblightclient/keeper/keeper.go @@ -0,0 +1,30 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Keeper is the keeper struct for the x/bnblightclient module +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + + // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. + authority string +} + +// NewKeeper creates a new Keeper object +func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, authority string) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + authority: authority, + } +} + +// ChainID returns the chain id +func (k Keeper) ChainID(ctx sdk.Context) uint32 { + return k.GetParams(ctx).ChainId +} diff --git a/x/bnblightclient/keeper/msg_server.go b/x/bnblightclient/keeper/msg_server.go new file mode 100644 index 00000000..875c0bfb --- /dev/null +++ b/x/bnblightclient/keeper/msg_server.go @@ -0,0 +1,70 @@ +package keeper + +import ( + "context" + "slices" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" +) + +type msgServer struct { + k Keeper +} + +var _ types.MsgServer = msgServer{} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{k: keeper} +} + +// UpdateHeader implements types.MsgServer. +func (m msgServer) UpdateHeader(goCtx context.Context, req *types.MsgUpdateHeader) (*types.MsgUpdateHeaderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + params := m.k.GetParams(ctx) + if !slices.Contains(params.AllowList, req.Signer) { + return nil, errorsmod.Wrapf(types.ErrUnauthorized, "signer %s is not in allowlist", req.Signer) + } + + if err := m.k.UpdateHeader(ctx, req.Header); err != nil { + return nil, err + } + return &types.MsgUpdateHeaderResponse{}, nil +} + +// UpdateParams implements types.MsgServer. +func (m msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if m.k.authority != req.Authority { + return nil, errorsmod.Wrapf( + govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", m.k.authority, req.Authority) + } + + if err := req.Params.Validate(); err != nil { + return nil, govtypes.ErrInvalidProposalMsg.Wrapf("invalid parameter: %v", err) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := m.k.SetParams(ctx, &req.Params); err != nil { + return nil, err + } + return &types.MsgUpdateParamsResponse{}, nil +} + +// UploadHeaders implements types.MsgServer. +func (m msgServer) UploadHeaders(goCtx context.Context, req *types.MsgUploadHeaders) (*types.MsgUploadHeadersResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + params := m.k.GetParams(ctx) + if !slices.Contains(params.AllowList, req.Signer) { + return nil, errorsmod.Wrapf(types.ErrUnauthorized, "signer %s is not in allowlist", req.Signer) + } + + if err := m.k.UploadHeaders(ctx, req.Headers); err != nil { + return nil, err + } + return &types.MsgUploadHeadersResponse{}, nil +} diff --git a/x/bnblightclient/keeper/params.go b/x/bnblightclient/keeper/params.go new file mode 100644 index 00000000..8b7e422b --- /dev/null +++ b/x/bnblightclient/keeper/params.go @@ -0,0 +1,37 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" +) + +// SetParams sets the parameters for the given context. +// +// ctx - Context object. +// p - Params object to be set. +// error - Returns an error if validation fails. +func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error { + if err := params.Validate(); err != nil { + return err + } + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(params) + store.Set(types.ParamsKey, bz) + return nil +} + +// GetParams retrieves the parameters of the Keeper. +// +// ctx sdk.Context - Context +// types.Params - Parameters +// returns p types.Params - Parameters +func (k Keeper) GetParams(ctx sdk.Context) (params *types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + k.cdc.MustUnmarshal(bz, params) + return params +} diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go new file mode 100644 index 00000000..b876be80 --- /dev/null +++ b/x/bnblightclient/keeper/proof.go @@ -0,0 +1,203 @@ +package keeper + +import ( + "bytes" + "math/big" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + evmtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" +) + +// VerifyReceiptProof verifies the receipt proof for a BNB cross-chain event. +// +// ctx - context in which the verification is done +// receipt - the EVM transaction receipt to verify +// proof - the proof object containing the necessary data for verification +// Returns an array of BNBCrossChainEvent and an error if the verification fails. +func (k Keeper) VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof *types.Proof) ([]types.CrossChainEvent, error) { + if err := k.verifyProof(ctx, receipt, proof); err != nil { + return nil, err + } + + events, err := k.parseEvents(ctx, receipt) + if err != nil { + return nil, err + } + + if len(events) == 0 { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "invalid receipt, no events found") + } + return events, nil +} + +// GetAllEvmEvents retrieves all event records stored in the context. +// +// ctx - The context object. +// []*types.EvmEvent - A slice of event records. +func (k Keeper) GetAllEvmEvents(ctx sdk.Context) (events []*types.EvmEvent) { + store := ctx.KVStore(k.storeKey) + + it := sdk.KVStorePrefixIterator(store, types.KeyPrefixEvmEvent) + defer it.Close() //nolint:errcheck + + for ; it.Valid(); it.Next() { + var event types.EvmEvent + k.cdc.MustUnmarshal(it.Value(), &event) + events = append(events, &event) + } + return events +} + +func (k Keeper) verifyProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof *types.Proof) error { + if receipt.Status != evmtypes.ReceiptStatusSuccessful { + return errorsmod.Wrapf(types.ErrInvalidTransaction, "cannot verify failed transactions") + } + + db := trie.NewDatabase(rawdb.NewMemoryDatabase()) + mpt := trie.NewEmpty(db) + _ = evmtypes.DeriveSha(evmtypes.Receipts{receipt}, mpt) + + var indexBuf []byte + indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(0)) + txValue := mpt.Get(indexBuf) + + header, exist := k.GetHeader(ctx, receipt.BlockNumber.Uint64()) + if !exist { + return errorsmod.Wrapf(types.ErrHeaderNotFound, "header %d not found", header.Number) + } + + val, err := trie.VerifyProof(common.Hash(header.ReceiptRoot), proof.Index, &proof.Path) + if err != nil { + return errorsmod.Wrapf(types.ErrInvalidProof, "invalid receipt proof") + } + + if !bytes.Equal(val, proof.Value) || !bytes.Equal(val, txValue) { + return errorsmod.Wrapf(types.ErrInvalidProof, "invalid receipt proof") + } + + return nil +} + +func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types.CrossChainEvent, error) { + if len(receipt.Logs) == 0 { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "no event log found") + } + + params := k.GetParams(ctx) + contractAddr := common.HexToAddress(params.StakePlanHubAddress).Bytes() + + events := make([]types.CrossChainEvent, 0, len(receipt.Logs)) + for _, log := range receipt.Logs { + if !bytes.Equal(contractAddr, log.Address.Bytes()) { + continue + } + + if len(log.Topics) != 4 { + return nil, errorsmod.Wrapf( + types.ErrInvalidEvent, + "event has wrong number of topics, expected 4, actual: %d", + len(log.Topics), + ) + } + + eventID := log.Topics[0] + event, err := types.ABIstakePlanHub().EventByID(eventID) + if err != nil { + continue + } + + if event.Name != params.EventName { + continue + } + + // stakeIndex + identifier := new(big.Int).SetBytes(log.Topics[1].Bytes()) + // planId + planID := new(big.Int).SetBytes(log.Topics[2].Bytes()) + // sender + sender := common.BytesToAddress(log.Topics[3].Bytes()) + + eventArgs, err := types.ABIstakePlanHub().Unpack(event.Name, log.Data) + if err != nil { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "failed to unpack %s event", event.Name) + } + + if len(eventArgs) != 3 { + return nil, errorsmod.Wrapf( + types.ErrInvalidEvent, + "event has wrong number of parameters, expected 2, actual: %d", + len(eventArgs), + ) + } + + record := &types.EvmEvent{ + BlockNumber: receipt.BlockNumber.Uint64(), + Identifier: identifier.Uint64(), + Contract: log.Address.Bytes(), + } + if k.hasEvmEvent(ctx, params.ChainId, record) { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "event identifier %d already exists", identifier.Uint64()) + } + k.setEvmEvent(ctx, params.ChainId, record) + + // btcContractAddress + btcContractAddress, ok := eventArgs[0].(common.Address) + if !ok { + return nil, errorsmod.Wrap( + types.ErrInvalidEvent, + "event `btcContractAddress` parameters is invalid, expected `common.Address`", + ) + } + + // stakeAmount + stakeAmount, ok := eventArgs[1].(*big.Int) + if !ok { + return nil, errorsmod.Wrap( + types.ErrInvalidEvent, + "event `stakeAmount` parameters is invalid, expected `*big.Int`", + ) + } + + // stBTCAmount + stBTCAmount, ok := eventArgs[2].(*big.Int) + if !ok { + return nil, errorsmod.Wrap( + types.ErrInvalidEvent, + "event `stBTCAmount` parameters is invalid, expected `*big.Int`", + ) + } + + bnbEvent := types.CrossChainEvent{ + TxHash: log.TxHash, + Identifier: identifier.Uint64(), + Sender: sender, + PlanID: planID.Uint64(), + BTCcontractAddress: btcContractAddress, + StakeAmount: *stakeAmount, + StBTCAmount: *stBTCAmount, + } + events = append(events, bnbEvent) + } + return events, nil +} + +func (k Keeper) hasEvmEvent(ctx sdk.Context, chainID uint32, record *types.EvmEvent) bool { + store := ctx.KVStore(k.storeKey) + key := record.Key(chainID) + return store.Has(key) +} + +func (k Keeper) setEvmEvent(ctx sdk.Context, chainID uint32, record *types.EvmEvent) { + store := ctx.KVStore(k.storeKey) + key := record.Key(chainID) + + bz := k.cdc.MustMarshal(record) + store.Set(key[:], bz) +} diff --git a/x/bnblightclient/keeper/prune.go b/x/bnblightclient/keeper/prune.go new file mode 100644 index 00000000..ffd3023c --- /dev/null +++ b/x/bnblightclient/keeper/prune.go @@ -0,0 +1,53 @@ +package keeper + +import ( + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) prune(ctx sdk.Context) { + // get the latested header + latestedNumber := k.GetLatestNumber(ctx) + params := k.GetParams(ctx) + pruneEndNumber := int64(latestedNumber - params.RetainedBlocks) + if pruneEndNumber <= 0 { + return + } + k.pruneHeaders(ctx, uint64(pruneEndNumber)) +} + +func (k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStoreReversePrefixIterator(store, types.KeyPrefixHeader) + defer func() { + _ = iterator.Close() + }() + + for ; iterator.Valid(); iterator.Next() { + iterKey := iterator.Key() + number := sdk.BigEndianToUint64(iterKey[1:]) + if number <= pruneEndNumber { + header, exist := k.GetHeader(ctx, number) + if !exist { + continue + } + + // delete header + store.Delete(iterKey) + // delete header hash + store.Delete(types.KeyHeaderHash(header.Hash)) + + // delete event record + prefix := append(types.KeyPrefixEvmEvent, sdk.Uint64ToBigEndian(number)...) + iterator2 := sdk.KVStoreReversePrefixIterator(store, prefix) + defer func() { + _ = iterator2.Close() + }() + + for ; iterator2.Valid(); iterator2.Next() { + iterKey2 := iterator2.Key() + store.Delete(iterKey2) + } + } + } +} diff --git a/x/bnblightclient/module.go b/x/bnblightclient/module.go new file mode 100644 index 00000000..6aebaf3f --- /dev/null +++ b/x/bnblightclient/module.go @@ -0,0 +1,161 @@ +package bnblightclient + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/client/cli" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/keeper" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the bnblightclient module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +// NewAppModuleBasic creates a new instance of the AppModuleBasic struct. +// +// Parameters: +// - cdc: The codec.BinaryCodec used for encoding and decoding. +// +// Returns: +// - An instance of the AppModuleBasic struct. +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the fee module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns the bnblightclient module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the bnblightclient module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck,gosec // generally we don't handle errors here +} + +// GetTxCmd returns the bnblightclient module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the bnblightclient module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the bnblightclient module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +// NewAppModule creates a new instance of the AppModule struct. +// +// Parameters: +// - cdc: The codec used for encoding and decoding. +// - keeper: The keeper for handling the module's state. +// +// Returns: +// - An instance of the AppModule struct. +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerierImpl(am.keeper)) +} + +// RegisterInvariants registers the bnblightclient module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the fe module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + am.keeper.InitGenesis(ctx, genState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the bnblightclient module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the bnblightclient module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the bnblightclient module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return nil +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} diff --git a/x/bnblightclient/types/client.pb.go b/x/bnblightclient/types/client.pb.go new file mode 100644 index 00000000..dc33d492 --- /dev/null +++ b/x/bnblightclient/types/client.pb.go @@ -0,0 +1,491 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/client.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Header struct { + // header defines the bnb header bytes + RawHeader []byte `protobuf:"bytes,1,opt,name=raw_header,json=rawHeader,proto3" json:"raw_header,omitempty"` + // parent_hash defines the previous bnb header hash + ParentHash []byte `protobuf:"bytes,2,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty"` + // hash defines the bnb header hash + Hash []byte `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty"` + // number defines the block number + Number uint64 `protobuf:"varint,4,opt,name=number,proto3" json:"number,omitempty"` + // receipt_root defines the receipts merkle root hash + ReceiptRoot []byte `protobuf:"bytes,5,opt,name=receipt_root,json=receiptRoot,proto3" json:"receipt_root,omitempty"` +} + +func (m *Header) Reset() { *m = Header{} } +func (m *Header) String() string { return proto.CompactTextString(m) } +func (*Header) ProtoMessage() {} +func (*Header) Descriptor() ([]byte, []int) { + return fileDescriptor_30c005374b948758, []int{0} +} +func (m *Header) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Header.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 *Header) XXX_Merge(src proto.Message) { + xxx_messageInfo_Header.Merge(m, src) +} +func (m *Header) XXX_Size() int { + return m.Size() +} +func (m *Header) XXX_DiscardUnknown() { + xxx_messageInfo_Header.DiscardUnknown(m) +} + +var xxx_messageInfo_Header proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Header)(nil), "lorenzo.bnblightclient.v1.Header") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/client.proto", fileDescriptor_30c005374b948758) +} + +var fileDescriptor_30c005374b948758 = []byte{ + // 276 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0xc9, 0x2f, 0x4a, + 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x87, 0xb0, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x24, + 0xa1, 0xea, 0xf4, 0x50, 0xd5, 0xe9, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, + 0xe9, 0x83, 0x58, 0x10, 0x0d, 0x4a, 0x73, 0x19, 0xb9, 0xd8, 0x3c, 0x52, 0x13, 0x53, 0x52, 0x8b, + 0x84, 0x64, 0xb9, 0xb8, 0x8a, 0x12, 0xcb, 0xe3, 0x33, 0xc0, 0x3c, 0x09, 0x46, 0x05, 0x46, 0x0d, + 0x9e, 0x20, 0xce, 0xa2, 0xc4, 0x72, 0xa8, 0xb4, 0x3c, 0x17, 0x77, 0x41, 0x62, 0x51, 0x6a, 0x5e, + 0x49, 0x7c, 0x46, 0x62, 0x71, 0x86, 0x04, 0x13, 0x58, 0x9e, 0x0b, 0x22, 0xe4, 0x91, 0x58, 0x9c, + 0x21, 0x24, 0xc4, 0xc5, 0x02, 0x96, 0x61, 0x06, 0xcb, 0x80, 0xd9, 0x42, 0x62, 0x5c, 0x6c, 0x79, + 0xa5, 0xb9, 0x49, 0xa9, 0x45, 0x12, 0x2c, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x50, 0x9e, 0x90, 0x22, + 0x17, 0x4f, 0x51, 0x6a, 0x72, 0x6a, 0x66, 0x41, 0x49, 0x7c, 0x51, 0x7e, 0x7e, 0x89, 0x04, 0x2b, + 0x58, 0x0f, 0x37, 0x54, 0x2c, 0x28, 0x3f, 0xbf, 0xc4, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x53, + 0xf8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, + 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xd9, 0xa6, 0x67, 0x96, 0x64, + 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x40, 0x7c, 0xad, 0x1b, 0x00, 0xf2, 0x53, 0x72, + 0x7e, 0x8e, 0x3e, 0x2c, 0xb8, 0xca, 0x8c, 0xf4, 0x2b, 0xd0, 0xc3, 0xac, 0xa4, 0xb2, 0x20, 0xb5, + 0x38, 0x89, 0x0d, 0xec, 0x7f, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x8e, 0x25, 0x7b, + 0x5a, 0x01, 0x00, 0x00, +} + +func (m *Header) 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 *Header) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ReceiptRoot) > 0 { + i -= len(m.ReceiptRoot) + copy(dAtA[i:], m.ReceiptRoot) + i = encodeVarintClient(dAtA, i, uint64(len(m.ReceiptRoot))) + i-- + dAtA[i] = 0x2a + } + if m.Number != 0 { + i = encodeVarintClient(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x20 + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintClient(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x1a + } + if len(m.ParentHash) > 0 { + i -= len(m.ParentHash) + copy(dAtA[i:], m.ParentHash) + i = encodeVarintClient(dAtA, i, uint64(len(m.ParentHash))) + i-- + dAtA[i] = 0x12 + } + if len(m.RawHeader) > 0 { + i -= len(m.RawHeader) + copy(dAtA[i:], m.RawHeader) + i = encodeVarintClient(dAtA, i, uint64(len(m.RawHeader))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintClient(dAtA []byte, offset int, v uint64) int { + offset -= sovClient(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Header) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RawHeader) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + l = len(m.ParentHash) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + if m.Number != 0 { + n += 1 + sovClient(uint64(m.Number)) + } + l = len(m.ReceiptRoot) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + return n +} + +func sovClient(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozClient(x uint64) (n int) { + return sovClient(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Header) 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 ErrIntOverflowClient + } + 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: Header: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawHeader", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawHeader = append(m.RawHeader[:0], dAtA[iNdEx:postIndex]...) + if m.RawHeader == nil { + m.RawHeader = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParentHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ParentHash = append(m.ParentHash[:0], dAtA[iNdEx:postIndex]...) + if m.ParentHash == nil { + m.ParentHash = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + m.Number = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Number |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReceiptRoot", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReceiptRoot = append(m.ReceiptRoot[:0], dAtA[iNdEx:postIndex]...) + if m.ReceiptRoot == nil { + m.ReceiptRoot = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipClient(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipClient(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, ErrIntOverflowClient + } + 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, ErrIntOverflowClient + } + 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, ErrIntOverflowClient + } + 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, ErrInvalidLengthClient + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupClient + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthClient + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthClient = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowClient = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupClient = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bnblightclient/types/codec.go b/x/bnblightclient/types/codec.go new file mode 100644 index 00000000..3a5a0f88 --- /dev/null +++ b/x/bnblightclient/types/codec.go @@ -0,0 +1,20 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterInterfaces registers implementations for sdk.Msg and MsgUpdateParams in the given InterfaceRegistry. +// +// Parameter: +// - registry: the InterfaceRegistry to register implementations to. +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateParams{}, + &MsgUpdateHeader{}, + &MsgUploadHeaders{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/x/bnblightclient/types/errors.go b/x/bnblightclient/types/errors.go new file mode 100644 index 00000000..a7ac1310 --- /dev/null +++ b/x/bnblightclient/types/errors.go @@ -0,0 +1,21 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +var ( + // ErrHeaderNotFound is returned when header is not found + ErrHeaderNotFound = errorsmod.Register(ModuleName, 2, "header not found") + + // ErrInvalidHeader is returned when header is not valid + ErrInvalidHeader = errorsmod.Register(ModuleName, 3, "invalid header") + // ErrUnauthorized is returned when tx is not authorized + ErrUnauthorized = errorsmod.Register(ModuleName, 4, "tx unauthorized") + // ErrInvalidProof is returned when proof is not valid + ErrInvalidProof = errorsmod.Register(ModuleName, 5, "invalid proof") + // ErrInvalidTransaction is returned when transaction is not valid + ErrInvalidTransaction = errorsmod.Register(ModuleName, 6, "invalid transaction") + // ErrInvalidEvent is returned when event is not valid + ErrInvalidEvent = errorsmod.Register(ModuleName, 7, "invalid event") +) diff --git a/x/bnblightclient/types/events.go b/x/bnblightclient/types/events.go new file mode 100644 index 00000000..267a0704 --- /dev/null +++ b/x/bnblightclient/types/events.go @@ -0,0 +1,45 @@ +package types + +import ( + _ "embed" //nolint: golint + "encoding/json" + "math/big" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" +) + +//go:embed stake_plan_hub_abi.json +var stakePlanHubContractABIJSON []byte //nolint: golint + +var stakePlanHubContractABI abi.ABI + +func init() { + // unmarshal the StakePlanHubContractABI + err := json.Unmarshal(stakePlanHubContractABIJSON, &stakePlanHubContractABI) + if err != nil { + panic(err) + } +} + +// ABIstakePlanHub is the compiled StakePlanHub contract abi +func ABIstakePlanHub() *abi.ABI { + return &stakePlanHubContractABI +} + +// CrossChainEvent is a struct that contains the sender, plan id, BTC contract address, stake amount, and stBTC amount. +type CrossChainEvent struct { + // Note: TxHash is non-consensus data and untrustworthy + TxHash common.Hash `json:"tx_hash"` + Identifier uint64 `json:"identifier"` + Sender common.Address `json:"sender"` + PlanID uint64 `json:"plan_id"` + BTCcontractAddress common.Address `json:"btc_contract_address"` + StakeAmount big.Int `json:"stake_amount"` + StBTCAmount big.Int `json:"st_btc_amount"` +} + +// Key returns the unique key of the EvmEvent struct +func (e EvmEvent) Key(chainID uint32) []byte { + return KeyEvmEvent(chainID, e.BlockNumber, e.Contract, e.Identifier) +} diff --git a/x/bnblightclient/types/genesis.go b/x/bnblightclient/types/genesis.go new file mode 100644 index 00000000..bb159378 --- /dev/null +++ b/x/bnblightclient/types/genesis.go @@ -0,0 +1,20 @@ +package types + +// Validate validates the GenesisState. +// +// It returns an error if the GenesisState parameters are invalid. +func (gs GenesisState) Validate() error { + if err := gs.Params.Validate(); err != nil { + return err + } + return VeryHeaders(gs.Headers) +} + +// DefaultGenesisState returns the default genesis state +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Params: &Params{}, + Headers: []*Header{}, + Events: []*EvmEvent{}, + } +} diff --git a/x/bnblightclient/types/genesis.pb.go b/x/bnblightclient/types/genesis.pb.go new file mode 100644 index 00000000..8af89ab4 --- /dev/null +++ b/x/bnblightclient/types/genesis.pb.go @@ -0,0 +1,709 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/genesis.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the bnb light client state +type GenesisState struct { + // params defines the bnb light client parameters + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` + // headers defines the bnb light client headers + Headers []*Header `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"` + // events defines the bnb chain generated events + Events []*EvmEvent `protobuf:"bytes,3,rep,name=events,proto3" json:"events,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_4f928fb205bb2cf6, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + +func (m *GenesisState) GetHeaders() []*Header { + if m != nil { + return m.Headers + } + return nil +} + +func (m *GenesisState) GetEvents() []*EvmEvent { + if m != nil { + return m.Events + } + return nil +} + +type EvmEvent struct { + // block_number defines the block number + BlockNumber uint64 `protobuf:"varint,1,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + // contract defines the contract + Contract []byte `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` + // index defines the unique identifier of the event + Identifier uint64 `protobuf:"varint,3,opt,name=identifier,proto3" json:"identifier,omitempty"` +} + +func (m *EvmEvent) Reset() { *m = EvmEvent{} } +func (m *EvmEvent) String() string { return proto.CompactTextString(m) } +func (*EvmEvent) ProtoMessage() {} +func (*EvmEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_4f928fb205bb2cf6, []int{1} +} +func (m *EvmEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EvmEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EvmEvent.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 *EvmEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_EvmEvent.Merge(m, src) +} +func (m *EvmEvent) XXX_Size() int { + return m.Size() +} +func (m *EvmEvent) XXX_DiscardUnknown() { + xxx_messageInfo_EvmEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_EvmEvent proto.InternalMessageInfo + +func (m *EvmEvent) GetBlockNumber() uint64 { + if m != nil { + return m.BlockNumber + } + return 0 +} + +func (m *EvmEvent) GetContract() []byte { + if m != nil { + return m.Contract + } + return nil +} + +func (m *EvmEvent) GetIdentifier() uint64 { + if m != nil { + return m.Identifier + } + return 0 +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "lorenzo.bnblightclient.v1.GenesisState") + proto.RegisterType((*EvmEvent)(nil), "lorenzo.bnblightclient.v1.EvmEvent") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/genesis.proto", fileDescriptor_4f928fb205bb2cf6) +} + +var fileDescriptor_4f928fb205bb2cf6 = []byte{ + // 321 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x31, 0x4f, 0x32, 0x31, + 0x18, 0xc7, 0x29, 0xbc, 0xe1, 0x25, 0x85, 0xa9, 0xd3, 0xc9, 0xd0, 0x00, 0x26, 0xca, 0x62, 0x1b, + 0x70, 0x32, 0xc4, 0xc5, 0x84, 0xe8, 0x60, 0x0c, 0x39, 0x07, 0x13, 0x17, 0x73, 0x2d, 0x8f, 0xd0, + 0x78, 0xd7, 0x92, 0x5e, 0xb9, 0xa8, 0x9f, 0xc2, 0xef, 0xe4, 0xe2, 0xc8, 0xe8, 0x68, 0xe0, 0x8b, + 0x18, 0xca, 0x9d, 0x51, 0x13, 0x70, 0xbc, 0x7f, 0x7e, 0xbf, 0xe7, 0x79, 0xae, 0x7f, 0x7c, 0x18, + 0x1b, 0x0b, 0xfa, 0xd9, 0x70, 0xa1, 0x45, 0xac, 0x26, 0x53, 0x27, 0x63, 0x05, 0xda, 0xf1, 0xac, + 0xc7, 0x27, 0xa0, 0x21, 0x55, 0x29, 0x9b, 0x59, 0xe3, 0x0c, 0xd9, 0xcb, 0x41, 0xf6, 0x13, 0x64, + 0x59, 0xaf, 0x79, 0xb0, 0x7d, 0x46, 0x0e, 0xf9, 0x11, 0xbb, 0xb8, 0x59, 0x64, 0xa3, 0x24, 0x5f, + 0xd5, 0x79, 0x45, 0xb8, 0x71, 0xbe, 0x59, 0x7e, 0xed, 0x22, 0x07, 0xe4, 0x04, 0x57, 0x37, 0x40, + 0x80, 0x5a, 0xa8, 0x5b, 0xef, 0xb7, 0xd9, 0xd6, 0x63, 0xd8, 0xc8, 0x83, 0x61, 0x2e, 0x90, 0x01, + 0xfe, 0x3f, 0x85, 0x68, 0x0c, 0x36, 0x0d, 0xca, 0xad, 0xca, 0x1f, 0xee, 0x85, 0x27, 0xc3, 0xc2, + 0x20, 0x03, 0x5c, 0x85, 0x0c, 0xb4, 0x4b, 0x83, 0x8a, 0x77, 0xf7, 0x77, 0xb8, 0xc3, 0x2c, 0x19, + 0xae, 0xd9, 0x30, 0x57, 0x3a, 0x0a, 0xd7, 0x8a, 0x8c, 0xb4, 0x71, 0x43, 0xc4, 0x46, 0x3e, 0xdc, + 0xe9, 0x79, 0x22, 0xc0, 0xfa, 0xdf, 0xf8, 0x17, 0xd6, 0x7d, 0x76, 0xe5, 0x23, 0xd2, 0xc4, 0x35, + 0x69, 0xb4, 0xb3, 0x91, 0x74, 0x41, 0xb9, 0x85, 0xba, 0x8d, 0xf0, 0xeb, 0x9b, 0x50, 0x8c, 0xd5, + 0x18, 0xb4, 0x53, 0xf7, 0x0a, 0x6c, 0x50, 0xf1, 0xf2, 0xb7, 0xe4, 0xec, 0xe6, 0x6d, 0x49, 0xd1, + 0x62, 0x49, 0xd1, 0xc7, 0x92, 0xa2, 0x97, 0x15, 0x2d, 0x2d, 0x56, 0xb4, 0xf4, 0xbe, 0xa2, 0xa5, + 0xdb, 0xd3, 0x89, 0x72, 0xd3, 0xb9, 0x60, 0xd2, 0x24, 0xfc, 0x72, 0x73, 0xfb, 0xd1, 0x68, 0xfd, + 0xc8, 0xd2, 0xc4, 0xbc, 0xa8, 0x23, 0xeb, 0xf3, 0xc7, 0xdf, 0x9d, 0xb8, 0xa7, 0x19, 0xa4, 0xa2, + 0xea, 0x0b, 0x39, 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x8b, 0x2e, 0xa6, 0x26, 0x02, 0x00, + 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Events) > 0 { + for iNdEx := len(m.Events) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Events[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Headers) > 0 { + for iNdEx := len(m.Headers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Headers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EvmEvent) 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 *EvmEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EvmEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Identifier != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Identifier)) + i-- + dAtA[i] = 0x18 + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0x12 + } + if m.BlockNumber != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Headers) > 0 { + for _, e := range m.Headers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Events) > 0 { + for _, e := range m.Events { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *EvmEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockNumber != 0 { + n += 1 + sovGenesis(uint64(m.BlockNumber)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.Identifier != 0 { + n += 1 + sovGenesis(uint64(m.Identifier)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Headers = append(m.Headers, &Header{}) + if err := m.Headers[len(m.Headers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Events", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Events = append(m.Events, &EvmEvent{}) + if err := m.Events[len(m.Events)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EvmEvent) 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 ErrIntOverflowGenesis + } + 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: EvmEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EvmEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockNumber", wireType) + } + m.BlockNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = append(m.Contract[:0], dAtA[iNdEx:postIndex]...) + if m.Contract == nil { + m.Contract = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) + } + m.Identifier = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Identifier |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bnblightclient/types/header.go b/x/bnblightclient/types/header.go new file mode 100644 index 00000000..8689bebc --- /dev/null +++ b/x/bnblightclient/types/header.go @@ -0,0 +1,157 @@ +package types + +import ( + "math/big" + "sync" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/rlp" + "golang.org/x/crypto/sha3" + + errorsmod "cosmossdk.io/errors" +) + +// hasherPool holds LegacyKeccak256 hashers for rlpHash. +var hasherPool = sync.Pool{ + New: func() interface{} { return sha3.NewLegacyKeccak256() }, +} + +//go:generate go run github.com/fjl/gencodec -type Header -field-override headerMarshaling -out gen_header_json.go +//go:generate go run ../../rlp/rlpgen -type Header -out gen_header_rlp.go + +// BNBHeader represents a block header in the Ethereum blockchain. +type BNBHeader struct { + ParentHash common.Hash `json:"parentHash" gencodec:"required"` + UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` + Coinbase common.Address `json:"miner"` + Root common.Hash `json:"stateRoot" gencodec:"required"` + TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` + ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` + Bloom types.Bloom `json:"logsBloom" gencodec:"required"` + Difficulty *big.Int `json:"difficulty" gencodec:"required"` + Number *big.Int `json:"number" gencodec:"required"` + GasLimit uint64 `json:"gasLimit" gencodec:"required"` + GasUsed uint64 `json:"gasUsed" gencodec:"required"` + Time uint64 `json:"timestamp" gencodec:"required"` + Extra []byte `json:"extraData" gencodec:"required"` + MixDigest common.Hash `json:"mixHash"` + Nonce types.BlockNonce `json:"nonce"` + + // BaseFee was added by EIP-1559 and is ignored in legacy headers. + BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` + + // WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers. + WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` + + // BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. + BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"` + + // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. + ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"` + + // ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers. + ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"` +} + +// Hash returns the block hash of the header, which is simply the keccak256 hash of its +// RLP encoding. +func (h *BNBHeader) Hash() common.Hash { + return rlpHash(h) +} + +// ConvertToBNBHeader decodes the input data into a BNBHeader struct and validates it against the provided Header. +// +// It takes a pointer to a Header struct as input and returns a pointer to a BNBHeader struct and an error. +// The function decodes the RawHeader field of the Header struct into a BNBHeader struct using the rlp package. +// It then checks if the Number field of the BNBHeader struct is equal to the Number field of the Header struct. +// If not, it returns an ErrInvalidHeader error with the message "number not equal". +// It also checks if the Hash() method of the BNBHeader struct is equal to the Hash field of the Header struct. +// If not, it returns an ErrInvalidHeader error with the message "hash not equal". +// It also checks if the ReceiptHash field of the BNBHeader struct is equal to the ReceiptRoot field of the Header struct. +// If not, it returns an ErrInvalidHeader error with the message "receipt hash not equal". +// If all checks pass, it returns the BNBHeader struct and a nil error. +func ConvertToBNBHeader(header *Header) (*BNBHeader, error) { + bnbHeader, err := UnmarshalBNBHeader(header.RawHeader) + if err != nil { + return nil, err + } + + if bnbHeader.Number.Uint64() != header.Number { + return nil, errorsmod.Wrap(ErrInvalidHeader, "number not equal") + } + + if bnbHeader.Hash() != common.Hash(header.Hash) { + return nil, errorsmod.Wrap(ErrInvalidHeader, "hash not equal") + } + + if bnbHeader.ParentHash != common.Hash(header.ParentHash) { + return nil, errorsmod.Wrap(ErrInvalidHeader, "parentHash not equal") + } + + if bnbHeader.ReceiptHash != common.Hash(header.ReceiptRoot) { + return nil, errorsmod.Wrap(ErrInvalidHeader, "receipt hash not equal") + } + return bnbHeader, nil +} + +// UnmarshalBNBHeader decodes the input data into a BNBHeader struct. +// +// It takes a byte slice data as input and returns a BNBHeader pointer and an error. +func UnmarshalBNBHeader(rawHeader []byte) (*BNBHeader, error) { + bnbHeader := new(BNBHeader) + if err := rlp.DecodeBytes(rawHeader, bnbHeader); err != nil { + return nil, err + } + return bnbHeader, nil +} + +// VeryHeaders checks the validity of a sequence of BNBHeaders. +// +// It takes a slice of Header pointers as input and returns an error. +// The function iterates over the headers and checks if the current header's +// hash is equal to the next header's parent hash. It also checks if the +// current header's number is one less than the next header's number. +// If any of these conditions are not met, the function returns an +// ErrInvalidHeader error. +func VeryHeaders(headers []*Header) error { + if len(headers) == 0 { + return errorsmod.Wrap(ErrInvalidHeader, "empty headers") + } + + if len(headers) == 1 { + _, err := ConvertToBNBHeader(headers[0]) + return err + } + + for i := 0; i < len(headers)-1; i++ { + preHeader, err := ConvertToBNBHeader(headers[i]) + if err != nil { + return err + } + + nextHeader, err := ConvertToBNBHeader(headers[i+1]) + if err != nil { + return err + } + + if preHeader.Hash() != nextHeader.ParentHash { + return errorsmod.Wrap(ErrInvalidHeader, "hash not equal") + } + + if preHeader.Number.Uint64()+1 != nextHeader.Number.Uint64() { + return errorsmod.Wrap(ErrInvalidHeader, "hash not equal") + } + } + return nil +} + +func rlpHash(x interface{}) (h common.Hash) { + sha, _ := hasherPool.Get().(crypto.KeccakState) + defer hasherPool.Put(sha) + sha.Reset() + _ = rlp.Encode(sha, x) + _, _ = sha.Read(h[:]) + return h +} diff --git a/x/bnblightclient/types/keys.go b/x/bnblightclient/types/keys.go new file mode 100644 index 00000000..7dc37e46 --- /dev/null +++ b/x/bnblightclient/types/keys.go @@ -0,0 +1,65 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName is the name of the module + ModuleName = "bnblightclient" + + // StoreKey is the string store representation + StoreKey = ModuleName +) + +var ( + // Delimiter is the delimiter for the keys + Delimiter = []byte{0x00} + // ParamsKey defines the key to store the Params object + ParamsKey = []byte{0x01} + // KeyPrefixHeader defines the prefix to retrieve all headers + KeyPrefixHeader = []byte{0x02} + // KeyPrefixLatestNumber defines the prefix to retrieve the latest header number + KeyPrefixLatestNumber = []byte{0x03} + + // KeyPrefixHeadHash defines the prefix to retrieve the head hash + KeyPrefixHeadHash = []byte{0x04} + // KeyPrefixEvmEvent defines the prefix to retrieve the cross chain event + KeyPrefixEvmEvent = []byte{0x05} +) + +// KeyHeader returns the key for a header +func KeyHeader(blockNumber uint64) []byte { + bz := sdk.Uint64ToBigEndian(blockNumber) + return append(KeyPrefixHeader, bz...) +} + +// KeyHeaderHash returns the key for the header hash +func KeyHeaderHash(hash []byte) []byte { + return append(KeyPrefixHeadHash, hash...) +} + +// KeyLatestHeaderNumber returns the key for the latest header number +func KeyLatestHeaderNumber() []byte { + return KeyPrefixLatestNumber +} + +// KeyEvmEvent returns the key for the cross chain event index +func KeyEvmEvent(chainID uint32, blockNumber uint64, contract []byte, idx uint64) []byte { + key := append([]byte{}, KeyPrefixEvmEvent...) + + chainIDBz := sdk.Uint64ToBigEndian(uint64(chainID)) + key = append(key, chainIDBz...) + key = append(key, Delimiter...) + + bumberBz := sdk.Uint64ToBigEndian(blockNumber) + key = append(key, bumberBz...) + key = append(key, Delimiter...) + + key = append(key, contract...) + key = append(key, Delimiter...) + + idxBz := sdk.Uint64ToBigEndian(idx) + key = append(key, idxBz...) + return key +} diff --git a/x/bnblightclient/types/msg.go b/x/bnblightclient/types/msg.go new file mode 100644 index 00000000..99dc2eb6 --- /dev/null +++ b/x/bnblightclient/types/msg.go @@ -0,0 +1,50 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ sdk.Msg = (*MsgUpdateHeader)(nil) + _ sdk.Msg = (*MsgUploadHeaders)(nil) + _ sdk.Msg = (*MsgUpdateParams)(nil) +) + +// ValidateBasic implements sdk.Msg interface +func (m *MsgUpdateHeader) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return err + } + return VeryHeaders([]*Header{m.Header}) +} + +// GetSigners implements sdk.Msg interface +func (m *MsgUpdateHeader) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Signer)} +} + +// ValidateBasic implements sdk.Msg interface +func (m *MsgUploadHeaders) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return err + } + return VeryHeaders(m.Headers) +} + +// GetSigners implements sdk.Msg interface +func (m *MsgUploadHeaders) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Signer)} +} + +// ValidateBasic implements sdk.Msg interface +func (m *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return err + } + return m.Params.Validate() +} + +// GetSigners implements sdk.Msg interface +func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Authority)} +} diff --git a/x/bnblightclient/types/params.go b/x/bnblightclient/types/params.go new file mode 100644 index 00000000..acdf8260 --- /dev/null +++ b/x/bnblightclient/types/params.go @@ -0,0 +1,51 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" +) + +// Validate validates the Params struct. +// +// It does not take any parameters. +// It returns an error if the validation fails. +func (p Params) Validate() error { + if len(p.StakePlanHubAddress) == 0 { + return fmt.Errorf("stake plan hub address cannot be empty") + } + + if !common.IsHexAddress(p.StakePlanHubAddress) { + return fmt.Errorf("invalid stake plan hub address: %s", p.StakePlanHubAddress) + } + + if len(p.EventName) == 0 { + return fmt.Errorf("event name cannot be empty") + } + + if err := ValidateAllowList(p.AllowList); err != nil { + return err + } + return nil +} + +// ValidateAllowList validates a list of addresses. +// +// It takes a list of strings representing addresses as a parameter. +// It returns an error if any address is invalid. +func ValidateAllowList(allowList []string) error { + seenAddr := make(map[string]bool) + for _, addr := range allowList { + if seenAddr[addr] { + return fmt.Errorf("duplicate address: %s", addr) + } + + // check that the address is valid + if _, err := sdk.AccAddressFromBech32(addr); err != nil { + return fmt.Errorf("invalid address: %s", addr) + } + seenAddr[addr] = true + } + return nil +} diff --git a/x/bnblightclient/types/params.pb.go b/x/bnblightclient/types/params.pb.go new file mode 100644 index 00000000..31cbcd39 --- /dev/null +++ b/x/bnblightclient/types/params.pb.go @@ -0,0 +1,550 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + // the stake plan hub contract address + StakePlanHubAddress string `protobuf:"bytes,1,opt,name=stake_plan_hub_address,json=stakePlanHubAddress,proto3" json:"stake_plan_hub_address,omitempty"` + // event_name defines the event name + EventName string `protobuf:"bytes,2,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` + // the maximum number of bnb block headers to retain + RetainedBlocks uint64 `protobuf:"varint,3,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` + // list of people who can upload bnb block header information + AllowList []string `protobuf:"bytes,4,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` + // chain_id defines the bnb chain id + ChainId uint32 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_3608f71b6e08ae9c, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetStakePlanHubAddress() string { + if m != nil { + return m.StakePlanHubAddress + } + return "" +} + +func (m *Params) GetEventName() string { + if m != nil { + return m.EventName + } + return "" +} + +func (m *Params) GetRetainedBlocks() uint64 { + if m != nil { + return m.RetainedBlocks + } + return 0 +} + +func (m *Params) GetAllowList() []string { + if m != nil { + return m.AllowList + } + return nil +} + +func (m *Params) GetChainId() uint32 { + if m != nil { + return m.ChainId + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "lorenzo.bnblightclient.v1.Params") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/params.proto", fileDescriptor_3608f71b6e08ae9c) +} + +var fileDescriptor_3608f71b6e08ae9c = []byte{ + // 317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x4f, 0x4b, 0xf3, 0x30, + 0x00, 0xc6, 0x97, 0x77, 0x7b, 0xa7, 0x0b, 0xa8, 0x50, 0x45, 0x3a, 0xc1, 0x58, 0x3c, 0xe8, 0x2e, + 0x36, 0xcc, 0xdd, 0x04, 0x0f, 0xee, 0xa4, 0x30, 0x64, 0xec, 0x22, 0x78, 0x09, 0x49, 0x1b, 0xda, + 0xb0, 0x34, 0x29, 0x4d, 0x56, 0xff, 0x7c, 0x0a, 0x3f, 0x82, 0x5f, 0x46, 0xf0, 0xb8, 0xa3, 0x47, + 0x59, 0x2f, 0x7e, 0x0c, 0x69, 0xea, 0x0e, 0x7a, 0x4b, 0x9e, 0xe7, 0x97, 0x07, 0xf2, 0x83, 0x27, + 0x52, 0x17, 0x5c, 0x3d, 0x6b, 0xcc, 0x14, 0x93, 0x22, 0x49, 0x6d, 0x24, 0x05, 0x57, 0x16, 0x97, + 0x43, 0x9c, 0xd3, 0x82, 0x66, 0x26, 0xcc, 0x0b, 0x6d, 0xb5, 0xd7, 0xff, 0xe1, 0xc2, 0xdf, 0x5c, + 0x58, 0x0e, 0x0f, 0xf6, 0x12, 0x9d, 0x68, 0x47, 0xe1, 0xfa, 0xd4, 0x3c, 0x38, 0x7e, 0x03, 0xb0, + 0x3b, 0x75, 0x0b, 0xde, 0x08, 0xee, 0x1b, 0x4b, 0xe7, 0x9c, 0xe4, 0x92, 0x2a, 0x92, 0x2e, 0x18, + 0xa1, 0x71, 0x5c, 0x70, 0x63, 0x7c, 0x10, 0x80, 0x41, 0x6f, 0xb6, 0xeb, 0xda, 0xa9, 0xa4, 0xea, + 0x7a, 0xc1, 0xae, 0x9a, 0xca, 0x3b, 0x84, 0x90, 0x97, 0x5c, 0x59, 0xa2, 0x68, 0xc6, 0xfd, 0x7f, + 0x0e, 0xec, 0xb9, 0xe4, 0x96, 0x66, 0xdc, 0x3b, 0x85, 0x3b, 0x05, 0xb7, 0x54, 0x28, 0x1e, 0x13, + 0x26, 0x75, 0x34, 0x37, 0x7e, 0x3b, 0x00, 0x83, 0xce, 0x6c, 0x7b, 0x1d, 0x8f, 0x5d, 0x5a, 0xef, + 0x50, 0x29, 0xf5, 0x03, 0x91, 0xc2, 0x58, 0xbf, 0x13, 0xb4, 0xeb, 0x1d, 0x97, 0x4c, 0x84, 0xb1, + 0x5e, 0x1f, 0x6e, 0x46, 0x29, 0x15, 0x8a, 0x88, 0xd8, 0xff, 0x1f, 0x80, 0xc1, 0xd6, 0x6c, 0xc3, + 0xdd, 0x6f, 0xe2, 0x8b, 0xce, 0xd7, 0xeb, 0x11, 0x18, 0xdf, 0xbd, 0xaf, 0x10, 0x58, 0xae, 0x10, + 0xf8, 0x5c, 0x21, 0xf0, 0x52, 0xa1, 0xd6, 0xb2, 0x42, 0xad, 0x8f, 0x0a, 0xb5, 0xee, 0x2f, 0x13, + 0x61, 0xd3, 0x05, 0x0b, 0x23, 0x9d, 0xe1, 0x49, 0x63, 0xe7, 0x6c, 0x5a, 0xff, 0x3d, 0xd2, 0x12, + 0xaf, 0xb5, 0x96, 0xe7, 0xf8, 0xf1, 0xaf, 0x5b, 0xfb, 0x94, 0x73, 0xc3, 0xba, 0xce, 0xd3, 0xe8, + 0x3b, 0x00, 0x00, 0xff, 0xff, 0x46, 0xfe, 0x1a, 0x62, 0x82, 0x01, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.StakePlanHubAddress != that1.StakePlanHubAddress { + return false + } + if this.EventName != that1.EventName { + return false + } + if this.RetainedBlocks != that1.RetainedBlocks { + return false + } + if len(this.AllowList) != len(that1.AllowList) { + return false + } + for i := range this.AllowList { + if this.AllowList[i] != that1.AllowList[i] { + return false + } + } + if this.ChainId != that1.ChainId { + return false + } + return true +} +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChainId != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x28 + } + if len(m.AllowList) > 0 { + for iNdEx := len(m.AllowList) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowList[iNdEx]) + copy(dAtA[i:], m.AllowList[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.AllowList[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if m.RetainedBlocks != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.RetainedBlocks)) + i-- + dAtA[i] = 0x18 + } + if len(m.EventName) > 0 { + i -= len(m.EventName) + copy(dAtA[i:], m.EventName) + i = encodeVarintParams(dAtA, i, uint64(len(m.EventName))) + i-- + dAtA[i] = 0x12 + } + if len(m.StakePlanHubAddress) > 0 { + i -= len(m.StakePlanHubAddress) + copy(dAtA[i:], m.StakePlanHubAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.StakePlanHubAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakePlanHubAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.EventName) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.RetainedBlocks != 0 { + n += 1 + sovParams(uint64(m.RetainedBlocks)) + } + if len(m.AllowList) > 0 { + for _, s := range m.AllowList { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + if m.ChainId != 0 { + n += 1 + sovParams(uint64(m.ChainId)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakePlanHubAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakePlanHubAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EventName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EventName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RetainedBlocks", wireType) + } + m.RetainedBlocks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RetainedBlocks |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowList", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowList = append(m.AllowList, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + m.ChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bnblightclient/types/proof.go b/x/bnblightclient/types/proof.go new file mode 100644 index 00000000..2c2a5e9c --- /dev/null +++ b/x/bnblightclient/types/proof.go @@ -0,0 +1,176 @@ +package types + +import ( + "encoding/base64" + "encoding/json" + "errors" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + evmtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" +) + +// Proof is a struct that contains the index, value, and proof. +type Proof struct { + Index []byte `json:"index"` + Value []byte `json:"value"` + Path ProofPath `json:"path"` +} + +// ProofPath is a struct that contains the keys and values of the proof. +type ProofPath struct { + Keys []string `json:"keys"` + Values [][]byte `json:"values"` +} + +// NewProofPath creates a new ProofPath. +func NewProofPath() ProofPath { + return ProofPath{ + Keys: make([]string, 0), + Values: make([][]byte, 0), + } +} + +// Put adds a new key-value pair to the ProofPath. +func (pm *ProofPath) Put(key []byte, value []byte) error { + if pm.Keys == nil || pm.Values == nil { + return errors.New("proofMap db is nil") + } + + vIdx := pm.valueIdx(key) + if vIdx != -1 { + pm.Values[vIdx] = value + return nil + } + + pm.Keys = append(pm.Keys, pm.encodeKey(key)) + pm.Values = append(pm.Values, value) + return nil +} + +// Delete removes a key-value pair from the ProofPath. +func (pm *ProofPath) Delete(key []byte) error { + if pm.Keys == nil || pm.Values == nil { + return errors.New("proofMap db is nil") + } + + vIdx := pm.valueIdx(key) + if vIdx == -1 { + return errors.New("key not found") + } + + pm.Keys = append(pm.Keys[:vIdx], pm.Keys[vIdx+1:]...) + pm.Values = append(pm.Values[:vIdx], pm.Values[vIdx+1:]...) + + return nil +} + +// Has checks if a key exists in the ProofPath. +func (pm *ProofPath) Has(key []byte) (bool, error) { + if pm.Keys == nil || pm.Values == nil { + return false, errors.New("proofMap db is nil") + } + vIdx := pm.valueIdx(key) + if vIdx == -1 { + return false, nil + } + return true, nil +} + +// Get returns the value of a key in the ProofPath. +func (pm *ProofPath) Get(key []byte) ([]byte, error) { + if pm.Keys == nil || pm.Values == nil { + return nil, errors.New("proofMap db is nil") + } + + vIdx := pm.valueIdx(key) + if vIdx == -1 { + return nil, errors.New("value not found") + } + return pm.Values[vIdx], nil +} + +func (pm *ProofPath) encodeKey(key []byte) string { + return base64.StdEncoding.EncodeToString(key) +} + +func (pm *ProofPath) valueIdx(key []byte) int { + encodedKey := pm.encodeKey(key) + for i, k := range pm.Keys { + if k == encodedKey { + return i + } + } + return -1 +} + +// GenReceiptProof generates a Merkle Patricia Trie (MPT) proof for a specific transaction index in a list of receipts. +// +// Parameters: +// - txIndex: the index of the transaction for which the proof is generated. +// - root: the root hash of the MPT. +// - receipts: a list of receipts. +// +// Returns: +// - *mptproof.MPTProof: a pointer to an MPTProof struct containing the index, value, and proof of the transaction. +// - error: an error if the proof generation fails. +func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*evmtypes.Receipt) (*Proof, error) { + db := trie.NewDatabase(rawdb.NewMemoryDatabase()) + mpt := trie.NewEmpty(db) + receiptHash := evmtypes.DeriveSha(evmtypes.Receipts(receipts), mpt) + if receiptHash != root { + return nil, errors.New("root hash mismatch") + } + + var indexBuf []byte + indexBuf = rlp.AppendUint64(indexBuf[:0], txIndex) + valueTarget := mpt.Get(indexBuf) + + proof := NewProofPath() + err := mpt.Prove(indexBuf, 0, &proof) + if err != nil { + return nil, err + } + + res := Proof{ + Index: indexBuf, + Value: valueTarget, + Path: proof, + } + + return &res, nil +} + +// UnmarshalProof unmarshals a byte slice into a Proof struct. +// +// Parameters: +// - data: a byte slice containing the JSON representation of a Proof struct. +// +// Returns: +// - *Proof: a pointer to a Proof struct if the unmarshalling is successful. +// - error: an error if the unmarshalling fails. +func UnmarshalProof(data []byte) (*Proof, error) { + var proof Proof + if err := json.Unmarshal(data, &proof); err != nil { + return nil, ErrInvalidProof + } + return &proof, nil +} + +// UnmarshalReceipt unmarshals the given data into an evmtypes.Receipt object. +// +// Parameters: +// - data: a byte slice containing the JSON-encoded receipt data. +// +// Returns: +// - *evmtypes.Receipt: a pointer to the unmarshaled receipt object. +// - error: an error if the unmarshaling process fails. +func UnmarshalReceipt(data []byte) (*evmtypes.Receipt, error) { + receipt := &evmtypes.Receipt{} + if err := receipt.UnmarshalJSON(data); err != nil { + return nil, err + } + return receipt, nil +} \ No newline at end of file diff --git a/x/bnblightclient/types/query.pb.go b/x/bnblightclient/types/query.pb.go new file mode 100644 index 00000000..70da899e --- /dev/null +++ b/x/bnblightclient/types/query.pb.go @@ -0,0 +1,1653 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryHeaderRequest is the request type for the Query/Header RPC method. +type QueryHeaderRequest struct { + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` +} + +func (m *QueryHeaderRequest) Reset() { *m = QueryHeaderRequest{} } +func (m *QueryHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderRequest) ProtoMessage() {} +func (*QueryHeaderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{2} +} +func (m *QueryHeaderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryHeaderRequest.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 *QueryHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderRequest.Merge(m, src) +} +func (m *QueryHeaderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryHeaderRequest proto.InternalMessageInfo + +func (m *QueryHeaderRequest) GetNumber() uint64 { + if m != nil { + return m.Number + } + return 0 +} + +// QueryParamsResponse is the response type for the Query/Header RPC method. +type QueryHeaderResponse struct { + // params holds all the parameters of this module. + Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` +} + +func (m *QueryHeaderResponse) Reset() { *m = QueryHeaderResponse{} } +func (m *QueryHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderResponse) ProtoMessage() {} +func (*QueryHeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{3} +} +func (m *QueryHeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryHeaderResponse.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 *QueryHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderResponse.Merge(m, src) +} +func (m *QueryHeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryHeaderResponse proto.InternalMessageInfo + +func (m *QueryHeaderResponse) GetHeader() *Header { + if m != nil { + return m.Header + } + return nil +} + +// QueryHeaderByHashRequest is the request type for the Query/HeaderByHash RPC +// method. +type QueryHeaderByHashRequest struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *QueryHeaderByHashRequest) Reset() { *m = QueryHeaderByHashRequest{} } +func (m *QueryHeaderByHashRequest) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderByHashRequest) ProtoMessage() {} +func (*QueryHeaderByHashRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{4} +} +func (m *QueryHeaderByHashRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryHeaderByHashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryHeaderByHashRequest.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 *QueryHeaderByHashRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderByHashRequest.Merge(m, src) +} +func (m *QueryHeaderByHashRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryHeaderByHashRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderByHashRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryHeaderByHashRequest proto.InternalMessageInfo + +func (m *QueryHeaderByHashRequest) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +// QueryHeaderByHashResponse is the response type for the Query/HeaderByHash RPC +// method. +type QueryHeaderByHashResponse struct { + // params holds all the parameters of this module. + Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` +} + +func (m *QueryHeaderByHashResponse) Reset() { *m = QueryHeaderByHashResponse{} } +func (m *QueryHeaderByHashResponse) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderByHashResponse) ProtoMessage() {} +func (*QueryHeaderByHashResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{5} +} +func (m *QueryHeaderByHashResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryHeaderByHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryHeaderByHashResponse.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 *QueryHeaderByHashResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderByHashResponse.Merge(m, src) +} +func (m *QueryHeaderByHashResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryHeaderByHashResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderByHashResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryHeaderByHashResponse proto.InternalMessageInfo + +func (m *QueryHeaderByHashResponse) GetHeader() *Header { + if m != nil { + return m.Header + } + return nil +} + +// QueryLatestHeaderRequest is the request type for the Query/LatestHeader +// RPC method. +type QueryLatestHeaderRequest struct { +} + +func (m *QueryLatestHeaderRequest) Reset() { *m = QueryLatestHeaderRequest{} } +func (m *QueryLatestHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryLatestHeaderRequest) ProtoMessage() {} +func (*QueryLatestHeaderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{6} +} +func (m *QueryLatestHeaderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLatestHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLatestHeaderRequest.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 *QueryLatestHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLatestHeaderRequest.Merge(m, src) +} +func (m *QueryLatestHeaderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryLatestHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLatestHeaderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLatestHeaderRequest proto.InternalMessageInfo + +// QueryLatestHeaderResponse is the response type for the Query/LatestHeader +// RPC method. +type QueryLatestHeaderResponse struct { + // header holds the bnb light client header. + Header Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` +} + +func (m *QueryLatestHeaderResponse) Reset() { *m = QueryLatestHeaderResponse{} } +func (m *QueryLatestHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryLatestHeaderResponse) ProtoMessage() {} +func (*QueryLatestHeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{7} +} +func (m *QueryLatestHeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLatestHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLatestHeaderResponse.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 *QueryLatestHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLatestHeaderResponse.Merge(m, src) +} +func (m *QueryLatestHeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryLatestHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLatestHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLatestHeaderResponse proto.InternalMessageInfo + +func (m *QueryLatestHeaderResponse) GetHeader() Header { + if m != nil { + return m.Header + } + return Header{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "lorenzo.bnblightclient.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "lorenzo.bnblightclient.v1.QueryParamsResponse") + proto.RegisterType((*QueryHeaderRequest)(nil), "lorenzo.bnblightclient.v1.QueryHeaderRequest") + proto.RegisterType((*QueryHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryHeaderResponse") + proto.RegisterType((*QueryHeaderByHashRequest)(nil), "lorenzo.bnblightclient.v1.QueryHeaderByHashRequest") + proto.RegisterType((*QueryHeaderByHashResponse)(nil), "lorenzo.bnblightclient.v1.QueryHeaderByHashResponse") + proto.RegisterType((*QueryLatestHeaderRequest)(nil), "lorenzo.bnblightclient.v1.QueryLatestHeaderRequest") + proto.RegisterType((*QueryLatestHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryLatestHeaderResponse") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/query.proto", fileDescriptor_f139d6422d3b3b56) +} + +var fileDescriptor_f139d6422d3b3b56 = []byte{ + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6e, 0xd3, 0x30, + 0x1c, 0xc6, 0x63, 0xd4, 0xe5, 0x60, 0x7a, 0x32, 0x13, 0xda, 0x22, 0x14, 0x58, 0x10, 0x68, 0x4c, + 0xab, 0xcd, 0x3a, 0x38, 0x22, 0xa4, 0x9e, 0x76, 0xd8, 0x61, 0xe4, 0x00, 0x12, 0x42, 0x42, 0x4e, + 0xb1, 0x92, 0x48, 0xa9, 0x9d, 0xc5, 0x6e, 0x45, 0x41, 0xbb, 0xf0, 0x04, 0x08, 0x8e, 0x7b, 0x04, + 0x2e, 0x3c, 0xc6, 0x8e, 0x93, 0xb8, 0x70, 0x42, 0xa8, 0xe5, 0x41, 0x50, 0x6c, 0xb7, 0x34, 0xd0, + 0x36, 0x41, 0x70, 0xa9, 0x52, 0xe7, 0xff, 0x7d, 0xdf, 0xaf, 0xff, 0x7e, 0x32, 0xbc, 0x93, 0x89, + 0x82, 0xf1, 0x37, 0x82, 0x44, 0x3c, 0xca, 0xd2, 0x38, 0x51, 0xfd, 0x2c, 0x65, 0x5c, 0x91, 0xd1, + 0x01, 0x39, 0x1d, 0xb2, 0x62, 0x8c, 0xf3, 0x42, 0x28, 0x81, 0xb6, 0xed, 0x18, 0xae, 0x8e, 0xe1, + 0xd1, 0x81, 0xb7, 0x19, 0x8b, 0x58, 0xe8, 0x29, 0x52, 0x3e, 0x19, 0x81, 0x77, 0x23, 0x16, 0x22, + 0xce, 0x18, 0xa1, 0x79, 0x4a, 0x28, 0xe7, 0x42, 0x51, 0x95, 0x0a, 0x2e, 0xed, 0xdb, 0xbb, 0xab, + 0x53, 0xad, 0x71, 0xed, 0x5c, 0x4e, 0x0b, 0x3a, 0xb0, 0x7e, 0xc1, 0x26, 0x44, 0x4f, 0x4a, 0xda, + 0x13, 0x7d, 0x18, 0xb2, 0xd3, 0x21, 0x93, 0x2a, 0x78, 0x0a, 0xaf, 0x55, 0x4e, 0x65, 0x2e, 0xb8, + 0x64, 0xe8, 0x31, 0x74, 0x8d, 0x78, 0x0b, 0xdc, 0x02, 0xbb, 0x57, 0xbb, 0x3b, 0x78, 0xe5, 0x8f, + 0xc3, 0x46, 0xda, 0x6b, 0x5d, 0x7c, 0xbb, 0xe9, 0x84, 0x56, 0x16, 0xec, 0xdb, 0xb4, 0x23, 0x46, + 0x5f, 0xb1, 0xc2, 0xa6, 0xa1, 0xeb, 0xd0, 0xe5, 0xc3, 0x41, 0xc4, 0x0a, 0x6d, 0xdb, 0x0a, 0xed, + 0xb7, 0x39, 0xc5, 0x6c, 0xfa, 0x17, 0x45, 0xa2, 0x4f, 0x1a, 0x50, 0x18, 0xa9, 0xa6, 0x00, 0xa1, + 0x95, 0x05, 0x18, 0x6e, 0x2d, 0xf8, 0xf6, 0xc6, 0x47, 0x54, 0x26, 0x33, 0x16, 0x04, 0x5b, 0x09, + 0x95, 0x89, 0xb6, 0x6e, 0x87, 0xfa, 0x39, 0x78, 0x01, 0xb7, 0x97, 0xcc, 0xff, 0x2f, 0x1a, 0xcf, + 0xd2, 0x1c, 0x53, 0xc5, 0xa4, 0xaa, 0x6c, 0x66, 0x9e, 0x5c, 0x7d, 0xf7, 0x6f, 0xc9, 0xce, 0x2c, + 0xb9, 0x7b, 0xbe, 0x01, 0x37, 0xb4, 0x3d, 0xfa, 0x00, 0xa0, 0x6b, 0xfe, 0x30, 0xd4, 0x59, 0xe3, + 0xf2, 0x67, 0x53, 0x3c, 0xdc, 0x74, 0xdc, 0x40, 0x07, 0xf7, 0xde, 0x7d, 0xf9, 0xf1, 0xf1, 0xca, + 0x6d, 0xb4, 0x43, 0xea, 0x0a, 0x8a, 0xce, 0x01, 0x74, 0x0d, 0x77, 0x3d, 0x54, 0x65, 0x6d, 0xf5, + 0x50, 0xd5, 0x4d, 0x06, 0x5d, 0x0d, 0xb5, 0x8f, 0xf6, 0xd6, 0x40, 0x99, 0x9d, 0x91, 0xb7, 0xa6, + 0x9b, 0x67, 0xe8, 0x33, 0x80, 0xed, 0xc5, 0x42, 0xa0, 0xc3, 0x66, 0xa1, 0x95, 0xba, 0x79, 0x0f, + 0xfe, 0x4e, 0x64, 0x79, 0x1f, 0x6a, 0x5e, 0x82, 0x3a, 0x0d, 0x78, 0xcb, 0x06, 0x9f, 0x91, 0xf2, + 0x13, 0x7d, 0x02, 0xb0, 0xbd, 0xd8, 0xa4, 0x7a, 0xe4, 0x25, 0x9d, 0xac, 0x47, 0x5e, 0x56, 0xd6, + 0xe0, 0xbe, 0x46, 0xde, 0x43, 0xbb, 0x6b, 0x90, 0x33, 0x2d, 0x7c, 0x69, 0xc8, 0x7b, 0xcf, 0x2e, + 0x26, 0x3e, 0xb8, 0x9c, 0xf8, 0xe0, 0xfb, 0xc4, 0x07, 0xef, 0xa7, 0xbe, 0x73, 0x39, 0xf5, 0x9d, + 0xaf, 0x53, 0xdf, 0x79, 0xfe, 0x28, 0x4e, 0x55, 0x32, 0x8c, 0x70, 0x5f, 0x0c, 0xc8, 0xb1, 0x71, + 0xeb, 0x9c, 0x94, 0xb7, 0x59, 0x5f, 0x64, 0x73, 0xfb, 0x51, 0x97, 0xbc, 0xfe, 0x3d, 0x43, 0x8d, + 0x73, 0x26, 0x23, 0x57, 0xdf, 0x7c, 0x87, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x44, 0x8d, 0xaf, + 0x5e, 0xc1, 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Header returns the header in bnb chain by number + Header(ctx context.Context, in *QueryHeaderRequest, opts ...grpc.CallOption) (*QueryHeaderResponse, error) + // HeaderByHash returns the header in bnb chain by hash + HeaderByHash(ctx context.Context, in *QueryHeaderByHashRequest, opts ...grpc.CallOption) (*QueryHeaderByHashResponse, error) + // LatestHeader returns the latest header in bnb chain + LatestHeader(ctx context.Context, in *QueryLatestHeaderRequest, opts ...grpc.CallOption) (*QueryLatestHeaderResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Header(ctx context.Context, in *QueryHeaderRequest, opts ...grpc.CallOption) (*QueryHeaderResponse, error) { + out := new(QueryHeaderResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/Header", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) HeaderByHash(ctx context.Context, in *QueryHeaderByHashRequest, opts ...grpc.CallOption) (*QueryHeaderByHashResponse, error) { + out := new(QueryHeaderByHashResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/HeaderByHash", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) LatestHeader(ctx context.Context, in *QueryLatestHeaderRequest, opts ...grpc.CallOption) (*QueryLatestHeaderResponse, error) { + out := new(QueryLatestHeaderResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/LatestHeader", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Header returns the header in bnb chain by number + Header(context.Context, *QueryHeaderRequest) (*QueryHeaderResponse, error) + // HeaderByHash returns the header in bnb chain by hash + HeaderByHash(context.Context, *QueryHeaderByHashRequest) (*QueryHeaderByHashResponse, error) + // LatestHeader returns the latest header in bnb chain + LatestHeader(context.Context, *QueryLatestHeaderRequest) (*QueryLatestHeaderResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Header(ctx context.Context, req *QueryHeaderRequest) (*QueryHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Header not implemented") +} +func (*UnimplementedQueryServer) HeaderByHash(ctx context.Context, req *QueryHeaderByHashRequest) (*QueryHeaderByHashResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HeaderByHash not implemented") +} +func (*UnimplementedQueryServer) LatestHeader(ctx context.Context, req *QueryLatestHeaderRequest) (*QueryLatestHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LatestHeader not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Header_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryHeaderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Header(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Query/Header", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Header(ctx, req.(*QueryHeaderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_HeaderByHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryHeaderByHashRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).HeaderByHash(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Query/HeaderByHash", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).HeaderByHash(ctx, req.(*QueryHeaderByHashRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_LatestHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryLatestHeaderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).LatestHeader(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Query/LatestHeader", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).LatestHeader(ctx, req.(*QueryLatestHeaderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lorenzo.bnblightclient.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Header", + Handler: _Query_Header_Handler, + }, + { + MethodName: "HeaderByHash", + Handler: _Query_HeaderByHash_Handler, + }, + { + MethodName: "LatestHeader", + Handler: _Query_LatestHeader_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lorenzo/bnblightclient/v1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryHeaderRequest) 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 *QueryHeaderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Number != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryHeaderResponse) 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 *QueryHeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryHeaderByHashRequest) 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 *QueryHeaderByHashRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderByHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryHeaderByHashResponse) 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 *QueryHeaderByHashResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryLatestHeaderRequest) 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 *QueryLatestHeaderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLatestHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryLatestHeaderResponse) 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 *QueryLatestHeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLatestHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryHeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Number != 0 { + n += 1 + sovQuery(uint64(m.Number)) + } + return n +} + +func (m *QueryHeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryHeaderByHashRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryHeaderByHashResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryLatestHeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryLatestHeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Header.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryHeaderRequest) 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 ErrIntOverflowQuery + } + 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: QueryHeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + m.Number = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Number |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryHeaderResponse) 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 ErrIntOverflowQuery + } + 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: QueryHeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &Header{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryHeaderByHashRequest) 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 ErrIntOverflowQuery + } + 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: QueryHeaderByHashRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderByHashRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryHeaderByHashResponse) 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 ErrIntOverflowQuery + } + 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: QueryHeaderByHashResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderByHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &Header{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLatestHeaderRequest) 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 ErrIntOverflowQuery + } + 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: QueryLatestHeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLatestHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLatestHeaderResponse) 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 ErrIntOverflowQuery + } + 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: QueryLatestHeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLatestHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bnblightclient/types/query.pb.gw.go b/x/bnblightclient/types/query.pb.gw.go new file mode 100644 index 00000000..6f0e1015 --- /dev/null +++ b/x/bnblightclient/types/query.pb.gw.go @@ -0,0 +1,420 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Header_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["number"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "number") + } + + protoReq.Number, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "number", err) + } + + msg, err := client.Header(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Header_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["number"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "number") + } + + protoReq.Number, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "number", err) + } + + msg, err := server.Header(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_HeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderByHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.HeaderByHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_HeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderByHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.HeaderByHash(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_LatestHeader_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLatestHeaderRequest + var metadata runtime.ServerMetadata + + msg, err := client.LatestHeader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_LatestHeader_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLatestHeaderRequest + var metadata runtime.ServerMetadata + + msg, err := server.LatestHeader(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Header_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Header_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Header_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_HeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_HeaderByHash_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_HeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LatestHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_LatestHeader_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_LatestHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Header_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Header_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Header_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_HeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_HeaderByHash_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_HeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LatestHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_LatestHeader_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_LatestHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lorenzo", "bnblightclient", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Header_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"lorenzo", "bnblightclient", "v1", "header", "number"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_HeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 4}, []string{"lorenzo", "bnblightclient", "v1", "header", "hash"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_LatestHeader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lorenzo", "bnblightclient", "v1", "latest_header"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Header_0 = runtime.ForwardResponseMessage + + forward_Query_HeaderByHash_0 = runtime.ForwardResponseMessage + + forward_Query_LatestHeader_0 = runtime.ForwardResponseMessage +) diff --git a/x/bnblightclient/types/stake_plan_hub_abi.json b/x/bnblightclient/types/stake_plan_hub_abi.json new file mode 100644 index 00000000..0221f871 --- /dev/null +++ b/x/bnblightclient/types/stake_plan_hub_abi.json @@ -0,0 +1,798 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1167FailedCreateClone", + "type": "error" + }, + { + "inputs": [], + "name": "EnforcedPause", + "type": "error" + }, + { + "inputs": [], + "name": "ExpectedPause", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBTCContractAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidPlanId", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTime", + "type": "error" + }, + { + "inputs": [], + "name": "NoPermission", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [], + "name": "StakePlanNotAvailable", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "btcContractAddress", + "type": "address" + } + ], + "name": "BTCContractAddressAdd", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "btcContractAddress", + "type": "address" + } + ], + "name": "BTCContractAddressRemove", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "planId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "derivedStakePlanAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakePlanStartTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "periodTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "descUri", + "type": "string" + } + ], + "name": "CreateNewPlan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "preGovernance", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "GovernanceSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "gov", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "stakePlanImpl", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "lorenzoAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "mintstBTCAuthorityAddress_", + "type": "address" + } + ], + "name": "Initialize", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "preLorenzoAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newLorenzoAdmin", + "type": "address" + } + ], + "name": "LorenzoAdminSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "planId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool", + "name": "available", + "type": "bool" + } + ], + "name": "SetStakePlanAvailable", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "preStBTCMintAuthorityAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newStBTCMintAuthorityAddress", + "type": "address" + } + ], + "name": "StBTCMintAuthoritySet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "stakeIndex", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "planId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "btcContractAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stBTCAmount", + "type": "uint256" + } + ], + "name": "StakeBTC2JoinStakePlan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "preStakePlanImpl", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newStakePlanImpl", + "type": "address" + } + ], + "name": "StakePlanImplSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "planId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "btcContractAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "WithdrawBTC", + "type": "event" + }, + { + "inputs": [], + "name": "_governance", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_lorenzoAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_stBTCMintAuthorityAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_stakeIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "_stakePlanAvailableMap", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_stakePlanCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_stakePlanImpl", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "_stakePlanMap", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "btcContractAddress_", + "type": "address[]" + } + ], + "name": "addSupportBtcContractAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "adminPauseBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "adminUnpauseBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "string", + "name": "descUri", + "type": "string" + }, + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakePlanStartTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "periodTime", + "type": "uint256" + } + ], + "internalType": "struct DataTypes.CreateNewPlanData", + "name": "vars_", + "type": "tuple" + } + ], + "name": "createNewPlan", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getSupportBtcContractAddress", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "gov_", + "type": "address" + }, + { + "internalType": "address", + "name": "stakePlanImpl_", + "type": "address" + }, + { + "internalType": "address", + "name": "lorenzoAdmin_", + "type": "address" + }, + { + "internalType": "address", + "name": "stBTCMintAuthorityAddress_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "btcContractAddress_", + "type": "address[]" + } + ], + "name": "removeSupportBtcContractAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newGov_", + "type": "address" + } + ], + "name": "setGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newLorenzoAdmin_", + "type": "address" + } + ], + "name": "setLorenzoAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newStBTCMintAuthorityAddress_", + "type": "address" + } + ], + "name": "setStBTCMintAuthorityAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "planId_", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "available_", + "type": "bool" + } + ], + "name": "setStakePlanAvailable", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newStakePlanImpl_", + "type": "address" + } + ], + "name": "setStakePlanImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "planId_", + "type": "uint256" + }, + { + "internalType": "address", + "name": "btcContractAddress_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stakeAmount", + "type": "uint256" + } + ], + "name": "stakeBTC2JoinStakePlan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "planId_", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + } + ], + "name": "withdrawBTC", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/x/bnblightclient/types/tx.pb.go b/x/bnblightclient/types/tx.pb.go new file mode 100644 index 00000000..8b53396f --- /dev/null +++ b/x/bnblightclient/types/tx.pb.go @@ -0,0 +1,1390 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// MsgUploadHeaders defines the message for multiple incoming header bytes +type MsgUploadHeaders struct { + Headers []*Header `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgUploadHeaders) Reset() { *m = MsgUploadHeaders{} } +func (m *MsgUploadHeaders) String() string { return proto.CompactTextString(m) } +func (*MsgUploadHeaders) ProtoMessage() {} +func (*MsgUploadHeaders) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{0} +} +func (m *MsgUploadHeaders) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUploadHeaders) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUploadHeaders.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 *MsgUploadHeaders) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUploadHeaders.Merge(m, src) +} +func (m *MsgUploadHeaders) XXX_Size() int { + return m.Size() +} +func (m *MsgUploadHeaders) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUploadHeaders.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUploadHeaders proto.InternalMessageInfo + +func (m *MsgUploadHeaders) GetHeaders() []*Header { + if m != nil { + return m.Headers + } + return nil +} + +func (m *MsgUploadHeaders) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +// MsgUploadHeadersResponse defines the response for the UploadHeaders transaction +type MsgUploadHeadersResponse struct { +} + +func (m *MsgUploadHeadersResponse) Reset() { *m = MsgUploadHeadersResponse{} } +func (m *MsgUploadHeadersResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUploadHeadersResponse) ProtoMessage() {} +func (*MsgUploadHeadersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{1} +} +func (m *MsgUploadHeadersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUploadHeadersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUploadHeadersResponse.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 *MsgUploadHeadersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUploadHeadersResponse.Merge(m, src) +} +func (m *MsgUploadHeadersResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUploadHeadersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUploadHeadersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUploadHeadersResponse proto.InternalMessageInfo + +// MsgUpdateHeader defines the message for updating bnb light client header. +type MsgUpdateHeader struct { + Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgUpdateHeader) Reset() { *m = MsgUpdateHeader{} } +func (m *MsgUpdateHeader) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateHeader) ProtoMessage() {} +func (*MsgUpdateHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{2} +} +func (m *MsgUpdateHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateHeader.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 *MsgUpdateHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateHeader.Merge(m, src) +} +func (m *MsgUpdateHeader) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateHeader) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateHeader proto.InternalMessageInfo + +func (m *MsgUpdateHeader) GetHeader() *Header { + if m != nil { + return m.Header + } + return nil +} + +func (m *MsgUpdateHeader) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +// MsgUpdateHeaderResponse defines the response for the UpdateHeader +// transaction +type MsgUpdateHeaderResponse struct { +} + +func (m *MsgUpdateHeaderResponse) Reset() { *m = MsgUpdateHeaderResponse{} } +func (m *MsgUpdateHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateHeaderResponse) ProtoMessage() {} +func (*MsgUpdateHeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{3} +} +func (m *MsgUpdateHeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateHeaderResponse.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 *MsgUpdateHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateHeaderResponse.Merge(m, src) +} +func (m *MsgUpdateHeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateHeaderResponse proto.InternalMessageInfo + +// MsgUpdateParams defines a message for updating fee module parameters. +type MsgUpdateParams struct { + // authority is the address of the governance account. + // just FYI: cosmos.AddressString marks that this field should use type alias + // for AddressString instead of string, but the functionality is not yet + // implemented in cosmos-proto + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the bnb light client parameters. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{4} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse is the response to the MsgUpdateParams message. +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{5} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUploadHeaders)(nil), "lorenzo.bnblightclient.v1.MsgUploadHeaders") + proto.RegisterType((*MsgUploadHeadersResponse)(nil), "lorenzo.bnblightclient.v1.MsgUploadHeadersResponse") + proto.RegisterType((*MsgUpdateHeader)(nil), "lorenzo.bnblightclient.v1.MsgUpdateHeader") + proto.RegisterType((*MsgUpdateHeaderResponse)(nil), "lorenzo.bnblightclient.v1.MsgUpdateHeaderResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "lorenzo.bnblightclient.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "lorenzo.bnblightclient.v1.MsgUpdateParamsResponse") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/tx.proto", fileDescriptor_7077a7889346cb20) +} + +var fileDescriptor_7077a7889346cb20 = []byte{ + // 474 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x33, 0xad, 0xae, 0x74, 0xea, 0x3f, 0x86, 0x42, 0xb3, 0x39, 0xc4, 0x75, 0x0f, 0x52, + 0x56, 0x9a, 0xb1, 0x5b, 0x10, 0xac, 0x88, 0xb8, 0x27, 0x0f, 0x16, 0x4a, 0x44, 0x04, 0x2f, 0x92, + 0x3f, 0xc3, 0x24, 0x90, 0x64, 0xc2, 0xcc, 0x74, 0x69, 0x3d, 0x89, 0x57, 0x41, 0x3c, 0xfb, 0x29, + 0x7a, 0xf0, 0x43, 0xf4, 0x58, 0x3c, 0x79, 0x12, 0xdd, 0x3d, 0xf4, 0x6b, 0x48, 0x32, 0x93, 0xc6, + 0x04, 0xba, 0x1b, 0xe9, 0x6d, 0x86, 0xf7, 0x79, 0xe6, 0xf9, 0xcd, 0xcc, 0xfb, 0xc2, 0x61, 0xc2, + 0x38, 0xc9, 0x3e, 0x30, 0xec, 0x67, 0x7e, 0x12, 0xd3, 0x48, 0x06, 0x49, 0x4c, 0x32, 0x89, 0xa7, + 0x3b, 0x58, 0x1e, 0x39, 0x39, 0x67, 0x92, 0xa1, 0xbe, 0xd6, 0x38, 0x4d, 0x8d, 0x33, 0xdd, 0xb1, + 0x36, 0x28, 0xa3, 0xac, 0x54, 0xe1, 0x62, 0xa5, 0x0c, 0x56, 0x3f, 0x60, 0x22, 0x65, 0xe2, 0xbd, + 0x2a, 0xa8, 0x8d, 0x2e, 0x6d, 0xaa, 0x1d, 0x4e, 0x05, 0x2d, 0x32, 0x52, 0x41, 0x75, 0xe1, 0xc1, + 0xe5, 0x20, 0x3a, 0x6e, 0xa9, 0x2e, 0xf7, 0xb8, 0x97, 0xea, 0xa0, 0xe1, 0x17, 0x00, 0xef, 0xee, + 0x0b, 0xfa, 0x26, 0x4f, 0x98, 0x17, 0xbe, 0x24, 0x5e, 0x48, 0xb8, 0x40, 0x4f, 0xe1, 0x8d, 0x48, + 0x2d, 0x4d, 0x30, 0x58, 0xdd, 0x5a, 0x1f, 0xdf, 0x77, 0x2e, 0xbd, 0x9b, 0xa3, 0x4c, 0x6e, 0xe5, + 0x40, 0x8f, 0x60, 0x4f, 0xc4, 0x34, 0x23, 0xdc, 0x5c, 0x19, 0x80, 0xad, 0xb5, 0x89, 0xf9, 0xe3, + 0xfb, 0xf6, 0x86, 0xbe, 0xdc, 0x8b, 0x30, 0xe4, 0x44, 0x88, 0xd7, 0x92, 0xc7, 0x19, 0x75, 0xb5, + 0x6e, 0x6f, 0xfd, 0xd3, 0xf9, 0xc9, 0x48, 0x6f, 0x86, 0x16, 0x34, 0xdb, 0x3c, 0x2e, 0x11, 0x39, + 0xcb, 0x04, 0x19, 0x7e, 0x06, 0xf0, 0x4e, 0x59, 0x0c, 0x3d, 0x49, 0x54, 0x11, 0x3d, 0x81, 0x3d, + 0x95, 0x6c, 0x82, 0x01, 0xe8, 0x86, 0xaa, 0x0d, 0x57, 0x25, 0xed, 0xc3, 0xcd, 0x16, 0xcc, 0x05, + 0xe8, 0xb7, 0x7f, 0x41, 0x0f, 0xca, 0xf7, 0x46, 0x8f, 0xe1, 0x9a, 0x77, 0x28, 0x23, 0xc6, 0x63, + 0x79, 0x5c, 0xb2, 0x2e, 0x0a, 0xac, 0xa5, 0xe8, 0x39, 0xec, 0xa9, 0x1f, 0x2b, 0x29, 0x17, 0x5f, + 0x50, 0x45, 0x4d, 0xae, 0x9d, 0xfe, 0xba, 0x67, 0xb8, 0xda, 0xb6, 0x77, 0xbb, 0x80, 0xae, 0x0f, + 0x6c, 0x70, 0x2b, 0x43, 0xc5, 0x3d, 0xfe, 0xb3, 0x02, 0x57, 0xf7, 0x05, 0x45, 0x02, 0xde, 0x6a, + 0x76, 0xc4, 0xc3, 0x05, 0xa1, 0xed, 0xef, 0xb2, 0x76, 0xff, 0x43, 0x7c, 0xf1, 0x64, 0x06, 0xca, + 0xe0, 0xcd, 0xc6, 0x83, 0x8d, 0x96, 0x1d, 0x53, 0x6b, 0xad, 0x71, 0x77, 0x6d, 0x95, 0x58, 0xe7, + 0xe9, 0x4e, 0xea, 0x94, 0xa7, 0xb4, 0xdd, 0xf2, 0x9a, 0x4d, 0x61, 0x5d, 0xff, 0x78, 0x7e, 0x32, + 0x02, 0x93, 0xb7, 0xa7, 0x33, 0x1b, 0x9c, 0xcd, 0x6c, 0xf0, 0x7b, 0x66, 0x83, 0xaf, 0x73, 0xdb, + 0x38, 0x9b, 0xdb, 0xc6, 0xcf, 0xb9, 0x6d, 0xbc, 0x7b, 0x46, 0x63, 0x19, 0x1d, 0xfa, 0x4e, 0xc0, + 0x52, 0xfc, 0x4a, 0x1d, 0xbf, 0x7d, 0x50, 0x4c, 0x69, 0xc0, 0x12, 0x5c, 0xcd, 0xf3, 0x74, 0x8c, + 0x8f, 0xda, 0x43, 0x2d, 0x8f, 0x73, 0x22, 0xfc, 0x5e, 0x39, 0xd1, 0xbb, 0x7f, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x55, 0x15, 0xdb, 0x42, 0xac, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // UploadHeaders adds a batch of headers to the bnb light client chain + UploadHeaders(ctx context.Context, in *MsgUploadHeaders, opts ...grpc.CallOption) (*MsgUploadHeadersResponse, error) + // UpdateParams defines a method for updating bnb light client module + // parameters. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // UpdateHeader defines a method for updating bnb light client header. + UpdateHeader(ctx context.Context, in *MsgUpdateHeader, opts ...grpc.CallOption) (*MsgUpdateHeaderResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UploadHeaders(ctx context.Context, in *MsgUploadHeaders, opts ...grpc.CallOption) (*MsgUploadHeadersResponse, error) { + out := new(MsgUploadHeadersResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Msg/UploadHeaders", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateHeader(ctx context.Context, in *MsgUpdateHeader, opts ...grpc.CallOption) (*MsgUpdateHeaderResponse, error) { + out := new(MsgUpdateHeaderResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Msg/UpdateHeader", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UploadHeaders adds a batch of headers to the bnb light client chain + UploadHeaders(context.Context, *MsgUploadHeaders) (*MsgUploadHeadersResponse, error) + // UpdateParams defines a method for updating bnb light client module + // parameters. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // UpdateHeader defines a method for updating bnb light client header. + UpdateHeader(context.Context, *MsgUpdateHeader) (*MsgUpdateHeaderResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UploadHeaders(ctx context.Context, req *MsgUploadHeaders) (*MsgUploadHeadersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UploadHeaders not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} +func (*UnimplementedMsgServer) UpdateHeader(ctx context.Context, req *MsgUpdateHeader) (*MsgUpdateHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateHeader not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UploadHeaders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUploadHeaders) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UploadHeaders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Msg/UploadHeaders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UploadHeaders(ctx, req.(*MsgUploadHeaders)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateHeader) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateHeader(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Msg/UpdateHeader", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateHeader(ctx, req.(*MsgUpdateHeader)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lorenzo.bnblightclient.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UploadHeaders", + Handler: _Msg_UploadHeaders_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + { + MethodName: "UpdateHeader", + Handler: _Msg_UpdateHeader_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lorenzo/bnblightclient/v1/tx.proto", +} + +func (m *MsgUploadHeaders) 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 *MsgUploadHeaders) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUploadHeaders) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if len(m.Headers) > 0 { + for iNdEx := len(m.Headers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Headers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgUploadHeadersResponse) 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 *MsgUploadHeadersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUploadHeadersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateHeader) 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 *MsgUpdateHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateHeaderResponse) 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 *MsgUpdateHeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUploadHeaders) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Headers) > 0 { + for _, e := range m.Headers { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUploadHeadersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateHeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUploadHeaders) 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 ErrIntOverflowTx + } + 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: MsgUploadHeaders: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUploadHeaders: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Headers = append(m.Headers, &Header{}) + if err := m.Headers[len(m.Headers)-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 Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUploadHeadersResponse) 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 ErrIntOverflowTx + } + 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: MsgUploadHeadersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUploadHeadersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateHeader) 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 ErrIntOverflowTx + } + 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: MsgUpdateHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &Header{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateHeaderResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateHeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/btcstaking/keeper/keeper.go b/x/btcstaking/keeper/keeper.go index 85fa5d91..485dd615 100644 --- a/x/btcstaking/keeper/keeper.go +++ b/x/btcstaking/keeper/keeper.go @@ -20,6 +20,7 @@ type ( bankKeeper bankkeeper.Keeper btclcKeeper types.BTCLightClientKeeper + bnbLcKeeper types.BNBLightClientKeeper evmKeeper types.EvmKeeper diff --git a/x/btcstaking/keeper/msg_server.go b/x/btcstaking/keeper/msg_server.go index 7c995c1b..f744966a 100644 --- a/x/btcstaking/keeper/msg_server.go +++ b/x/btcstaking/keeper/msg_server.go @@ -291,6 +291,11 @@ func (ms msgServer) Burn(goCtx context.Context, req *types.MsgBurnRequest) (*typ return &types.MsgBurnResponse{}, nil } +// CreateBTCStakingFromBNB implements types.MsgServer. +func (ms msgServer) CreateBTCStakingFromBNB(goctx context.Context, req *types.MsgCreateBTCStakingFromBNB) (*types.MsgCreateBTCStakingFromBNBResponse, error) { + return &types.MsgCreateBTCStakingFromBNBResponse{}, nil +} + func findReceiver(receivers []*types.Receiver, name string) (int, *types.Receiver) { var receiver *types.Receiver = nil idx := -1 diff --git a/x/btcstaking/keeper/staking.go b/x/btcstaking/keeper/staking.go new file mode 100644 index 00000000..29450232 --- /dev/null +++ b/x/btcstaking/keeper/staking.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + + bnblightclienttypes "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/btcstaking/types" +) + +// DepositBTCB deposits BTCB to the staking module. +// +// ctx: the context of the current blockchain. +// depositor: the address of the depositor. +// receiptBz: the byte array representation of the receipt. +// proofBz: the byte array representation of the proof. +// error: returns an error if there was a problem with the deposit. +func (k Keeper) DepositBTCB(ctx sdk.Context, depositor sdk.AccAddress, receiptBz, proofBz []byte) error { + proof, err := bnblightclienttypes.UnmarshalProof(proofBz) + if err != nil { + return err + } + + receipt, err := bnblightclienttypes.UnmarshalReceipt(receiptBz) + if err != nil { + return err + } + + event,err := k.bnbLcKeeper.VerifyReceiptProof(ctx, receipt, proof) + if err != nil { + return err + } + + bridgeAddr := sdk.MustAccAddressFromBech32(k.GetParams(ctx).BridgeAddr) + totalStBTCAmt := new(big.Int) + for _, e := range event { + totalStBTCAmt = totalStBTCAmt.Add(totalStBTCAmt, &e.StBTCAmount) + } + + // mint stBTC to the bridgeAddr + totalStBTC := sdk.NewCoins(sdk.NewCoin(types.NativeTokenDenom, sdk.NewIntFromBigInt(totalStBTCAmt))) + if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, totalStBTC);err != nil { + return err + } + + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, bridgeAddr, totalStBTC) + if err != nil { + return err + } + return nil +} diff --git a/x/btcstaking/types/expected_keepers.go b/x/btcstaking/types/expected_keepers.go index a7b1d9b9..89b554fe 100644 --- a/x/btcstaking/types/expected_keepers.go +++ b/x/btcstaking/types/expected_keepers.go @@ -3,11 +3,13 @@ package types import ( big "math/big" + "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" + evmtypes "github.com/ethereum/go-ethereum/core/types" lrz "github.com/Lorenzo-Protocol/lorenzo/v2/types" + bnblightclienttypes "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" btclctypes "github.com/Lorenzo-Protocol/lorenzo/v2/x/btclightclient/types" - "github.com/btcsuite/btcd/chaincfg" ) type BTCLightClientKeeper interface { @@ -18,6 +20,11 @@ type BTCLightClientKeeper interface { GetFeeRate(ctx sdk.Context) uint64 } +// BNBLightClientKeeper is an expected keeper for the bnblightclient module +type BNBLightClientKeeper interface { + VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof *bnblightclienttypes.Proof) ([]bnblightclienttypes.CrossChainEvent, error) +} + type EvmKeeper interface { ChainID() *big.Int } diff --git a/x/btcstaking/types/msg.go b/x/btcstaking/types/msg.go index f488bb4b..6b6d9751 100644 --- a/x/btcstaking/types/msg.go +++ b/x/btcstaking/types/msg.go @@ -13,6 +13,7 @@ import ( // ensure that these message types implement the sdk.Msg interface var ( _ sdk.Msg = &MsgCreateBTCStaking{} + _ sdk.Msg = &MsgCreateBTCStakingFromBNB{} _ sdk.Msg = &MsgBurnRequest{} _ sdk.Msg = &MsgRemoveReceiver{} _ sdk.Msg = &MsgAddReceiver{} @@ -33,6 +34,28 @@ func (m *MsgCreateBTCStaking) ValidateBasic() error { return nil } +// GetSigners implements types.Msg. +func (m *MsgCreateBTCStakingFromBNB) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Signer) + return []sdk.AccAddress{addr} +} + +// ValidateBasic implements types.Msg. +func (m *MsgCreateBTCStakingFromBNB) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return errorsmod.Wrap(err, "invalid signer address") + } + + if len(m.Proof) == 0 { + return fmt.Errorf("proof name cannot be empty") + } + + if len(m.Receipt) == 0 { + return fmt.Errorf("receipt name cannot be empty") + } + return nil +} + func (m *MsgAddReceiver) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(m.Authority) return []sdk.AccAddress{addr} diff --git a/x/btcstaking/types/staking_record.pb.go b/x/btcstaking/types/staking_record.pb.go index 3b8ef9b1..4af00278 100644 --- a/x/btcstaking/types/staking_record.pb.go +++ b/x/btcstaking/types/staking_record.pb.go @@ -4,9 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -109,8 +108,84 @@ func (m *BTCStakingRecord) GetChainId() uint32 { return 0 } +// BTCBStakingRecord defines the message for btcb staking record +type BTCBStakingRecord struct { + // tx_hash defines the tx hash + TxHash []byte `protobuf:"bytes,1,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` + // event_idx defines the event index + EventIdx uint64 `protobuf:"varint,2,opt,name=event_idx,json=eventIdx,proto3" json:"event_idx,omitempty"` + // receiver_addr defines the receiver address + ReceiverAddr string `protobuf:"bytes,3,opt,name=receiver_addr,json=receiverAddr,proto3" json:"receiver_addr,omitempty"` + // amount defines the stBTC amount + Amount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` + // chain_id defines the chain id + ChainId uint32 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *BTCBStakingRecord) Reset() { *m = BTCBStakingRecord{} } +func (m *BTCBStakingRecord) String() string { return proto.CompactTextString(m) } +func (*BTCBStakingRecord) ProtoMessage() {} +func (*BTCBStakingRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_8fe1ffedd1828bb5, []int{1} +} +func (m *BTCBStakingRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BTCBStakingRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BTCBStakingRecord.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 *BTCBStakingRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCBStakingRecord.Merge(m, src) +} +func (m *BTCBStakingRecord) XXX_Size() int { + return m.Size() +} +func (m *BTCBStakingRecord) XXX_DiscardUnknown() { + xxx_messageInfo_BTCBStakingRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCBStakingRecord proto.InternalMessageInfo + +func (m *BTCBStakingRecord) GetTxHash() []byte { + if m != nil { + return m.TxHash + } + return nil +} + +func (m *BTCBStakingRecord) GetEventIdx() uint64 { + if m != nil { + return m.EventIdx + } + return 0 +} + +func (m *BTCBStakingRecord) GetReceiverAddr() string { + if m != nil { + return m.ReceiverAddr + } + return "" +} + +func (m *BTCBStakingRecord) GetChainId() uint32 { + if m != nil { + return m.ChainId + } + return 0 +} + func init() { proto.RegisterType((*BTCStakingRecord)(nil), "lorenzo.btcstaking.v1.BTCStakingRecord") + proto.RegisterType((*BTCBStakingRecord)(nil), "lorenzo.btcstaking.v1.BTCBStakingRecord") } func init() { @@ -118,28 +193,32 @@ func init() { } var fileDescriptor_8fe1ffedd1828bb5 = []byte{ - // 330 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0x41, 0x4b, 0xc3, 0x30, - 0x14, 0xc7, 0x17, 0x9d, 0x9d, 0x0b, 0x9b, 0x48, 0x51, 0xd7, 0x0d, 0x2c, 0x45, 0x3d, 0x14, 0xc1, - 0x86, 0xe9, 0xc9, 0xa3, 0xf3, 0xa2, 0x20, 0x22, 0x9d, 0x27, 0x2f, 0x25, 0x4d, 0x42, 0x5b, 0x5c, - 0x9a, 0x91, 0x64, 0x65, 0xfa, 0x29, 0xfc, 0x58, 0x3b, 0xee, 0xe8, 0x51, 0xb6, 0x2f, 0x22, 0x4b, - 0x3a, 0xf4, 0xf6, 0xfe, 0xbf, 0xf7, 0x7f, 0xff, 0x90, 0xf7, 0xe0, 0xe5, 0x44, 0x48, 0x56, 0x7e, - 0x0a, 0x94, 0x6a, 0xa2, 0x34, 0x7e, 0x2f, 0xca, 0x0c, 0x55, 0x43, 0x54, 0x97, 0x89, 0x64, 0x44, - 0x48, 0x1a, 0x4d, 0xa5, 0xd0, 0xc2, 0x3d, 0xae, 0xbd, 0xd1, 0x9f, 0x37, 0xaa, 0x86, 0x83, 0x1e, - 0x11, 0x8a, 0x0b, 0x85, 0xb8, 0x32, 0xa3, 0x5c, 0x65, 0xd6, 0x3f, 0xe8, 0xdb, 0x46, 0x62, 0x14, - 0xb2, 0xa2, 0x6e, 0x1d, 0x65, 0x22, 0x13, 0x96, 0x6f, 0x2a, 0x4b, 0xcf, 0x16, 0x00, 0x1e, 0x8e, - 0x5e, 0xef, 0xc7, 0x36, 0x3b, 0x36, 0x6f, 0xbb, 0x3d, 0xd8, 0xd2, 0xf3, 0x24, 0xc7, 0x2a, 0xf7, - 0x40, 0x00, 0xc2, 0x4e, 0xec, 0xe8, 0xf9, 0x03, 0x56, 0xb9, 0x7b, 0x02, 0x1d, 0xcc, 0xc5, 0xac, - 0xd4, 0xde, 0x4e, 0x00, 0xc2, 0x66, 0x5c, 0x2b, 0xf7, 0x1c, 0x76, 0x25, 0x23, 0xac, 0xa8, 0x98, - 0x4c, 0x30, 0xa5, 0xd2, 0xdb, 0x35, 0x63, 0x9d, 0x2d, 0xbc, 0xa3, 0x54, 0xba, 0xa7, 0x10, 0xe2, - 0x8c, 0x95, 0x3a, 0x29, 0x31, 0x67, 0x5e, 0x33, 0x00, 0x61, 0x3b, 0x6e, 0x1b, 0xf2, 0x8c, 0x39, - 0x73, 0x2f, 0xe0, 0x81, 0x6d, 0xa7, 0x9a, 0xd8, 0x90, 0x3d, 0x63, 0xe9, 0x18, 0x3a, 0xd2, 0xc4, - 0x84, 0xf4, 0xe1, 0x3e, 0xc9, 0x71, 0x51, 0x26, 0x05, 0xf5, 0x9c, 0x00, 0x84, 0xdd, 0xb8, 0x65, - 0xf4, 0x23, 0x1d, 0x8d, 0x17, 0x2b, 0x1f, 0x2c, 0x57, 0x3e, 0xf8, 0x59, 0xf9, 0xe0, 0x6b, 0xed, - 0x37, 0x96, 0x6b, 0xbf, 0xf1, 0xbd, 0xf6, 0x1b, 0x6f, 0xb7, 0x59, 0xa1, 0xf3, 0x59, 0x1a, 0x11, - 0xc1, 0xd1, 0x93, 0x5d, 0xe8, 0xd5, 0xcb, 0xe6, 0xfb, 0x44, 0x4c, 0xd0, 0xf6, 0x1a, 0xd5, 0x35, - 0x9a, 0xff, 0x3f, 0x89, 0xfe, 0x98, 0x32, 0x95, 0x3a, 0x66, 0x4d, 0x37, 0xbf, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x9f, 0x38, 0x65, 0x97, 0xb5, 0x01, 0x00, 0x00, + // 388 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0xce, 0xd2, 0x40, + 0x14, 0x85, 0x3b, 0x0a, 0x85, 0x4e, 0xc0, 0x68, 0x23, 0x5a, 0x35, 0x94, 0x06, 0x5d, 0x34, 0x26, + 0x76, 0x82, 0xc6, 0x85, 0x4b, 0xcb, 0x46, 0x12, 0x63, 0x4c, 0x61, 0xe5, 0xa6, 0x99, 0xce, 0x4c, + 0xda, 0x06, 0xda, 0x21, 0xd3, 0xa1, 0xa9, 0x3e, 0x85, 0x8f, 0xe4, 0x92, 0x25, 0x4b, 0xe3, 0x82, + 0x18, 0x78, 0x11, 0xc3, 0xb4, 0x20, 0x9a, 0x7f, 0xf1, 0xef, 0xee, 0x3d, 0x3d, 0xbd, 0x93, 0xef, + 0x9e, 0x0b, 0x5f, 0xae, 0xb8, 0x60, 0xf9, 0x37, 0x8e, 0x22, 0x49, 0x0a, 0x89, 0x97, 0x69, 0x1e, + 0xa3, 0x72, 0x82, 0x9a, 0x32, 0x14, 0x8c, 0x70, 0x41, 0xbd, 0xb5, 0xe0, 0x92, 0x9b, 0x83, 0xc6, + 0xeb, 0xfd, 0xf5, 0x7a, 0xe5, 0xe4, 0xe9, 0xc3, 0x98, 0xc7, 0x5c, 0x39, 0xd0, 0xa9, 0xaa, 0xcd, + 0xe3, 0x2d, 0x80, 0xf7, 0xfd, 0xc5, 0x74, 0x5e, 0xfb, 0x02, 0x35, 0xc7, 0x7c, 0x0c, 0x3b, 0xb2, + 0x0a, 0x13, 0x5c, 0x24, 0x16, 0x70, 0x80, 0xdb, 0x0b, 0x74, 0x59, 0x7d, 0xc0, 0x45, 0x62, 0x3e, + 0x82, 0x3a, 0xce, 0xf8, 0x26, 0x97, 0xd6, 0x1d, 0x07, 0xb8, 0xad, 0xa0, 0xe9, 0xcc, 0xe7, 0xb0, + 0x2f, 0x18, 0x61, 0x69, 0xc9, 0x44, 0x88, 0x29, 0x15, 0xd6, 0x5d, 0xf5, 0x5b, 0xef, 0x2c, 0xbe, + 0xa7, 0x54, 0x98, 0x43, 0x08, 0x71, 0xcc, 0x72, 0x19, 0xe6, 0x38, 0x63, 0x56, 0xcb, 0x01, 0xae, + 0x11, 0x18, 0x4a, 0xf9, 0x84, 0x33, 0x66, 0xbe, 0x80, 0xf7, 0xea, 0xcf, 0x91, 0x24, 0xf5, 0x90, + 0xb6, 0xb2, 0xf4, 0x94, 0xea, 0x4b, 0xa2, 0x86, 0x3c, 0x81, 0x5d, 0x92, 0xe0, 0x34, 0x0f, 0x53, + 0x6a, 0xe9, 0x0e, 0x70, 0xfb, 0x41, 0x47, 0xf5, 0x33, 0x3a, 0xfe, 0x01, 0xe0, 0x03, 0x7f, 0x31, + 0xf5, 0x6f, 0xc9, 0xf2, 0x0c, 0x1a, 0xac, 0x3c, 0xbd, 0x97, 0xd2, 0xaa, 0xc1, 0xe9, 0x2a, 0x61, + 0x46, 0xab, 0x9b, 0x81, 0x8c, 0xff, 0x80, 0xde, 0x5e, 0xb6, 0xa1, 0x60, 0xfc, 0xe1, 0x76, 0x3f, + 0xd2, 0x7e, 0xed, 0x47, 0x03, 0xc2, 0x8b, 0x8c, 0x17, 0x05, 0x5d, 0x7a, 0x29, 0x47, 0x19, 0x96, + 0x89, 0x37, 0xcb, 0xe5, 0x65, 0x59, 0xd7, 0x08, 0xed, 0x7f, 0x10, 0xfc, 0xf9, 0xf6, 0x60, 0x83, + 0xdd, 0xc1, 0x06, 0xbf, 0x0f, 0x36, 0xf8, 0x7e, 0xb4, 0xb5, 0xdd, 0xd1, 0xd6, 0x7e, 0x1e, 0x6d, + 0xed, 0xcb, 0xbb, 0x38, 0x95, 0xc9, 0x26, 0xf2, 0x08, 0xcf, 0xd0, 0xc7, 0x3a, 0xdf, 0x57, 0x9f, + 0x4f, 0x09, 0x12, 0xbe, 0x42, 0xe7, 0xe3, 0x28, 0x5f, 0xa3, 0xea, 0xfa, 0x42, 0xe4, 0xd7, 0x35, + 0x2b, 0x22, 0x5d, 0x25, 0xfd, 0xe6, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6d, 0x85, 0x94, 0x50, + 0x44, 0x02, 0x00, 0x00, } func (m *BTCStakingRecord) Marshal() (dAtA []byte, err error) { @@ -203,6 +282,63 @@ func (m *BTCStakingRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *BTCBStakingRecord) 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 *BTCBStakingRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCBStakingRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChainId != 0 { + i = encodeVarintStakingRecord(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x28 + } + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintStakingRecord(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.ReceiverAddr) > 0 { + i -= len(m.ReceiverAddr) + copy(dAtA[i:], m.ReceiverAddr) + i = encodeVarintStakingRecord(dAtA, i, uint64(len(m.ReceiverAddr))) + i-- + dAtA[i] = 0x1a + } + if m.EventIdx != 0 { + i = encodeVarintStakingRecord(dAtA, i, uint64(m.EventIdx)) + i-- + dAtA[i] = 0x10 + } + if len(m.TxHash) > 0 { + i -= len(m.TxHash) + copy(dAtA[i:], m.TxHash) + i = encodeVarintStakingRecord(dAtA, i, uint64(len(m.TxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintStakingRecord(dAtA []byte, offset int, v uint64) int { offset -= sovStakingRecord(v) base := offset @@ -245,6 +381,31 @@ func (m *BTCStakingRecord) Size() (n int) { return n } +func (m *BTCBStakingRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TxHash) + if l > 0 { + n += 1 + l + sovStakingRecord(uint64(l)) + } + if m.EventIdx != 0 { + n += 1 + sovStakingRecord(uint64(m.EventIdx)) + } + l = len(m.ReceiverAddr) + if l > 0 { + n += 1 + l + sovStakingRecord(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovStakingRecord(uint64(l)) + if m.ChainId != 0 { + n += 1 + sovStakingRecord(uint64(m.ChainId)) + } + return n +} + func sovStakingRecord(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -471,6 +632,194 @@ func (m *BTCStakingRecord) Unmarshal(dAtA []byte) error { } return nil } +func (m *BTCBStakingRecord) 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 ErrIntOverflowStakingRecord + } + 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: BTCBStakingRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCBStakingRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthStakingRecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthStakingRecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxHash = append(m.TxHash[:0], dAtA[iNdEx:postIndex]...) + if m.TxHash == nil { + m.TxHash = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EventIdx", wireType) + } + m.EventIdx = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EventIdx |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReceiverAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStakingRecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReceiverAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStakingRecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + m.ChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipStakingRecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingRecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipStakingRecord(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/btcstaking/types/tx.pb.go b/x/btcstaking/types/tx.pb.go index 52316e41..d4e57df3 100644 --- a/x/btcstaking/types/tx.pb.go +++ b/x/btcstaking/types/tx.pb.go @@ -245,6 +245,102 @@ func (m *MsgCreateBTCStakingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateBTCStakingResponse proto.InternalMessageInfo +type MsgCreateBTCStakingFromBNB struct { + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + Receipt []byte `protobuf:"bytes,2,opt,name=receipt,proto3" json:"receipt,omitempty"` + Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *MsgCreateBTCStakingFromBNB) Reset() { *m = MsgCreateBTCStakingFromBNB{} } +func (m *MsgCreateBTCStakingFromBNB) String() string { return proto.CompactTextString(m) } +func (*MsgCreateBTCStakingFromBNB) ProtoMessage() {} +func (*MsgCreateBTCStakingFromBNB) Descriptor() ([]byte, []int) { + return fileDescriptor_6be51bab5db52b8e, []int{4} +} +func (m *MsgCreateBTCStakingFromBNB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateBTCStakingFromBNB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateBTCStakingFromBNB.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 *MsgCreateBTCStakingFromBNB) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateBTCStakingFromBNB.Merge(m, src) +} +func (m *MsgCreateBTCStakingFromBNB) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateBTCStakingFromBNB) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateBTCStakingFromBNB.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateBTCStakingFromBNB proto.InternalMessageInfo + +func (m *MsgCreateBTCStakingFromBNB) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgCreateBTCStakingFromBNB) GetReceipt() []byte { + if m != nil { + return m.Receipt + } + return nil +} + +func (m *MsgCreateBTCStakingFromBNB) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +type MsgCreateBTCStakingFromBNBResponse struct { +} + +func (m *MsgCreateBTCStakingFromBNBResponse) Reset() { *m = MsgCreateBTCStakingFromBNBResponse{} } +func (m *MsgCreateBTCStakingFromBNBResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateBTCStakingFromBNBResponse) ProtoMessage() {} +func (*MsgCreateBTCStakingFromBNBResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6be51bab5db52b8e, []int{5} +} +func (m *MsgCreateBTCStakingFromBNBResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateBTCStakingFromBNBResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateBTCStakingFromBNBResponse.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 *MsgCreateBTCStakingFromBNBResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateBTCStakingFromBNBResponse.Merge(m, src) +} +func (m *MsgCreateBTCStakingFromBNBResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateBTCStakingFromBNBResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateBTCStakingFromBNBResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateBTCStakingFromBNBResponse proto.InternalMessageInfo + type MsgBurnRequest struct { Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` BtcTargetAddress string `protobuf:"bytes,2,opt,name=btc_target_address,json=btcTargetAddress,proto3" json:"btc_target_address,omitempty"` @@ -255,7 +351,7 @@ func (m *MsgBurnRequest) Reset() { *m = MsgBurnRequest{} } func (m *MsgBurnRequest) String() string { return proto.CompactTextString(m) } func (*MsgBurnRequest) ProtoMessage() {} func (*MsgBurnRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{4} + return fileDescriptor_6be51bab5db52b8e, []int{6} } func (m *MsgBurnRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -305,7 +401,7 @@ func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} } func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) } func (*MsgBurnResponse) ProtoMessage() {} func (*MsgBurnResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{5} + return fileDescriptor_6be51bab5db52b8e, []int{7} } func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -343,7 +439,7 @@ func (m *MsgAddReceiver) Reset() { *m = MsgAddReceiver{} } func (m *MsgAddReceiver) String() string { return proto.CompactTextString(m) } func (*MsgAddReceiver) ProtoMessage() {} func (*MsgAddReceiver) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{6} + return fileDescriptor_6be51bab5db52b8e, []int{8} } func (m *MsgAddReceiver) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -393,7 +489,7 @@ func (m *MsgAddReceiverResponse) Reset() { *m = MsgAddReceiverResponse{} func (m *MsgAddReceiverResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddReceiverResponse) ProtoMessage() {} func (*MsgAddReceiverResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{7} + return fileDescriptor_6be51bab5db52b8e, []int{9} } func (m *MsgAddReceiverResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -431,7 +527,7 @@ func (m *MsgRemoveReceiver) Reset() { *m = MsgRemoveReceiver{} } func (m *MsgRemoveReceiver) String() string { return proto.CompactTextString(m) } func (*MsgRemoveReceiver) ProtoMessage() {} func (*MsgRemoveReceiver) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{8} + return fileDescriptor_6be51bab5db52b8e, []int{10} } func (m *MsgRemoveReceiver) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -481,7 +577,7 @@ func (m *MsgRemoveReceiverResponse) Reset() { *m = MsgRemoveReceiverResp func (m *MsgRemoveReceiverResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveReceiverResponse) ProtoMessage() {} func (*MsgRemoveReceiverResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{9} + return fileDescriptor_6be51bab5db52b8e, []int{11} } func (m *MsgRemoveReceiverResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -519,7 +615,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{10} + return fileDescriptor_6be51bab5db52b8e, []int{12} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -569,7 +665,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{11} + return fileDescriptor_6be51bab5db52b8e, []int{13} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -603,6 +699,8 @@ func init() { proto.RegisterType((*TransactionInfo)(nil), "lorenzo.btcstaking.v1.TransactionInfo") proto.RegisterType((*MsgCreateBTCStaking)(nil), "lorenzo.btcstaking.v1.MsgCreateBTCStaking") proto.RegisterType((*MsgCreateBTCStakingResponse)(nil), "lorenzo.btcstaking.v1.MsgCreateBTCStakingResponse") + proto.RegisterType((*MsgCreateBTCStakingFromBNB)(nil), "lorenzo.btcstaking.v1.MsgCreateBTCStakingFromBNB") + proto.RegisterType((*MsgCreateBTCStakingFromBNBResponse)(nil), "lorenzo.btcstaking.v1.MsgCreateBTCStakingFromBNBResponse") proto.RegisterType((*MsgBurnRequest)(nil), "lorenzo.btcstaking.v1.MsgBurnRequest") proto.RegisterType((*MsgBurnResponse)(nil), "lorenzo.btcstaking.v1.MsgBurnResponse") proto.RegisterType((*MsgAddReceiver)(nil), "lorenzo.btcstaking.v1.MsgAddReceiver") @@ -616,55 +714,59 @@ func init() { func init() { proto.RegisterFile("lorenzo/btcstaking/v1/tx.proto", fileDescriptor_6be51bab5db52b8e) } var fileDescriptor_6be51bab5db52b8e = []byte{ - // 761 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0x41, 0x4f, 0xdb, 0x48, - 0x14, 0xc7, 0xe3, 0x25, 0x44, 0x9b, 0x17, 0x36, 0xc0, 0x2c, 0x0b, 0xc1, 0x88, 0x04, 0x45, 0x02, - 0x21, 0xb4, 0xb1, 0x97, 0xac, 0xb4, 0xab, 0xdd, 0x1e, 0x2a, 0x1c, 0xb5, 0x02, 0xb5, 0x91, 0x90, - 0x09, 0xaa, 0xd4, 0x4b, 0xe4, 0xd8, 0x83, 0x13, 0x41, 0x3c, 0xe9, 0xcc, 0x24, 0x4d, 0x7a, 0x69, - 0xc5, 0x27, 0xa8, 0x7a, 0xe8, 0xa5, 0xea, 0x27, 0xe8, 0x85, 0x43, 0x3f, 0x04, 0x47, 0xd4, 0x53, - 0xc5, 0x01, 0x55, 0x70, 0xe0, 0x6b, 0x54, 0xf6, 0x4c, 0x12, 0x07, 0x12, 0x88, 0xda, 0x53, 0xf2, - 0xe6, 0xbd, 0x79, 0xff, 0xdf, 0x7b, 0xf3, 0xc6, 0x03, 0xe9, 0x23, 0x42, 0xb1, 0xf7, 0x8a, 0xe8, - 0x15, 0x6e, 0x33, 0x6e, 0x1d, 0xd6, 0x3c, 0x57, 0x6f, 0x6d, 0xea, 0xbc, 0xad, 0x35, 0x28, 0xe1, - 0x04, 0xfd, 0x21, 0xfd, 0x5a, 0xdf, 0xaf, 0xb5, 0x36, 0xd5, 0x05, 0x9b, 0xb0, 0x3a, 0x61, 0x7a, - 0x9d, 0x05, 0xe1, 0x75, 0xe6, 0x8a, 0x78, 0x75, 0x51, 0x38, 0xca, 0x81, 0xa5, 0x0b, 0x43, 0xba, - 0xe6, 0x5c, 0xe2, 0x12, 0xb1, 0xee, 0xff, 0x93, 0xab, 0xd9, 0xe1, 0x00, 0x0d, 0x8b, 0x5a, 0x75, - 0xb9, 0x33, 0xfb, 0x1a, 0x92, 0x25, 0x6a, 0x79, 0xcc, 0xb2, 0x79, 0x8d, 0x78, 0x4f, 0x70, 0x07, - 0xcd, 0xc1, 0x64, 0xcd, 0x73, 0x70, 0x3b, 0xa5, 0xac, 0x28, 0xeb, 0xbf, 0x99, 0xc2, 0x40, 0xcf, - 0x20, 0x5a, 0xb5, 0x58, 0x35, 0xf5, 0xcb, 0x8a, 0xb2, 0x3e, 0x65, 0x14, 0xce, 0x2f, 0x32, 0x0f, - 0xdd, 0x1a, 0xaf, 0x36, 0x2b, 0x9a, 0x4d, 0xea, 0xfa, 0x53, 0x21, 0x94, 0xdb, 0xf5, 0x73, 0xda, - 0xe4, 0x48, 0xef, 0x2a, 0xb7, 0xf2, 0x3a, 0xef, 0x34, 0x30, 0xd3, 0x8c, 0x52, 0x61, 0x1b, 0x5b, - 0x0e, 0xa6, 0xdb, 0x16, 0xab, 0x1a, 0x1d, 0x8e, 0x99, 0x19, 0x24, 0xcc, 0x1e, 0x2b, 0x30, 0x1d, - 0x22, 0xd8, 0xf1, 0x0e, 0x08, 0xfa, 0x17, 0x26, 0x0e, 0x71, 0x27, 0x00, 0x48, 0xe4, 0x57, 0xb5, - 0xa1, 0x7d, 0xd2, 0x06, 0xb1, 0x4d, 0x7f, 0x07, 0x5a, 0x81, 0x04, 0xef, 0x2f, 0x0b, 0x58, 0x33, - 0xbc, 0xe4, 0x57, 0xd7, 0xa0, 0x84, 0x1c, 0xa4, 0x26, 0x02, 0x9f, 0x30, 0xb2, 0x1f, 0x15, 0xf8, - 0xbd, 0xc8, 0xdc, 0x02, 0xc5, 0x16, 0xc7, 0x46, 0xa9, 0xb0, 0x27, 0x64, 0xd0, 0x3c, 0xc4, 0x58, - 0xcd, 0xf5, 0x30, 0x0d, 0x58, 0xe2, 0xa6, 0xb4, 0xd0, 0x23, 0x00, 0x49, 0x52, 0xe6, 0xed, 0x40, - 0x26, 0x91, 0x5f, 0xbb, 0x9f, 0xd3, 0x2f, 0xce, 0x8c, 0x4b, 0x5f, 0xa9, 0x8d, 0x54, 0xf8, 0x95, - 0x62, 0x1b, 0xd7, 0x5a, 0x98, 0x06, 0x3c, 0x71, 0xb3, 0x67, 0xff, 0x9f, 0x38, 0xbe, 0x3e, 0xd9, - 0x90, 0x7a, 0xd9, 0x65, 0x58, 0x1a, 0x82, 0x67, 0x62, 0xd6, 0x20, 0x1e, 0xc3, 0xd9, 0x4f, 0x0a, - 0x24, 0x8b, 0xcc, 0x35, 0x9a, 0xd4, 0x33, 0xf1, 0x8b, 0x26, 0x66, 0x7c, 0x24, 0xf9, 0x9f, 0x80, - 0x2a, 0xdc, 0x2e, 0x73, 0x8b, 0xba, 0x98, 0x97, 0x2d, 0xc7, 0xa1, 0x98, 0xb1, 0xa0, 0x82, 0xb8, - 0x39, 0x53, 0xe1, 0x76, 0x29, 0x70, 0x6c, 0x89, 0x75, 0xf4, 0x18, 0x62, 0x56, 0x9d, 0x34, 0x3d, - 0x2e, 0xf0, 0x0c, 0xed, 0xf4, 0x22, 0x13, 0x39, 0xbf, 0xc8, 0xac, 0x85, 0xce, 0x5e, 0x8e, 0xab, - 0xf8, 0xc9, 0x31, 0xe7, 0x50, 0x9e, 0xf8, 0x8e, 0xc7, 0x4d, 0xb9, 0x7b, 0xb0, 0x98, 0x59, 0x98, - 0xee, 0xc1, 0xca, 0x02, 0x3e, 0x88, 0x02, 0xb6, 0x1c, 0xc7, 0x94, 0xf5, 0xa3, 0x7f, 0x20, 0x6e, - 0x35, 0x79, 0x95, 0xd0, 0x1a, 0x17, 0x93, 0x10, 0x37, 0x52, 0x5f, 0x3e, 0xe7, 0xe6, 0xe4, 0xdc, - 0x4b, 0xc2, 0x3d, 0x4e, 0xfd, 0x46, 0xf4, 0x43, 0xd1, 0x56, 0xa8, 0xa7, 0xe2, 0x60, 0x32, 0x23, - 0x0e, 0xa6, 0x2b, 0x65, 0x44, 0xfd, 0xaa, 0x42, 0xad, 0x4f, 0xfa, 0xb4, 0xfd, 0x94, 0xd9, 0x14, - 0xcc, 0x0f, 0xc2, 0xf5, 0xb8, 0x5f, 0xc2, 0x6c, 0x91, 0xb9, 0x26, 0xae, 0x93, 0x16, 0xfe, 0x69, - 0x72, 0xf5, 0x06, 0x79, 0xfc, 0x0e, 0xa4, 0x25, 0x58, 0xbc, 0x25, 0xdc, 0xa3, 0x7a, 0xaf, 0x04, - 0x1d, 0xde, 0x6f, 0x38, 0x16, 0xc7, 0xbb, 0xc1, 0x6d, 0xff, 0x61, 0xa8, 0x07, 0x10, 0x13, 0xdf, - 0x0b, 0xd9, 0xcc, 0xe5, 0x11, 0xcd, 0x14, 0x32, 0xb2, 0x95, 0x72, 0xcb, 0x2d, 0xea, 0x45, 0x58, - 0xb8, 0xc1, 0xd5, 0x65, 0xce, 0xbf, 0x8b, 0xc2, 0x44, 0x91, 0xb9, 0x88, 0xc2, 0xcc, 0xad, 0x5b, - 0xb8, 0x31, 0x42, 0x73, 0xc8, 0x95, 0x50, 0xf3, 0xe3, 0xc7, 0x76, 0xb5, 0xd1, 0x3e, 0x44, 0xfd, - 0x69, 0x44, 0xab, 0xa3, 0xf7, 0x86, 0xae, 0x96, 0xba, 0x76, 0x5f, 0x98, 0x4c, 0x6b, 0x43, 0x22, - 0x3c, 0xd0, 0x77, 0x64, 0x0f, 0x85, 0xa9, 0xb9, 0xb1, 0xc2, 0x7a, 0x22, 0x47, 0x90, 0xbc, 0x31, - 0x7e, 0xeb, 0xa3, 0x13, 0x0c, 0x46, 0xaa, 0x7f, 0x8d, 0x1b, 0xd9, 0x53, 0x3b, 0x80, 0xa9, 0x81, - 0xa9, 0xba, 0xa3, 0x15, 0xe1, 0x38, 0x55, 0x1b, 0x2f, 0xae, 0xab, 0xa3, 0x4e, 0xbe, 0xb9, 0x3e, - 0xd9, 0x50, 0x8c, 0xbd, 0xd3, 0xcb, 0xb4, 0x72, 0x76, 0x99, 0x56, 0xbe, 0x5d, 0xa6, 0x95, 0xb7, - 0x57, 0xe9, 0xc8, 0xd9, 0x55, 0x3a, 0xf2, 0xf5, 0x2a, 0x1d, 0x79, 0xfe, 0xdf, 0x98, 0x8f, 0x4f, - 0x3b, 0xfc, 0xf6, 0x05, 0xdf, 0xa5, 0x4a, 0x2c, 0x78, 0xf8, 0xfe, 0xfe, 0x1e, 0x00, 0x00, 0xff, - 0xff, 0xd1, 0x9a, 0xb5, 0x53, 0x9f, 0x07, 0x00, 0x00, + // 822 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0xc7, 0x63, 0xda, 0x06, 0xf2, 0xb2, 0x64, 0x77, 0x87, 0xb2, 0x4d, 0xbd, 0xda, 0xa4, 0xb2, + 0xd8, 0xaa, 0xaa, 0x88, 0xbd, 0x0d, 0x12, 0xa8, 0x70, 0x40, 0x75, 0x44, 0xd5, 0x0a, 0x82, 0x2a, + 0x37, 0x15, 0x12, 0x97, 0xc8, 0xb1, 0xa7, 0x4e, 0xd4, 0xda, 0x13, 0x66, 0x26, 0x21, 0xe1, 0x02, + 0xea, 0x85, 0x03, 0x17, 0x4e, 0x5c, 0x80, 0x4f, 0xc0, 0xa5, 0x07, 0x3e, 0x44, 0x8f, 0x15, 0x27, + 0xd4, 0x43, 0x85, 0xda, 0x43, 0xbf, 0x06, 0xb2, 0x67, 0xe2, 0x38, 0x6d, 0xdc, 0x06, 0xf6, 0xd4, + 0xbe, 0x79, 0x6f, 0xde, 0xff, 0xf7, 0x5e, 0xdf, 0x9b, 0x1a, 0x4a, 0xc7, 0x84, 0xe2, 0xe0, 0x3b, + 0x62, 0xb4, 0xb8, 0xc3, 0xb8, 0x7d, 0xd4, 0x09, 0x3c, 0xa3, 0xbf, 0x61, 0xf0, 0x81, 0xde, 0xa5, + 0x84, 0x13, 0xf4, 0xae, 0xf4, 0xeb, 0x63, 0xbf, 0xde, 0xdf, 0x50, 0x97, 0x1c, 0xc2, 0x7c, 0xc2, + 0x0c, 0x9f, 0x45, 0xe1, 0x3e, 0xf3, 0x44, 0xbc, 0xba, 0x2c, 0x1c, 0xcd, 0xc8, 0x32, 0x84, 0x21, + 0x5d, 0x8b, 0x1e, 0xf1, 0x88, 0x38, 0x0f, 0x7f, 0x93, 0xa7, 0xda, 0x74, 0x80, 0xae, 0x4d, 0x6d, + 0x5f, 0xde, 0xd4, 0xbe, 0x87, 0x42, 0x83, 0xda, 0x01, 0xb3, 0x1d, 0xde, 0x21, 0xc1, 0xe7, 0x78, + 0x88, 0x16, 0x61, 0xa1, 0x13, 0xb8, 0x78, 0x50, 0x54, 0x56, 0x94, 0xb5, 0xb7, 0x2d, 0x61, 0xa0, + 0xaf, 0x60, 0xbe, 0x6d, 0xb3, 0x76, 0xf1, 0x8d, 0x15, 0x65, 0xed, 0x91, 0x59, 0xbb, 0xb8, 0x2c, + 0x7f, 0xea, 0x75, 0x78, 0xbb, 0xd7, 0xd2, 0x1d, 0xe2, 0x1b, 0x5f, 0x08, 0xa1, 0xca, 0x5e, 0x98, + 0xd3, 0x21, 0xc7, 0xc6, 0x48, 0xb9, 0x5f, 0x35, 0xf8, 0xb0, 0x8b, 0x99, 0x6e, 0x36, 0x6a, 0x3b, + 0xd8, 0x76, 0x31, 0xdd, 0xb1, 0x59, 0xdb, 0x1c, 0x72, 0xcc, 0xac, 0x28, 0xa1, 0x76, 0xa2, 0xc0, + 0xe3, 0x04, 0xc1, 0x6e, 0x70, 0x48, 0xd0, 0x47, 0x30, 0x77, 0x84, 0x87, 0x11, 0x40, 0xbe, 0xfa, + 0x52, 0x9f, 0xda, 0x27, 0x7d, 0x12, 0xdb, 0x0a, 0x6f, 0xa0, 0x15, 0xc8, 0xf3, 0xf1, 0xb1, 0x80, + 0xb5, 0x92, 0x47, 0x61, 0x75, 0x5d, 0x4a, 0xc8, 0x61, 0x71, 0x2e, 0xf2, 0x09, 0x43, 0xfb, 0x5d, + 0x81, 0x77, 0xea, 0xcc, 0xab, 0x51, 0x6c, 0x73, 0x6c, 0x36, 0x6a, 0xfb, 0x42, 0x06, 0x3d, 0x83, + 0x2c, 0xeb, 0x78, 0x01, 0xa6, 0x11, 0x4b, 0xce, 0x92, 0x16, 0xfa, 0x0c, 0x40, 0x92, 0x34, 0xf9, + 0x20, 0x92, 0xc9, 0x57, 0x57, 0x1f, 0xe6, 0x0c, 0x8b, 0xb3, 0x72, 0xd2, 0xd7, 0x18, 0x20, 0x15, + 0xde, 0xa2, 0xd8, 0xc1, 0x9d, 0x3e, 0xa6, 0x11, 0x4f, 0xce, 0x8a, 0xed, 0x8f, 0xf3, 0x27, 0x37, + 0xa7, 0xeb, 0x52, 0x4f, 0x7b, 0x01, 0xcf, 0xa7, 0xe0, 0x59, 0x98, 0x75, 0x49, 0xc0, 0xb0, 0xf6, + 0x93, 0x02, 0xea, 0x14, 0xff, 0x36, 0x25, 0xbe, 0xf9, 0xa5, 0x89, 0x5e, 0x4d, 0x56, 0x61, 0x16, + 0xff, 0xfa, 0xb3, 0xb2, 0x28, 0xe7, 0x67, 0xcb, 0x75, 0x29, 0x66, 0x6c, 0x9f, 0xd3, 0x30, 0xe1, + 0xa8, 0xbe, 0x22, 0xbc, 0x19, 0x81, 0x74, 0xb9, 0xec, 0xe1, 0xc8, 0x9c, 0xde, 0xbf, 0x49, 0xd8, + 0xf7, 0x40, 0x4b, 0x87, 0x89, 0x99, 0xff, 0x50, 0xa0, 0x50, 0x67, 0x9e, 0xd9, 0xa3, 0x81, 0x85, + 0xbf, 0xe9, 0x61, 0xc6, 0x53, 0xbb, 0xfd, 0x3e, 0xa0, 0x16, 0x77, 0x9a, 0xdc, 0xa6, 0x1e, 0xe6, + 0x4d, 0x5b, 0x10, 0x47, 0x60, 0x39, 0xeb, 0x49, 0x8b, 0x3b, 0x8d, 0xc8, 0x21, 0x2b, 0x41, 0xdb, + 0x90, 0xb5, 0x7d, 0xd2, 0x0b, 0xb8, 0x68, 0xa9, 0xa9, 0x9f, 0x5d, 0x96, 0x33, 0x17, 0x97, 0xe5, + 0xd5, 0xc4, 0xbc, 0xca, 0x15, 0x13, 0x3f, 0x2a, 0xcc, 0x3d, 0x92, 0x53, 0xba, 0x1b, 0x70, 0x4b, + 0xde, 0x9e, 0xac, 0xe9, 0x29, 0x3c, 0x8e, 0x61, 0x65, 0x01, 0xbf, 0x8a, 0x02, 0xb6, 0x5c, 0xd7, + 0x92, 0x7f, 0x33, 0xf4, 0x21, 0xe4, 0xec, 0x1e, 0x6f, 0x13, 0xda, 0xe1, 0xc3, 0x07, 0x7b, 0x3d, + 0x0e, 0x45, 0x5b, 0x89, 0x39, 0x10, 0xc3, 0x54, 0x4e, 0x19, 0xa6, 0x91, 0x94, 0x39, 0x1f, 0x56, + 0x95, 0x18, 0x97, 0x42, 0x48, 0x3b, 0x4e, 0xa9, 0x15, 0xe1, 0xd9, 0x24, 0x5c, 0xcc, 0xfd, 0x2d, + 0x3c, 0xad, 0x33, 0xcf, 0xc2, 0x3e, 0xe9, 0xe3, 0xd7, 0x26, 0x57, 0x6f, 0x91, 0xe7, 0xee, 0x41, + 0x7a, 0x0e, 0xcb, 0x77, 0x84, 0x63, 0xaa, 0x5f, 0x94, 0xa8, 0xc3, 0x07, 0x5d, 0xd7, 0xe6, 0x78, + 0x2f, 0x7a, 0xa1, 0xfe, 0x37, 0xd4, 0x27, 0x90, 0x15, 0x6f, 0x9c, 0x6c, 0xe6, 0x8b, 0x94, 0x66, + 0x0a, 0x19, 0xd9, 0x4a, 0x79, 0xe5, 0x0e, 0xf5, 0x32, 0x2c, 0xdd, 0xe2, 0x1a, 0x31, 0x57, 0x7f, + 0x5b, 0x80, 0xb9, 0x3a, 0xf3, 0x10, 0x85, 0x27, 0x77, 0x5e, 0x8e, 0xf5, 0x14, 0xcd, 0x29, 0x9b, + 0xa1, 0x56, 0x67, 0x8f, 0x1d, 0x69, 0xa3, 0x1f, 0x15, 0x58, 0x4a, 0xdb, 0xf7, 0x8d, 0xd9, 0xf3, + 0xc9, 0x2b, 0xea, 0xe6, 0x7f, 0xbe, 0x12, 0x93, 0x1c, 0xc0, 0x7c, 0xb8, 0x17, 0xe8, 0x65, 0x7a, + 0x8a, 0xc4, 0x92, 0xab, 0xab, 0x0f, 0x85, 0xc9, 0xb4, 0x0e, 0xe4, 0x93, 0xab, 0x75, 0x4f, 0xf6, + 0x44, 0x98, 0x5a, 0x99, 0x29, 0x2c, 0x16, 0x39, 0x86, 0xc2, 0xad, 0x45, 0x58, 0x4b, 0x4f, 0x30, + 0x19, 0xa9, 0xbe, 0x9a, 0x35, 0x32, 0x56, 0x3b, 0x84, 0x47, 0x13, 0xf3, 0x7d, 0x4f, 0x2b, 0x92, + 0x71, 0xaa, 0x3e, 0x5b, 0xdc, 0x48, 0x47, 0x5d, 0xf8, 0xe1, 0xe6, 0x74, 0x5d, 0x31, 0xf7, 0xcf, + 0xae, 0x4a, 0xca, 0xf9, 0x55, 0x49, 0xf9, 0xe7, 0xaa, 0xa4, 0xfc, 0x7c, 0x5d, 0xca, 0x9c, 0x5f, + 0x97, 0x32, 0x7f, 0x5f, 0x97, 0x32, 0x5f, 0x6f, 0xce, 0xf8, 0xaf, 0x7b, 0x90, 0xfc, 0x72, 0x88, + 0x5e, 0xc8, 0x56, 0x36, 0xfa, 0x6c, 0xf8, 0xe0, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0xd9, + 0x87, 0x66, 0xdd, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -680,6 +782,7 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { CreateBTCStaking(ctx context.Context, in *MsgCreateBTCStaking, opts ...grpc.CallOption) (*MsgCreateBTCStakingResponse, error) + CreateBTCStakingFromBNB(ctx context.Context, in *MsgCreateBTCStakingFromBNB, opts ...grpc.CallOption) (*MsgCreateBTCStakingFromBNBResponse, error) Burn(ctx context.Context, in *MsgBurnRequest, opts ...grpc.CallOption) (*MsgBurnResponse, error) AddReceiver(ctx context.Context, in *MsgAddReceiver, opts ...grpc.CallOption) (*MsgAddReceiverResponse, error) RemoveReceiver(ctx context.Context, in *MsgRemoveReceiver, opts ...grpc.CallOption) (*MsgRemoveReceiverResponse, error) @@ -703,6 +806,15 @@ func (c *msgClient) CreateBTCStaking(ctx context.Context, in *MsgCreateBTCStakin return out, nil } +func (c *msgClient) CreateBTCStakingFromBNB(ctx context.Context, in *MsgCreateBTCStakingFromBNB, opts ...grpc.CallOption) (*MsgCreateBTCStakingFromBNBResponse, error) { + out := new(MsgCreateBTCStakingFromBNBResponse) + err := c.cc.Invoke(ctx, "/lorenzo.btcstaking.v1.Msg/CreateBTCStakingFromBNB", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) Burn(ctx context.Context, in *MsgBurnRequest, opts ...grpc.CallOption) (*MsgBurnResponse, error) { out := new(MsgBurnResponse) err := c.cc.Invoke(ctx, "/lorenzo.btcstaking.v1.Msg/Burn", in, out, opts...) @@ -742,6 +854,7 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { CreateBTCStaking(context.Context, *MsgCreateBTCStaking) (*MsgCreateBTCStakingResponse, error) + CreateBTCStakingFromBNB(context.Context, *MsgCreateBTCStakingFromBNB) (*MsgCreateBTCStakingFromBNBResponse, error) Burn(context.Context, *MsgBurnRequest) (*MsgBurnResponse, error) AddReceiver(context.Context, *MsgAddReceiver) (*MsgAddReceiverResponse, error) RemoveReceiver(context.Context, *MsgRemoveReceiver) (*MsgRemoveReceiverResponse, error) @@ -755,6 +868,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) CreateBTCStaking(ctx context.Context, req *MsgCreateBTCStaking) (*MsgCreateBTCStakingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBTCStaking not implemented") } +func (*UnimplementedMsgServer) CreateBTCStakingFromBNB(ctx context.Context, req *MsgCreateBTCStakingFromBNB) (*MsgCreateBTCStakingFromBNBResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateBTCStakingFromBNB not implemented") +} func (*UnimplementedMsgServer) Burn(ctx context.Context, req *MsgBurnRequest) (*MsgBurnResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Burn not implemented") } @@ -790,6 +906,24 @@ func _Msg_CreateBTCStaking_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Msg_CreateBTCStakingFromBNB_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateBTCStakingFromBNB) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateBTCStakingFromBNB(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.btcstaking.v1.Msg/CreateBTCStakingFromBNB", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateBTCStakingFromBNB(ctx, req.(*MsgCreateBTCStakingFromBNB)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_Burn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgBurnRequest) if err := dec(in); err != nil { @@ -870,6 +1004,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateBTCStaking", Handler: _Msg_CreateBTCStaking_Handler, }, + { + MethodName: "CreateBTCStakingFromBNB", + Handler: _Msg_CreateBTCStakingFromBNB_Handler, + }, { MethodName: "Burn", Handler: _Msg_Burn_Handler, @@ -1052,6 +1190,73 @@ func (m *MsgCreateBTCStakingResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } +func (m *MsgCreateBTCStakingFromBNB) 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 *MsgCreateBTCStakingFromBNB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateBTCStakingFromBNB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x1a + } + if len(m.Receipt) > 0 { + i -= len(m.Receipt) + copy(dAtA[i:], m.Receipt) + i = encodeVarintTx(dAtA, i, uint64(len(m.Receipt))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateBTCStakingFromBNBResponse) 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 *MsgCreateBTCStakingFromBNBResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateBTCStakingFromBNBResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgBurnRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1386,6 +1591,36 @@ func (m *MsgCreateBTCStakingResponse) Size() (n int) { return n } +func (m *MsgCreateBTCStakingFromBNB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Receipt) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateBTCStakingFromBNBResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgBurnRequest) Size() (n int) { if m == nil { return 0 @@ -1952,6 +2187,206 @@ func (m *MsgCreateBTCStakingResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreateBTCStakingFromBNB) 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 ErrIntOverflowTx + } + 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: MsgCreateBTCStakingFromBNB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBTCStakingFromBNB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receipt", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Receipt = append(m.Receipt[:0], dAtA[iNdEx:postIndex]...) + if m.Receipt == nil { + m.Receipt = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateBTCStakingFromBNBResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateBTCStakingFromBNBResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBTCStakingFromBNBResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgBurnRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0