From 333f514090f0eed9bef3cc6f52d3bfe817b3d7bd Mon Sep 17 00:00:00 2001 From: olegfomenko Date: Fri, 28 Jun 2024 19:40:29 +0300 Subject: [PATCH 01/14] adding release info to the mainnet docs --- docs/common/mainnet/002-upgrades.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/common/mainnet/002-upgrades.md b/docs/common/mainnet/002-upgrades.md index f165fafe..15b8c6c3 100644 --- a/docs/common/mainnet/002-upgrades.md +++ b/docs/common/mainnet/002-upgrades.md @@ -5,6 +5,24 @@ title: Mainnet upgrades # Mainnet upgrades +## V1.1.3 + +Core binary: ( +alpine-linux/amd64): "". + +Also, you can build core from sources by yourself: use "" +release information. + +Also, if you are using Ubuntu linux, please install `musl-dev` using `sudo apt install musl-dev` command to be able to +use Alpine binary on your machine. + +If you are using `cosmovisor` the upgrade will be done automatically. + +### What's new? + +Upgrade v1.1.3 introduces the new Arbitrary proposal in terms of `rarimocore` module that can be used to sign any +specified byte data in body. + ## V1.1.2 Core binary: ( @@ -18,6 +36,7 @@ use Alpine binary on your machine. If you are using `cosmovisor` the upgrade will be done automatically. +### What's new? Upgrade v1.1.2 changes the parameters of [feemarket](../../../x/feemarket) module, in particular `BaseFee` and `NoBaseFee` that should be `0` and `true` while we are using zero commissions on production. @@ -32,6 +51,7 @@ release information. Also, if you are using Ubuntu linux, please install `musl-dev` using `sudo apt install musl-dev` command to be able to use Alpine binary on your machine. +### What's new? Upgrade v1.1.1 introduces a new module to store and manage [CSCA Master List](https://pkddownloadsg.icao.int/). More information can be found in [module docs](../../../x/cscalist/README.md). @@ -48,6 +68,7 @@ Upgrade will perform automatically if you are using `cosmovisor` under Alpine li Also, if you are using Ubuntu linux, please install `musl-dev` using `sudo apt install musl-dev` command to be able to use Alpine binary on your machine. +### What's new? Upgrade v1.1.0 introduces a couple of features for identity transfers: - New WorldCoin identity transfer @@ -65,6 +86,7 @@ Upgrade will perform automatically if you are using `cosmovisor` under Alpine li Also, if you are using Ubuntu linux, please install `musl-dev` using `sudo apt install musl-dev` command to be able to use Alpine binary on your machine. +### What's new? Upgrade v1.0.7 introduces fixes to the `rarimocore` module: - Adding feature to clear old TSS violation reports. @@ -78,6 +100,7 @@ Upgrade will perform automatically if you are using `cosmovisor` under Alpine li Also, if you are using Ubuntu linux, please install `musl-dev` using `sudo apt install musl-dev` command to be able to use Alpine binary on your machine. +### What's new? Upgrade V1.0.6 introduces: - Adding message for operation resign by Threshold signature producers. @@ -93,6 +116,7 @@ Upgrade will perform automatically if you are using `cosmovisor` under Alpine li Also, if you are using Ubuntu linux, please install `musl-dev` using `sudo apt install musl-dev` command to be able to use Alpine binary on your machine. +### What's new? Upgrade v1.0.5 introduces several fixes: - Adding `createdAtBlock` field to `StateInfo` entry in `identity` module. @@ -106,6 +130,7 @@ Upgrade will perform automatically if you are using `cosmovisor` under Alpine li Also, if you are using Ubuntu linux, please install `musl-dev` using `sudo apt install musl-dev` command to be able to use Alpine binary on your machine. +### What's new? Upgrade v1.0.4 introduces `identity` core module that is responsible for storing aggregated information about identity state transitions published into Rarimo chain. It uses deployed into Rarimo EVM original Iden3 state smart-contracts. From 6356e0f462b276e8fd4b61c9c0cf0e4855991e39 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Thu, 8 Aug 2024 17:47:22 +0300 Subject: [PATCH 02/14] proto --- app/app.go | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++- go.mod | 24 ++++++++++---------- go.sum | 42 +++++++++++++++++------------------ 3 files changed, 96 insertions(+), 34 deletions(-) diff --git a/app/app.go b/app/app.go index 8f30df60..78210c96 100644 --- a/app/app.go +++ b/app/app.go @@ -127,6 +127,9 @@ import ( rarimocoremodule "github.com/rarimo/rarimo-core/x/rarimocore" rarimocoremodulekeeper "github.com/rarimo/rarimo-core/x/rarimocore/keeper" rarimocoremoduletypes "github.com/rarimo/rarimo-core/x/rarimocore/types" + rootupdatermodule "github.com/rarimo/rarimo-core/x/rootupdater" + rootupdatermodulekeeper "github.com/rarimo/rarimo-core/x/rootupdater/keeper" + rootupdatermoduletypes "github.com/rarimo/rarimo-core/x/rootupdater/types" tokenmanagermodule "github.com/rarimo/rarimo-core/x/tokenmanager" tokenmanagermodulekeeper "github.com/rarimo/rarimo-core/x/tokenmanager/keeper" tokenmanagermoduletypes "github.com/rarimo/rarimo-core/x/tokenmanager/types" @@ -206,6 +209,12 @@ var ( vestingmintmodule.AppModuleBasic{}, identitymodule.AppModuleBasic{}, cscalistmodule.AppModuleBasic{}, + rootupdatermodule.AppModuleBasic{}, + rootupdatermodule.AppModuleBasic{}, + rootupdatermodule.AppModuleBasic{}, + rootupdatermodule.AppModuleBasic{}, + rootupdatermodule.AppModuleBasic{}, + rootupdatermodule.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -288,6 +297,9 @@ type App struct { VestingmintKeeper vestingmintmodulekeeper.Keeper IdentityKeeper identitymodulekeeper.Keeper CSCAListKeeper cscalistkeeper.Keeper + + RootupdaterKeeper rootupdatermodulekeeper.Keeper + // this line is used by starport scaffolding # stargate/app/keeperDeclaration RarimocoreKeeper rarimocoremodulekeeper.Keeper @@ -352,6 +364,12 @@ func New( vestingmintmoduletypes.StoreKey, identitymoduletypes.StoreKey, cscalisttypes.StoreKey, + rootupdatermoduletypes.StoreKey, + rootupdatermoduletypes.StoreKey, + rootupdatermoduletypes.StoreKey, + rootupdatermoduletypes.StoreKey, + rootupdatermoduletypes.StoreKey, + rootupdatermoduletypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) @@ -662,6 +680,14 @@ func New( ) vestingmintModule := vestingmintmodule.NewAppModule(appCodec, app.VestingmintKeeper, app.AccountKeeper, app.BankKeeper) + app.RootupdaterKeeper = *rootupdatermodulekeeper.NewKeeper( + appCodec, + keys[rootupdatermoduletypes.StoreKey], + keys[rootupdatermoduletypes.MemStoreKey], + app.GetSubspace(rootupdatermoduletypes.ModuleName), + ) + rootupdaterModule := rootupdatermodule.NewAppModule(appCodec, app.RootupdaterKeeper, app.AccountKeeper, app.BankKeeper) + // this line is used by starport scaffolding # stargate/app/keeperDefinition /**** IBC Routing ****/ @@ -690,7 +716,7 @@ func New( app.GovKeeper.SetHooks( govtypes.NewMultiGovHooks( - // insert governance hooks receivers here + // insert governance hooks receivers here ), ) @@ -737,6 +763,12 @@ func New( vestingmintModule, identityModule, cscaListModule, + rootupdaterModule, + rootupdaterModule, + rootupdaterModule, + rootupdaterModule, + rootupdaterModule, + rootupdaterModule, // this line is used by starport scaffolding # stargate/app/appModule ) @@ -776,6 +808,12 @@ func New( vestingmintmoduletypes.ModuleName, identitymoduletypes.ModuleName, cscalisttypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -810,6 +848,12 @@ func New( vestingmintmoduletypes.ModuleName, identitymoduletypes.ModuleName, cscalisttypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -854,6 +898,12 @@ func New( identitymoduletypes.ModuleName, cscalisttypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, + rootupdatermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -890,6 +940,12 @@ func New( multisigModule, evmModule, feeMarketModule, + rootupdaterModule, + rootupdaterModule, + rootupdaterModule, + rootupdaterModule, + rootupdaterModule, + rootupdaterModule, // this line is used by starport scaffolding # stargate/app/appModule ) app.sm.RegisterStoreDecoders() @@ -1136,6 +1192,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino //paramsKeeper.Subspace(monitoringptypes.ModuleName) paramsKeeper.Subspace(evmtypes.ModuleName) paramsKeeper.Subspace(feemarkettypes.ModuleName) + paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) + paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) + paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) + paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) + paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) + paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/go.mod b/go.mod index 979e6d52..33d40677 100644 --- a/go.mod +++ b/go.mod @@ -39,11 +39,12 @@ require ( github.com/tidwall/gjson v1.14.4 github.com/tidwall/sjson v1.2.5 github.com/tyler-smith/go-bip39 v1.1.0 - golang.org/x/net v0.24.0 - golang.org/x/text v0.15.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 - google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.34.1 + golang.org/x/net v0.26.0 + golang.org/x/text v0.16.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a + google.golang.org/grpc v1.64.1 + google.golang.org/protobuf v1.34.2 + gopkg.in/yaml.v2 v2.4.0 sigs.k8s.io/yaml v1.4.0 ) @@ -117,7 +118,7 @@ require ( github.com/googleapis/gax-go/v2 v2.12.3 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect @@ -195,20 +196,19 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect - golang.org/x/oauth2 v0.20.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/term v0.19.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/term v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.170.0 // indirect google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect ) diff --git a/go.sum b/go.sum index f6106b77..d893ee06 100644 --- a/go.sum +++ b/go.sum @@ -1045,8 +1045,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -1671,8 +1671,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1803,8 +1803,8 @@ golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1832,8 +1832,8 @@ golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= -golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1967,8 +1967,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1977,8 +1977,8 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1993,8 +1993,8 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2075,7 +2075,7 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= 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= @@ -2294,10 +2294,10 @@ google.golang.org/genproto v0.0.0-20230222225845-10f96fb3dbec/go.mod h1:3Dl5ZL0q google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be h1:g4aX8SUFA8V5F4LrSY5EclyGYw1OZN4HS1jTyjB9ZDc= google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be/go.mod h1:FeSdT5fk+lkxatqJP38MsUicGqHax5cLtmy/6TAuxO4= -google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No= -google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= +google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a h1:YIa/rzVqMEokBkPtydCkx1VLmv3An1Uw7w1P1m6EhOY= +google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a h1:hqK4+jJZXCU4pW7jsAdGOVFIfLHQeV7LaizZKnZ84HI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2317,8 +2317,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From f2768e6667910a71b0ee426eb3a5fec1e9beb8c5 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Tue, 13 Aug 2024 11:33:46 +0300 Subject: [PATCH 03/14] listen events from contract and create operation --- app/app.go | 51 +- proto/rarimocore/op_root_update.proto | 11 + proto/rarimocore/operation.proto | 1 + proto/rootupdater/genesis.proto | 12 + proto/rootupdater/params.proto | 15 + proto/rootupdater/query.proto | 26 + proto/rootupdater/tx.proto | 17 + .../crypto/operation/op_root_update.go | 25 + x/rarimocore/crypto/pkg/content/main.go | 19 + x/rarimocore/crypto/pkg/op_root_update.go | 25 + x/rarimocore/keeper/keeper.go | 38 + x/rarimocore/types/op_root_update.pb.go | 404 +++++ x/rarimocore/types/operation.pb.go | 70 +- x/rootupdater/client/cli/query.go | 32 + x/rootupdater/client/cli/query_params.go | 34 + x/rootupdater/client/cli/tx.go | 24 + x/rootupdater/client/cli/tx_update_root.go | 38 + x/rootupdater/genesis.go | 23 + x/rootupdater/handler.go | 29 + x/rootupdater/keeper/abci.go | 29 + x/rootupdater/keeper/keeper.go | 120 ++ x/rootupdater/keeper/msg_server.go | 17 + .../keeper/msg_server_update_root.go | 18 + x/rootupdater/keeper/params.go | 29 + x/rootupdater/keeper/query.go | 7 + x/rootupdater/keeper/query_params.go | 19 + x/rootupdater/module.go | 155 ++ x/rootupdater/module_simulation.go | 65 + x/rootupdater/pkg/state/state.go | 1517 +++++++++++++++++ x/rootupdater/simulation/helpers.go | 15 + x/rootupdater/types/codec.go | 22 + x/rootupdater/types/errors.go | 13 + x/rootupdater/types/expected_keepers.go | 10 + x/rootupdater/types/genesis.go | 24 + x/rootupdater/types/genesis.pb.go | 321 ++++ x/rootupdater/types/genesis_test.go | 40 + x/rootupdater/types/keys.go | 22 + x/rootupdater/types/message_root_update.go | 55 + x/rootupdater/types/params.go | 32 + x/rootupdater/types/params.pb.go | 526 ++++++ x/rootupdater/types/query.pb.go | 537 ++++++ x/rootupdater/types/query.pb.gw.go | 153 ++ x/rootupdater/types/tx.pb.go | 572 +++++++ x/rootupdater/types/types.go | 1 + 44 files changed, 5142 insertions(+), 71 deletions(-) create mode 100644 proto/rarimocore/op_root_update.proto create mode 100644 proto/rootupdater/genesis.proto create mode 100644 proto/rootupdater/params.proto create mode 100644 proto/rootupdater/query.proto create mode 100644 proto/rootupdater/tx.proto create mode 100644 x/rarimocore/crypto/operation/op_root_update.go create mode 100644 x/rarimocore/crypto/pkg/op_root_update.go create mode 100644 x/rarimocore/types/op_root_update.pb.go create mode 100644 x/rootupdater/client/cli/query.go create mode 100644 x/rootupdater/client/cli/query_params.go create mode 100644 x/rootupdater/client/cli/tx.go create mode 100644 x/rootupdater/client/cli/tx_update_root.go create mode 100644 x/rootupdater/genesis.go create mode 100644 x/rootupdater/handler.go create mode 100644 x/rootupdater/keeper/abci.go create mode 100644 x/rootupdater/keeper/keeper.go create mode 100644 x/rootupdater/keeper/msg_server.go create mode 100644 x/rootupdater/keeper/msg_server_update_root.go create mode 100644 x/rootupdater/keeper/params.go create mode 100644 x/rootupdater/keeper/query.go create mode 100644 x/rootupdater/keeper/query_params.go create mode 100644 x/rootupdater/module.go create mode 100644 x/rootupdater/module_simulation.go create mode 100644 x/rootupdater/pkg/state/state.go create mode 100644 x/rootupdater/simulation/helpers.go create mode 100644 x/rootupdater/types/codec.go create mode 100644 x/rootupdater/types/errors.go create mode 100644 x/rootupdater/types/expected_keepers.go create mode 100644 x/rootupdater/types/genesis.go create mode 100644 x/rootupdater/types/genesis.pb.go create mode 100644 x/rootupdater/types/genesis_test.go create mode 100644 x/rootupdater/types/keys.go create mode 100644 x/rootupdater/types/message_root_update.go create mode 100644 x/rootupdater/types/params.go create mode 100644 x/rootupdater/types/params.pb.go create mode 100644 x/rootupdater/types/query.pb.go create mode 100644 x/rootupdater/types/query.pb.gw.go create mode 100644 x/rootupdater/types/tx.pb.go create mode 100644 x/rootupdater/types/types.go diff --git a/app/app.go b/app/app.go index 78210c96..771550aa 100644 --- a/app/app.go +++ b/app/app.go @@ -365,11 +365,7 @@ func New( identitymoduletypes.StoreKey, cscalisttypes.StoreKey, rootupdatermoduletypes.StoreKey, - rootupdatermoduletypes.StoreKey, - rootupdatermoduletypes.StoreKey, - rootupdatermoduletypes.StoreKey, - rootupdatermoduletypes.StoreKey, - rootupdatermoduletypes.StoreKey, + // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) @@ -669,7 +665,11 @@ func New( app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, nil, geth.NewEVM, cast.ToString(appOpts.Get(srvflags.EVMTracer)), evmSs, ) - app.EvmKeeper = app.EvmKeeper.SetHooks(app.IdentityKeeper) + app.EvmKeeper = app.EvmKeeper.SetHooks(evmkeeper.NewMultiEvmHooks( + app.IdentityKeeper, + app.RootupdaterKeeper, + )) + evmModule := evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs) // <- ACTUAL module creation in app.go that you need app.VestingmintKeeper = *vestingmintmodulekeeper.NewKeeper( @@ -685,8 +685,9 @@ func New( keys[rootupdatermoduletypes.StoreKey], keys[rootupdatermoduletypes.MemStoreKey], app.GetSubspace(rootupdatermoduletypes.ModuleName), + app.RarimocoreKeeper, ) - rootupdaterModule := rootupdatermodule.NewAppModule(appCodec, app.RootupdaterKeeper, app.AccountKeeper, app.BankKeeper) + rootupdaterModule := rootupdatermodule.NewAppModule(appCodec, app.RootupdaterKeeper) // this line is used by starport scaffolding # stargate/app/keeperDefinition @@ -716,7 +717,7 @@ func New( app.GovKeeper.SetHooks( govtypes.NewMultiGovHooks( - // insert governance hooks receivers here + // insert governance hooks receivers here ), ) @@ -764,11 +765,7 @@ func New( identityModule, cscaListModule, rootupdaterModule, - rootupdaterModule, - rootupdaterModule, - rootupdaterModule, - rootupdaterModule, - rootupdaterModule, + // this line is used by starport scaffolding # stargate/app/appModule ) @@ -809,11 +806,7 @@ func New( identitymoduletypes.ModuleName, cscalisttypes.ModuleName, rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, + // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -849,11 +842,7 @@ func New( identitymoduletypes.ModuleName, cscalisttypes.ModuleName, rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, + // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -898,11 +887,6 @@ func New( identitymoduletypes.ModuleName, cscalisttypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, - rootupdatermoduletypes.ModuleName, rootupdatermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -941,11 +925,7 @@ func New( evmModule, feeMarketModule, rootupdaterModule, - rootupdaterModule, - rootupdaterModule, - rootupdaterModule, - rootupdaterModule, - rootupdaterModule, + // this line is used by starport scaffolding # stargate/app/appModule ) app.sm.RegisterStoreDecoders() @@ -1193,11 +1173,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(evmtypes.ModuleName) paramsKeeper.Subspace(feemarkettypes.ModuleName) paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) - paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) - paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) - paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) - paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) - paramsKeeper.Subspace(rootupdatermoduletypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/proto/rarimocore/op_root_update.proto b/proto/rarimocore/op_root_update.proto new file mode 100644 index 00000000..d7e96e38 --- /dev/null +++ b/proto/rarimocore/op_root_update.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package rarimo.rarimocore.rarimocore; + +option go_package = "github.com/rarimo/rarimo-core/x/rarimocore/types"; + +message RootUpdate { +// Root is new Merkle root. Hex 0x uint256 + string root = 1; + string contract_address = 2; + uint64 timestamp = 3; +} diff --git a/proto/rarimocore/operation.proto b/proto/rarimocore/operation.proto index a8e91451..9c4d2fbc 100644 --- a/proto/rarimocore/operation.proto +++ b/proto/rarimocore/operation.proto @@ -17,6 +17,7 @@ enum OpType { WORLDCOIN_IDENTITY_TRANSFER = 8; CSCA_ROOT_UPDATE = 9; ARBITRARY = 10; + UPDATE_ROOT = 11; } enum OpStatus { diff --git a/proto/rootupdater/genesis.proto b/proto/rootupdater/genesis.proto new file mode 100644 index 00000000..ed445b3d --- /dev/null +++ b/proto/rootupdater/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package rarimo.rootupdater; + +import "gogoproto/gogo.proto"; +import "rootupdater/params.proto"; + +option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; + +// GenesisState defines the rootupdater module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/rootupdater/params.proto b/proto/rootupdater/params.proto new file mode 100644 index 00000000..af239212 --- /dev/null +++ b/proto/rootupdater/params.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package rarimo.rootupdater; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; + +// Params defines the parameters for the module. +message Params { + string contract_address = 1; + string root = 2; + string last_root = 3; + string index = 4; + string event_name = 5; +} diff --git a/proto/rootupdater/query.proto b/proto/rootupdater/query.proto new file mode 100644 index 00000000..9d04c7c2 --- /dev/null +++ b/proto/rootupdater/query.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package rarimo.rootupdater; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "rootupdater/params.proto"; + +option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/rarimo/rarimo-core/rootupdater/params"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/rootupdater/tx.proto b/proto/rootupdater/tx.proto new file mode 100644 index 00000000..0d8a9029 --- /dev/null +++ b/proto/rootupdater/tx.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package rarimo.rootupdater; + +option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; + +// Msg defines the Msg service. +service Msg { + rpc UpdateRoot(MsgUpdateRoot) returns (MsgUpdateRootResponse); +} + +message MsgUpdateRoot{ + string creator = 1; + string root = 2; +} + +message MsgUpdateRootResponse {} + diff --git a/x/rarimocore/crypto/operation/op_root_update.go b/x/rarimocore/crypto/operation/op_root_update.go new file mode 100644 index 00000000..2ab3d6d1 --- /dev/null +++ b/x/rarimocore/crypto/operation/op_root_update.go @@ -0,0 +1,25 @@ +package operation + +import ( + "bytes" + + eth "github.com/ethereum/go-ethereum/crypto" + merkle "github.com/rarimo/go-merkle" +) + +type RootUpdateContent struct { + ContractAddress []byte + Root []byte +} + +const hashRootUpdatePrefix = "Rarimo root" + +var _ merkle.Content = RootUpdateContent{} + +func (c RootUpdateContent) CalculateHash() []byte { + return eth.Keccak256([]byte(hashRootUpdatePrefix), c.ContractAddress, c.Root) +} + +func (c RootUpdateContent) Equals(other merkle.Content) bool { + return bytes.Equal(other.CalculateHash(), c.CalculateHash()) +} diff --git a/x/rarimocore/crypto/pkg/content/main.go b/x/rarimocore/crypto/pkg/content/main.go index 412f9b8d..bdc3a2d5 100644 --- a/x/rarimocore/crypto/pkg/content/main.go +++ b/x/rarimocore/crypto/pkg/content/main.go @@ -106,6 +106,15 @@ func GetContents(client *grpc.ClientConn, operations ...*types.Operation) ([]mer return nil, err } + if content != nil { + contents = append(contents, content) + } + case types.OpType_UPDATE_ROOT: + content, err := GetRootUpdateContent(op) + if err != nil { + return nil, err + } + if content != nil { contents = append(contents, content) } @@ -270,3 +279,13 @@ func GetArbitraryContent(op *types.Operation) (merkle.Content, error) { content, err := pkg.GetArbitraryContent(update) return content, errors.Wrap(err, "error creating content") } + +func GetRootUpdateContent(op *types.Operation) (merkle.Content, error) { + update, err := pkg.GetRootUpdate(*op) + if err != nil { + return nil, errors.Wrap(err, "error parsing operation details") + } + + content, err := pkg.GetRootUpdateContent(update) + return content, errors.Wrap(err, "error creating content") +} diff --git a/x/rarimocore/crypto/pkg/op_root_update.go b/x/rarimocore/crypto/pkg/op_root_update.go new file mode 100644 index 00000000..75ce5635 --- /dev/null +++ b/x/rarimocore/crypto/pkg/op_root_update.go @@ -0,0 +1,25 @@ +package pkg + +import ( + "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/gogo/protobuf/proto" + "github.com/rarimo/rarimo-core/x/rarimocore/crypto/operation" + "github.com/rarimo/rarimo-core/x/rarimocore/types" +) + +func GetRootUpdate(operation types.Operation) (*types.RootUpdate, error) { + if operation.OperationType == types.OpType_UPDATE_ROOT { + op := new(types.RootUpdate) + return op, proto.Unmarshal(operation.Details.Value, op) + } + return nil, errors.Wrap(sdkerrors.ErrInvalidType, "invalid operation type") +} + +func GetRootUpdateContent(op *types.RootUpdate) (*operation.RootUpdateContent, error) { + return &operation.RootUpdateContent{ + ContractAddress: operation.To32Bytes(hexutil.MustDecode(op.ContractAddress)), + Root: operation.To32Bytes(hexutil.MustDecode(op.Root)), + }, nil +} diff --git a/x/rarimocore/keeper/keeper.go b/x/rarimocore/keeper/keeper.go index 3f31ac31..9eb39765 100644 --- a/x/rarimocore/keeper/keeper.go +++ b/x/rarimocore/keeper/keeper.go @@ -577,6 +577,44 @@ func (k Keeper) CreateArbitraryOperation(ctx sdk.Context, creator string, arbitr return nil } +func (k Keeper) CreateRootUpdateOperation(ctx sdk.Context, creator string, update *types.RootUpdate) (string, error) { + details, err := cosmostypes.NewAnyWithValue(update) + if err != nil { + return "", errors.Wrapf(sdkerrors.ErrInvalidRequest, "error parsing details: %s", err.Error()) + } + + content, err := pkg.GetRootUpdateContent(update) + if err != nil { + return "", errors.Wrapf(sdkerrors.ErrInvalidRequest, "error creating content: %s", err.Error()) + } + + operation := types.Operation{ + Index: hexutil.Encode(content.CalculateHash()), + OperationType: types.OpType_UPDATE_ROOT, + Details: details, + Status: types.OpStatus_INITIALIZED, + Creator: creator, + Timestamp: uint64(ctx.BlockTime().Unix()), + } + + if _, ok := k.GetOperation(ctx, operation.Index); ok { + return "", errors.Wrapf(sdkerrors.ErrInvalidRequest, "that operation can not be changed") + } + k.SetOperation(ctx, operation) + + ctx.EventManager().EmitEvent(sdk.NewEvent(types.EventTypeNewOperation, + sdk.NewAttribute(types.AttributeKeyOperationId, operation.Index), + sdk.NewAttribute(types.AttributeKeyOperationType, operation.OperationType.String()), + )) + + // Operation is auto-approved (cause created by EndBlock) + if err = k.ApproveOperation(ctx, operation); err != nil { + return "", errors.Wrap(err, "failed to auto-approve operation") + } + + return operation.Index, nil +} + func (k Keeper) GetTransfer(ctx sdk.Context, msg *oracletypes.MsgCreateTransferOp) (*types.Transfer, error) { hash := origin.NewDefaultOriginBuilder(). SetTxHash(msg.Tx). diff --git a/x/rarimocore/types/op_root_update.pb.go b/x/rarimocore/types/op_root_update.pb.go new file mode 100644 index 00000000..6e1d7e85 --- /dev/null +++ b/x/rarimocore/types/op_root_update.pb.go @@ -0,0 +1,404 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rarimocore/op_root_update.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type RootUpdate struct { + // Root is new Merkle root. Hex 0x uint256 + Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *RootUpdate) Reset() { *m = RootUpdate{} } +func (m *RootUpdate) String() string { return proto.CompactTextString(m) } +func (*RootUpdate) ProtoMessage() {} +func (*RootUpdate) Descriptor() ([]byte, []int) { + return fileDescriptor_27d0fc6c9dd91d98, []int{0} +} +func (m *RootUpdate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RootUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RootUpdate.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 *RootUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_RootUpdate.Merge(m, src) +} +func (m *RootUpdate) XXX_Size() int { + return m.Size() +} +func (m *RootUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_RootUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_RootUpdate proto.InternalMessageInfo + +func (m *RootUpdate) GetRoot() string { + if m != nil { + return m.Root + } + return "" +} + +func (m *RootUpdate) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *RootUpdate) GetTimestamp() uint64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func init() { + proto.RegisterType((*RootUpdate)(nil), "rarimo.rarimocore.rarimocore.RootUpdate") +} + +func init() { proto.RegisterFile("rarimocore/op_root_update.proto", fileDescriptor_27d0fc6c9dd91d98) } + +var fileDescriptor_27d0fc6c9dd91d98 = []byte{ + // 206 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2f, 0x4a, 0x2c, 0xca, + 0xcc, 0xcd, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x88, 0x2f, 0xca, 0xcf, 0x2f, 0x89, 0x2f, + 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0x28, 0xd0, + 0x43, 0xa8, 0x43, 0x62, 0x2a, 0x65, 0x72, 0x71, 0x05, 0xe5, 0xe7, 0x97, 0x84, 0x82, 0x75, 0x08, + 0x09, 0x71, 0xb1, 0x80, 0x0c, 0x90, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x85, 0x34, + 0xb9, 0x04, 0x92, 0xf3, 0xf3, 0x4a, 0x8a, 0x12, 0x93, 0x4b, 0xe2, 0x13, 0x53, 0x52, 0x8a, 0x52, + 0x8b, 0x8b, 0x25, 0x98, 0xc0, 0xf2, 0xfc, 0x30, 0x71, 0x47, 0x88, 0xb0, 0x90, 0x0c, 0x17, 0x67, + 0x49, 0x66, 0x6e, 0x6a, 0x71, 0x49, 0x62, 0x6e, 0x81, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x4b, 0x10, + 0x42, 0xc0, 0xc9, 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, + 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, + 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x21, 0x6e, 0x83, 0x52, 0xba, 0x60, + 0x6f, 0x55, 0xe8, 0x23, 0xf9, 0xb1, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x37, 0x63, + 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x58, 0x2e, 0x6c, 0xfe, 0x00, 0x00, 0x00, +} + +func (m *RootUpdate) 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 *RootUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RootUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintOpRootUpdate(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x18 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintOpRootUpdate(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Root) > 0 { + i -= len(m.Root) + copy(dAtA[i:], m.Root) + i = encodeVarintOpRootUpdate(dAtA, i, uint64(len(m.Root))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOpRootUpdate(dAtA []byte, offset int, v uint64) int { + offset -= sovOpRootUpdate(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RootUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Root) + if l > 0 { + n += 1 + l + sovOpRootUpdate(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovOpRootUpdate(uint64(l)) + } + if m.Timestamp != 0 { + n += 1 + sovOpRootUpdate(uint64(m.Timestamp)) + } + return n +} + +func sovOpRootUpdate(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOpRootUpdate(x uint64) (n int) { + return sovOpRootUpdate(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RootUpdate) 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 ErrIntOverflowOpRootUpdate + } + 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: RootUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RootUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpRootUpdate + } + 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 ErrInvalidLengthOpRootUpdate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOpRootUpdate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Root = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpRootUpdate + } + 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 ErrInvalidLengthOpRootUpdate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOpRootUpdate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpRootUpdate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOpRootUpdate(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOpRootUpdate + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOpRootUpdate(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, ErrIntOverflowOpRootUpdate + } + 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, ErrIntOverflowOpRootUpdate + } + 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, ErrIntOverflowOpRootUpdate + } + 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, ErrInvalidLengthOpRootUpdate + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOpRootUpdate + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOpRootUpdate + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOpRootUpdate = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOpRootUpdate = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOpRootUpdate = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rarimocore/types/operation.pb.go b/x/rarimocore/types/operation.pb.go index b4ab3860..0efa4de9 100644 --- a/x/rarimocore/types/operation.pb.go +++ b/x/rarimocore/types/operation.pb.go @@ -37,6 +37,7 @@ const ( OpType_WORLDCOIN_IDENTITY_TRANSFER OpType = 8 OpType_CSCA_ROOT_UPDATE OpType = 9 OpType_ARBITRARY OpType = 10 + OpType_UPDATE_ROOT OpType = 11 ) var OpType_name = map[int32]string{ @@ -51,6 +52,7 @@ var OpType_name = map[int32]string{ 8: "WORLDCOIN_IDENTITY_TRANSFER", 9: "CSCA_ROOT_UPDATE", 10: "ARBITRARY", + 11: "UPDATE_ROOT", } var OpType_value = map[string]int32{ @@ -65,6 +67,7 @@ var OpType_value = map[string]int32{ "WORLDCOIN_IDENTITY_TRANSFER": 8, "CSCA_ROOT_UPDATE": 9, "ARBITRARY": 10, + "UPDATE_ROOT": 11, } func (x OpType) String() string { @@ -201,40 +204,41 @@ func init() { func init() { proto.RegisterFile("rarimocore/operation.proto", fileDescriptor_4615e59ddf669d07) } var fileDescriptor_4615e59ddf669d07 = []byte{ - // 523 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6f, 0xda, 0x30, - 0x1c, 0xc5, 0x09, 0x85, 0x00, 0xdf, 0xfe, 0x98, 0x65, 0xa1, 0x2d, 0xa5, 0x2c, 0x43, 0xd3, 0x34, + // 530 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xc1, 0x6e, 0xda, 0x30, + 0x1c, 0xc6, 0x09, 0x2d, 0x01, 0xfe, 0xb4, 0x9d, 0x65, 0xa1, 0x2d, 0xa5, 0x2c, 0x43, 0xd3, 0x34, 0xa1, 0x4a, 0x0b, 0x53, 0x77, 0x9f, 0xe4, 0x12, 0x93, 0xb9, 0xa3, 0x0e, 0x72, 0xdc, 0x4d, 0xed, - 0x25, 0x0a, 0x34, 0x63, 0x91, 0x0a, 0x89, 0x42, 0x90, 0xca, 0x7f, 0xb1, 0xcb, 0x2e, 0xfb, 0x8b, - 0x76, 0xec, 0x71, 0xc7, 0x09, 0xfe, 0x91, 0x89, 0xa4, 0x04, 0x76, 0xd9, 0x4e, 0x89, 0xfd, 0x3e, - 0x2f, 0xef, 0xd9, 0xb1, 0xa1, 0x11, 0x7b, 0x71, 0x30, 0x09, 0x47, 0x61, 0xec, 0x77, 0xc2, 0xc8, - 0x8f, 0xbd, 0x24, 0x08, 0xa7, 0x46, 0x14, 0x87, 0x49, 0x88, 0x9b, 0x99, 0x66, 0x6c, 0x91, 0x9d, - 0xd7, 0xc6, 0xf1, 0x38, 0x0c, 0xc7, 0x77, 0x7e, 0x27, 0x65, 0x87, 0xf3, 0x2f, 0x1d, 0x6f, 0xba, - 0xc8, 0x8c, 0x2f, 0xbf, 0x17, 0xa1, 0x66, 0x6f, 0x3e, 0x86, 0xeb, 0x50, 0x0e, 0xa6, 0xb7, 0xfe, - 0xbd, 0xa6, 0xb4, 0x94, 0x76, 0x4d, 0x64, 0x03, 0x7c, 0x01, 0x87, 0x79, 0x9e, 0x5c, 0x44, 0xbe, - 0x56, 0x6c, 0x29, 0xed, 0xa3, 0xb3, 0x57, 0xc6, 0xbf, 0x42, 0x0d, 0x3b, 0x5a, 0xb3, 0xe2, 0x6f, - 0x2b, 0x36, 0xa0, 0x72, 0xeb, 0x27, 0x5e, 0x70, 0x37, 0xd3, 0xf6, 0x5a, 0x4a, 0x7b, 0xff, 0xac, - 0x6e, 0x64, 0xe5, 0x8c, 0x4d, 0x39, 0x83, 0x4c, 0x17, 0x62, 0x03, 0xe1, 0xf7, 0xa0, 0xce, 0x12, - 0x2f, 0x99, 0xcf, 0xb4, 0x52, 0x1a, 0xfa, 0xfa, 0x7f, 0xa1, 0x4e, 0x4a, 0x8b, 0x47, 0x17, 0xd6, - 0xa0, 0x32, 0x8a, 0x7d, 0x2f, 0x09, 0x63, 0xad, 0x9c, 0xae, 0x69, 0x33, 0xc4, 0x4d, 0xa8, 0x25, - 0xc1, 0xc4, 0x9f, 0x25, 0xde, 0x24, 0xd2, 0xd4, 0x96, 0xd2, 0x2e, 0x89, 0xed, 0xc4, 0xe9, 0x8f, - 0x22, 0xa8, 0xd9, 0x0a, 0xf0, 0x01, 0x54, 0xa5, 0x20, 0xdc, 0xe9, 0x51, 0x81, 0x0a, 0x18, 0xc3, - 0x51, 0xf7, 0x03, 0xe1, 0x16, 0x75, 0x07, 0x44, 0x48, 0x46, 0x1d, 0xa4, 0x60, 0x0d, 0xea, 0x3d, - 0x4a, 0x5d, 0x69, 0x7f, 0xa4, 0xdc, 0xbd, 0x24, 0x9c, 0x58, 0xf4, 0x92, 0x72, 0x89, 0x8a, 0xb8, - 0x0e, 0xa8, 0x6b, 0x73, 0x29, 0x48, 0x57, 0xba, 0x57, 0x03, 0x4b, 0x10, 0x93, 0xa2, 0x3d, 0xfc, - 0x1c, 0x8e, 0x99, 0x49, 0xb9, 0x64, 0xf2, 0xda, 0x35, 0x69, 0x8f, 0x5c, 0xf5, 0xa5, 0x9b, 0x47, - 0x94, 0x70, 0x0b, 0x9a, 0xb9, 0x4c, 0x2c, 0x4b, 0x50, 0x8b, 0x48, 0x6a, 0x6e, 0x89, 0x32, 0x6e, - 0xc0, 0xd3, 0x9c, 0xb0, 0x98, 0xb3, 0xe3, 0x56, 0xf1, 0x09, 0x3c, 0xcb, 0x35, 0x47, 0x12, 0x49, - 0xb7, 0x62, 0x05, 0xbf, 0x80, 0x93, 0xcf, 0xb6, 0xe8, 0x9b, 0x5d, 0x9b, 0x71, 0x37, 0xc7, 0x72, - 0xa0, 0x9a, 0x16, 0x76, 0xba, 0xc4, 0x15, 0xb6, 0xbd, 0x6e, 0x6c, 0x12, 0x49, 0x51, 0x0d, 0x1f, - 0x42, 0x8d, 0x88, 0x73, 0x26, 0x05, 0x11, 0xd7, 0x08, 0x4e, 0x2d, 0xa8, 0x6e, 0x36, 0x1a, 0x3f, - 0x81, 0x7d, 0xc6, 0x99, 0x64, 0xa4, 0xcf, 0x6e, 0xa8, 0x89, 0x0a, 0xeb, 0xed, 0x22, 0x83, 0x81, - 0xb0, 0x3f, 0x51, 0x13, 0x29, 0x18, 0xc1, 0x01, 0xb7, 0xa5, 0x9b, 0xcf, 0x14, 0x31, 0x80, 0xea, - 0x30, 0x8b, 0x53, 0x13, 0xed, 0x9d, 0x5f, 0xfc, 0x5c, 0xea, 0xca, 0xc3, 0x52, 0x57, 0x7e, 0x2f, - 0x75, 0xe5, 0xdb, 0x4a, 0x2f, 0x3c, 0xac, 0xf4, 0xc2, 0xaf, 0x95, 0x5e, 0xb8, 0x79, 0x3b, 0x0e, - 0x92, 0xaf, 0xf3, 0xa1, 0x31, 0x0a, 0x27, 0x9d, 0xec, 0xff, 0x3e, 0x3e, 0xde, 0xa4, 0xe7, 0xff, - 0xbe, 0xb3, 0x73, 0x19, 0x92, 0x45, 0xe4, 0xcf, 0x86, 0x6a, 0x7a, 0x80, 0xde, 0xfd, 0x09, 0x00, - 0x00, 0xff, 0xff, 0x73, 0x87, 0x50, 0xfd, 0x27, 0x03, 0x00, 0x00, + 0x25, 0x0a, 0x34, 0x63, 0x91, 0x0a, 0x89, 0x42, 0x90, 0xca, 0x5b, 0xec, 0xb2, 0xa7, 0xd8, 0x8b, + 0xec, 0xd8, 0xe3, 0x8e, 0x13, 0xbc, 0xc8, 0x44, 0x52, 0x02, 0xbb, 0x6c, 0xa7, 0xc4, 0xfe, 0x7e, + 0x5f, 0xbe, 0xcf, 0x8e, 0x0d, 0x8d, 0xd8, 0x8b, 0x83, 0x49, 0x38, 0x0a, 0x63, 0xbf, 0x13, 0x46, + 0x7e, 0xec, 0x25, 0x41, 0x38, 0x35, 0xa2, 0x38, 0x4c, 0x42, 0xdc, 0xcc, 0x34, 0x63, 0x8b, 0xec, + 0xbc, 0x36, 0x8e, 0xc7, 0x61, 0x38, 0xbe, 0xf3, 0x3b, 0x29, 0x3b, 0x9c, 0x7f, 0xe9, 0x78, 0xd3, + 0x45, 0x66, 0x7c, 0xf9, 0xbd, 0x08, 0x55, 0x7b, 0xf3, 0x31, 0x5c, 0x87, 0x52, 0x30, 0xbd, 0xf5, + 0xef, 0x35, 0xa5, 0xa5, 0xb4, 0xab, 0x22, 0x1b, 0xe0, 0x0b, 0x38, 0xcc, 0xf3, 0xe4, 0x22, 0xf2, + 0xb5, 0x62, 0x4b, 0x69, 0x1f, 0x9d, 0xbd, 0x32, 0xfe, 0x15, 0x6a, 0xd8, 0xd1, 0x9a, 0x15, 0x7f, + 0x5b, 0xb1, 0x01, 0xe5, 0x5b, 0x3f, 0xf1, 0x82, 0xbb, 0x99, 0xb6, 0xd7, 0x52, 0xda, 0xb5, 0xb3, + 0xba, 0x91, 0x95, 0x33, 0x36, 0xe5, 0x0c, 0x32, 0x5d, 0x88, 0x0d, 0x84, 0xdf, 0x83, 0x3a, 0x4b, + 0xbc, 0x64, 0x3e, 0xd3, 0xf6, 0xd3, 0xd0, 0xd7, 0xff, 0x0b, 0x75, 0x52, 0x5a, 0x3c, 0xba, 0xb0, + 0x06, 0xe5, 0x51, 0xec, 0x7b, 0x49, 0x18, 0x6b, 0xa5, 0x74, 0x4d, 0x9b, 0x21, 0x6e, 0x42, 0x35, + 0x09, 0x26, 0xfe, 0x2c, 0xf1, 0x26, 0x91, 0xa6, 0xb6, 0x94, 0xf6, 0xbe, 0xd8, 0x4e, 0x9c, 0xfe, + 0x28, 0x82, 0x9a, 0xad, 0x00, 0x1f, 0x40, 0x45, 0x0a, 0xc2, 0x9d, 0x1e, 0x15, 0xa8, 0x80, 0x31, + 0x1c, 0x75, 0x3f, 0x10, 0x6e, 0x51, 0x77, 0x40, 0x84, 0x64, 0xd4, 0x41, 0x0a, 0xd6, 0xa0, 0xde, + 0xa3, 0xd4, 0x95, 0xf6, 0x47, 0xca, 0xdd, 0x4b, 0xc2, 0x89, 0x45, 0x2f, 0x29, 0x97, 0xa8, 0x88, + 0xeb, 0x80, 0xba, 0x36, 0x97, 0x82, 0x74, 0xa5, 0x7b, 0x35, 0xb0, 0x04, 0x31, 0x29, 0xda, 0xc3, + 0xcf, 0xe1, 0x98, 0x99, 0x94, 0x4b, 0x26, 0xaf, 0x5d, 0x93, 0xf6, 0xc8, 0x55, 0x5f, 0xba, 0x79, + 0xc4, 0x3e, 0x6e, 0x41, 0x33, 0x97, 0x89, 0x65, 0x09, 0x6a, 0x11, 0x49, 0xcd, 0x2d, 0x51, 0xc2, + 0x0d, 0x78, 0x9a, 0x13, 0x16, 0x73, 0x76, 0xdc, 0x2a, 0x3e, 0x81, 0x67, 0xb9, 0xe6, 0x48, 0x22, + 0xe9, 0x56, 0x2c, 0xe3, 0x17, 0x70, 0xf2, 0xd9, 0x16, 0x7d, 0xb3, 0x6b, 0x33, 0xee, 0xe6, 0x58, + 0x0e, 0x54, 0xd2, 0xc2, 0x4e, 0x97, 0xb8, 0xc2, 0xb6, 0xd7, 0x8d, 0x4d, 0x22, 0x29, 0xaa, 0xe2, + 0x43, 0xa8, 0x12, 0x71, 0xce, 0xa4, 0x20, 0xe2, 0x1a, 0x01, 0x7e, 0x02, 0xb5, 0x4c, 0x4a, 0x31, + 0x54, 0x3b, 0xb5, 0xa0, 0xb2, 0xd9, 0xf9, 0xb5, 0xc8, 0x38, 0x93, 0x8c, 0xf4, 0xd9, 0x0d, 0x35, + 0x51, 0x61, 0xbd, 0x7f, 0x64, 0x30, 0x10, 0xf6, 0x27, 0x6a, 0x22, 0x05, 0x23, 0x38, 0xe0, 0xb6, + 0x74, 0xf3, 0x99, 0x22, 0x06, 0x50, 0x1d, 0x66, 0x71, 0x6a, 0xa2, 0xbd, 0xf3, 0x8b, 0x9f, 0x4b, + 0x5d, 0x79, 0x58, 0xea, 0xca, 0xef, 0xa5, 0xae, 0x7c, 0x5b, 0xe9, 0x85, 0x87, 0x95, 0x5e, 0xf8, + 0xb5, 0xd2, 0x0b, 0x37, 0x6f, 0xc7, 0x41, 0xf2, 0x75, 0x3e, 0x34, 0x46, 0xe1, 0xa4, 0x93, 0xfd, + 0xf0, 0xc7, 0xc7, 0x9b, 0xf4, 0x42, 0xdc, 0x77, 0x76, 0x6e, 0x47, 0xb2, 0x88, 0xfc, 0xd9, 0x50, + 0x4d, 0x4f, 0xd4, 0xbb, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x63, 0x80, 0x51, 0x1f, 0x38, 0x03, + 0x00, 0x00, } func (m *Operation) Marshal() (dAtA []byte, err error) { diff --git a/x/rootupdater/client/cli/query.go b/x/rootupdater/client/cli/query.go new file mode 100644 index 00000000..67f6caec --- /dev/null +++ b/x/rootupdater/client/cli/query.go @@ -0,0 +1,32 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group rootupdater queries under a subcommand + 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()) + // this line is used by starport scaffolding # 1 + + return cmd +} + diff --git a/x/rootupdater/client/cli/query_params.go b/x/rootupdater/client/cli/query_params.go new file mode 100644 index 00000000..b478c3e9 --- /dev/null +++ b/x/rootupdater/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the 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 +} diff --git a/x/rootupdater/client/cli/tx.go b/x/rootupdater/client/cli/tx.go new file mode 100644 index 00000000..5412967b --- /dev/null +++ b/x/rootupdater/client/cli/tx.go @@ -0,0 +1,24 @@ +package cli + +import ( + "fmt" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// GetTxCmd returns the transaction commands for this 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, + } + + // this line is used by starport scaffolding # 1 + cmd.AddCommand(CmdUpdateRoot()) + return cmd +} diff --git a/x/rootupdater/client/cli/tx_update_root.go b/x/rootupdater/client/cli/tx_update_root.go new file mode 100644 index 00000000..36a6d68c --- /dev/null +++ b/x/rootupdater/client/cli/tx_update_root.go @@ -0,0 +1,38 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/rarimo/rarimo-core/x/rootupdater/types" + "github.com/spf13/cobra" +) + +func CmdUpdateRoot() *cobra.Command { + cmd := &cobra.Command{ + Use: "update [root]", + Short: "Update a root", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + root := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgUpdateRoot( + clientCtx.GetFromAddress().String(), + root, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rootupdater/genesis.go b/x/rootupdater/genesis.go new file mode 100644 index 00000000..6431e8cc --- /dev/null +++ b/x/rootupdater/genesis.go @@ -0,0 +1,23 @@ +package rootupdater + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rootupdater/keeper" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/rootupdater/handler.go b/x/rootupdater/handler.go new file mode 100644 index 00000000..851c7254 --- /dev/null +++ b/x/rootupdater/handler.go @@ -0,0 +1,29 @@ +package rootupdater + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/rarimo/rarimo-core/x/rootupdater/keeper" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// NewHandler ... +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + // this line is used by starport scaffolding # handler/msgServer + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgUpdateRoot: + res, err := msgServer.UpdateRoot(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + } + } +} diff --git a/x/rootupdater/keeper/abci.go b/x/rootupdater/keeper/abci.go new file mode 100644 index 00000000..e5612aa4 --- /dev/null +++ b/x/rootupdater/keeper/abci.go @@ -0,0 +1,29 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + rarimocoremoduletypes "github.com/rarimo/rarimo-core/x/rarimocore/types" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +func (k Keeper) EndBlocker(ctx sdk.Context) { + params := k.GetParams(ctx) + + if params.Root == params.LastRoot { + return + } + // Creating operation to be signed by TSS parties + index, err := k.rarimo.CreateRootUpdateOperation(ctx, types.ModuleName, &rarimocoremoduletypes.RootUpdate{ + ContractAddress: params.ContractAddress, + Root: params.Root, + }) + + if err != nil { + k.Logger(ctx).Error("Failed to create identity aggregated transfer: " + err.Error()) + return + } + + params.LastRoot = params.Root + params.Index = index + k.SetParams(ctx, params) +} diff --git a/x/rootupdater/keeper/keeper.go b/x/rootupdater/keeper/keeper.go new file mode 100644 index 00000000..bd9d119c --- /dev/null +++ b/x/rootupdater/keeper/keeper.go @@ -0,0 +1,120 @@ +package keeper + +import ( + "bytes" + "encoding/hex" + "fmt" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/rarimo/rarimo-core/x/rootupdater/pkg/state" + "strings" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/tendermint/tendermint/libs/log" + + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + rarimo types.RarimocoreKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + rarimo types.RarimocoreKeeper, + +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + rarimo: rarimo, + } +} + +// PostTxProcessing is used to listen EVM smart contract events, +// filter and process `StateTransited` events emitted by configured in module params contract address. +// Will be called by EVM module as hook. +func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { + params := k.GetParams(ctx) + + stateV2, err := abi.JSON(strings.NewReader(state.PoseidonSMTABI)) + if err != nil { + return err + } + + // Validating message receiver address (should be our state smart contract) + if msg.To() == nil || bytes.Compare(msg.To().Bytes(), hexutil.MustDecode(params.ContractAddress)) != 0 { + return nil + } + + // https://docs.evmos.org/protocol/modules/evm#posttxprocessing + for _, log := range receipt.Logs { + eventId := log.Topics[0] + + event, err := stateV2.EventByID(eventId) + if err != nil { + continue + } + + if event.Name != params.EventName { + continue + } + + eventBody := state.PoseidonSMTRootUpdated{} + if err := unpackLog(stateV2, &eventBody, event.Name, log); err != nil { + return err + } + + params.Root = hex.EncodeToString(eventBody.Root[:]) + + k.Logger(ctx).Info(fmt.Sprintf("Received PostTxProcessing event in %s module: %v", types.ModuleName, eventBody)) + k.SetParams(ctx, params) + } + + return nil +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// unpackLog copy-pasted from logic in generated s-c bindings. +func unpackLog(contractAbi abi.ABI, out interface{}, event string, log *ethtypes.Log) error { + if log.Topics[0] != contractAbi.Events[event].ID { + return fmt.Errorf("event signature mismatch") + } + + if len(log.Data) > 0 { + if err := contractAbi.UnpackIntoInterface(out, event, log.Data); err != nil { + return err + } + } + var indexed abi.Arguments + for _, arg := range contractAbi.Events[event].Inputs { + if arg.Indexed { + indexed = append(indexed, arg) + } + } + return abi.ParseTopics(out, indexed, log.Topics[1:]) +} diff --git a/x/rootupdater/keeper/msg_server.go b/x/rootupdater/keeper/msg_server.go new file mode 100644 index 00000000..dbd464bf --- /dev/null +++ b/x/rootupdater/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/rootupdater/keeper/msg_server_update_root.go b/x/rootupdater/keeper/msg_server_update_root.go new file mode 100644 index 00000000..d8e78940 --- /dev/null +++ b/x/rootupdater/keeper/msg_server_update_root.go @@ -0,0 +1,18 @@ +package keeper + +import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +func (m msgServer) UpdateRoot(goctx context.Context, req *types.MsgUpdateRoot) (*types.MsgUpdateRootResponse, error) { + ctx := sdk.UnwrapSDKContext(goctx) + params := m.GetParams(ctx) + + params.Root = req.Root + + m.SetParams(ctx, params) + + return &types.MsgUpdateRootResponse{}, nil +} diff --git a/x/rootupdater/keeper/params.go b/x/rootupdater/keeper/params.go new file mode 100644 index 00000000..0a5bbb04 --- /dev/null +++ b/x/rootupdater/keeper/params.go @@ -0,0 +1,29 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + + b := store.Get(types.KeyPrefix(types.ParamsKey)) + if b == nil { + return types.DefaultParams() + } + + k.cdc.MustUnmarshal(b, ¶ms) + return params +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + if err := params.Validate(); err != nil { + panic("failed to set params: " + err.Error()) + } + + b := k.cdc.MustMarshal(¶ms) + ctx.KVStore(k.storeKey).Set(types.KeyPrefix(types.ParamsKey), b) +} diff --git a/x/rootupdater/keeper/query.go b/x/rootupdater/keeper/query.go new file mode 100644 index 00000000..8fe66cb0 --- /dev/null +++ b/x/rootupdater/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/rootupdater/keeper/query_params.go b/x/rootupdater/keeper/query_params.go new file mode 100644 index 00000000..d73dc71b --- /dev/null +++ b/x/rootupdater/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rootupdater/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/rootupdater/module.go b/x/rootupdater/module.go new file mode 100644 index 00000000..10c50dea --- /dev/null +++ b/x/rootupdater/module.go @@ -0,0 +1,155 @@ +package rootupdater + +import ( + "context" + "encoding/json" + "fmt" + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/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/rarimo/rarimo-core/x/rootupdater/client/cli" + "github.com/rarimo/rarimo-core/x/rootupdater/keeper" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +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)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Deprecated: use RegisterServices +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// Deprecated: use RegisterServices +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// Deprecated: use RegisterServices +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil +} + +// 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(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the 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) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/rootupdater/module_simulation.go b/x/rootupdater/module_simulation.go new file mode 100644 index 00000000..8629bacd --- /dev/null +++ b/x/rootupdater/module_simulation.go @@ -0,0 +1,65 @@ +package rootupdater + +import ( + "math/rand" + + "github.com/rarimo/rarimo-core/testutil/sample" + rootupdatersimulation "github.com/rarimo/rarimo-core/x/rootupdater/simulation" + "github.com/rarimo/rarimo-core/x/rootupdater/types" + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = rootupdatersimulation.FindAccount + _ = simappparams.StakePerAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace +) + +const ( + // this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + rootupdaterGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&rootupdaterGenesis) +} + +// ProposalContents doesn't return any content functions for governance proposals +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized param changes for the simulator +func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + + return []simtypes.ParamChange{ + } +} + +// RegisterStoreDecoder registers a decoder +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} diff --git a/x/rootupdater/pkg/state/state.go b/x/rootupdater/pkg/state/state.go new file mode 100644 index 00000000..7db05cb9 --- /dev/null +++ b/x/rootupdater/pkg/state/state.go @@ -0,0 +1,1517 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package state + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// SparseMerkleTreeNode is an auto generated low-level Go binding around an user-defined struct. +type SparseMerkleTreeNode struct { + NodeType uint8 + ChildLeft uint64 + ChildRight uint64 + NodeHash [32]byte + Key [32]byte + Value [32]byte +} + +// SparseMerkleTreeProof is an auto generated low-level Go binding around an user-defined struct. +type SparseMerkleTreeProof struct { + Root [32]byte + Siblings [][32]byte + Existence bool + Key [32]byte + Value [32]byte + AuxExistence bool + AuxKey [32]byte + AuxValue [32]byte +} + +// PoseidonSMTMetaData contains all meta data concerning the PoseidonSMT contract. +var PoseidonSMTMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"root\",\"type\":\"bytes32\"}],\"name\":\"RootUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAGIC_ID\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"P\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROOT_VALIDITY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signer_\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"chainName_\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"stateKeeper_\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"treeHeight_\",\"type\":\"uint256\"}],\"name\":\"__PoseidonSMT_init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"keyOfElement_\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"element_\",\"type\":\"bytes32\"}],\"name\":\"add\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"chainName\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"newSignerPubKey_\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"signature_\",\"type\":\"bytes\"}],\"name\":\"changeSigner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"key_\",\"type\":\"bytes32\"}],\"name\":\"getNodeByKey\",\"outputs\":[{\"components\":[{\"internalType\":\"enumSparseMerkleTree.NodeType\",\"name\":\"nodeType\",\"type\":\"uint8\"},{\"internalType\":\"uint64\",\"name\":\"childLeft\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"childRight\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"nodeHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"value\",\"type\":\"bytes32\"}],\"internalType\":\"structSparseMerkleTree.Node\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"methodId_\",\"type\":\"uint8\"}],\"name\":\"getNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"key_\",\"type\":\"bytes32\"}],\"name\":\"getProof\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"root\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"},{\"internalType\":\"bool\",\"name\":\"existence\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"value\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"auxExistence\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"auxKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"auxValue\",\"type\":\"bytes32\"}],\"internalType\":\"structSparseMerkleTree.Proof\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"root_\",\"type\":\"bytes32\"}],\"name\":\"isRootLatest\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"root_\",\"type\":\"bytes32\"}],\"name\":\"isRootValid\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proxiableUUID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"keyOfElement_\",\"type\":\"bytes32\"}],\"name\":\"remove\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"signer\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stateKeeper\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"keyOfElement_\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"newElement_\",\"type\":\"bytes32\"}],\"name\":\"update\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"proof_\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"data_\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCallWithProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"proof_\",\"type\":\"bytes\"}],\"name\":\"upgradeToWithProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// PoseidonSMTABI is the input ABI used to generate the binding from. +// Deprecated: Use PoseidonSMTMetaData.ABI instead. +var PoseidonSMTABI = PoseidonSMTMetaData.ABI + +// PoseidonSMT is an auto generated Go binding around an Ethereum contract. +type PoseidonSMT struct { + PoseidonSMTCaller // Read-only binding to the contract + PoseidonSMTTransactor // Write-only binding to the contract + PoseidonSMTFilterer // Log filterer for contract events +} + +// PoseidonSMTCaller is an auto generated read-only Go binding around an Ethereum contract. +type PoseidonSMTCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoseidonSMTTransactor is an auto generated write-only Go binding around an Ethereum contract. +type PoseidonSMTTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoseidonSMTFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type PoseidonSMTFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoseidonSMTSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type PoseidonSMTSession struct { + Contract *PoseidonSMT // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PoseidonSMTCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type PoseidonSMTCallerSession struct { + Contract *PoseidonSMTCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// PoseidonSMTTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type PoseidonSMTTransactorSession struct { + Contract *PoseidonSMTTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PoseidonSMTRaw is an auto generated low-level Go binding around an Ethereum contract. +type PoseidonSMTRaw struct { + Contract *PoseidonSMT // Generic contract binding to access the raw methods on +} + +// PoseidonSMTCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type PoseidonSMTCallerRaw struct { + Contract *PoseidonSMTCaller // Generic read-only contract binding to access the raw methods on +} + +// PoseidonSMTTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type PoseidonSMTTransactorRaw struct { + Contract *PoseidonSMTTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewPoseidonSMT creates a new instance of PoseidonSMT, bound to a specific deployed contract. +func NewPoseidonSMT(address common.Address, backend bind.ContractBackend) (*PoseidonSMT, error) { + contract, err := bindPoseidonSMT(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &PoseidonSMT{PoseidonSMTCaller: PoseidonSMTCaller{contract: contract}, PoseidonSMTTransactor: PoseidonSMTTransactor{contract: contract}, PoseidonSMTFilterer: PoseidonSMTFilterer{contract: contract}}, nil +} + +// NewPoseidonSMTCaller creates a new read-only instance of PoseidonSMT, bound to a specific deployed contract. +func NewPoseidonSMTCaller(address common.Address, caller bind.ContractCaller) (*PoseidonSMTCaller, error) { + contract, err := bindPoseidonSMT(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &PoseidonSMTCaller{contract: contract}, nil +} + +// NewPoseidonSMTTransactor creates a new write-only instance of PoseidonSMT, bound to a specific deployed contract. +func NewPoseidonSMTTransactor(address common.Address, transactor bind.ContractTransactor) (*PoseidonSMTTransactor, error) { + contract, err := bindPoseidonSMT(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &PoseidonSMTTransactor{contract: contract}, nil +} + +// NewPoseidonSMTFilterer creates a new log filterer instance of PoseidonSMT, bound to a specific deployed contract. +func NewPoseidonSMTFilterer(address common.Address, filterer bind.ContractFilterer) (*PoseidonSMTFilterer, error) { + contract, err := bindPoseidonSMT(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &PoseidonSMTFilterer{contract: contract}, nil +} + +// bindPoseidonSMT binds a generic wrapper to an already deployed contract. +func bindPoseidonSMT(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := PoseidonSMTMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PoseidonSMT *PoseidonSMTRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PoseidonSMT.Contract.PoseidonSMTCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PoseidonSMT *PoseidonSMTRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PoseidonSMT.Contract.PoseidonSMTTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PoseidonSMT *PoseidonSMTRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PoseidonSMT.Contract.PoseidonSMTTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PoseidonSMT *PoseidonSMTCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PoseidonSMT.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PoseidonSMT *PoseidonSMTTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PoseidonSMT.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PoseidonSMT *PoseidonSMTTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PoseidonSMT.Contract.contract.Transact(opts, method, params...) +} + +// MAGICID is a free data retrieval call binding the contract method 0xdf95574a. +// +// Solidity: function MAGIC_ID() view returns(uint8) +func (_PoseidonSMT *PoseidonSMTCaller) MAGICID(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "MAGIC_ID") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// MAGICID is a free data retrieval call binding the contract method 0xdf95574a. +// +// Solidity: function MAGIC_ID() view returns(uint8) +func (_PoseidonSMT *PoseidonSMTSession) MAGICID() (uint8, error) { + return _PoseidonSMT.Contract.MAGICID(&_PoseidonSMT.CallOpts) +} + +// MAGICID is a free data retrieval call binding the contract method 0xdf95574a. +// +// Solidity: function MAGIC_ID() view returns(uint8) +func (_PoseidonSMT *PoseidonSMTCallerSession) MAGICID() (uint8, error) { + return _PoseidonSMT.Contract.MAGICID(&_PoseidonSMT.CallOpts) +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCaller) P(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "P") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTSession) P() (*big.Int, error) { + return _PoseidonSMT.Contract.P(&_PoseidonSMT.CallOpts) +} + +// P is a free data retrieval call binding the contract method 0x8b8fbd92. +// +// Solidity: function P() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCallerSession) P() (*big.Int, error) { + return _PoseidonSMT.Contract.P(&_PoseidonSMT.CallOpts) +} + +// ROOTVALIDITY is a free data retrieval call binding the contract method 0xcffe9676. +// +// Solidity: function ROOT_VALIDITY() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCaller) ROOTVALIDITY(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "ROOT_VALIDITY") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ROOTVALIDITY is a free data retrieval call binding the contract method 0xcffe9676. +// +// Solidity: function ROOT_VALIDITY() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTSession) ROOTVALIDITY() (*big.Int, error) { + return _PoseidonSMT.Contract.ROOTVALIDITY(&_PoseidonSMT.CallOpts) +} + +// ROOTVALIDITY is a free data retrieval call binding the contract method 0xcffe9676. +// +// Solidity: function ROOT_VALIDITY() view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCallerSession) ROOTVALIDITY() (*big.Int, error) { + return _PoseidonSMT.Contract.ROOTVALIDITY(&_PoseidonSMT.CallOpts) +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_PoseidonSMT *PoseidonSMTCaller) ChainName(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "chainName") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_PoseidonSMT *PoseidonSMTSession) ChainName() (string, error) { + return _PoseidonSMT.Contract.ChainName(&_PoseidonSMT.CallOpts) +} + +// ChainName is a free data retrieval call binding the contract method 0x1c93b03a. +// +// Solidity: function chainName() view returns(string) +func (_PoseidonSMT *PoseidonSMTCallerSession) ChainName() (string, error) { + return _PoseidonSMT.Contract.ChainName(&_PoseidonSMT.CallOpts) +} + +// GetNodeByKey is a free data retrieval call binding the contract method 0x083a8580. +// +// Solidity: function getNodeByKey(bytes32 key_) view returns((uint8,uint64,uint64,bytes32,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTCaller) GetNodeByKey(opts *bind.CallOpts, key_ [32]byte) (SparseMerkleTreeNode, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "getNodeByKey", key_) + + if err != nil { + return *new(SparseMerkleTreeNode), err + } + + out0 := *abi.ConvertType(out[0], new(SparseMerkleTreeNode)).(*SparseMerkleTreeNode) + + return out0, err + +} + +// GetNodeByKey is a free data retrieval call binding the contract method 0x083a8580. +// +// Solidity: function getNodeByKey(bytes32 key_) view returns((uint8,uint64,uint64,bytes32,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTSession) GetNodeByKey(key_ [32]byte) (SparseMerkleTreeNode, error) { + return _PoseidonSMT.Contract.GetNodeByKey(&_PoseidonSMT.CallOpts, key_) +} + +// GetNodeByKey is a free data retrieval call binding the contract method 0x083a8580. +// +// Solidity: function getNodeByKey(bytes32 key_) view returns((uint8,uint64,uint64,bytes32,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTCallerSession) GetNodeByKey(key_ [32]byte) (SparseMerkleTreeNode, error) { + return _PoseidonSMT.Contract.GetNodeByKey(&_PoseidonSMT.CallOpts, key_) +} + +// GetNonce is a free data retrieval call binding the contract method 0xf4fc6341. +// +// Solidity: function getNonce(uint8 methodId_) view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCaller) GetNonce(opts *bind.CallOpts, methodId_ uint8) (*big.Int, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "getNonce", methodId_) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetNonce is a free data retrieval call binding the contract method 0xf4fc6341. +// +// Solidity: function getNonce(uint8 methodId_) view returns(uint256) +func (_PoseidonSMT *PoseidonSMTSession) GetNonce(methodId_ uint8) (*big.Int, error) { + return _PoseidonSMT.Contract.GetNonce(&_PoseidonSMT.CallOpts, methodId_) +} + +// GetNonce is a free data retrieval call binding the contract method 0xf4fc6341. +// +// Solidity: function getNonce(uint8 methodId_) view returns(uint256) +func (_PoseidonSMT *PoseidonSMTCallerSession) GetNonce(methodId_ uint8) (*big.Int, error) { + return _PoseidonSMT.Contract.GetNonce(&_PoseidonSMT.CallOpts, methodId_) +} + +// GetProof is a free data retrieval call binding the contract method 0x1b80bb3a. +// +// Solidity: function getProof(bytes32 key_) view returns((bytes32,bytes32[],bool,bytes32,bytes32,bool,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTCaller) GetProof(opts *bind.CallOpts, key_ [32]byte) (SparseMerkleTreeProof, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "getProof", key_) + + if err != nil { + return *new(SparseMerkleTreeProof), err + } + + out0 := *abi.ConvertType(out[0], new(SparseMerkleTreeProof)).(*SparseMerkleTreeProof) + + return out0, err + +} + +// GetProof is a free data retrieval call binding the contract method 0x1b80bb3a. +// +// Solidity: function getProof(bytes32 key_) view returns((bytes32,bytes32[],bool,bytes32,bytes32,bool,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTSession) GetProof(key_ [32]byte) (SparseMerkleTreeProof, error) { + return _PoseidonSMT.Contract.GetProof(&_PoseidonSMT.CallOpts, key_) +} + +// GetProof is a free data retrieval call binding the contract method 0x1b80bb3a. +// +// Solidity: function getProof(bytes32 key_) view returns((bytes32,bytes32[],bool,bytes32,bytes32,bool,bytes32,bytes32)) +func (_PoseidonSMT *PoseidonSMTCallerSession) GetProof(key_ [32]byte) (SparseMerkleTreeProof, error) { + return _PoseidonSMT.Contract.GetProof(&_PoseidonSMT.CallOpts, key_) +} + +// GetRoot is a free data retrieval call binding the contract method 0x5ca1e165. +// +// Solidity: function getRoot() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTCaller) GetRoot(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "getRoot") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetRoot is a free data retrieval call binding the contract method 0x5ca1e165. +// +// Solidity: function getRoot() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTSession) GetRoot() ([32]byte, error) { + return _PoseidonSMT.Contract.GetRoot(&_PoseidonSMT.CallOpts) +} + +// GetRoot is a free data retrieval call binding the contract method 0x5ca1e165. +// +// Solidity: function getRoot() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTCallerSession) GetRoot() ([32]byte, error) { + return _PoseidonSMT.Contract.GetRoot(&_PoseidonSMT.CallOpts) +} + +// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. +// +// Solidity: function implementation() view returns(address) +func (_PoseidonSMT *PoseidonSMTCaller) Implementation(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "implementation") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. +// +// Solidity: function implementation() view returns(address) +func (_PoseidonSMT *PoseidonSMTSession) Implementation() (common.Address, error) { + return _PoseidonSMT.Contract.Implementation(&_PoseidonSMT.CallOpts) +} + +// Implementation is a free data retrieval call binding the contract method 0x5c60da1b. +// +// Solidity: function implementation() view returns(address) +func (_PoseidonSMT *PoseidonSMTCallerSession) Implementation() (common.Address, error) { + return _PoseidonSMT.Contract.Implementation(&_PoseidonSMT.CallOpts) +} + +// IsRootLatest is a free data retrieval call binding the contract method 0x8492307f. +// +// Solidity: function isRootLatest(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTCaller) IsRootLatest(opts *bind.CallOpts, root_ [32]byte) (bool, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "isRootLatest", root_) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsRootLatest is a free data retrieval call binding the contract method 0x8492307f. +// +// Solidity: function isRootLatest(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTSession) IsRootLatest(root_ [32]byte) (bool, error) { + return _PoseidonSMT.Contract.IsRootLatest(&_PoseidonSMT.CallOpts, root_) +} + +// IsRootLatest is a free data retrieval call binding the contract method 0x8492307f. +// +// Solidity: function isRootLatest(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTCallerSession) IsRootLatest(root_ [32]byte) (bool, error) { + return _PoseidonSMT.Contract.IsRootLatest(&_PoseidonSMT.CallOpts, root_) +} + +// IsRootValid is a free data retrieval call binding the contract method 0x30ef41b4. +// +// Solidity: function isRootValid(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTCaller) IsRootValid(opts *bind.CallOpts, root_ [32]byte) (bool, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "isRootValid", root_) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsRootValid is a free data retrieval call binding the contract method 0x30ef41b4. +// +// Solidity: function isRootValid(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTSession) IsRootValid(root_ [32]byte) (bool, error) { + return _PoseidonSMT.Contract.IsRootValid(&_PoseidonSMT.CallOpts, root_) +} + +// IsRootValid is a free data retrieval call binding the contract method 0x30ef41b4. +// +// Solidity: function isRootValid(bytes32 root_) view returns(bool) +func (_PoseidonSMT *PoseidonSMTCallerSession) IsRootValid(root_ [32]byte) (bool, error) { + return _PoseidonSMT.Contract.IsRootValid(&_PoseidonSMT.CallOpts, root_) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTCaller) ProxiableUUID(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "proxiableUUID") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTSession) ProxiableUUID() ([32]byte, error) { + return _PoseidonSMT.Contract.ProxiableUUID(&_PoseidonSMT.CallOpts) +} + +// ProxiableUUID is a free data retrieval call binding the contract method 0x52d1902d. +// +// Solidity: function proxiableUUID() view returns(bytes32) +func (_PoseidonSMT *PoseidonSMTCallerSession) ProxiableUUID() ([32]byte, error) { + return _PoseidonSMT.Contract.ProxiableUUID(&_PoseidonSMT.CallOpts) +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_PoseidonSMT *PoseidonSMTCaller) Signer(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "signer") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_PoseidonSMT *PoseidonSMTSession) Signer() (common.Address, error) { + return _PoseidonSMT.Contract.Signer(&_PoseidonSMT.CallOpts) +} + +// Signer is a free data retrieval call binding the contract method 0x238ac933. +// +// Solidity: function signer() view returns(address) +func (_PoseidonSMT *PoseidonSMTCallerSession) Signer() (common.Address, error) { + return _PoseidonSMT.Contract.Signer(&_PoseidonSMT.CallOpts) +} + +// StateKeeper is a free data retrieval call binding the contract method 0xc3e6f8f9. +// +// Solidity: function stateKeeper() view returns(address) +func (_PoseidonSMT *PoseidonSMTCaller) StateKeeper(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PoseidonSMT.contract.Call(opts, &out, "stateKeeper") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// StateKeeper is a free data retrieval call binding the contract method 0xc3e6f8f9. +// +// Solidity: function stateKeeper() view returns(address) +func (_PoseidonSMT *PoseidonSMTSession) StateKeeper() (common.Address, error) { + return _PoseidonSMT.Contract.StateKeeper(&_PoseidonSMT.CallOpts) +} + +// StateKeeper is a free data retrieval call binding the contract method 0xc3e6f8f9. +// +// Solidity: function stateKeeper() view returns(address) +func (_PoseidonSMT *PoseidonSMTCallerSession) StateKeeper() (common.Address, error) { + return _PoseidonSMT.Contract.StateKeeper(&_PoseidonSMT.CallOpts) +} + +// PoseidonSMTInit is a paid mutator transaction binding the contract method 0x897f0f79. +// +// Solidity: function __PoseidonSMT_init(address signer_, string chainName_, address stateKeeper_, uint256 treeHeight_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) PoseidonSMTInit(opts *bind.TransactOpts, signer_ common.Address, chainName_ string, stateKeeper_ common.Address, treeHeight_ *big.Int) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "__PoseidonSMT_init", signer_, chainName_, stateKeeper_, treeHeight_) +} + +// PoseidonSMTInit is a paid mutator transaction binding the contract method 0x897f0f79. +// +// Solidity: function __PoseidonSMT_init(address signer_, string chainName_, address stateKeeper_, uint256 treeHeight_) returns() +func (_PoseidonSMT *PoseidonSMTSession) PoseidonSMTInit(signer_ common.Address, chainName_ string, stateKeeper_ common.Address, treeHeight_ *big.Int) (*types.Transaction, error) { + return _PoseidonSMT.Contract.PoseidonSMTInit(&_PoseidonSMT.TransactOpts, signer_, chainName_, stateKeeper_, treeHeight_) +} + +// PoseidonSMTInit is a paid mutator transaction binding the contract method 0x897f0f79. +// +// Solidity: function __PoseidonSMT_init(address signer_, string chainName_, address stateKeeper_, uint256 treeHeight_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) PoseidonSMTInit(signer_ common.Address, chainName_ string, stateKeeper_ common.Address, treeHeight_ *big.Int) (*types.Transaction, error) { + return _PoseidonSMT.Contract.PoseidonSMTInit(&_PoseidonSMT.TransactOpts, signer_, chainName_, stateKeeper_, treeHeight_) +} + +// Add is a paid mutator transaction binding the contract method 0xd1de592a. +// +// Solidity: function add(bytes32 keyOfElement_, bytes32 element_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) Add(opts *bind.TransactOpts, keyOfElement_ [32]byte, element_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "add", keyOfElement_, element_) +} + +// Add is a paid mutator transaction binding the contract method 0xd1de592a. +// +// Solidity: function add(bytes32 keyOfElement_, bytes32 element_) returns() +func (_PoseidonSMT *PoseidonSMTSession) Add(keyOfElement_ [32]byte, element_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Add(&_PoseidonSMT.TransactOpts, keyOfElement_, element_) +} + +// Add is a paid mutator transaction binding the contract method 0xd1de592a. +// +// Solidity: function add(bytes32 keyOfElement_, bytes32 element_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) Add(keyOfElement_ [32]byte, element_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Add(&_PoseidonSMT.TransactOpts, keyOfElement_, element_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) ChangeSigner(opts *bind.TransactOpts, newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "changeSigner", newSignerPubKey_, signature_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_PoseidonSMT *PoseidonSMTSession) ChangeSigner(newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.ChangeSigner(&_PoseidonSMT.TransactOpts, newSignerPubKey_, signature_) +} + +// ChangeSigner is a paid mutator transaction binding the contract method 0x497f6959. +// +// Solidity: function changeSigner(bytes newSignerPubKey_, bytes signature_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) ChangeSigner(newSignerPubKey_ []byte, signature_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.ChangeSigner(&_PoseidonSMT.TransactOpts, newSignerPubKey_, signature_) +} + +// Remove is a paid mutator transaction binding the contract method 0x95bc2673. +// +// Solidity: function remove(bytes32 keyOfElement_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) Remove(opts *bind.TransactOpts, keyOfElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "remove", keyOfElement_) +} + +// Remove is a paid mutator transaction binding the contract method 0x95bc2673. +// +// Solidity: function remove(bytes32 keyOfElement_) returns() +func (_PoseidonSMT *PoseidonSMTSession) Remove(keyOfElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Remove(&_PoseidonSMT.TransactOpts, keyOfElement_) +} + +// Remove is a paid mutator transaction binding the contract method 0x95bc2673. +// +// Solidity: function remove(bytes32 keyOfElement_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) Remove(keyOfElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Remove(&_PoseidonSMT.TransactOpts, keyOfElement_) +} + +// Update is a paid mutator transaction binding the contract method 0x13f57c3e. +// +// Solidity: function update(bytes32 keyOfElement_, bytes32 newElement_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) Update(opts *bind.TransactOpts, keyOfElement_ [32]byte, newElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "update", keyOfElement_, newElement_) +} + +// Update is a paid mutator transaction binding the contract method 0x13f57c3e. +// +// Solidity: function update(bytes32 keyOfElement_, bytes32 newElement_) returns() +func (_PoseidonSMT *PoseidonSMTSession) Update(keyOfElement_ [32]byte, newElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Update(&_PoseidonSMT.TransactOpts, keyOfElement_, newElement_) +} + +// Update is a paid mutator transaction binding the contract method 0x13f57c3e. +// +// Solidity: function update(bytes32 keyOfElement_, bytes32 newElement_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) Update(keyOfElement_ [32]byte, newElement_ [32]byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.Update(&_PoseidonSMT.TransactOpts, keyOfElement_, newElement_) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) UpgradeTo(opts *bind.TransactOpts, newImplementation common.Address) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "upgradeTo", newImplementation) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_PoseidonSMT *PoseidonSMTSession) UpgradeTo(newImplementation common.Address) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeTo(&_PoseidonSMT.TransactOpts, newImplementation) +} + +// UpgradeTo is a paid mutator transaction binding the contract method 0x3659cfe6. +// +// Solidity: function upgradeTo(address newImplementation) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) UpgradeTo(newImplementation common.Address) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeTo(&_PoseidonSMT.TransactOpts, newImplementation) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_PoseidonSMT *PoseidonSMTTransactor) UpgradeToAndCall(opts *bind.TransactOpts, newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "upgradeToAndCall", newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_PoseidonSMT *PoseidonSMTSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToAndCall(&_PoseidonSMT.TransactOpts, newImplementation, data) +} + +// UpgradeToAndCall is a paid mutator transaction binding the contract method 0x4f1ef286. +// +// Solidity: function upgradeToAndCall(address newImplementation, bytes data) payable returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) UpgradeToAndCall(newImplementation common.Address, data []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToAndCall(&_PoseidonSMT.TransactOpts, newImplementation, data) +} + +// UpgradeToAndCallWithProof is a paid mutator transaction binding the contract method 0xbf2c6db7. +// +// Solidity: function upgradeToAndCallWithProof(address newImplementation_, bytes proof_, bytes data_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) UpgradeToAndCallWithProof(opts *bind.TransactOpts, newImplementation_ common.Address, proof_ []byte, data_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "upgradeToAndCallWithProof", newImplementation_, proof_, data_) +} + +// UpgradeToAndCallWithProof is a paid mutator transaction binding the contract method 0xbf2c6db7. +// +// Solidity: function upgradeToAndCallWithProof(address newImplementation_, bytes proof_, bytes data_) returns() +func (_PoseidonSMT *PoseidonSMTSession) UpgradeToAndCallWithProof(newImplementation_ common.Address, proof_ []byte, data_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToAndCallWithProof(&_PoseidonSMT.TransactOpts, newImplementation_, proof_, data_) +} + +// UpgradeToAndCallWithProof is a paid mutator transaction binding the contract method 0xbf2c6db7. +// +// Solidity: function upgradeToAndCallWithProof(address newImplementation_, bytes proof_, bytes data_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) UpgradeToAndCallWithProof(newImplementation_ common.Address, proof_ []byte, data_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToAndCallWithProof(&_PoseidonSMT.TransactOpts, newImplementation_, proof_, data_) +} + +// UpgradeToWithProof is a paid mutator transaction binding the contract method 0x628543ab. +// +// Solidity: function upgradeToWithProof(address newImplementation_, bytes proof_) returns() +func (_PoseidonSMT *PoseidonSMTTransactor) UpgradeToWithProof(opts *bind.TransactOpts, newImplementation_ common.Address, proof_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.contract.Transact(opts, "upgradeToWithProof", newImplementation_, proof_) +} + +// UpgradeToWithProof is a paid mutator transaction binding the contract method 0x628543ab. +// +// Solidity: function upgradeToWithProof(address newImplementation_, bytes proof_) returns() +func (_PoseidonSMT *PoseidonSMTSession) UpgradeToWithProof(newImplementation_ common.Address, proof_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToWithProof(&_PoseidonSMT.TransactOpts, newImplementation_, proof_) +} + +// UpgradeToWithProof is a paid mutator transaction binding the contract method 0x628543ab. +// +// Solidity: function upgradeToWithProof(address newImplementation_, bytes proof_) returns() +func (_PoseidonSMT *PoseidonSMTTransactorSession) UpgradeToWithProof(newImplementation_ common.Address, proof_ []byte) (*types.Transaction, error) { + return _PoseidonSMT.Contract.UpgradeToWithProof(&_PoseidonSMT.TransactOpts, newImplementation_, proof_) +} + +// PoseidonSMTAdminChangedIterator is returned from FilterAdminChanged and is used to iterate over the raw logs and unpacked data for AdminChanged events raised by the PoseidonSMT contract. +type PoseidonSMTAdminChangedIterator struct { + Event *PoseidonSMTAdminChanged // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTAdminChangedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTAdminChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTAdminChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTAdminChanged represents a AdminChanged event raised by the PoseidonSMT contract. +type PoseidonSMTAdminChanged struct { + PreviousAdmin common.Address + NewAdmin common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterAdminChanged is a free log retrieval operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterAdminChanged(opts *bind.FilterOpts) (*PoseidonSMTAdminChangedIterator, error) { + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "AdminChanged") + if err != nil { + return nil, err + } + return &PoseidonSMTAdminChangedIterator{contract: _PoseidonSMT.contract, event: "AdminChanged", logs: logs, sub: sub}, nil +} + +// WatchAdminChanged is a free log subscription operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchAdminChanged(opts *bind.WatchOpts, sink chan<- *PoseidonSMTAdminChanged) (event.Subscription, error) { + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "AdminChanged") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTAdminChanged) + if err := _PoseidonSMT.contract.UnpackLog(event, "AdminChanged", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseAdminChanged is a log parse operation binding the contract event 0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f. +// +// Solidity: event AdminChanged(address previousAdmin, address newAdmin) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseAdminChanged(log types.Log) (*PoseidonSMTAdminChanged, error) { + event := new(PoseidonSMTAdminChanged) + if err := _PoseidonSMT.contract.UnpackLog(event, "AdminChanged", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoseidonSMTBeaconUpgradedIterator is returned from FilterBeaconUpgraded and is used to iterate over the raw logs and unpacked data for BeaconUpgraded events raised by the PoseidonSMT contract. +type PoseidonSMTBeaconUpgradedIterator struct { + Event *PoseidonSMTBeaconUpgraded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTBeaconUpgradedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTBeaconUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTBeaconUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTBeaconUpgradedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTBeaconUpgradedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTBeaconUpgraded represents a BeaconUpgraded event raised by the PoseidonSMT contract. +type PoseidonSMTBeaconUpgraded struct { + Beacon common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBeaconUpgraded is a free log retrieval operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterBeaconUpgraded(opts *bind.FilterOpts, beacon []common.Address) (*PoseidonSMTBeaconUpgradedIterator, error) { + + var beaconRule []interface{} + for _, beaconItem := range beacon { + beaconRule = append(beaconRule, beaconItem) + } + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "BeaconUpgraded", beaconRule) + if err != nil { + return nil, err + } + return &PoseidonSMTBeaconUpgradedIterator{contract: _PoseidonSMT.contract, event: "BeaconUpgraded", logs: logs, sub: sub}, nil +} + +// WatchBeaconUpgraded is a free log subscription operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchBeaconUpgraded(opts *bind.WatchOpts, sink chan<- *PoseidonSMTBeaconUpgraded, beacon []common.Address) (event.Subscription, error) { + + var beaconRule []interface{} + for _, beaconItem := range beacon { + beaconRule = append(beaconRule, beaconItem) + } + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "BeaconUpgraded", beaconRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTBeaconUpgraded) + if err := _PoseidonSMT.contract.UnpackLog(event, "BeaconUpgraded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBeaconUpgraded is a log parse operation binding the contract event 0x1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e. +// +// Solidity: event BeaconUpgraded(address indexed beacon) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseBeaconUpgraded(log types.Log) (*PoseidonSMTBeaconUpgraded, error) { + event := new(PoseidonSMTBeaconUpgraded) + if err := _PoseidonSMT.contract.UnpackLog(event, "BeaconUpgraded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoseidonSMTInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the PoseidonSMT contract. +type PoseidonSMTInitializedIterator struct { + Event *PoseidonSMTInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTInitialized represents a Initialized event raised by the PoseidonSMT contract. +type PoseidonSMTInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterInitialized(opts *bind.FilterOpts) (*PoseidonSMTInitializedIterator, error) { + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &PoseidonSMTInitializedIterator{contract: _PoseidonSMT.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *PoseidonSMTInitialized) (event.Subscription, error) { + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTInitialized) + if err := _PoseidonSMT.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseInitialized(log types.Log) (*PoseidonSMTInitialized, error) { + event := new(PoseidonSMTInitialized) + if err := _PoseidonSMT.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoseidonSMTRootUpdatedIterator is returned from FilterRootUpdated and is used to iterate over the raw logs and unpacked data for RootUpdated events raised by the PoseidonSMT contract. +type PoseidonSMTRootUpdatedIterator struct { + Event *PoseidonSMTRootUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTRootUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTRootUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTRootUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTRootUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTRootUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTRootUpdated represents a RootUpdated event raised by the PoseidonSMT contract. +type PoseidonSMTRootUpdated struct { + Root [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRootUpdated is a free log retrieval operation binding the contract event 0x2cbc14f49c068133583f7cb530018af451c87c1cf1327cf2a4ff4698c4730aa4. +// +// Solidity: event RootUpdated(bytes32 root) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterRootUpdated(opts *bind.FilterOpts) (*PoseidonSMTRootUpdatedIterator, error) { + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "RootUpdated") + if err != nil { + return nil, err + } + return &PoseidonSMTRootUpdatedIterator{contract: _PoseidonSMT.contract, event: "RootUpdated", logs: logs, sub: sub}, nil +} + +// WatchRootUpdated is a free log subscription operation binding the contract event 0x2cbc14f49c068133583f7cb530018af451c87c1cf1327cf2a4ff4698c4730aa4. +// +// Solidity: event RootUpdated(bytes32 root) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchRootUpdated(opts *bind.WatchOpts, sink chan<- *PoseidonSMTRootUpdated) (event.Subscription, error) { + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "RootUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTRootUpdated) + if err := _PoseidonSMT.contract.UnpackLog(event, "RootUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRootUpdated is a log parse operation binding the contract event 0x2cbc14f49c068133583f7cb530018af451c87c1cf1327cf2a4ff4698c4730aa4. +// +// Solidity: event RootUpdated(bytes32 root) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseRootUpdated(log types.Log) (*PoseidonSMTRootUpdated, error) { + event := new(PoseidonSMTRootUpdated) + if err := _PoseidonSMT.contract.UnpackLog(event, "RootUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoseidonSMTUpgradedIterator is returned from FilterUpgraded and is used to iterate over the raw logs and unpacked data for Upgraded events raised by the PoseidonSMT contract. +type PoseidonSMTUpgradedIterator struct { + Event *PoseidonSMTUpgraded // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *PoseidonSMTUpgradedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(PoseidonSMTUpgraded) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *PoseidonSMTUpgradedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoseidonSMTUpgradedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoseidonSMTUpgraded represents a Upgraded event raised by the PoseidonSMT contract. +type PoseidonSMTUpgraded struct { + Implementation common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUpgraded is a free log retrieval operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_PoseidonSMT *PoseidonSMTFilterer) FilterUpgraded(opts *bind.FilterOpts, implementation []common.Address) (*PoseidonSMTUpgradedIterator, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _PoseidonSMT.contract.FilterLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return &PoseidonSMTUpgradedIterator{contract: _PoseidonSMT.contract, event: "Upgraded", logs: logs, sub: sub}, nil +} + +// WatchUpgraded is a free log subscription operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_PoseidonSMT *PoseidonSMTFilterer) WatchUpgraded(opts *bind.WatchOpts, sink chan<- *PoseidonSMTUpgraded, implementation []common.Address) (event.Subscription, error) { + + var implementationRule []interface{} + for _, implementationItem := range implementation { + implementationRule = append(implementationRule, implementationItem) + } + + logs, sub, err := _PoseidonSMT.contract.WatchLogs(opts, "Upgraded", implementationRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(PoseidonSMTUpgraded) + if err := _PoseidonSMT.contract.UnpackLog(event, "Upgraded", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUpgraded is a log parse operation binding the contract event 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b. +// +// Solidity: event Upgraded(address indexed implementation) +func (_PoseidonSMT *PoseidonSMTFilterer) ParseUpgraded(log types.Log) (*PoseidonSMTUpgraded, error) { + event := new(PoseidonSMTUpgraded) + if err := _PoseidonSMT.contract.UnpackLog(event, "Upgraded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/x/rootupdater/simulation/helpers.go b/x/rootupdater/simulation/helpers.go new file mode 100644 index 00000000..92c437c0 --- /dev/null +++ b/x/rootupdater/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/rootupdater/types/codec.go b/x/rootupdater/types/codec.go new file mode 100644 index 00000000..09dd9f18 --- /dev/null +++ b/x/rootupdater/types/codec.go @@ -0,0 +1,22 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/rootupdater/types/errors.go b/x/rootupdater/types/errors.go new file mode 100644 index 00000000..0d126001 --- /dev/null +++ b/x/rootupdater/types/errors.go @@ -0,0 +1,13 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/rootupdater module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + +) diff --git a/x/rootupdater/types/expected_keepers.go b/x/rootupdater/types/expected_keepers.go new file mode 100644 index 00000000..bf29a07f --- /dev/null +++ b/x/rootupdater/types/expected_keepers.go @@ -0,0 +1,10 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/rarimo/rarimo-core/x/rarimocore/types" +) + +type RarimocoreKeeper interface { + CreateRootUpdateOperation(ctx sdk.Context, creator string, update *types.RootUpdate) (string, error) +} diff --git a/x/rootupdater/types/genesis.go b/x/rootupdater/types/genesis.go new file mode 100644 index 00000000..c41be074 --- /dev/null +++ b/x/rootupdater/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/rootupdater/types/genesis.pb.go b/x/rootupdater/types/genesis.pb.go new file mode 100644 index 00000000..5168d617 --- /dev/null +++ b/x/rootupdater/types/genesis.pb.go @@ -0,0 +1,321 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rootupdater/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the rootupdater module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +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_9aceb595c789c725, []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 Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "rarimo.rootupdater.GenesisState") +} + +func init() { proto.RegisterFile("rootupdater/genesis.proto", fileDescriptor_9aceb595c789c725) } + +var fileDescriptor_9aceb595c789c725 = []byte{ + // 194 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0xca, 0xcf, 0x2f, + 0x29, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2a, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x43, 0x52, + 0x21, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x96, 0xd6, 0x07, 0xb1, 0x20, 0x2a, 0xa5, 0x24, 0x90, + 0x0d, 0x29, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x9a, 0xa1, 0xe4, 0xc1, 0xc5, 0xe3, 0x0e, 0x31, 0x34, + 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x82, 0x8b, 0x0d, 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, + 0x6d, 0x24, 0xa5, 0x87, 0x69, 0x89, 0x5e, 0x00, 0x58, 0x85, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, + 0x41, 0x50, 0xf5, 0x4e, 0xde, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, + 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, + 0x98, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x31, 0x0d, 0x4a, 0xe9, + 0x26, 0xe7, 0x17, 0xa5, 0xea, 0x57, 0xe8, 0x23, 0xbb, 0xae, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, + 0x0d, 0xec, 0x3a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x0c, 0x84, 0x8e, 0xfe, 0x00, + 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 + { + 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 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 + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + 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 err := m.Params.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 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/rootupdater/types/genesis_test.go b/x/rootupdater/types/genesis_test.go new file mode 100644 index 00000000..f9ef03ee --- /dev/null +++ b/x/rootupdater/types/genesis_test.go @@ -0,0 +1,40 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/rarimo/rarimo-core/x/rootupdater/types" +) + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + } { + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} \ No newline at end of file diff --git a/x/rootupdater/types/keys.go b/x/rootupdater/types/keys.go new file mode 100644 index 00000000..eceb4eb1 --- /dev/null +++ b/x/rootupdater/types/keys.go @@ -0,0 +1,22 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "rootupdater" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_rootupdater" + + // ParamsKey defines the store key for module params entry + ParamsKey = "params" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/rootupdater/types/message_root_update.go b/x/rootupdater/types/message_root_update.go new file mode 100644 index 00000000..6c6b9794 --- /dev/null +++ b/x/rootupdater/types/message_root_update.go @@ -0,0 +1,55 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + TypeMsgUpdateRoot = "update_root" +) + +var _ sdk.Msg = &MsgUpdateRoot{} + +func NewMsgUpdateRoot( + creator string, + address string, +) *MsgUpdateRoot { + return &MsgUpdateRoot{ + Creator: creator, + Root: address, + } +} + +func (msg *MsgUpdateRoot) Route() string { + return RouterKey +} + +func (msg *MsgUpdateRoot) Type() string { + return TypeMsgUpdateRoot +} + +func (msg *MsgUpdateRoot) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateRoot) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateRoot) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if msg.Root == "" { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid root") + } + return nil +} diff --git a/x/rootupdater/types/params.go b/x/rootupdater/types/params.go new file mode 100644 index 00000000..4f3215e3 --- /dev/null +++ b/x/rootupdater/types/params.go @@ -0,0 +1,32 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} diff --git a/x/rootupdater/types/params.pb.go b/x/rootupdater/types/params.pb.go new file mode 100644 index 00000000..e7caae72 --- /dev/null +++ b/x/rootupdater/types/params.pb.go @@ -0,0 +1,526 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rootupdater/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + Root string `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` + LastRoot string `protobuf:"bytes,3,opt,name=last_root,json=lastRoot,proto3" json:"last_root,omitempty"` + Index string `protobuf:"bytes,4,opt,name=index,proto3" json:"index,omitempty"` + EventName string `protobuf:"bytes,5,opt,name=event_name,json=eventName,proto3" json:"event_name,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_31e4e5f76db9f10e, []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) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *Params) GetRoot() string { + if m != nil { + return m.Root + } + return "" +} + +func (m *Params) GetLastRoot() string { + if m != nil { + return m.LastRoot + } + return "" +} + +func (m *Params) GetIndex() string { + if m != nil { + return m.Index + } + return "" +} + +func (m *Params) GetEventName() string { + if m != nil { + return m.EventName + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "rarimo.rootupdater.Params") +} + +func init() { proto.RegisterFile("rootupdater/params.proto", fileDescriptor_31e4e5f76db9f10e) } + +var fileDescriptor_31e4e5f76db9f10e = []byte{ + // 247 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4a, 0xc4, 0x30, + 0x10, 0x86, 0x1b, 0xdd, 0x5d, 0x6c, 0x2e, 0x4a, 0xd8, 0x43, 0x50, 0x0c, 0xe2, 0x49, 0x0f, 0x36, + 0x88, 0x4f, 0xa0, 0x57, 0x41, 0x64, 0x8f, 0x5e, 0x4a, 0xb6, 0x0d, 0xb5, 0x60, 0x3a, 0x65, 0x32, + 0x2b, 0xeb, 0x5b, 0x78, 0xf5, 0x8d, 0x3c, 0xee, 0xd1, 0xa3, 0xb4, 0x2f, 0x22, 0x9d, 0xba, 0xd0, + 0x53, 0x26, 0xdf, 0xf7, 0x27, 0xf0, 0x8f, 0xd4, 0x08, 0x40, 0x9b, 0xb6, 0x74, 0xe4, 0xd1, 0xb6, + 0x0e, 0x5d, 0x88, 0x59, 0x8b, 0x40, 0xa0, 0x14, 0x3a, 0xac, 0x03, 0x64, 0x93, 0xc0, 0xe9, 0xb2, + 0x82, 0x0a, 0x58, 0xdb, 0x61, 0x1a, 0x93, 0x97, 0x5f, 0x42, 0x2e, 0x9e, 0xf9, 0xa9, 0xba, 0x96, + 0x27, 0x05, 0x34, 0x84, 0xae, 0xa0, 0xdc, 0x95, 0x25, 0xfa, 0x18, 0xb5, 0xb8, 0x10, 0x57, 0xe9, + 0xea, 0x78, 0xcf, 0xef, 0x47, 0xac, 0x94, 0x9c, 0x0d, 0x5f, 0xeb, 0x03, 0xd6, 0x3c, 0xab, 0x33, + 0x99, 0xbe, 0xb9, 0x48, 0x39, 0x8b, 0x43, 0x16, 0x47, 0x03, 0x58, 0x0d, 0x72, 0x29, 0xe7, 0x75, + 0x53, 0xfa, 0xad, 0x9e, 0xb1, 0x18, 0x2f, 0xea, 0x5c, 0x4a, 0xff, 0xee, 0x1b, 0xca, 0x1b, 0x17, + 0xbc, 0x9e, 0xb3, 0x4a, 0x99, 0x3c, 0xb9, 0xe0, 0x1f, 0x1e, 0xbf, 0x3b, 0x23, 0x76, 0x9d, 0x11, + 0xbf, 0x9d, 0x11, 0x9f, 0xbd, 0x49, 0x76, 0xbd, 0x49, 0x7e, 0x7a, 0x93, 0xbc, 0xdc, 0x56, 0x35, + 0xbd, 0x6e, 0xd6, 0x59, 0x01, 0xc1, 0x8e, 0x55, 0xff, 0x8f, 0x9b, 0x02, 0xd0, 0xdb, 0xad, 0x9d, + 0x6e, 0x86, 0x3e, 0x5a, 0x1f, 0xd7, 0x0b, 0xee, 0x7b, 0xf7, 0x17, 0x00, 0x00, 0xff, 0xff, 0x07, + 0x19, 0xc0, 0x2c, 0x35, 0x01, 0x00, 0x00, +} + +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 len(m.EventName) > 0 { + i -= len(m.EventName) + copy(dAtA[i:], m.EventName) + i = encodeVarintParams(dAtA, i, uint64(len(m.EventName))) + i-- + dAtA[i] = 0x2a + } + if len(m.Index) > 0 { + i -= len(m.Index) + copy(dAtA[i:], m.Index) + i = encodeVarintParams(dAtA, i, uint64(len(m.Index))) + i-- + dAtA[i] = 0x22 + } + if len(m.LastRoot) > 0 { + i -= len(m.LastRoot) + copy(dAtA[i:], m.LastRoot) + i = encodeVarintParams(dAtA, i, uint64(len(m.LastRoot))) + i-- + dAtA[i] = 0x1a + } + if len(m.Root) > 0 { + i -= len(m.Root) + copy(dAtA[i:], m.Root) + i = encodeVarintParams(dAtA, i, uint64(len(m.Root))) + i-- + dAtA[i] = 0x12 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.ContractAddress))) + 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.ContractAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.Root) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.LastRoot) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.Index) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.EventName) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + 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 ContractAddress", 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.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", 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.Root = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastRoot", 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.LastRoot = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Index = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + 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 + 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/rootupdater/types/query.pb.go b/x/rootupdater/types/query.pb.go new file mode 100644 index 00000000..cb4dba15 --- /dev/null +++ b/x/rootupdater/types/query.pb.go @@ -0,0 +1,537 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rootupdater/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/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 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_3408f22fd1bb339b, []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 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_3408f22fd1bb339b, []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{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "rarimo.rootupdater.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "rarimo.rootupdater.QueryParamsResponse") +} + +func init() { proto.RegisterFile("rootupdater/query.proto", fileDescriptor_3408f22fd1bb339b) } + +var fileDescriptor_3408f22fd1bb339b = []byte{ + // 300 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0xb1, 0x4b, 0x03, 0x31, + 0x18, 0xc5, 0x2f, 0xa2, 0x1d, 0xe2, 0x16, 0x0b, 0x96, 0x43, 0xa2, 0xdc, 0x50, 0x8b, 0x60, 0xc2, + 0xd5, 0xc5, 0xb9, 0xab, 0x83, 0xda, 0xd1, 0x2d, 0x77, 0x86, 0x78, 0xe0, 0xdd, 0x97, 0x26, 0x39, + 0xb1, 0xab, 0x9b, 0x9b, 0xd0, 0x7f, 0xaa, 0x63, 0xc1, 0xc5, 0x49, 0xe4, 0xce, 0x3f, 0x44, 0x7a, + 0xb9, 0xa1, 0xe5, 0x0a, 0x4e, 0x09, 0xdf, 0xfb, 0xbd, 0x97, 0x97, 0x0f, 0x1f, 0x1b, 0x00, 0x57, + 0xea, 0x47, 0xe1, 0xa4, 0xe1, 0xb3, 0x52, 0x9a, 0x39, 0xd3, 0x06, 0x1c, 0x10, 0x62, 0x84, 0xc9, + 0x72, 0x60, 0x1b, 0x7a, 0xd8, 0x57, 0xa0, 0xa0, 0x91, 0xf9, 0xfa, 0xe6, 0xc9, 0xf0, 0x44, 0x01, + 0xa8, 0x67, 0xc9, 0x85, 0xce, 0xb8, 0x28, 0x0a, 0x70, 0xc2, 0x65, 0x50, 0xd8, 0x56, 0xbd, 0x48, + 0xc1, 0xe6, 0x60, 0x79, 0x22, 0xac, 0xf4, 0x0f, 0xf0, 0x97, 0x38, 0x91, 0x4e, 0xc4, 0x5c, 0x0b, + 0x95, 0x15, 0x0d, 0xdc, 0xb2, 0x83, 0xcd, 0x32, 0x5a, 0x18, 0x91, 0xb7, 0x29, 0x51, 0x1f, 0x93, + 0xfb, 0xb5, 0xf7, 0xae, 0x19, 0x4e, 0xe5, 0xac, 0x94, 0xd6, 0x45, 0xb7, 0xf8, 0x68, 0x6b, 0x6a, + 0x35, 0x14, 0x56, 0x92, 0x6b, 0xdc, 0xf3, 0xe6, 0x01, 0x3a, 0x43, 0xa3, 0xc3, 0x71, 0xc8, 0xba, + 0x7f, 0x61, 0xde, 0x33, 0xd9, 0x5f, 0x7e, 0x9f, 0x06, 0xd3, 0x96, 0x1f, 0x2f, 0x10, 0x3e, 0x68, + 0x12, 0xc9, 0x3b, 0xc2, 0x3d, 0x8f, 0x90, 0xe1, 0x2e, 0x7b, 0xb7, 0x4d, 0x78, 0xfe, 0x2f, 0xe7, + 0xfb, 0x45, 0xec, 0xed, 0xf3, 0x77, 0xb1, 0x37, 0x22, 0x43, 0xee, 0x0d, 0xed, 0x71, 0x99, 0x82, + 0x91, 0xbc, 0xbb, 0x82, 0xc9, 0xcd, 0xb2, 0xa2, 0x68, 0x55, 0x51, 0xf4, 0x53, 0x51, 0xf4, 0x51, + 0xd3, 0x60, 0x55, 0xd3, 0xe0, 0xab, 0xa6, 0xc1, 0x43, 0xac, 0x32, 0xf7, 0x54, 0x26, 0x2c, 0x85, + 0x7c, 0x57, 0xd6, 0xeb, 0x56, 0x9a, 0x9b, 0x6b, 0x69, 0x93, 0x5e, 0xb3, 0xd0, 0xab, 0xbf, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xb0, 0x88, 0x26, 0x94, 0xf9, 0x01, 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 { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, 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, "/rarimo.rootupdater.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, 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 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: "/rarimo.rootupdater.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "rarimo.rootupdater.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "rootupdater/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 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 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 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/rootupdater/types/query.pb.gw.go b/x/rootupdater/types/query.pb.gw.go new file mode 100644 index 00000000..3ae4ed08 --- /dev/null +++ b/x/rootupdater/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: rootupdater/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 + +} + +// 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()...) + + }) + + 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()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"rarimo", "rarimo-core", "rootupdater", "params"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/rootupdater/types/tx.pb.go b/x/rootupdater/types/tx.pb.go new file mode 100644 index 00000000..48229bb7 --- /dev/null +++ b/x/rootupdater/types/tx.pb.go @@ -0,0 +1,572 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rootupdater/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/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 + +type MsgUpdateRoot struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Root string `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` +} + +func (m *MsgUpdateRoot) Reset() { *m = MsgUpdateRoot{} } +func (m *MsgUpdateRoot) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateRoot) ProtoMessage() {} +func (*MsgUpdateRoot) Descriptor() ([]byte, []int) { + return fileDescriptor_72679a1b23c83bcf, []int{0} +} +func (m *MsgUpdateRoot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateRoot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateRoot.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 *MsgUpdateRoot) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateRoot.Merge(m, src) +} +func (m *MsgUpdateRoot) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateRoot) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateRoot.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateRoot proto.InternalMessageInfo + +func (m *MsgUpdateRoot) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateRoot) GetRoot() string { + if m != nil { + return m.Root + } + return "" +} + +type MsgUpdateRootResponse struct { +} + +func (m *MsgUpdateRootResponse) Reset() { *m = MsgUpdateRootResponse{} } +func (m *MsgUpdateRootResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateRootResponse) ProtoMessage() {} +func (*MsgUpdateRootResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_72679a1b23c83bcf, []int{1} +} +func (m *MsgUpdateRootResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateRootResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateRootResponse.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 *MsgUpdateRootResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateRootResponse.Merge(m, src) +} +func (m *MsgUpdateRootResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateRootResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateRootResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateRootResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateRoot)(nil), "rarimo.rootupdater.MsgUpdateRoot") + proto.RegisterType((*MsgUpdateRootResponse)(nil), "rarimo.rootupdater.MsgUpdateRootResponse") +} + +func init() { proto.RegisterFile("rootupdater/tx.proto", fileDescriptor_72679a1b23c83bcf) } + +var fileDescriptor_72679a1b23c83bcf = []byte{ + // 208 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0xca, 0xcf, 0x2f, + 0x29, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x2d, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x2a, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x43, 0x92, 0x54, 0xb2, 0xe5, 0xe2, 0xf5, + 0x2d, 0x4e, 0x0f, 0x05, 0xf3, 0x82, 0xf2, 0xf3, 0x4b, 0x84, 0x24, 0xb8, 0xd8, 0x93, 0x8b, 0x52, + 0x13, 0x4b, 0xf2, 0x8b, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x21, 0x21, 0x2e, + 0x16, 0x90, 0x4e, 0x09, 0x26, 0xb0, 0x30, 0x98, 0xad, 0x24, 0xce, 0x25, 0x8a, 0xa2, 0x3d, 0x28, + 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0x28, 0x91, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x8a, + 0x8b, 0x0b, 0xc9, 0x6c, 0x45, 0x3d, 0x4c, 0x17, 0xe8, 0xa1, 0xe8, 0x97, 0xd2, 0x24, 0xa8, 0x04, + 0x66, 0x85, 0x93, 0xf7, 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, 0x19, 0xa6, + 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x8c, 0x83, 0x52, 0xba, 0xc9, + 0xf9, 0x45, 0xa9, 0xfa, 0x15, 0xfa, 0x28, 0xc1, 0x53, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, + 0x22, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x83, 0x19, 0x2d, 0x21, 0x3a, 0x01, 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 { + UpdateRoot(ctx context.Context, in *MsgUpdateRoot, opts ...grpc.CallOption) (*MsgUpdateRootResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateRoot(ctx context.Context, in *MsgUpdateRoot, opts ...grpc.CallOption) (*MsgUpdateRootResponse, error) { + out := new(MsgUpdateRootResponse) + err := c.cc.Invoke(ctx, "/rarimo.rootupdater.Msg/UpdateRoot", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + UpdateRoot(context.Context, *MsgUpdateRoot) (*MsgUpdateRootResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateRoot(ctx context.Context, req *MsgUpdateRoot) (*MsgUpdateRootResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateRoot not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateRoot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateRoot) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateRoot(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rarimo.rootupdater.Msg/UpdateRoot", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateRoot(ctx, req.(*MsgUpdateRoot)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "rarimo.rootupdater.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateRoot", + Handler: _Msg_UpdateRoot_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "rootupdater/tx.proto", +} + +func (m *MsgUpdateRoot) 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 *MsgUpdateRoot) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateRoot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Root) > 0 { + i -= len(m.Root) + copy(dAtA[i:], m.Root) + i = encodeVarintTx(dAtA, i, uint64(len(m.Root))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateRootResponse) 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 *MsgUpdateRootResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateRootResponse) 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 *MsgUpdateRoot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Root) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateRootResponse) 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 *MsgUpdateRoot) 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: MsgUpdateRoot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateRoot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", 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.Root = 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 *MsgUpdateRootResponse) 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: MsgUpdateRootResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateRootResponse: 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/rootupdater/types/types.go b/x/rootupdater/types/types.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/rootupdater/types/types.go @@ -0,0 +1 @@ +package types From 38e05cedbecdc1a834a1a8e2819919e58615c41b Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Tue, 13 Aug 2024 15:40:34 +0300 Subject: [PATCH 04/14] clean up app.go --- app/app.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/app.go b/app/app.go index 771550aa..a7d51abd 100644 --- a/app/app.go +++ b/app/app.go @@ -210,11 +210,7 @@ var ( identitymodule.AppModuleBasic{}, cscalistmodule.AppModuleBasic{}, rootupdatermodule.AppModuleBasic{}, - rootupdatermodule.AppModuleBasic{}, - rootupdatermodule.AppModuleBasic{}, - rootupdatermodule.AppModuleBasic{}, - rootupdatermodule.AppModuleBasic{}, - rootupdatermodule.AppModuleBasic{}, + // this line is used by starport scaffolding # stargate/app/moduleBasic ) From 5dbfb818a04495f8a4aa79425babbe92d6797eb8 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Wed, 14 Aug 2024 15:20:30 +0300 Subject: [PATCH 05/14] main fixes --- ethermint/utils/events.go | 27 + ...te.proto => op_passport_root_update.proto} | 6 +- proto/rarimocore/operation.proto | 2 +- proto/rootupdater/params.proto | 5 +- proto/rootupdater/tx.proto | 12 +- x/identity/keeper/keeper.go | 23 +- .../operation/op_passport_root_update.go | 26 + .../crypto/operation/op_root_update.go | 25 - x/rarimocore/crypto/pkg/content/main.go | 10 +- ...t_update.go => op_passport_root_update.go} | 15 +- x/rarimocore/keeper/keeper.go | 6 +- .../keeper/msg_server_confirmation.go | 6 + x/rarimocore/types/op_root_update.pb.go | 404 -------------- x/rarimocore/types/operation.pb.go | 76 +-- x/rootupdater/client/cli/tx.go | 1 - x/rootupdater/client/cli/tx_update_root.go | 38 -- x/rootupdater/handler.go | 29 - x/rootupdater/keeper/abci.go | 10 +- x/rootupdater/keeper/keeper.go | 25 +- .../keeper/msg_server_update_root.go | 18 - x/rootupdater/module.go | 2 +- x/rootupdater/types/expected_keepers.go | 2 +- x/rootupdater/types/message_root_update.go | 55 -- x/rootupdater/types/params.pb.go | 117 ++-- x/rootupdater/types/tx.pb.go | 512 +----------------- 25 files changed, 224 insertions(+), 1228 deletions(-) create mode 100644 ethermint/utils/events.go rename proto/rarimocore/{op_root_update.proto => op_passport_root_update.proto} (67%) create mode 100644 x/rarimocore/crypto/operation/op_passport_root_update.go delete mode 100644 x/rarimocore/crypto/operation/op_root_update.go rename x/rarimocore/crypto/pkg/{op_root_update.go => op_passport_root_update.go} (53%) delete mode 100644 x/rarimocore/types/op_root_update.pb.go delete mode 100644 x/rootupdater/client/cli/tx_update_root.go delete mode 100644 x/rootupdater/handler.go delete mode 100644 x/rootupdater/keeper/msg_server_update_root.go delete mode 100644 x/rootupdater/types/message_root_update.go diff --git a/ethermint/utils/events.go b/ethermint/utils/events.go new file mode 100644 index 00000000..325f34af --- /dev/null +++ b/ethermint/utils/events.go @@ -0,0 +1,27 @@ +package utils + +import ( + "fmt" + "github.com/ethereum/go-ethereum/accounts/abi" + ethtypes "github.com/ethereum/go-ethereum/core/types" +) + +// unpackLog copy-pasted from logic in generated s-c bindings. +func UnpackLog(contractAbi abi.ABI, out interface{}, event string, log *ethtypes.Log) error { + if log.Topics[0] != contractAbi.Events[event].ID { + return fmt.Errorf("event signature mismatch") + } + + if len(log.Data) > 0 { + if err := contractAbi.UnpackIntoInterface(out, event, log.Data); err != nil { + return err + } + } + var indexed abi.Arguments + for _, arg := range contractAbi.Events[event].Inputs { + if arg.Indexed { + indexed = append(indexed, arg) + } + } + return abi.ParseTopics(out, indexed, log.Topics[1:]) +} diff --git a/proto/rarimocore/op_root_update.proto b/proto/rarimocore/op_passport_root_update.proto similarity index 67% rename from proto/rarimocore/op_root_update.proto rename to proto/rarimocore/op_passport_root_update.proto index d7e96e38..a2df09bf 100644 --- a/proto/rarimocore/op_root_update.proto +++ b/proto/rarimocore/op_passport_root_update.proto @@ -3,9 +3,9 @@ package rarimo.rarimocore.rarimocore; option go_package = "github.com/rarimo/rarimo-core/x/rarimocore/types"; -message RootUpdate { -// Root is new Merkle root. Hex 0x uint256 +message PassportRootUpdate { string root = 1; string contract_address = 2; - uint64 timestamp = 3; + uint32 timestamp = 3; } + diff --git a/proto/rarimocore/operation.proto b/proto/rarimocore/operation.proto index 9c4d2fbc..b940dea3 100644 --- a/proto/rarimocore/operation.proto +++ b/proto/rarimocore/operation.proto @@ -17,7 +17,7 @@ enum OpType { WORLDCOIN_IDENTITY_TRANSFER = 8; CSCA_ROOT_UPDATE = 9; ARBITRARY = 10; - UPDATE_ROOT = 11; + PASSPORT_ROOT_UPDATE = 11; } enum OpStatus { diff --git a/proto/rootupdater/params.proto b/proto/rootupdater/params.proto index af239212..cb2774a0 100644 --- a/proto/rootupdater/params.proto +++ b/proto/rootupdater/params.proto @@ -9,7 +9,8 @@ option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; message Params { string contract_address = 1; string root = 2; - string last_root = 3; - string index = 4; + string last_signed_root = 3; + string last_signed_root_index = 4; string event_name = 5; + uint32 root_timestamp = 6; } diff --git a/proto/rootupdater/tx.proto b/proto/rootupdater/tx.proto index 0d8a9029..9ce810f6 100644 --- a/proto/rootupdater/tx.proto +++ b/proto/rootupdater/tx.proto @@ -4,14 +4,6 @@ package rarimo.rootupdater; option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; // Msg defines the Msg service. -service Msg { - rpc UpdateRoot(MsgUpdateRoot) returns (MsgUpdateRootResponse); -} - -message MsgUpdateRoot{ - string creator = 1; - string root = 2; -} - -message MsgUpdateRootResponse {} +service Msg {} +// this line is used by starport scaffolding # proto/tx/message diff --git a/x/identity/keeper/keeper.go b/x/identity/keeper/keeper.go index 3e8d984f..1f742412 100644 --- a/x/identity/keeper/keeper.go +++ b/x/identity/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "bytes" "fmt" + "github.com/rarimo/rarimo-core/ethermint/utils" "strings" "github.com/cosmos/cosmos-sdk/codec" @@ -122,7 +123,7 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth } eventBody := state.StateStateTransited{} - if err := unpackLog(stateV2, &eventBody, event.Name, log); err != nil { + if err := utils.UnpackLog(stateV2, &eventBody, event.Name, log); err != nil { return err } @@ -134,23 +135,3 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth return nil } - -// unpackLog copy-pasted from logic in generated s-c bindings. -func unpackLog(contractAbi abi.ABI, out interface{}, event string, log *ethtypes.Log) error { - if log.Topics[0] != contractAbi.Events[event].ID { - return fmt.Errorf("event signature mismatch") - } - - if len(log.Data) > 0 { - if err := contractAbi.UnpackIntoInterface(out, event, log.Data); err != nil { - return err - } - } - var indexed abi.Arguments - for _, arg := range contractAbi.Events[event].Inputs { - if arg.Indexed { - indexed = append(indexed, arg) - } - } - return abi.ParseTopics(out, indexed, log.Topics[1:]) -} diff --git a/x/rarimocore/crypto/operation/op_passport_root_update.go b/x/rarimocore/crypto/operation/op_passport_root_update.go new file mode 100644 index 00000000..ea6cc0e4 --- /dev/null +++ b/x/rarimocore/crypto/operation/op_passport_root_update.go @@ -0,0 +1,26 @@ +package operation + +import ( + "bytes" + + eth "github.com/ethereum/go-ethereum/crypto" + merkle "github.com/rarimo/go-merkle" +) + +type PassportRootUpdateContent struct { + ContractAddress []byte + Root []byte + RootTimestamp []byte +} + +const hashPassportRootUpdatePrefix = "Rarimo passport root" + +var _ merkle.Content = PassportRootUpdateContent{} + +func (c PassportRootUpdateContent) CalculateHash() []byte { + return eth.Keccak256([]byte(hashPassportRootUpdatePrefix), c.ContractAddress, c.Root, c.RootTimestamp) +} + +func (c PassportRootUpdateContent) Equals(other merkle.Content) bool { + return bytes.Equal(other.CalculateHash(), c.CalculateHash()) +} diff --git a/x/rarimocore/crypto/operation/op_root_update.go b/x/rarimocore/crypto/operation/op_root_update.go deleted file mode 100644 index 2ab3d6d1..00000000 --- a/x/rarimocore/crypto/operation/op_root_update.go +++ /dev/null @@ -1,25 +0,0 @@ -package operation - -import ( - "bytes" - - eth "github.com/ethereum/go-ethereum/crypto" - merkle "github.com/rarimo/go-merkle" -) - -type RootUpdateContent struct { - ContractAddress []byte - Root []byte -} - -const hashRootUpdatePrefix = "Rarimo root" - -var _ merkle.Content = RootUpdateContent{} - -func (c RootUpdateContent) CalculateHash() []byte { - return eth.Keccak256([]byte(hashRootUpdatePrefix), c.ContractAddress, c.Root) -} - -func (c RootUpdateContent) Equals(other merkle.Content) bool { - return bytes.Equal(other.CalculateHash(), c.CalculateHash()) -} diff --git a/x/rarimocore/crypto/pkg/content/main.go b/x/rarimocore/crypto/pkg/content/main.go index bdc3a2d5..aed3dc1d 100644 --- a/x/rarimocore/crypto/pkg/content/main.go +++ b/x/rarimocore/crypto/pkg/content/main.go @@ -109,8 +109,8 @@ func GetContents(client *grpc.ClientConn, operations ...*types.Operation) ([]mer if content != nil { contents = append(contents, content) } - case types.OpType_UPDATE_ROOT: - content, err := GetRootUpdateContent(op) + case types.OpType_PASSPORT_ROOT_UPDATE: + content, err := GetPassportRootUpdateContent(op) if err != nil { return nil, err } @@ -280,12 +280,12 @@ func GetArbitraryContent(op *types.Operation) (merkle.Content, error) { return content, errors.Wrap(err, "error creating content") } -func GetRootUpdateContent(op *types.Operation) (merkle.Content, error) { - update, err := pkg.GetRootUpdate(*op) +func GetPassportRootUpdateContent(op *types.Operation) (merkle.Content, error) { + update, err := pkg.GetPassportRootUpdate(*op) if err != nil { return nil, errors.Wrap(err, "error parsing operation details") } - content, err := pkg.GetRootUpdateContent(update) + content, err := pkg.GetPassportRootUpdateContent(update) return content, errors.Wrap(err, "error creating content") } diff --git a/x/rarimocore/crypto/pkg/op_root_update.go b/x/rarimocore/crypto/pkg/op_passport_root_update.go similarity index 53% rename from x/rarimocore/crypto/pkg/op_root_update.go rename to x/rarimocore/crypto/pkg/op_passport_root_update.go index 75ce5635..7943909e 100644 --- a/x/rarimocore/crypto/pkg/op_root_update.go +++ b/x/rarimocore/crypto/pkg/op_passport_root_update.go @@ -2,6 +2,7 @@ package pkg import ( "cosmossdk.io/errors" + "encoding/binary" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gogo/protobuf/proto" @@ -9,17 +10,21 @@ import ( "github.com/rarimo/rarimo-core/x/rarimocore/types" ) -func GetRootUpdate(operation types.Operation) (*types.RootUpdate, error) { - if operation.OperationType == types.OpType_UPDATE_ROOT { - op := new(types.RootUpdate) +func GetPassportRootUpdate(operation types.Operation) (*types.PassportRootUpdate, error) { + if operation.OperationType == types.OpType_PASSPORT_ROOT_UPDATE { + op := new(types.PassportRootUpdate) return op, proto.Unmarshal(operation.Details.Value, op) } return nil, errors.Wrap(sdkerrors.ErrInvalidType, "invalid operation type") } -func GetRootUpdateContent(op *types.RootUpdate) (*operation.RootUpdateContent, error) { - return &operation.RootUpdateContent{ +func GetPassportRootUpdateContent(op *types.PassportRootUpdate) (*operation.PassportRootUpdateContent, error) { + bytesTimestamp := make([]byte, 0) + binary.BigEndian.PutUint32(bytesTimestamp, op.Timestamp) + + return &operation.PassportRootUpdateContent{ ContractAddress: operation.To32Bytes(hexutil.MustDecode(op.ContractAddress)), Root: operation.To32Bytes(hexutil.MustDecode(op.Root)), + RootTimestamp: operation.To32Bytes(bytesTimestamp), }, nil } diff --git a/x/rarimocore/keeper/keeper.go b/x/rarimocore/keeper/keeper.go index 9eb39765..90e44fad 100644 --- a/x/rarimocore/keeper/keeper.go +++ b/x/rarimocore/keeper/keeper.go @@ -577,20 +577,20 @@ func (k Keeper) CreateArbitraryOperation(ctx sdk.Context, creator string, arbitr return nil } -func (k Keeper) CreateRootUpdateOperation(ctx sdk.Context, creator string, update *types.RootUpdate) (string, error) { +func (k Keeper) CreateRootUpdateOperation(ctx sdk.Context, creator string, update *types.PassportRootUpdate) (string, error) { details, err := cosmostypes.NewAnyWithValue(update) if err != nil { return "", errors.Wrapf(sdkerrors.ErrInvalidRequest, "error parsing details: %s", err.Error()) } - content, err := pkg.GetRootUpdateContent(update) + content, err := pkg.GetPassportRootUpdateContent(update) if err != nil { return "", errors.Wrapf(sdkerrors.ErrInvalidRequest, "error creating content: %s", err.Error()) } operation := types.Operation{ Index: hexutil.Encode(content.CalculateHash()), - OperationType: types.OpType_UPDATE_ROOT, + OperationType: types.OpType_PASSPORT_ROOT_UPDATE, Details: details, Status: types.OpStatus_INITIALIZED, Creator: creator, diff --git a/x/rarimocore/keeper/msg_server_confirmation.go b/x/rarimocore/keeper/msg_server_confirmation.go index 72956f7c..34a1e670 100644 --- a/x/rarimocore/keeper/msg_server_confirmation.go +++ b/x/rarimocore/keeper/msg_server_confirmation.go @@ -229,6 +229,12 @@ func (k Keeper) getContent(ctx sdk.Context, op types.Operation) (merkle.Content, return nil, fmt.Errorf("%w: failed to unmarshal details: %s", sdkerrors.ErrInvalidRequest, err.Error()) } return pkg.GetCSCARootUpdateContent(update) + case types.OpType_PASSPORT_ROOT_UPDATE: + update, err := pkg.GetPassportRootUpdate(op) + if err != nil { + return nil, fmt.Errorf("%w: failed to unmarshal details: %s", sdkerrors.ErrInvalidRequest, err.Error()) + } + return pkg.GetPassportRootUpdateContent(update) case types.OpType_ARBITRARY: arbitrary, err := pkg.GetArbitrary(op) if err != nil { diff --git a/x/rarimocore/types/op_root_update.pb.go b/x/rarimocore/types/op_root_update.pb.go deleted file mode 100644 index 6e1d7e85..00000000 --- a/x/rarimocore/types/op_root_update.pb.go +++ /dev/null @@ -1,404 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: rarimocore/op_root_update.proto - -package types - -import ( - fmt "fmt" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type RootUpdate struct { - // Root is new Merkle root. Hex 0x uint256 - Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` - ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` -} - -func (m *RootUpdate) Reset() { *m = RootUpdate{} } -func (m *RootUpdate) String() string { return proto.CompactTextString(m) } -func (*RootUpdate) ProtoMessage() {} -func (*RootUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_27d0fc6c9dd91d98, []int{0} -} -func (m *RootUpdate) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RootUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RootUpdate.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 *RootUpdate) XXX_Merge(src proto.Message) { - xxx_messageInfo_RootUpdate.Merge(m, src) -} -func (m *RootUpdate) XXX_Size() int { - return m.Size() -} -func (m *RootUpdate) XXX_DiscardUnknown() { - xxx_messageInfo_RootUpdate.DiscardUnknown(m) -} - -var xxx_messageInfo_RootUpdate proto.InternalMessageInfo - -func (m *RootUpdate) GetRoot() string { - if m != nil { - return m.Root - } - return "" -} - -func (m *RootUpdate) GetContractAddress() string { - if m != nil { - return m.ContractAddress - } - return "" -} - -func (m *RootUpdate) GetTimestamp() uint64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -func init() { - proto.RegisterType((*RootUpdate)(nil), "rarimo.rarimocore.rarimocore.RootUpdate") -} - -func init() { proto.RegisterFile("rarimocore/op_root_update.proto", fileDescriptor_27d0fc6c9dd91d98) } - -var fileDescriptor_27d0fc6c9dd91d98 = []byte{ - // 206 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2f, 0x4a, 0x2c, 0xca, - 0xcc, 0xcd, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x88, 0x2f, 0xca, 0xcf, 0x2f, 0x89, 0x2f, - 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0x28, 0xd0, - 0x43, 0xa8, 0x43, 0x62, 0x2a, 0x65, 0x72, 0x71, 0x05, 0xe5, 0xe7, 0x97, 0x84, 0x82, 0x75, 0x08, - 0x09, 0x71, 0xb1, 0x80, 0x0c, 0x90, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x85, 0x34, - 0xb9, 0x04, 0x92, 0xf3, 0xf3, 0x4a, 0x8a, 0x12, 0x93, 0x4b, 0xe2, 0x13, 0x53, 0x52, 0x8a, 0x52, - 0x8b, 0x8b, 0x25, 0x98, 0xc0, 0xf2, 0xfc, 0x30, 0x71, 0x47, 0x88, 0xb0, 0x90, 0x0c, 0x17, 0x67, - 0x49, 0x66, 0x6e, 0x6a, 0x71, 0x49, 0x62, 0x6e, 0x81, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x4b, 0x10, - 0x42, 0xc0, 0xc9, 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, - 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, - 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x21, 0x6e, 0x83, 0x52, 0xba, 0x60, - 0x6f, 0x55, 0xe8, 0x23, 0xf9, 0xb1, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x37, 0x63, - 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x58, 0x2e, 0x6c, 0xfe, 0x00, 0x00, 0x00, -} - -func (m *RootUpdate) 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 *RootUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RootUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Timestamp != 0 { - i = encodeVarintOpRootUpdate(dAtA, i, uint64(m.Timestamp)) - i-- - dAtA[i] = 0x18 - } - if len(m.ContractAddress) > 0 { - i -= len(m.ContractAddress) - copy(dAtA[i:], m.ContractAddress) - i = encodeVarintOpRootUpdate(dAtA, i, uint64(len(m.ContractAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.Root) > 0 { - i -= len(m.Root) - copy(dAtA[i:], m.Root) - i = encodeVarintOpRootUpdate(dAtA, i, uint64(len(m.Root))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintOpRootUpdate(dAtA []byte, offset int, v uint64) int { - offset -= sovOpRootUpdate(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *RootUpdate) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Root) - if l > 0 { - n += 1 + l + sovOpRootUpdate(uint64(l)) - } - l = len(m.ContractAddress) - if l > 0 { - n += 1 + l + sovOpRootUpdate(uint64(l)) - } - if m.Timestamp != 0 { - n += 1 + sovOpRootUpdate(uint64(m.Timestamp)) - } - return n -} - -func sovOpRootUpdate(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozOpRootUpdate(x uint64) (n int) { - return sovOpRootUpdate(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *RootUpdate) 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 ErrIntOverflowOpRootUpdate - } - 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: RootUpdate: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RootUpdate: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowOpRootUpdate - } - 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 ErrInvalidLengthOpRootUpdate - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthOpRootUpdate - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Root = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowOpRootUpdate - } - 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 ErrInvalidLengthOpRootUpdate - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthOpRootUpdate - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ContractAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) - } - m.Timestamp = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowOpRootUpdate - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Timestamp |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipOpRootUpdate(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthOpRootUpdate - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipOpRootUpdate(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, ErrIntOverflowOpRootUpdate - } - 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, ErrIntOverflowOpRootUpdate - } - 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, ErrIntOverflowOpRootUpdate - } - 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, ErrInvalidLengthOpRootUpdate - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupOpRootUpdate - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthOpRootUpdate - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthOpRootUpdate = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowOpRootUpdate = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupOpRootUpdate = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/rarimocore/types/operation.pb.go b/x/rarimocore/types/operation.pb.go index 0efa4de9..bdf247d2 100644 --- a/x/rarimocore/types/operation.pb.go +++ b/x/rarimocore/types/operation.pb.go @@ -37,7 +37,7 @@ const ( OpType_WORLDCOIN_IDENTITY_TRANSFER OpType = 8 OpType_CSCA_ROOT_UPDATE OpType = 9 OpType_ARBITRARY OpType = 10 - OpType_UPDATE_ROOT OpType = 11 + OpType_PASSPORT_ROOT_UPDATE OpType = 11 ) var OpType_name = map[int32]string{ @@ -52,7 +52,7 @@ var OpType_name = map[int32]string{ 8: "WORLDCOIN_IDENTITY_TRANSFER", 9: "CSCA_ROOT_UPDATE", 10: "ARBITRARY", - 11: "UPDATE_ROOT", + 11: "PASSPORT_ROOT_UPDATE", } var OpType_value = map[string]int32{ @@ -67,7 +67,7 @@ var OpType_value = map[string]int32{ "WORLDCOIN_IDENTITY_TRANSFER": 8, "CSCA_ROOT_UPDATE": 9, "ARBITRARY": 10, - "UPDATE_ROOT": 11, + "PASSPORT_ROOT_UPDATE": 11, } func (x OpType) String() string { @@ -204,41 +204,41 @@ func init() { func init() { proto.RegisterFile("rarimocore/operation.proto", fileDescriptor_4615e59ddf669d07) } var fileDescriptor_4615e59ddf669d07 = []byte{ - // 530 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xc1, 0x6e, 0xda, 0x30, - 0x1c, 0xc6, 0x09, 0x2d, 0x01, 0xfe, 0xb4, 0x9d, 0x65, 0xa1, 0x2d, 0xa5, 0x2c, 0x43, 0xd3, 0x34, - 0xa1, 0x4a, 0x0b, 0x53, 0x77, 0x9f, 0xe4, 0x12, 0x93, 0xb9, 0xa3, 0x0e, 0x72, 0xdc, 0x4d, 0xed, - 0x25, 0x0a, 0x34, 0x63, 0x91, 0x0a, 0x89, 0x42, 0x90, 0xca, 0x5b, 0xec, 0xb2, 0xa7, 0xd8, 0x8b, - 0xec, 0xd8, 0xe3, 0x8e, 0x13, 0xbc, 0xc8, 0x44, 0x52, 0x02, 0xbb, 0x6c, 0xa7, 0xc4, 0xfe, 0x7e, - 0x5f, 0xbe, 0xcf, 0x8e, 0x0d, 0x8d, 0xd8, 0x8b, 0x83, 0x49, 0x38, 0x0a, 0x63, 0xbf, 0x13, 0x46, - 0x7e, 0xec, 0x25, 0x41, 0x38, 0x35, 0xa2, 0x38, 0x4c, 0x42, 0xdc, 0xcc, 0x34, 0x63, 0x8b, 0xec, - 0xbc, 0x36, 0x8e, 0xc7, 0x61, 0x38, 0xbe, 0xf3, 0x3b, 0x29, 0x3b, 0x9c, 0x7f, 0xe9, 0x78, 0xd3, - 0x45, 0x66, 0x7c, 0xf9, 0xbd, 0x08, 0x55, 0x7b, 0xf3, 0x31, 0x5c, 0x87, 0x52, 0x30, 0xbd, 0xf5, - 0xef, 0x35, 0xa5, 0xa5, 0xb4, 0xab, 0x22, 0x1b, 0xe0, 0x0b, 0x38, 0xcc, 0xf3, 0xe4, 0x22, 0xf2, - 0xb5, 0x62, 0x4b, 0x69, 0x1f, 0x9d, 0xbd, 0x32, 0xfe, 0x15, 0x6a, 0xd8, 0xd1, 0x9a, 0x15, 0x7f, - 0x5b, 0xb1, 0x01, 0xe5, 0x5b, 0x3f, 0xf1, 0x82, 0xbb, 0x99, 0xb6, 0xd7, 0x52, 0xda, 0xb5, 0xb3, - 0xba, 0x91, 0x95, 0x33, 0x36, 0xe5, 0x0c, 0x32, 0x5d, 0x88, 0x0d, 0x84, 0xdf, 0x83, 0x3a, 0x4b, - 0xbc, 0x64, 0x3e, 0xd3, 0xf6, 0xd3, 0xd0, 0xd7, 0xff, 0x0b, 0x75, 0x52, 0x5a, 0x3c, 0xba, 0xb0, - 0x06, 0xe5, 0x51, 0xec, 0x7b, 0x49, 0x18, 0x6b, 0xa5, 0x74, 0x4d, 0x9b, 0x21, 0x6e, 0x42, 0x35, - 0x09, 0x26, 0xfe, 0x2c, 0xf1, 0x26, 0x91, 0xa6, 0xb6, 0x94, 0xf6, 0xbe, 0xd8, 0x4e, 0x9c, 0xfe, - 0x28, 0x82, 0x9a, 0xad, 0x00, 0x1f, 0x40, 0x45, 0x0a, 0xc2, 0x9d, 0x1e, 0x15, 0xa8, 0x80, 0x31, - 0x1c, 0x75, 0x3f, 0x10, 0x6e, 0x51, 0x77, 0x40, 0x84, 0x64, 0xd4, 0x41, 0x0a, 0xd6, 0xa0, 0xde, - 0xa3, 0xd4, 0x95, 0xf6, 0x47, 0xca, 0xdd, 0x4b, 0xc2, 0x89, 0x45, 0x2f, 0x29, 0x97, 0xa8, 0x88, - 0xeb, 0x80, 0xba, 0x36, 0x97, 0x82, 0x74, 0xa5, 0x7b, 0x35, 0xb0, 0x04, 0x31, 0x29, 0xda, 0xc3, - 0xcf, 0xe1, 0x98, 0x99, 0x94, 0x4b, 0x26, 0xaf, 0x5d, 0x93, 0xf6, 0xc8, 0x55, 0x5f, 0xba, 0x79, - 0xc4, 0x3e, 0x6e, 0x41, 0x33, 0x97, 0x89, 0x65, 0x09, 0x6a, 0x11, 0x49, 0xcd, 0x2d, 0x51, 0xc2, - 0x0d, 0x78, 0x9a, 0x13, 0x16, 0x73, 0x76, 0xdc, 0x2a, 0x3e, 0x81, 0x67, 0xb9, 0xe6, 0x48, 0x22, - 0xe9, 0x56, 0x2c, 0xe3, 0x17, 0x70, 0xf2, 0xd9, 0x16, 0x7d, 0xb3, 0x6b, 0x33, 0xee, 0xe6, 0x58, - 0x0e, 0x54, 0xd2, 0xc2, 0x4e, 0x97, 0xb8, 0xc2, 0xb6, 0xd7, 0x8d, 0x4d, 0x22, 0x29, 0xaa, 0xe2, - 0x43, 0xa8, 0x12, 0x71, 0xce, 0xa4, 0x20, 0xe2, 0x1a, 0x01, 0x7e, 0x02, 0xb5, 0x4c, 0x4a, 0x31, - 0x54, 0x3b, 0xb5, 0xa0, 0xb2, 0xd9, 0xf9, 0xb5, 0xc8, 0x38, 0x93, 0x8c, 0xf4, 0xd9, 0x0d, 0x35, - 0x51, 0x61, 0xbd, 0x7f, 0x64, 0x30, 0x10, 0xf6, 0x27, 0x6a, 0x22, 0x05, 0x23, 0x38, 0xe0, 0xb6, - 0x74, 0xf3, 0x99, 0x22, 0x06, 0x50, 0x1d, 0x66, 0x71, 0x6a, 0xa2, 0xbd, 0xf3, 0x8b, 0x9f, 0x4b, - 0x5d, 0x79, 0x58, 0xea, 0xca, 0xef, 0xa5, 0xae, 0x7c, 0x5b, 0xe9, 0x85, 0x87, 0x95, 0x5e, 0xf8, - 0xb5, 0xd2, 0x0b, 0x37, 0x6f, 0xc7, 0x41, 0xf2, 0x75, 0x3e, 0x34, 0x46, 0xe1, 0xa4, 0x93, 0xfd, - 0xf0, 0xc7, 0xc7, 0x9b, 0xf4, 0x42, 0xdc, 0x77, 0x76, 0x6e, 0x47, 0xb2, 0x88, 0xfc, 0xd9, 0x50, - 0x4d, 0x4f, 0xd4, 0xbb, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x63, 0x80, 0x51, 0x1f, 0x38, 0x03, - 0x00, 0x00, + // 537 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6e, 0xda, 0x4c, + 0x14, 0xc5, 0x31, 0x7f, 0x0c, 0x5c, 0x92, 0x7c, 0xd6, 0x08, 0x7d, 0x75, 0x08, 0x75, 0x51, 0x55, + 0x55, 0x28, 0x52, 0x4d, 0x95, 0xee, 0x2b, 0x4d, 0xf0, 0xe0, 0x3a, 0x25, 0x33, 0xd6, 0x78, 0xd2, + 0x2a, 0xd9, 0x58, 0x86, 0xb8, 0xd4, 0x52, 0xc0, 0x96, 0x31, 0x52, 0x78, 0x8b, 0x6e, 0xfa, 0x26, + 0x7d, 0x88, 0x2e, 0xb3, 0xec, 0xb2, 0x82, 0x17, 0xa9, 0xb0, 0x83, 0x21, 0x9b, 0x76, 0x65, 0xcf, + 0xdc, 0xdf, 0xf1, 0x39, 0xd7, 0x33, 0x17, 0x5a, 0xb1, 0x17, 0x07, 0xd3, 0x70, 0x1c, 0xc6, 0x7e, + 0x2f, 0x8c, 0xfc, 0xd8, 0x4b, 0x82, 0x70, 0xa6, 0x47, 0x71, 0x98, 0x84, 0xa8, 0x9d, 0xd5, 0xf4, + 0x1d, 0xb2, 0xf7, 0xda, 0x3a, 0x9e, 0x84, 0xe1, 0xe4, 0xce, 0xef, 0xa5, 0xec, 0x68, 0xf1, 0xa5, + 0xe7, 0xcd, 0x96, 0x99, 0xf0, 0xe5, 0xf7, 0x22, 0xd4, 0xd9, 0xf6, 0x63, 0xa8, 0x09, 0x95, 0x60, + 0x76, 0xeb, 0xdf, 0xab, 0x52, 0x47, 0xea, 0xd6, 0x79, 0xb6, 0x40, 0x17, 0x70, 0x98, 0xfb, 0x89, + 0x65, 0xe4, 0xab, 0xc5, 0x8e, 0xd4, 0x3d, 0x3a, 0x7b, 0xa5, 0xff, 0xcd, 0x54, 0x67, 0xd1, 0x86, + 0xe5, 0x4f, 0xa5, 0x48, 0x87, 0xea, 0xad, 0x9f, 0x78, 0xc1, 0xdd, 0x5c, 0x2d, 0x75, 0xa4, 0x6e, + 0xe3, 0xac, 0xa9, 0x67, 0xe1, 0xf4, 0x6d, 0x38, 0x1d, 0xcf, 0x96, 0x7c, 0x0b, 0xa1, 0xf7, 0x20, + 0xcf, 0x13, 0x2f, 0x59, 0xcc, 0xd5, 0x72, 0x6a, 0xfa, 0xfa, 0x5f, 0xa6, 0x4e, 0x4a, 0xf3, 0x47, + 0x15, 0x52, 0xa1, 0x3a, 0x8e, 0x7d, 0x2f, 0x09, 0x63, 0xb5, 0x92, 0xf6, 0xb4, 0x5d, 0xa2, 0x36, + 0xd4, 0x93, 0x60, 0xea, 0xcf, 0x13, 0x6f, 0x1a, 0xa9, 0x72, 0x47, 0xea, 0x96, 0xf9, 0x6e, 0xe3, + 0xf4, 0x47, 0x11, 0xe4, 0xac, 0x03, 0x74, 0x00, 0x35, 0xc1, 0x31, 0x75, 0x06, 0x84, 0x2b, 0x05, + 0x84, 0xe0, 0xa8, 0xff, 0x01, 0x53, 0x93, 0xb8, 0x36, 0xe6, 0xc2, 0x22, 0x8e, 0x22, 0x21, 0x15, + 0x9a, 0x03, 0x42, 0x5c, 0xc1, 0x3e, 0x12, 0xea, 0x5e, 0x62, 0x8a, 0x4d, 0x72, 0x49, 0xa8, 0x50, + 0x8a, 0xa8, 0x09, 0x4a, 0x9f, 0x51, 0xc1, 0x71, 0x5f, 0xb8, 0x57, 0xb6, 0xc9, 0xb1, 0x41, 0x94, + 0x12, 0x7a, 0x0e, 0xc7, 0x96, 0x41, 0xa8, 0xb0, 0xc4, 0xb5, 0x6b, 0x90, 0x01, 0xbe, 0x1a, 0x0a, + 0x37, 0xb7, 0x28, 0xa3, 0x0e, 0xb4, 0xf3, 0x32, 0x36, 0x4d, 0x4e, 0x4c, 0x2c, 0x88, 0xb1, 0x23, + 0x2a, 0xa8, 0x05, 0xff, 0xe7, 0x84, 0x69, 0x39, 0x7b, 0x6a, 0x19, 0x9d, 0xc0, 0xb3, 0xbc, 0xe6, + 0x08, 0x2c, 0xc8, 0xae, 0x58, 0x45, 0x2f, 0xe0, 0xe4, 0x33, 0xe3, 0x43, 0xa3, 0xcf, 0x2c, 0xea, + 0xe6, 0x58, 0x0e, 0xd4, 0xd2, 0xc0, 0x4e, 0x1f, 0xbb, 0x9c, 0xb1, 0x4d, 0x62, 0x03, 0x0b, 0xa2, + 0xd4, 0xd1, 0x21, 0xd4, 0x31, 0x3f, 0xb7, 0x04, 0xc7, 0xfc, 0x5a, 0x81, 0x4d, 0xbf, 0x36, 0x76, + 0x1c, 0x9b, 0x71, 0xf1, 0x04, 0x6c, 0x9c, 0x9a, 0x50, 0xdb, 0x1e, 0x01, 0xfa, 0x0f, 0x1a, 0x16, + 0xb5, 0x84, 0x85, 0x87, 0xd6, 0x0d, 0x31, 0x94, 0xc2, 0xe6, 0x47, 0x62, 0xdb, 0xe6, 0xec, 0x13, + 0x31, 0x14, 0x09, 0x29, 0x70, 0x40, 0x99, 0x70, 0xf3, 0x9d, 0x22, 0x02, 0x90, 0x1d, 0xcb, 0xa4, + 0xc4, 0x50, 0x4a, 0xe7, 0x17, 0x3f, 0x57, 0x9a, 0xf4, 0xb0, 0xd2, 0xa4, 0xdf, 0x2b, 0x4d, 0xfa, + 0xb6, 0xd6, 0x0a, 0x0f, 0x6b, 0xad, 0xf0, 0x6b, 0xad, 0x15, 0x6e, 0xde, 0x4e, 0x82, 0xe4, 0xeb, + 0x62, 0xa4, 0x8f, 0xc3, 0x69, 0x2f, 0x3b, 0xf9, 0xc7, 0xc7, 0x9b, 0x74, 0x32, 0xee, 0x7b, 0x7b, + 0x63, 0x92, 0x2c, 0x23, 0x7f, 0x3e, 0x92, 0xd3, 0xab, 0xf5, 0xee, 0x4f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x78, 0xd6, 0x3b, 0x89, 0x41, 0x03, 0x00, 0x00, } func (m *Operation) Marshal() (dAtA []byte, err error) { diff --git a/x/rootupdater/client/cli/tx.go b/x/rootupdater/client/cli/tx.go index 5412967b..9a8e026b 100644 --- a/x/rootupdater/client/cli/tx.go +++ b/x/rootupdater/client/cli/tx.go @@ -19,6 +19,5 @@ func GetTxCmd() *cobra.Command { } // this line is used by starport scaffolding # 1 - cmd.AddCommand(CmdUpdateRoot()) return cmd } diff --git a/x/rootupdater/client/cli/tx_update_root.go b/x/rootupdater/client/cli/tx_update_root.go deleted file mode 100644 index 36a6d68c..00000000 --- a/x/rootupdater/client/cli/tx_update_root.go +++ /dev/null @@ -1,38 +0,0 @@ -package cli - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/rarimo/rarimo-core/x/rootupdater/types" - "github.com/spf13/cobra" -) - -func CmdUpdateRoot() *cobra.Command { - cmd := &cobra.Command{ - Use: "update [root]", - Short: "Update a root", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { - root := args[0] - - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := types.NewMsgUpdateRoot( - clientCtx.GetFromAddress().String(), - root, - ) - if err := msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/rootupdater/handler.go b/x/rootupdater/handler.go deleted file mode 100644 index 851c7254..00000000 --- a/x/rootupdater/handler.go +++ /dev/null @@ -1,29 +0,0 @@ -package rootupdater - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/rarimo/rarimo-core/x/rootupdater/keeper" - "github.com/rarimo/rarimo-core/x/rootupdater/types" -) - -// NewHandler ... -func NewHandler(k keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - // this line is used by starport scaffolding # handler/msgServer - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgUpdateRoot: - res, err := msgServer.UpdateRoot(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - } -} diff --git a/x/rootupdater/keeper/abci.go b/x/rootupdater/keeper/abci.go index e5612aa4..cd488659 100644 --- a/x/rootupdater/keeper/abci.go +++ b/x/rootupdater/keeper/abci.go @@ -9,13 +9,15 @@ import ( func (k Keeper) EndBlocker(ctx sdk.Context) { params := k.GetParams(ctx) - if params.Root == params.LastRoot { + if params.Root == params.LastSignedRoot { return } + // Creating operation to be signed by TSS parties - index, err := k.rarimo.CreateRootUpdateOperation(ctx, types.ModuleName, &rarimocoremoduletypes.RootUpdate{ + index, err := k.rarimo.CreateRootUpdateOperation(ctx, types.ModuleName, &rarimocoremoduletypes.PassportRootUpdate{ ContractAddress: params.ContractAddress, Root: params.Root, + Timestamp: params.RootTimestamp, }) if err != nil { @@ -23,7 +25,7 @@ func (k Keeper) EndBlocker(ctx sdk.Context) { return } - params.LastRoot = params.Root - params.Index = index + params.LastSignedRoot = params.Root + params.LastSignedRootIndex = index k.SetParams(ctx, params) } diff --git a/x/rootupdater/keeper/keeper.go b/x/rootupdater/keeper/keeper.go index bd9d119c..21776449 100644 --- a/x/rootupdater/keeper/keeper.go +++ b/x/rootupdater/keeper/keeper.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/rarimo/rarimo-core/ethermint/utils" "github.com/rarimo/rarimo-core/x/rootupdater/pkg/state" "strings" @@ -53,7 +54,7 @@ func NewKeeper( } // PostTxProcessing is used to listen EVM smart contract events, -// filter and process `StateTransited` events emitted by configured in module params contract address. +// filter and process `RootUpdated` events emitted by configured in module params contract address. // Will be called by EVM module as hook. func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { params := k.GetParams(ctx) @@ -82,7 +83,7 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth } eventBody := state.PoseidonSMTRootUpdated{} - if err := unpackLog(stateV2, &eventBody, event.Name, log); err != nil { + if err := utils.UnpackLog(stateV2, &eventBody, event.Name, log); err != nil { return err } @@ -98,23 +99,3 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } - -// unpackLog copy-pasted from logic in generated s-c bindings. -func unpackLog(contractAbi abi.ABI, out interface{}, event string, log *ethtypes.Log) error { - if log.Topics[0] != contractAbi.Events[event].ID { - return fmt.Errorf("event signature mismatch") - } - - if len(log.Data) > 0 { - if err := contractAbi.UnpackIntoInterface(out, event, log.Data); err != nil { - return err - } - } - var indexed abi.Arguments - for _, arg := range contractAbi.Events[event].Inputs { - if arg.Indexed { - indexed = append(indexed, arg) - } - } - return abi.ParseTopics(out, indexed, log.Topics[1:]) -} diff --git a/x/rootupdater/keeper/msg_server_update_root.go b/x/rootupdater/keeper/msg_server_update_root.go deleted file mode 100644 index d8e78940..00000000 --- a/x/rootupdater/keeper/msg_server_update_root.go +++ /dev/null @@ -1,18 +0,0 @@ -package keeper - -import ( - "context" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/rarimo/rarimo-core/x/rootupdater/types" -) - -func (m msgServer) UpdateRoot(goctx context.Context, req *types.MsgUpdateRoot) (*types.MsgUpdateRootResponse, error) { - ctx := sdk.UnwrapSDKContext(goctx) - params := m.GetParams(ctx) - - params.Root = req.Root - - m.SetParams(ctx, params) - - return &types.MsgUpdateRootResponse{}, nil -} diff --git a/x/rootupdater/module.go b/x/rootupdater/module.go index 10c50dea..588a6a89 100644 --- a/x/rootupdater/module.go +++ b/x/rootupdater/module.go @@ -106,7 +106,7 @@ func NewAppModule( // Deprecated: use RegisterServices func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) + return sdk.Route{} } // Deprecated: use RegisterServices diff --git a/x/rootupdater/types/expected_keepers.go b/x/rootupdater/types/expected_keepers.go index bf29a07f..e731e16a 100644 --- a/x/rootupdater/types/expected_keepers.go +++ b/x/rootupdater/types/expected_keepers.go @@ -6,5 +6,5 @@ import ( ) type RarimocoreKeeper interface { - CreateRootUpdateOperation(ctx sdk.Context, creator string, update *types.RootUpdate) (string, error) + CreateRootUpdateOperation(ctx sdk.Context, creator string, update *types.PassportRootUpdate) (string, error) } diff --git a/x/rootupdater/types/message_root_update.go b/x/rootupdater/types/message_root_update.go deleted file mode 100644 index 6c6b9794..00000000 --- a/x/rootupdater/types/message_root_update.go +++ /dev/null @@ -1,55 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -const ( - TypeMsgUpdateRoot = "update_root" -) - -var _ sdk.Msg = &MsgUpdateRoot{} - -func NewMsgUpdateRoot( - creator string, - address string, -) *MsgUpdateRoot { - return &MsgUpdateRoot{ - Creator: creator, - Root: address, - } -} - -func (msg *MsgUpdateRoot) Route() string { - return RouterKey -} - -func (msg *MsgUpdateRoot) Type() string { - return TypeMsgUpdateRoot -} - -func (msg *MsgUpdateRoot) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *MsgUpdateRoot) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - -func (msg *MsgUpdateRoot) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) - } - - if msg.Root == "" { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid root") - } - return nil -} diff --git a/x/rootupdater/types/params.pb.go b/x/rootupdater/types/params.pb.go index e7caae72..5c53211d 100644 --- a/x/rootupdater/types/params.pb.go +++ b/x/rootupdater/types/params.pb.go @@ -25,11 +25,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - Root string `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` - LastRoot string `protobuf:"bytes,3,opt,name=last_root,json=lastRoot,proto3" json:"last_root,omitempty"` - Index string `protobuf:"bytes,4,opt,name=index,proto3" json:"index,omitempty"` - EventName string `protobuf:"bytes,5,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + Root string `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` + LastSignedRoot string `protobuf:"bytes,3,opt,name=last_signed_root,json=lastSignedRoot,proto3" json:"last_signed_root,omitempty"` + LastSignedRootIndex string `protobuf:"bytes,4,opt,name=last_signed_root_index,json=lastSignedRootIndex,proto3" json:"last_signed_root_index,omitempty"` + EventName string `protobuf:"bytes,5,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` + RootTimestamp uint32 `protobuf:"varint,6,opt,name=root_timestamp,json=rootTimestamp,proto3" json:"root_timestamp,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -79,16 +80,16 @@ func (m *Params) GetRoot() string { return "" } -func (m *Params) GetLastRoot() string { +func (m *Params) GetLastSignedRoot() string { if m != nil { - return m.LastRoot + return m.LastSignedRoot } return "" } -func (m *Params) GetIndex() string { +func (m *Params) GetLastSignedRootIndex() string { if m != nil { - return m.Index + return m.LastSignedRootIndex } return "" } @@ -100,6 +101,13 @@ func (m *Params) GetEventName() string { return "" } +func (m *Params) GetRootTimestamp() uint32 { + if m != nil { + return m.RootTimestamp + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "rarimo.rootupdater.Params") } @@ -107,23 +115,25 @@ func init() { func init() { proto.RegisterFile("rootupdater/params.proto", fileDescriptor_31e4e5f76db9f10e) } var fileDescriptor_31e4e5f76db9f10e = []byte{ - // 247 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4a, 0xc4, 0x30, - 0x10, 0x86, 0x1b, 0xdd, 0x5d, 0x6c, 0x2e, 0x4a, 0xd8, 0x43, 0x50, 0x0c, 0xe2, 0x49, 0x0f, 0x36, - 0x88, 0x4f, 0xa0, 0x57, 0x41, 0x64, 0x8f, 0x5e, 0x4a, 0xb6, 0x0d, 0xb5, 0x60, 0x3a, 0x65, 0x32, - 0x2b, 0xeb, 0x5b, 0x78, 0xf5, 0x8d, 0x3c, 0xee, 0xd1, 0xa3, 0xb4, 0x2f, 0x22, 0x9d, 0xba, 0xd0, - 0x53, 0x26, 0xdf, 0xf7, 0x27, 0xf0, 0x8f, 0xd4, 0x08, 0x40, 0x9b, 0xb6, 0x74, 0xe4, 0xd1, 0xb6, - 0x0e, 0x5d, 0x88, 0x59, 0x8b, 0x40, 0xa0, 0x14, 0x3a, 0xac, 0x03, 0x64, 0x93, 0xc0, 0xe9, 0xb2, - 0x82, 0x0a, 0x58, 0xdb, 0x61, 0x1a, 0x93, 0x97, 0x5f, 0x42, 0x2e, 0x9e, 0xf9, 0xa9, 0xba, 0x96, - 0x27, 0x05, 0x34, 0x84, 0xae, 0xa0, 0xdc, 0x95, 0x25, 0xfa, 0x18, 0xb5, 0xb8, 0x10, 0x57, 0xe9, - 0xea, 0x78, 0xcf, 0xef, 0x47, 0xac, 0x94, 0x9c, 0x0d, 0x5f, 0xeb, 0x03, 0xd6, 0x3c, 0xab, 0x33, - 0x99, 0xbe, 0xb9, 0x48, 0x39, 0x8b, 0x43, 0x16, 0x47, 0x03, 0x58, 0x0d, 0x72, 0x29, 0xe7, 0x75, - 0x53, 0xfa, 0xad, 0x9e, 0xb1, 0x18, 0x2f, 0xea, 0x5c, 0x4a, 0xff, 0xee, 0x1b, 0xca, 0x1b, 0x17, - 0xbc, 0x9e, 0xb3, 0x4a, 0x99, 0x3c, 0xb9, 0xe0, 0x1f, 0x1e, 0xbf, 0x3b, 0x23, 0x76, 0x9d, 0x11, - 0xbf, 0x9d, 0x11, 0x9f, 0xbd, 0x49, 0x76, 0xbd, 0x49, 0x7e, 0x7a, 0x93, 0xbc, 0xdc, 0x56, 0x35, - 0xbd, 0x6e, 0xd6, 0x59, 0x01, 0xc1, 0x8e, 0x55, 0xff, 0x8f, 0x9b, 0x02, 0xd0, 0xdb, 0xad, 0x9d, - 0x6e, 0x86, 0x3e, 0x5a, 0x1f, 0xd7, 0x0b, 0xee, 0x7b, 0xf7, 0x17, 0x00, 0x00, 0xff, 0xff, 0x07, - 0x19, 0xc0, 0x2c, 0x35, 0x01, 0x00, 0x00, + // 285 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x41, 0x4b, 0xc3, 0x30, + 0x14, 0x80, 0x17, 0x9d, 0x83, 0x05, 0x36, 0x47, 0x14, 0x09, 0x82, 0x61, 0x08, 0xc2, 0x3c, 0xd8, + 0x22, 0xfb, 0x05, 0x7a, 0x13, 0x41, 0xa4, 0x7a, 0xf2, 0x52, 0xb2, 0xf6, 0x51, 0x0b, 0xa6, 0x29, + 0xc9, 0x9b, 0xcc, 0x7f, 0xe1, 0xcf, 0xf2, 0xb8, 0xa3, 0x47, 0x69, 0xaf, 0xfe, 0x08, 0xc9, 0xab, + 0x83, 0xe9, 0x29, 0x8f, 0xef, 0xfb, 0xf2, 0x0e, 0x8f, 0x4b, 0x67, 0x2d, 0x2e, 0xeb, 0x5c, 0x23, + 0xb8, 0xb8, 0xd6, 0x4e, 0x1b, 0x1f, 0xd5, 0xce, 0xa2, 0x15, 0xc2, 0x69, 0x57, 0x1a, 0x1b, 0x6d, + 0x05, 0xc7, 0x87, 0x85, 0x2d, 0x2c, 0xe9, 0x38, 0x4c, 0x5d, 0x79, 0xfa, 0xcd, 0xf8, 0xe0, 0x9e, + 0xbe, 0x8a, 0x73, 0x3e, 0xc9, 0x6c, 0x85, 0x4e, 0x67, 0x98, 0xea, 0x3c, 0x77, 0xe0, 0xbd, 0x64, + 0x53, 0x36, 0x1b, 0x26, 0xfb, 0x1b, 0x7e, 0xd5, 0x61, 0x21, 0x78, 0x3f, 0xac, 0x96, 0x3b, 0xa4, + 0x69, 0x16, 0x33, 0x3e, 0x79, 0xd1, 0x1e, 0x53, 0x5f, 0x16, 0x15, 0xe4, 0x29, 0xf9, 0x5d, 0xf2, + 0xe3, 0xc0, 0x1f, 0x08, 0x27, 0xa1, 0x9c, 0xf3, 0xa3, 0xff, 0x65, 0x5a, 0x56, 0x39, 0xac, 0x64, + 0x9f, 0xfa, 0x83, 0xbf, 0xfd, 0x4d, 0x50, 0xe2, 0x84, 0x73, 0x78, 0x85, 0x0a, 0xd3, 0x4a, 0x1b, + 0x90, 0x7b, 0x14, 0x0e, 0x89, 0xdc, 0x69, 0x03, 0xe2, 0x8c, 0x8f, 0x69, 0x0f, 0x96, 0x06, 0x3c, + 0x6a, 0x53, 0xcb, 0xc1, 0x94, 0xcd, 0x46, 0xc9, 0x28, 0xd0, 0xc7, 0x0d, 0xbc, 0xbe, 0xfd, 0x68, + 0x14, 0x5b, 0x37, 0x8a, 0x7d, 0x35, 0x8a, 0xbd, 0xb7, 0xaa, 0xb7, 0x6e, 0x55, 0xef, 0xb3, 0x55, + 0xbd, 0xa7, 0xcb, 0xa2, 0xc4, 0xe7, 0xe5, 0x22, 0xca, 0xac, 0x89, 0xbb, 0xeb, 0xfd, 0x3e, 0x17, + 0x99, 0x75, 0x10, 0xaf, 0xe2, 0xed, 0x63, 0xe3, 0x5b, 0x0d, 0x7e, 0x31, 0xa0, 0x13, 0xce, 0x7f, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x1d, 0xf0, 0x7c, 0x7b, 0x88, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -146,6 +156,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.RootTimestamp != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.RootTimestamp)) + i-- + dAtA[i] = 0x30 + } if len(m.EventName) > 0 { i -= len(m.EventName) copy(dAtA[i:], m.EventName) @@ -153,17 +168,17 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if len(m.Index) > 0 { - i -= len(m.Index) - copy(dAtA[i:], m.Index) - i = encodeVarintParams(dAtA, i, uint64(len(m.Index))) + if len(m.LastSignedRootIndex) > 0 { + i -= len(m.LastSignedRootIndex) + copy(dAtA[i:], m.LastSignedRootIndex) + i = encodeVarintParams(dAtA, i, uint64(len(m.LastSignedRootIndex))) i-- dAtA[i] = 0x22 } - if len(m.LastRoot) > 0 { - i -= len(m.LastRoot) - copy(dAtA[i:], m.LastRoot) - i = encodeVarintParams(dAtA, i, uint64(len(m.LastRoot))) + if len(m.LastSignedRoot) > 0 { + i -= len(m.LastSignedRoot) + copy(dAtA[i:], m.LastSignedRoot) + i = encodeVarintParams(dAtA, i, uint64(len(m.LastSignedRoot))) i-- dAtA[i] = 0x1a } @@ -209,11 +224,11 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - l = len(m.LastRoot) + l = len(m.LastSignedRoot) if l > 0 { n += 1 + l + sovParams(uint64(l)) } - l = len(m.Index) + l = len(m.LastSignedRootIndex) if l > 0 { n += 1 + l + sovParams(uint64(l)) } @@ -221,6 +236,9 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } + if m.RootTimestamp != 0 { + n += 1 + sovParams(uint64(m.RootTimestamp)) + } return n } @@ -325,7 +343,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastRoot", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LastSignedRoot", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -353,11 +371,11 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.LastRoot = string(dAtA[iNdEx:postIndex]) + m.LastSignedRoot = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LastSignedRootIndex", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -385,7 +403,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Index = string(dAtA[iNdEx:postIndex]) + m.LastSignedRootIndex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { @@ -419,6 +437,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.EventName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RootTimestamp", wireType) + } + m.RootTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RootTimestamp |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/rootupdater/types/tx.pb.go b/x/rootupdater/types/tx.pb.go index 48229bb7..9a00ca5e 100644 --- a/x/rootupdater/types/tx.pb.go +++ b/x/rootupdater/types/tx.pb.go @@ -9,11 +9,7 @@ import ( grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/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. @@ -27,116 +23,18 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type MsgUpdateRoot struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Root string `protobuf:"bytes,2,opt,name=root,proto3" json:"root,omitempty"` -} - -func (m *MsgUpdateRoot) Reset() { *m = MsgUpdateRoot{} } -func (m *MsgUpdateRoot) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateRoot) ProtoMessage() {} -func (*MsgUpdateRoot) Descriptor() ([]byte, []int) { - return fileDescriptor_72679a1b23c83bcf, []int{0} -} -func (m *MsgUpdateRoot) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateRoot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateRoot.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 *MsgUpdateRoot) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateRoot.Merge(m, src) -} -func (m *MsgUpdateRoot) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateRoot) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateRoot.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateRoot proto.InternalMessageInfo - -func (m *MsgUpdateRoot) GetCreator() string { - if m != nil { - return m.Creator - } - return "" -} - -func (m *MsgUpdateRoot) GetRoot() string { - if m != nil { - return m.Root - } - return "" -} - -type MsgUpdateRootResponse struct { -} - -func (m *MsgUpdateRootResponse) Reset() { *m = MsgUpdateRootResponse{} } -func (m *MsgUpdateRootResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateRootResponse) ProtoMessage() {} -func (*MsgUpdateRootResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_72679a1b23c83bcf, []int{1} -} -func (m *MsgUpdateRootResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateRootResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateRootResponse.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 *MsgUpdateRootResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateRootResponse.Merge(m, src) -} -func (m *MsgUpdateRootResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateRootResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateRootResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateRootResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgUpdateRoot)(nil), "rarimo.rootupdater.MsgUpdateRoot") - proto.RegisterType((*MsgUpdateRootResponse)(nil), "rarimo.rootupdater.MsgUpdateRootResponse") -} - func init() { proto.RegisterFile("rootupdater/tx.proto", fileDescriptor_72679a1b23c83bcf) } var fileDescriptor_72679a1b23c83bcf = []byte{ - // 208 bytes of a gzipped FileDescriptorProto + // 128 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0xca, 0xcf, 0x2f, 0x29, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x2d, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x12, 0x2a, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x43, 0x92, 0x54, 0xb2, 0xe5, 0xe2, 0xf5, - 0x2d, 0x4e, 0x0f, 0x05, 0xf3, 0x82, 0xf2, 0xf3, 0x4b, 0x84, 0x24, 0xb8, 0xd8, 0x93, 0x8b, 0x52, - 0x13, 0x4b, 0xf2, 0x8b, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x21, 0x21, 0x2e, - 0x16, 0x90, 0x4e, 0x09, 0x26, 0xb0, 0x30, 0x98, 0xad, 0x24, 0xce, 0x25, 0x8a, 0xa2, 0x3d, 0x28, - 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0x28, 0x91, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x8a, - 0x8b, 0x0b, 0xc9, 0x6c, 0x45, 0x3d, 0x4c, 0x17, 0xe8, 0xa1, 0xe8, 0x97, 0xd2, 0x24, 0xa8, 0x04, - 0x66, 0x85, 0x93, 0xf7, 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, 0x19, 0xa6, - 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x8c, 0x83, 0x52, 0xba, 0xc9, - 0xf9, 0x45, 0xa9, 0xfa, 0x15, 0xfa, 0x28, 0xc1, 0x53, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, - 0x22, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x83, 0x19, 0x2d, 0x21, 0x3a, 0x01, 0x00, 0x00, + 0x17, 0x12, 0x2a, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x43, 0x92, 0x34, 0x62, 0xe5, 0x62, 0xf6, + 0x2d, 0x4e, 0x77, 0xf2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, + 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xc3, + 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x88, 0x7e, 0x28, 0xa5, 0x9b, + 0x9c, 0x5f, 0x94, 0xaa, 0x5f, 0xa1, 0x8f, 0x62, 0x55, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, + 0x3a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9e, 0xbd, 0xae, 0x23, 0x86, 0x00, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -151,7 +49,6 @@ 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 { - UpdateRoot(ctx context.Context, in *MsgUpdateRoot, opts ...grpc.CallOption) (*MsgUpdateRootResponse, error) } type msgClient struct { @@ -162,411 +59,22 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) UpdateRoot(ctx context.Context, in *MsgUpdateRoot, opts ...grpc.CallOption) (*MsgUpdateRootResponse, error) { - out := new(MsgUpdateRootResponse) - err := c.cc.Invoke(ctx, "/rarimo.rootupdater.Msg/UpdateRoot", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // MsgServer is the server API for Msg service. type MsgServer interface { - UpdateRoot(context.Context, *MsgUpdateRoot) (*MsgUpdateRootResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) UpdateRoot(ctx context.Context, req *MsgUpdateRoot) (*MsgUpdateRootResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateRoot not implemented") -} - func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_UpdateRoot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateRoot) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateRoot(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/rarimo.rootupdater.Msg/UpdateRoot", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateRoot(ctx, req.(*MsgUpdateRoot)) - } - return interceptor(ctx, in, info, handler) -} - var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "rarimo.rootupdater.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "UpdateRoot", - Handler: _Msg_UpdateRoot_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "rootupdater/tx.proto", -} - -func (m *MsgUpdateRoot) 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 *MsgUpdateRoot) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateRoot) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Root) > 0 { - i -= len(m.Root) - copy(dAtA[i:], m.Root) - i = encodeVarintTx(dAtA, i, uint64(len(m.Root))) - i-- - dAtA[i] = 0x12 - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "rootupdater/tx.proto", } - -func (m *MsgUpdateRootResponse) 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 *MsgUpdateRootResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateRootResponse) 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 *MsgUpdateRoot) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Root) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgUpdateRootResponse) 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 *MsgUpdateRoot) 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: MsgUpdateRoot: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateRoot: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Root", 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.Root = 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 *MsgUpdateRootResponse) 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: MsgUpdateRootResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateRootResponse: 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") -) From 34ee4d4a5180c6dac2e8dbbafe4857a921a474cf Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Mon, 19 Aug 2024 12:50:39 +0300 Subject: [PATCH 06/14] fix evm hook issues and update rootupdater module --- app/app.go | 18 +- go.mod | 4 +- go.sum | 5 +- x/evm/keeper/hooks.go | 6 +- x/identity/keeper/keeper.go | 8 +- .../crypto/pkg/op_passport_root_update.go | 29 +- .../types/op_passport_root_update.pb.go | 406 ++++++++++++++++++ x/rootupdater/keeper/abci.go | 2 +- x/rootupdater/keeper/keeper.go | 9 +- x/rootupdater/module.go | 3 +- 10 files changed, 464 insertions(+), 26 deletions(-) create mode 100644 x/rarimocore/types/op_passport_root_update.pb.go diff --git a/app/app.go b/app/app.go index a7d51abd..e15dcd5b 100644 --- a/app/app.go +++ b/app/app.go @@ -654,6 +654,15 @@ func New( ) feeMarketModule := feemarket.NewAppModule(app.FeeMarketKeeper, feeMarketSs) // <- ACTUAL module creation in app.go that you need + app.RootupdaterKeeper = *rootupdatermodulekeeper.NewKeeper( + appCodec, + keys[rootupdatermoduletypes.StoreKey], + keys[rootupdatermoduletypes.MemStoreKey], + app.GetSubspace(rootupdatermoduletypes.ModuleName), + app.RarimocoreKeeper, + ) + rootupdaterModule := rootupdatermodule.NewAppModule(appCodec, app.RootupdaterKeeper) + // Set authority to x/gov module account to only expect the module account to update params evmSs := app.GetSubspace(evmtypes.ModuleName) app.EvmKeeper = evmkeeper.NewKeeper( @@ -676,15 +685,6 @@ func New( ) vestingmintModule := vestingmintmodule.NewAppModule(appCodec, app.VestingmintKeeper, app.AccountKeeper, app.BankKeeper) - app.RootupdaterKeeper = *rootupdatermodulekeeper.NewKeeper( - appCodec, - keys[rootupdatermoduletypes.StoreKey], - keys[rootupdatermoduletypes.MemStoreKey], - app.GetSubspace(rootupdatermoduletypes.ModuleName), - app.RarimocoreKeeper, - ) - rootupdaterModule := rootupdatermodule.NewAppModule(appCodec, app.RootupdaterKeeper) - // this line is used by starport scaffolding # stargate/app/keeperDefinition /**** IBC Routing ****/ diff --git a/go.mod b/go.mod index 33d40677..fb420d55 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,6 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a google.golang.org/grpc v1.64.1 google.golang.org/protobuf v1.34.2 - gopkg.in/yaml.v2 v2.4.0 sigs.k8s.io/yaml v1.4.0 ) @@ -93,7 +92,6 @@ require ( github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-gonic/gin v1.8.1 // indirect github.com/github/smimesign v0.2.0 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -209,6 +207,7 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect ) @@ -222,4 +221,5 @@ replace ( github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.24 google.golang.org/grpc => google.golang.org/grpc v1.55.0 + nhooyr.io/websocket => github.com/coder/websocket v1.8.6 ) diff --git a/go.sum b/go.sum index d893ee06..395a3682 100644 --- a/go.sum +++ b/go.sum @@ -681,6 +681,8 @@ github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b80 github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/coder/websocket v1.8.6 h1:OmNKdwUvLj7VvHnl5o8skaVghSPLjWdHGCnFbkWqs9w= +github.com/coder/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= @@ -808,7 +810,6 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqG github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -2398,8 +2399,6 @@ modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8= -nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= -nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/x/evm/keeper/hooks.go b/x/evm/keeper/hooks.go index 8ecbffbe..63f60ff4 100644 --- a/x/evm/keeper/hooks.go +++ b/x/evm/keeper/hooks.go @@ -35,10 +35,12 @@ func NewMultiEvmHooks(hooks ...types.EvmHooks) MultiEvmHooks { // PostTxProcessing delegate the call to underlying hooks func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error { + var errBunch error + for i := range mh { if err := mh[i].PostTxProcessing(ctx, msg, receipt); err != nil { - return errorsmod.Wrapf(err, "EVM hook %T failed", mh[i]) + errBunch = errorsmod.Wrapf(err, "EVM hook %T failed", mh[i]) } } - return nil + return errBunch } diff --git a/x/identity/keeper/keeper.go b/x/identity/keeper/keeper.go index 1f742412..6e4a4a8e 100644 --- a/x/identity/keeper/keeper.go +++ b/x/identity/keeper/keeper.go @@ -105,7 +105,13 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth } // Validating message receiver address (should be our state smart contract) - if msg.To() == nil || bytes.Compare(msg.To().Bytes(), hexutil.MustDecode(params.IdentityContractAddress)) != 0 { + addressBytes, err := hexutil.Decode(params.IdentityContractAddress) + if err != nil { + k.Logger(ctx).Debug("failed to decode contract address") + return nil + } + + if msg.To() == nil || bytes.Compare(msg.To().Bytes(), addressBytes) != 0 { return nil } diff --git a/x/rarimocore/crypto/pkg/op_passport_root_update.go b/x/rarimocore/crypto/pkg/op_passport_root_update.go index 7943909e..ff105945 100644 --- a/x/rarimocore/crypto/pkg/op_passport_root_update.go +++ b/x/rarimocore/crypto/pkg/op_passport_root_update.go @@ -2,12 +2,12 @@ package pkg import ( "cosmossdk.io/errors" - "encoding/binary" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/gogo/protobuf/proto" "github.com/rarimo/rarimo-core/x/rarimocore/crypto/operation" "github.com/rarimo/rarimo-core/x/rarimocore/types" + "time" ) func GetPassportRootUpdate(operation types.Operation) (*types.PassportRootUpdate, error) { @@ -19,12 +19,29 @@ func GetPassportRootUpdate(operation types.Operation) (*types.PassportRootUpdate } func GetPassportRootUpdateContent(op *types.PassportRootUpdate) (*operation.PassportRootUpdateContent, error) { - bytesTimestamp := make([]byte, 0) - binary.BigEndian.PutUint32(bytesTimestamp, op.Timestamp) + timestamp := time.Unix(int64(op.Timestamp), 0) + timestampBytes, err := timestamp.MarshalBinary() + if err != nil { + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + + if op.Root[:2] != "0x" { + op.Root = "0x" + op.Root + } + + root, err := hexutil.Decode(op.Root) + if err != nil { + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + + contractAddress, err := hexutil.Decode(op.ContractAddress) + if err != nil { + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } return &operation.PassportRootUpdateContent{ - ContractAddress: operation.To32Bytes(hexutil.MustDecode(op.ContractAddress)), - Root: operation.To32Bytes(hexutil.MustDecode(op.Root)), - RootTimestamp: operation.To32Bytes(bytesTimestamp), + ContractAddress: operation.To32Bytes(contractAddress), + Root: operation.To32Bytes(root), + RootTimestamp: operation.To32Bytes(timestampBytes), }, nil } diff --git a/x/rarimocore/types/op_passport_root_update.pb.go b/x/rarimocore/types/op_passport_root_update.pb.go new file mode 100644 index 00000000..27bd7b9b --- /dev/null +++ b/x/rarimocore/types/op_passport_root_update.pb.go @@ -0,0 +1,406 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rarimocore/op_passport_root_update.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type PassportRootUpdate struct { + Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` + ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + Timestamp uint32 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *PassportRootUpdate) Reset() { *m = PassportRootUpdate{} } +func (m *PassportRootUpdate) String() string { return proto.CompactTextString(m) } +func (*PassportRootUpdate) ProtoMessage() {} +func (*PassportRootUpdate) Descriptor() ([]byte, []int) { + return fileDescriptor_f6416f25faf40b9e, []int{0} +} +func (m *PassportRootUpdate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PassportRootUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PassportRootUpdate.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 *PassportRootUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_PassportRootUpdate.Merge(m, src) +} +func (m *PassportRootUpdate) XXX_Size() int { + return m.Size() +} +func (m *PassportRootUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_PassportRootUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_PassportRootUpdate proto.InternalMessageInfo + +func (m *PassportRootUpdate) GetRoot() string { + if m != nil { + return m.Root + } + return "" +} + +func (m *PassportRootUpdate) GetContractAddress() string { + if m != nil { + return m.ContractAddress + } + return "" +} + +func (m *PassportRootUpdate) GetTimestamp() uint32 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func init() { + proto.RegisterType((*PassportRootUpdate)(nil), "rarimo.rarimocore.rarimocore.PassportRootUpdate") +} + +func init() { + proto.RegisterFile("rarimocore/op_passport_root_update.proto", fileDescriptor_f6416f25faf40b9e) +} + +var fileDescriptor_f6416f25faf40b9e = []byte{ + // 218 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x4a, 0x2c, 0xca, + 0xcc, 0xcd, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x88, 0x2f, 0x48, 0x2c, 0x2e, 0x2e, 0xc8, + 0x2f, 0x2a, 0x89, 0x2f, 0xca, 0xcf, 0x2f, 0x89, 0x2f, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xd5, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0xa8, 0xd4, 0x43, 0x68, 0x40, 0x62, 0x2a, 0x15, 0x72, + 0x09, 0x05, 0x40, 0xf5, 0x06, 0xe5, 0xe7, 0x97, 0x84, 0x82, 0x75, 0x0a, 0x09, 0x71, 0xb1, 0x80, + 0x0c, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x85, 0x34, 0xb9, 0x04, 0x92, 0xf3, + 0xf3, 0x4a, 0x8a, 0x12, 0x93, 0x4b, 0xe2, 0x13, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x25, 0x98, + 0xc0, 0xf2, 0xfc, 0x30, 0x71, 0x47, 0x88, 0xb0, 0x90, 0x0c, 0x17, 0x67, 0x49, 0x66, 0x6e, 0x6a, + 0x71, 0x49, 0x62, 0x6e, 0x81, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x6f, 0x10, 0x42, 0xc0, 0xc9, 0xeb, + 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, + 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, + 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x21, 0x6e, 0x84, 0x52, 0xba, 0x60, 0x7f, 0x56, 0xe8, 0x23, + 0x79, 0xba, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x47, 0x63, 0x40, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xec, 0xe2, 0x89, 0x85, 0x0f, 0x01, 0x00, 0x00, +} + +func (m *PassportRootUpdate) 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 *PassportRootUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PassportRootUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x18 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Root) > 0 { + i -= len(m.Root) + copy(dAtA[i:], m.Root) + i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(len(m.Root))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOpPassportRootUpdate(dAtA []byte, offset int, v uint64) int { + offset -= sovOpPassportRootUpdate(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PassportRootUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Root) + if l > 0 { + n += 1 + l + sovOpPassportRootUpdate(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovOpPassportRootUpdate(uint64(l)) + } + if m.Timestamp != 0 { + n += 1 + sovOpPassportRootUpdate(uint64(m.Timestamp)) + } + return n +} + +func sovOpPassportRootUpdate(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOpPassportRootUpdate(x uint64) (n int) { + return sovOpPassportRootUpdate(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PassportRootUpdate) 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 ErrIntOverflowOpPassportRootUpdate + } + 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: PassportRootUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PassportRootUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Root", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + 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 ErrInvalidLengthOpPassportRootUpdate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOpPassportRootUpdate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Root = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + 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 ErrInvalidLengthOpPassportRootUpdate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOpPassportRootUpdate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOpPassportRootUpdate(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOpPassportRootUpdate + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOpPassportRootUpdate(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, ErrIntOverflowOpPassportRootUpdate + } + 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, ErrIntOverflowOpPassportRootUpdate + } + 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, ErrIntOverflowOpPassportRootUpdate + } + 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, ErrInvalidLengthOpPassportRootUpdate + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOpPassportRootUpdate + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOpPassportRootUpdate + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOpPassportRootUpdate = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOpPassportRootUpdate = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOpPassportRootUpdate = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rootupdater/keeper/abci.go b/x/rootupdater/keeper/abci.go index cd488659..01c40db8 100644 --- a/x/rootupdater/keeper/abci.go +++ b/x/rootupdater/keeper/abci.go @@ -9,7 +9,7 @@ import ( func (k Keeper) EndBlocker(ctx sdk.Context) { params := k.GetParams(ctx) - if params.Root == params.LastSignedRoot { + if params.Root == params.LastSignedRoot && params.Root != "" { return } diff --git a/x/rootupdater/keeper/keeper.go b/x/rootupdater/keeper/keeper.go index 21776449..8515b186 100644 --- a/x/rootupdater/keeper/keeper.go +++ b/x/rootupdater/keeper/keeper.go @@ -64,8 +64,15 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth return err } + contractAddress, err := hexutil.Decode(params.ContractAddress) + if err != nil { + // If return an error here, the whole EVM module won't work + k.Logger(ctx).Debug("failed to decode contract address") + return nil + } + // Validating message receiver address (should be our state smart contract) - if msg.To() == nil || bytes.Compare(msg.To().Bytes(), hexutil.MustDecode(params.ContractAddress)) != 0 { + if msg.To() == nil || bytes.Compare(msg.To().Bytes(), contractAddress) != 0 { return nil } diff --git a/x/rootupdater/module.go b/x/rootupdater/module.go index 588a6a89..833b64b2 100644 --- a/x/rootupdater/module.go +++ b/x/rootupdater/module.go @@ -150,6 +150,7 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} // EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + am.keeper.EndBlocker(ctx) return []abci.ValidatorUpdate{} } From a1bd0271ba74a2fef5aa590f36b7575962a0ec90 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Mon, 19 Aug 2024 14:02:56 +0300 Subject: [PATCH 07/14] update swagger --- docs/static/openapi.yml | 107 +++++++++++++++++++++++++++++++++++++ go.mod | 13 ++--- go.sum | 25 ++++----- proto/rootupdater/tx.proto | 4 +- 4 files changed, 130 insertions(+), 19 deletions(-) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 50567c09..7ca95ebb 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -52536,6 +52536,8 @@ paths: - IDENTITY_STATE_TRANSFER - WORLDCOIN_IDENTITY_TRANSFER - CSCA_ROOT_UPDATE + - ARBITRARY + - PASSPORT_ROOT_UPDATE default: TRANSFER details: title: Corresponding to type details @@ -53027,6 +53029,8 @@ paths: - IDENTITY_STATE_TRANSFER - WORLDCOIN_IDENTITY_TRANSFER - CSCA_ROOT_UPDATE + - ARBITRARY + - PASSPORT_ROOT_UPDATE default: TRANSFER details: title: Corresponding to type details @@ -57544,6 +57548,7 @@ paths: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -58928,6 +58933,7 @@ paths: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -60045,6 +60051,56 @@ paths: format: uint64 tags: - Query + /rarimo/rarimo-core/rootupdater/params: + get: + summary: Parameters queries the parameters of the module. + operationId: RarimoRootupdaterParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + contract_address: + type: string + root: + type: string + last_signed_root: + type: string + last_signed_root_index: + type: string + event_name: + type: string + root_timestamp: + type: integer + format: int64 + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query definitions: cosmos.auth.v1beta1.AddressBytesToStringResponse: type: object @@ -91007,6 +91063,8 @@ definitions: - IDENTITY_STATE_TRANSFER - WORLDCOIN_IDENTITY_TRANSFER - CSCA_ROOT_UPDATE + - ARBITRARY + - PASSPORT_ROOT_UPDATE default: TRANSFER rarimo.rarimocore.rarimocore.Operation: type: object @@ -91027,6 +91085,8 @@ definitions: - IDENTITY_STATE_TRANSFER - WORLDCOIN_IDENTITY_TRANSFER - CSCA_ROOT_UPDATE + - ARBITRARY + - PASSPORT_ROOT_UPDATE default: TRANSFER details: title: Corresponding to type details @@ -91377,6 +91437,8 @@ definitions: - IDENTITY_STATE_TRANSFER - WORLDCOIN_IDENTITY_TRANSFER - CSCA_ROOT_UPDATE + - ARBITRARY + - PASSPORT_ROOT_UPDATE default: TRANSFER details: title: Corresponding to type details @@ -91735,6 +91797,8 @@ definitions: - IDENTITY_STATE_TRANSFER - WORLDCOIN_IDENTITY_TRANSFER - CSCA_ROOT_UPDATE + - ARBITRARY + - PASSPORT_ROOT_UPDATE default: TRANSFER details: title: Corresponding to type details @@ -92211,6 +92275,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -92575,6 +92640,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM rarimo.rarimocore.tokenmanager.OnChainItem: type: object @@ -92609,6 +92675,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -93366,6 +93433,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -93577,6 +93645,7 @@ definitions: - Near - Other - Rarimo + - RarimoEVM default: EVM params: type: array @@ -93901,3 +93970,41 @@ definitions: format: uint64 denom: type: string + rarimo.rootupdater.Params: + type: object + properties: + contract_address: + type: string + root: + type: string + last_signed_root: + type: string + last_signed_root_index: + type: string + event_name: + type: string + root_timestamp: + type: integer + format: int64 + description: Params defines the parameters for the module. + rarimo.rootupdater.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + contract_address: + type: string + root: + type: string + last_signed_root: + type: string + last_signed_root_index: + type: string + event_name: + type: string + root_timestamp: + type: integer + format: int64 + description: QueryParamsResponse is response type for the Query/Params RPC method. diff --git a/go.mod b/go.mod index fb420d55..acb24bd7 100644 --- a/go.mod +++ b/go.mod @@ -40,8 +40,8 @@ require ( github.com/tidwall/sjson v1.2.5 github.com/tyler-smith/go-bip39 v1.1.0 golang.org/x/net v0.26.0 - golang.org/x/text v0.16.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a + golang.org/x/text v0.17.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 google.golang.org/grpc v1.64.1 google.golang.org/protobuf v1.34.2 sigs.k8s.io/yaml v1.4.0 @@ -92,6 +92,7 @@ require ( github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-gonic/gin v1.8.1 // indirect github.com/github/smimesign v0.2.0 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -116,7 +117,7 @@ require ( github.com/googleapis/gax-go/v2 v2.12.3 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect @@ -196,14 +197,14 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect - golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect + golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/term v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.170.0 // indirect google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect diff --git a/go.sum b/go.sum index 395a3682..db735c89 100644 --- a/go.sum +++ b/go.sum @@ -810,6 +810,7 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqG github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -1046,8 +1047,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -1833,8 +1834,8 @@ golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1851,8 +1852,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1994,8 +1995,8 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2295,10 +2296,10 @@ google.golang.org/genproto v0.0.0-20230222225845-10f96fb3dbec/go.mod h1:3Dl5ZL0q google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be h1:g4aX8SUFA8V5F4LrSY5EclyGYw1OZN4HS1jTyjB9ZDc= google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be/go.mod h1:FeSdT5fk+lkxatqJP38MsUicGqHax5cLtmy/6TAuxO4= -google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a h1:YIa/rzVqMEokBkPtydCkx1VLmv3An1Uw7w1P1m6EhOY= -google.golang.org/genproto/googleapis/api v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:AHT0dDg3SoMOgZGnZk29b5xTbPHMoEC8qthmBLJCpys= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a h1:hqK4+jJZXCU4pW7jsAdGOVFIfLHQeV7LaizZKnZ84HI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= diff --git a/proto/rootupdater/tx.proto b/proto/rootupdater/tx.proto index 9ce810f6..a1408b3c 100644 --- a/proto/rootupdater/tx.proto +++ b/proto/rootupdater/tx.proto @@ -4,6 +4,8 @@ package rarimo.rootupdater; option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; // Msg defines the Msg service. -service Msg {} +service Msg { + +} // this line is used by starport scaffolding # proto/tx/message From 6c1b8950631394109814c2bc17d456f7c474ddf3 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Mon, 19 Aug 2024 14:12:05 +0300 Subject: [PATCH 08/14] set timestemp --- x/rootupdater/keeper/keeper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/rootupdater/keeper/keeper.go b/x/rootupdater/keeper/keeper.go index 8515b186..945d4037 100644 --- a/x/rootupdater/keeper/keeper.go +++ b/x/rootupdater/keeper/keeper.go @@ -11,6 +11,7 @@ import ( "github.com/rarimo/rarimo-core/ethermint/utils" "github.com/rarimo/rarimo-core/x/rootupdater/pkg/state" "strings" + "time" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -95,6 +96,7 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth } params.Root = hex.EncodeToString(eventBody.Root[:]) + params.RootTimestamp = uint32(time.Now().Unix()) k.Logger(ctx).Info(fmt.Sprintf("Received PostTxProcessing event in %s module: %v", types.ModuleName, eventBody)) k.SetParams(ctx, params) From d1dcda75843f0715f2493f16d6e38fbb72b1fc63 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Wed, 21 Aug 2024 11:04:05 +0300 Subject: [PATCH 09/14] pr fixes --- go.sum | 3 +++ .../rarimocore/op_passport_root_update.proto | 3 ++- proto/rootupdater/params.proto | 2 +- x/evm/keeper/hooks.go | 2 +- .../crypto/pkg/op_passport_root_update.go | 27 +++---------------- .../types/op_passport_root_update.pb.go | 10 +++---- x/rootupdater/keeper/keeper.go | 17 +++++------- x/rootupdater/types/params.pb.go | 26 +++++++++--------- 8 files changed, 35 insertions(+), 55 deletions(-) diff --git a/go.sum b/go.sum index db735c89..66c35e63 100644 --- a/go.sum +++ b/go.sum @@ -1154,6 +1154,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o= @@ -1278,6 +1279,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= @@ -1531,6 +1533,7 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= diff --git a/proto/rarimocore/op_passport_root_update.proto b/proto/rarimocore/op_passport_root_update.proto index a2df09bf..3b207190 100644 --- a/proto/rarimocore/op_passport_root_update.proto +++ b/proto/rarimocore/op_passport_root_update.proto @@ -6,6 +6,7 @@ option go_package = "github.com/rarimo/rarimo-core/x/rarimocore/types"; message PassportRootUpdate { string root = 1; string contract_address = 2; - uint32 timestamp = 3; + int64 timestamp = 3; } + diff --git a/proto/rootupdater/params.proto b/proto/rootupdater/params.proto index cb2774a0..3bdbafc0 100644 --- a/proto/rootupdater/params.proto +++ b/proto/rootupdater/params.proto @@ -12,5 +12,5 @@ message Params { string last_signed_root = 3; string last_signed_root_index = 4; string event_name = 5; - uint32 root_timestamp = 6; + int64 root_timestamp = 6; } diff --git a/x/evm/keeper/hooks.go b/x/evm/keeper/hooks.go index 63f60ff4..be7c1cac 100644 --- a/x/evm/keeper/hooks.go +++ b/x/evm/keeper/hooks.go @@ -39,7 +39,7 @@ func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, msg core.Message, rece for i := range mh { if err := mh[i].PostTxProcessing(ctx, msg, receipt); err != nil { - errBunch = errorsmod.Wrapf(err, "EVM hook %T failed", mh[i]) + errBunch = errorsmod.Wrapf(errorsmod.Wrap(errBunch, err.Error()), "EVM hook %T failed", mh[i]) } } return errBunch diff --git a/x/rarimocore/crypto/pkg/op_passport_root_update.go b/x/rarimocore/crypto/pkg/op_passport_root_update.go index ff105945..11c76428 100644 --- a/x/rarimocore/crypto/pkg/op_passport_root_update.go +++ b/x/rarimocore/crypto/pkg/op_passport_root_update.go @@ -7,7 +7,6 @@ import ( "github.com/gogo/protobuf/proto" "github.com/rarimo/rarimo-core/x/rarimocore/crypto/operation" "github.com/rarimo/rarimo-core/x/rarimocore/types" - "time" ) func GetPassportRootUpdate(operation types.Operation) (*types.PassportRootUpdate, error) { @@ -19,29 +18,9 @@ func GetPassportRootUpdate(operation types.Operation) (*types.PassportRootUpdate } func GetPassportRootUpdateContent(op *types.PassportRootUpdate) (*operation.PassportRootUpdateContent, error) { - timestamp := time.Unix(int64(op.Timestamp), 0) - timestampBytes, err := timestamp.MarshalBinary() - if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) - } - - if op.Root[:2] != "0x" { - op.Root = "0x" + op.Root - } - - root, err := hexutil.Decode(op.Root) - if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) - } - - contractAddress, err := hexutil.Decode(op.ContractAddress) - if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) - } - return &operation.PassportRootUpdateContent{ - ContractAddress: operation.To32Bytes(contractAddress), - Root: operation.To32Bytes(root), - RootTimestamp: operation.To32Bytes(timestampBytes), + ContractAddress: operation.To32Bytes(hexutil.MustDecode(op.ContractAddress)), + Root: operation.To32Bytes(hexutil.MustDecode(op.Root)), + RootTimestamp: operation.IntTo32Bytes(int(op.Timestamp)), }, nil } diff --git a/x/rarimocore/types/op_passport_root_update.pb.go b/x/rarimocore/types/op_passport_root_update.pb.go index 27bd7b9b..ac4c0b63 100644 --- a/x/rarimocore/types/op_passport_root_update.pb.go +++ b/x/rarimocore/types/op_passport_root_update.pb.go @@ -25,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type PassportRootUpdate struct { Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` - Timestamp uint32 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (m *PassportRootUpdate) Reset() { *m = PassportRootUpdate{} } @@ -75,7 +75,7 @@ func (m *PassportRootUpdate) GetContractAddress() string { return "" } -func (m *PassportRootUpdate) GetTimestamp() uint32 { +func (m *PassportRootUpdate) GetTimestamp() int64 { if m != nil { return m.Timestamp } @@ -100,12 +100,12 @@ var fileDescriptor_f6416f25faf40b9e = []byte{ 0x0c, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x85, 0x34, 0xb9, 0x04, 0x92, 0xf3, 0xf3, 0x4a, 0x8a, 0x12, 0x93, 0x4b, 0xe2, 0x13, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x25, 0x98, 0xc0, 0xf2, 0xfc, 0x30, 0x71, 0x47, 0x88, 0xb0, 0x90, 0x0c, 0x17, 0x67, 0x49, 0x66, 0x6e, 0x6a, - 0x71, 0x49, 0x62, 0x6e, 0x81, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x6f, 0x10, 0x42, 0xc0, 0xc9, 0xeb, + 0x71, 0x49, 0x62, 0x6e, 0x81, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x73, 0x10, 0x42, 0xc0, 0xc9, 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x21, 0x6e, 0x84, 0x52, 0xba, 0x60, 0x7f, 0x56, 0xe8, 0x23, 0x79, 0xba, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x47, 0x63, 0x40, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xec, 0xe2, 0x89, 0x85, 0x0f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0xf6, 0xb5, 0x8c, 0x64, 0x0f, 0x01, 0x00, 0x00, } func (m *PassportRootUpdate) Marshal() (dAtA []byte, err error) { @@ -294,7 +294,7 @@ func (m *PassportRootUpdate) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Timestamp |= uint32(b&0x7F) << shift + m.Timestamp |= int64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/rootupdater/keeper/keeper.go b/x/rootupdater/keeper/keeper.go index 945d4037..05362e84 100644 --- a/x/rootupdater/keeper/keeper.go +++ b/x/rootupdater/keeper/keeper.go @@ -2,22 +2,19 @@ package keeper import ( "bytes" - "encoding/hex" "fmt" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/rarimo/rarimo-core/ethermint/utils" "github.com/rarimo/rarimo-core/x/rootupdater/pkg/state" - "strings" - "time" - - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" + "strings" "github.com/rarimo/rarimo-core/x/rootupdater/types" ) @@ -95,8 +92,8 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth return err } - params.Root = hex.EncodeToString(eventBody.Root[:]) - params.RootTimestamp = uint32(time.Now().Unix()) + params.Root = hexutil.Encode(eventBody.Root[:]) + params.RootTimestamp = ctx.BlockTime().Unix() k.Logger(ctx).Info(fmt.Sprintf("Received PostTxProcessing event in %s module: %v", types.ModuleName, eventBody)) k.SetParams(ctx, params) diff --git a/x/rootupdater/types/params.pb.go b/x/rootupdater/types/params.pb.go index 5c53211d..bed6944a 100644 --- a/x/rootupdater/types/params.pb.go +++ b/x/rootupdater/types/params.pb.go @@ -30,7 +30,7 @@ type Params struct { LastSignedRoot string `protobuf:"bytes,3,opt,name=last_signed_root,json=lastSignedRoot,proto3" json:"last_signed_root,omitempty"` LastSignedRootIndex string `protobuf:"bytes,4,opt,name=last_signed_root_index,json=lastSignedRootIndex,proto3" json:"last_signed_root_index,omitempty"` EventName string `protobuf:"bytes,5,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` - RootTimestamp uint32 `protobuf:"varint,6,opt,name=root_timestamp,json=rootTimestamp,proto3" json:"root_timestamp,omitempty"` + RootTimestamp int64 `protobuf:"varint,6,opt,name=root_timestamp,json=rootTimestamp,proto3" json:"root_timestamp,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -101,7 +101,7 @@ func (m *Params) GetEventName() string { return "" } -func (m *Params) GetRootTimestamp() uint32 { +func (m *Params) GetRootTimestamp() int64 { if m != nil { return m.RootTimestamp } @@ -117,23 +117,23 @@ func init() { proto.RegisterFile("rootupdater/params.proto", fileDescriptor_31e4 var fileDescriptor_31e4e5f76db9f10e = []byte{ // 285 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x41, 0x4b, 0xc3, 0x30, - 0x14, 0x80, 0x17, 0x9d, 0x83, 0x05, 0x36, 0x47, 0x14, 0x09, 0x82, 0x61, 0x08, 0xc2, 0x3c, 0xd8, + 0x14, 0x80, 0x17, 0x37, 0x07, 0x0b, 0x38, 0x47, 0x14, 0x09, 0x82, 0x61, 0x08, 0xc2, 0x3c, 0xd8, 0x22, 0xfb, 0x05, 0x7a, 0x13, 0x41, 0xa4, 0x7a, 0xf2, 0x52, 0xb2, 0xf6, 0x51, 0x0b, 0xa6, 0x29, 0xc9, 0x9b, 0xcc, 0x7f, 0xe1, 0xcf, 0xf2, 0xb8, 0xa3, 0x47, 0x69, 0xaf, 0xfe, 0x08, 0xc9, 0xab, 0x83, 0xe9, 0x29, 0x8f, 0xef, 0xfb, 0xf2, 0x0e, 0x8f, 0x4b, 0x67, 0x2d, 0x2e, 0xeb, 0x5c, 0x23, 0xb8, 0xb8, 0xd6, 0x4e, 0x1b, 0x1f, 0xd5, 0xce, 0xa2, 0x15, 0xc2, 0x69, 0x57, 0x1a, 0x1b, 0x6d, - 0x05, 0xc7, 0x87, 0x85, 0x2d, 0x2c, 0xe9, 0x38, 0x4c, 0x5d, 0x79, 0xfa, 0xcd, 0xf8, 0xe0, 0x9e, + 0x05, 0xc7, 0x87, 0x85, 0x2d, 0x2c, 0xe9, 0x38, 0x4c, 0x5d, 0x79, 0xfa, 0xcd, 0xf8, 0xf0, 0x9e, 0xbe, 0x8a, 0x73, 0x3e, 0xc9, 0x6c, 0x85, 0x4e, 0x67, 0x98, 0xea, 0x3c, 0x77, 0xe0, 0xbd, 0x64, - 0x53, 0x36, 0x1b, 0x26, 0xfb, 0x1b, 0x7e, 0xd5, 0x61, 0x21, 0x78, 0x3f, 0xac, 0x96, 0x3b, 0xa4, - 0x69, 0x16, 0x33, 0x3e, 0x79, 0xd1, 0x1e, 0x53, 0x5f, 0x16, 0x15, 0xe4, 0x29, 0xf9, 0x5d, 0xf2, - 0xe3, 0xc0, 0x1f, 0x08, 0x27, 0xa1, 0x9c, 0xf3, 0xa3, 0xff, 0x65, 0x5a, 0x56, 0x39, 0xac, 0x64, - 0x9f, 0xfa, 0x83, 0xbf, 0xfd, 0x4d, 0x50, 0xe2, 0x84, 0x73, 0x78, 0x85, 0x0a, 0xd3, 0x4a, 0x1b, - 0x90, 0x7b, 0x14, 0x0e, 0x89, 0xdc, 0x69, 0x03, 0xe2, 0x8c, 0x8f, 0x69, 0x0f, 0x96, 0x06, 0x3c, - 0x6a, 0x53, 0xcb, 0xc1, 0x94, 0xcd, 0x46, 0xc9, 0x28, 0xd0, 0xc7, 0x0d, 0xbc, 0xbe, 0xfd, 0x68, + 0x53, 0x36, 0x1b, 0x25, 0xfb, 0x1b, 0x7e, 0xd5, 0x61, 0x21, 0xf8, 0x20, 0xac, 0x96, 0x3b, 0xa4, + 0x69, 0x16, 0x33, 0x3e, 0x79, 0xd1, 0x1e, 0x53, 0x5f, 0x16, 0x15, 0xe4, 0x29, 0xf9, 0x3e, 0xf9, + 0x71, 0xe0, 0x0f, 0x84, 0x93, 0x50, 0xce, 0xf9, 0xd1, 0xff, 0x32, 0x2d, 0xab, 0x1c, 0x56, 0x72, + 0x40, 0xfd, 0xc1, 0xdf, 0xfe, 0x26, 0x28, 0x71, 0xc2, 0x39, 0xbc, 0x42, 0x85, 0x69, 0xa5, 0x0d, + 0xc8, 0x5d, 0x0a, 0x47, 0x44, 0xee, 0xb4, 0x01, 0x71, 0xc6, 0xc7, 0xb4, 0x07, 0x4b, 0x03, 0x1e, + 0xb5, 0xa9, 0xe5, 0x70, 0xca, 0x66, 0xfd, 0x64, 0x2f, 0xd0, 0xc7, 0x0d, 0xbc, 0xbe, 0xfd, 0x68, 0x14, 0x5b, 0x37, 0x8a, 0x7d, 0x35, 0x8a, 0xbd, 0xb7, 0xaa, 0xb7, 0x6e, 0x55, 0xef, 0xb3, 0x55, 0xbd, 0xa7, 0xcb, 0xa2, 0xc4, 0xe7, 0xe5, 0x22, 0xca, 0xac, 0x89, 0xbb, 0xeb, 0xfd, 0x3e, 0x17, - 0x99, 0x75, 0x10, 0xaf, 0xe2, 0xed, 0x63, 0xe3, 0x5b, 0x0d, 0x7e, 0x31, 0xa0, 0x13, 0xce, 0x7f, - 0x02, 0x00, 0x00, 0xff, 0xff, 0x1d, 0xf0, 0x7c, 0x7b, 0x88, 0x01, 0x00, 0x00, + 0x99, 0x75, 0x10, 0xaf, 0xe2, 0xed, 0x63, 0xe3, 0x5b, 0x0d, 0x7e, 0x31, 0xa4, 0x13, 0xce, 0x7f, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x63, 0x48, 0x58, 0x46, 0x88, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -451,7 +451,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.RootTimestamp |= uint32(b&0x7F) << shift + m.RootTimestamp |= int64(b&0x7F) << shift if b < 0x80 { break } From 710057c4d72a4d82d177af8167e18530dc3396ac Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Tue, 27 Aug 2024 12:08:10 +0300 Subject: [PATCH 10/14] register a new codec --- docs/static/openapi.yml | 176 +++++++++++++++--------------- proto/rootupdater/genesis.proto | 2 +- proto/rootupdater/params.proto | 2 +- proto/rootupdater/query.proto | 2 +- proto/rootupdater/tx.proto | 2 +- x/rarimocore/types/codec.go | 7 ++ x/rootupdater/types/genesis.pb.go | 26 ++--- x/rootupdater/types/params.pb.go | 39 +++---- x/rootupdater/types/query.pb.go | 51 ++++----- x/rootupdater/types/tx.pb.go | 17 +-- 10 files changed, 167 insertions(+), 157 deletions(-) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 7ca95ebb..304f1e0f 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -54947,6 +54947,56 @@ paths: type: string tags: - Query + /rarimo/rarimo-core/rootupdater/params: + get: + summary: Parameters queries the parameters of the module. + operationId: RarimoRarimocoreRootupdaterParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + contract_address: + type: string + root: + type: string + last_signed_root: + type: string + last_signed_root_index: + type: string + event_name: + type: string + root_timestamp: + type: string + format: int64 + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query /rarimo/rarimo-core/tokenmanager/collection: get: operationId: RarimoRarimocoreTokenmanagerCollectionAll @@ -60051,56 +60101,6 @@ paths: format: uint64 tags: - Query - /rarimo/rarimo-core/rootupdater/params: - get: - summary: Parameters queries the parameters of the module. - operationId: RarimoRootupdaterParams - responses: - '200': - description: A successful response. - schema: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - contract_address: - type: string - root: - type: string - last_signed_root: - type: string - last_signed_root_index: - type: string - event_name: - type: string - root_timestamp: - type: integer - format: int64 - description: >- - QueryParamsResponse is response type for the Query/Params RPC - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - tags: - - Query definitions: cosmos.auth.v1beta1.AddressBytesToStringResponse: type: object @@ -92156,6 +92156,44 @@ definitions: type: string validator: type: string + rarimo.rarimocore.rootupdater.Params: + type: object + properties: + contract_address: + type: string + root: + type: string + last_signed_root: + type: string + last_signed_root_index: + type: string + event_name: + type: string + root_timestamp: + type: string + format: int64 + description: Params defines the parameters for the module. + rarimo.rarimocore.rootupdater.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + contract_address: + type: string + root: + type: string + last_signed_root: + type: string + last_signed_root_index: + type: string + event_name: + type: string + root_timestamp: + type: string + format: int64 + description: QueryParamsResponse is response type for the Query/Params RPC method. rarimo.rarimocore.tokenmanager.Collection: type: object properties: @@ -93970,41 +94008,3 @@ definitions: format: uint64 denom: type: string - rarimo.rootupdater.Params: - type: object - properties: - contract_address: - type: string - root: - type: string - last_signed_root: - type: string - last_signed_root_index: - type: string - event_name: - type: string - root_timestamp: - type: integer - format: int64 - description: Params defines the parameters for the module. - rarimo.rootupdater.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - contract_address: - type: string - root: - type: string - last_signed_root: - type: string - last_signed_root_index: - type: string - event_name: - type: string - root_timestamp: - type: integer - format: int64 - description: QueryParamsResponse is response type for the Query/Params RPC method. diff --git a/proto/rootupdater/genesis.proto b/proto/rootupdater/genesis.proto index ed445b3d..76633ec8 100644 --- a/proto/rootupdater/genesis.proto +++ b/proto/rootupdater/genesis.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package rarimo.rootupdater; +package rarimo.rarimocore.rootupdater; import "gogoproto/gogo.proto"; import "rootupdater/params.proto"; diff --git a/proto/rootupdater/params.proto b/proto/rootupdater/params.proto index 3bdbafc0..a5b0ac64 100644 --- a/proto/rootupdater/params.proto +++ b/proto/rootupdater/params.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package rarimo.rootupdater; +package rarimo.rarimocore.rootupdater; import "gogoproto/gogo.proto"; diff --git a/proto/rootupdater/query.proto b/proto/rootupdater/query.proto index 9d04c7c2..53899607 100644 --- a/proto/rootupdater/query.proto +++ b/proto/rootupdater/query.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package rarimo.rootupdater; +package rarimo.rarimocore.rootupdater; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; diff --git a/proto/rootupdater/tx.proto b/proto/rootupdater/tx.proto index a1408b3c..c8863367 100644 --- a/proto/rootupdater/tx.proto +++ b/proto/rootupdater/tx.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package rarimo.rootupdater; +package rarimo.rarimocore.rootupdater; option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types"; diff --git a/x/rarimocore/types/codec.go b/x/rarimocore/types/codec.go index 5a44d6d3..a40f8996 100644 --- a/x/rarimocore/types/codec.go +++ b/x/rarimocore/types/codec.go @@ -33,6 +33,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&DropPartiesProposal{}, "rarimocore/DropPartiesProposal", nil) cdc.RegisterConcrete(&ArbitrarySigningProposal{}, "rarimocore/ArbitrarySigningProposal", nil) cdc.RegisterConcrete(&Arbitrary{}, "rarimocore/Arbitrary", nil) + cdc.RegisterConcrete(&PassportRootUpdate{}, "rarimocore/PassportRootUpdate", nil) // this line is used by starport scaffolding # 2 } @@ -151,6 +152,12 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { (*proto.Message)(nil), &Arbitrary{}, ) + + registry.RegisterInterface( + "rarimo.rarimocore.rarimocore.PassportRootUpdate", + (*proto.Message)(nil), + &PassportRootUpdate{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/rootupdater/types/genesis.pb.go b/x/rootupdater/types/genesis.pb.go index 5168d617..54df8037 100644 --- a/x/rootupdater/types/genesis.pb.go +++ b/x/rootupdater/types/genesis.pb.go @@ -69,26 +69,26 @@ func (m *GenesisState) GetParams() Params { } func init() { - proto.RegisterType((*GenesisState)(nil), "rarimo.rootupdater.GenesisState") + proto.RegisterType((*GenesisState)(nil), "rarimo.rarimocore.rootupdater.GenesisState") } func init() { proto.RegisterFile("rootupdater/genesis.proto", fileDescriptor_9aceb595c789c725) } var fileDescriptor_9aceb595c789c725 = []byte{ - // 194 bytes of a gzipped FileDescriptorProto + // 199 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0xca, 0xcf, 0x2f, 0x29, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2a, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x43, 0x52, - 0x21, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x96, 0xd6, 0x07, 0xb1, 0x20, 0x2a, 0xa5, 0x24, 0x90, - 0x0d, 0x29, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x9a, 0xa1, 0xe4, 0xc1, 0xc5, 0xe3, 0x0e, 0x31, 0x34, - 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x82, 0x8b, 0x0d, 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, - 0x6d, 0x24, 0xa5, 0x87, 0x69, 0x89, 0x5e, 0x00, 0x58, 0x85, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, - 0x41, 0x50, 0xf5, 0x4e, 0xde, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, - 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, - 0x98, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x31, 0x0d, 0x4a, 0xe9, - 0x26, 0xe7, 0x17, 0xa5, 0xea, 0x57, 0xe8, 0x23, 0xbb, 0xae, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, - 0x0d, 0xec, 0x3a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x0c, 0x84, 0x8e, 0xfe, 0x00, - 0x00, 0x00, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x2d, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x83, 0x50, + 0xc9, 0xf9, 0x45, 0xa9, 0x7a, 0x48, 0x8a, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x2a, 0xf5, + 0x41, 0x2c, 0x88, 0x26, 0x29, 0x09, 0x64, 0xf3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0xc6, 0x29, + 0x05, 0x73, 0xf1, 0xb8, 0x43, 0xcc, 0x0f, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x72, 0xe6, 0x62, 0x83, + 0xc8, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0xa9, 0xea, 0xe1, 0xb5, 0x4f, 0x2f, 0x00, 0xac, + 0xd8, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x56, 0x27, 0xef, 0x13, 0x8f, 0xe4, 0x18, + 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, + 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, + 0xcf, 0xd5, 0x87, 0x98, 0x08, 0xa5, 0x74, 0x41, 0x26, 0xeb, 0x57, 0xe8, 0x23, 0x3b, 0xb4, 0xa4, + 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x50, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb2, + 0xb4, 0x39, 0x26, 0x14, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/rootupdater/types/params.pb.go b/x/rootupdater/types/params.pb.go index bed6944a..a06c836e 100644 --- a/x/rootupdater/types/params.pb.go +++ b/x/rootupdater/types/params.pb.go @@ -109,31 +109,32 @@ func (m *Params) GetRootTimestamp() int64 { } func init() { - proto.RegisterType((*Params)(nil), "rarimo.rootupdater.Params") + proto.RegisterType((*Params)(nil), "rarimo.rarimocore.rootupdater.Params") } func init() { proto.RegisterFile("rootupdater/params.proto", fileDescriptor_31e4e5f76db9f10e) } var fileDescriptor_31e4e5f76db9f10e = []byte{ - // 285 bytes of a gzipped FileDescriptorProto + // 290 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x41, 0x4b, 0xc3, 0x30, - 0x14, 0x80, 0x17, 0x37, 0x07, 0x0b, 0x38, 0x47, 0x14, 0x09, 0x82, 0x61, 0x08, 0xc2, 0x3c, 0xd8, - 0x22, 0xfb, 0x05, 0x7a, 0x13, 0x41, 0xa4, 0x7a, 0xf2, 0x52, 0xb2, 0xf6, 0x51, 0x0b, 0xa6, 0x29, - 0xc9, 0x9b, 0xcc, 0x7f, 0xe1, 0xcf, 0xf2, 0xb8, 0xa3, 0x47, 0x69, 0xaf, 0xfe, 0x08, 0xc9, 0xab, - 0x83, 0xe9, 0x29, 0x8f, 0xef, 0xfb, 0xf2, 0x0e, 0x8f, 0x4b, 0x67, 0x2d, 0x2e, 0xeb, 0x5c, 0x23, - 0xb8, 0xb8, 0xd6, 0x4e, 0x1b, 0x1f, 0xd5, 0xce, 0xa2, 0x15, 0xc2, 0x69, 0x57, 0x1a, 0x1b, 0x6d, - 0x05, 0xc7, 0x87, 0x85, 0x2d, 0x2c, 0xe9, 0x38, 0x4c, 0x5d, 0x79, 0xfa, 0xcd, 0xf8, 0xf0, 0x9e, - 0xbe, 0x8a, 0x73, 0x3e, 0xc9, 0x6c, 0x85, 0x4e, 0x67, 0x98, 0xea, 0x3c, 0x77, 0xe0, 0xbd, 0x64, - 0x53, 0x36, 0x1b, 0x25, 0xfb, 0x1b, 0x7e, 0xd5, 0x61, 0x21, 0xf8, 0x20, 0xac, 0x96, 0x3b, 0xa4, - 0x69, 0x16, 0x33, 0x3e, 0x79, 0xd1, 0x1e, 0x53, 0x5f, 0x16, 0x15, 0xe4, 0x29, 0xf9, 0x3e, 0xf9, - 0x71, 0xe0, 0x0f, 0x84, 0x93, 0x50, 0xce, 0xf9, 0xd1, 0xff, 0x32, 0x2d, 0xab, 0x1c, 0x56, 0x72, - 0x40, 0xfd, 0xc1, 0xdf, 0xfe, 0x26, 0x28, 0x71, 0xc2, 0x39, 0xbc, 0x42, 0x85, 0x69, 0xa5, 0x0d, - 0xc8, 0x5d, 0x0a, 0x47, 0x44, 0xee, 0xb4, 0x01, 0x71, 0xc6, 0xc7, 0xb4, 0x07, 0x4b, 0x03, 0x1e, - 0xb5, 0xa9, 0xe5, 0x70, 0xca, 0x66, 0xfd, 0x64, 0x2f, 0xd0, 0xc7, 0x0d, 0xbc, 0xbe, 0xfd, 0x68, - 0x14, 0x5b, 0x37, 0x8a, 0x7d, 0x35, 0x8a, 0xbd, 0xb7, 0xaa, 0xb7, 0x6e, 0x55, 0xef, 0xb3, 0x55, - 0xbd, 0xa7, 0xcb, 0xa2, 0xc4, 0xe7, 0xe5, 0x22, 0xca, 0xac, 0x89, 0xbb, 0xeb, 0xfd, 0x3e, 0x17, - 0x99, 0x75, 0x10, 0xaf, 0xe2, 0xed, 0x63, 0xe3, 0x5b, 0x0d, 0x7e, 0x31, 0xa4, 0x13, 0xce, 0x7f, - 0x02, 0x00, 0x00, 0xff, 0xff, 0x63, 0x48, 0x58, 0x46, 0x88, 0x01, 0x00, 0x00, + 0x18, 0x86, 0x1b, 0x37, 0x0b, 0x0b, 0x38, 0x47, 0x14, 0x09, 0xc2, 0xc2, 0x10, 0x84, 0x7a, 0xb0, + 0x45, 0xf6, 0x0b, 0xf4, 0x26, 0x82, 0x48, 0xf5, 0xe4, 0xa5, 0x64, 0x6d, 0xa8, 0x05, 0xd3, 0x94, + 0xe4, 0x9b, 0xcc, 0x7f, 0xe1, 0xcf, 0xf2, 0xb8, 0xa3, 0x47, 0x69, 0xaf, 0xfe, 0x08, 0xc9, 0x57, + 0x07, 0x73, 0xa7, 0x7c, 0x3c, 0xef, 0x93, 0xf7, 0xf0, 0x52, 0x6e, 0x8d, 0x81, 0x65, 0x53, 0x48, + 0x50, 0x36, 0x69, 0xa4, 0x95, 0xda, 0xc5, 0x8d, 0x35, 0x60, 0xd8, 0xd4, 0x4a, 0x5b, 0x69, 0x13, + 0xf7, 0x4f, 0x6e, 0xac, 0x8a, 0xb7, 0xdc, 0xd3, 0xe3, 0xd2, 0x94, 0x06, 0xcd, 0xc4, 0x5f, 0xfd, + 0xa7, 0xb3, 0x1f, 0x42, 0xc3, 0x07, 0x6c, 0x61, 0x17, 0x74, 0x92, 0x9b, 0x1a, 0xac, 0xcc, 0x21, + 0x93, 0x45, 0x61, 0x95, 0x73, 0x9c, 0xcc, 0x48, 0x34, 0x4a, 0x0f, 0x37, 0xfc, 0xba, 0xc7, 0x8c, + 0xd1, 0xa1, 0xaf, 0xe6, 0x7b, 0x18, 0xe3, 0xcd, 0x22, 0x3a, 0x79, 0x95, 0x0e, 0x32, 0x57, 0x95, + 0xb5, 0x2a, 0x32, 0xcc, 0x07, 0x98, 0x8f, 0x3d, 0x7f, 0x44, 0x9c, 0x7a, 0x73, 0x4e, 0x4f, 0x76, + 0xcd, 0xac, 0xaa, 0x0b, 0xb5, 0xe2, 0x43, 0xf4, 0x8f, 0xfe, 0xfb, 0xb7, 0x3e, 0x62, 0x53, 0x4a, + 0xd5, 0x9b, 0xaa, 0x21, 0xab, 0xa5, 0x56, 0x7c, 0x1f, 0xc5, 0x11, 0x92, 0x7b, 0xa9, 0x15, 0x3b, + 0xa7, 0x63, 0xec, 0x81, 0x4a, 0x2b, 0x07, 0x52, 0x37, 0x3c, 0x9c, 0x91, 0x68, 0x90, 0x1e, 0x78, + 0xfa, 0xb4, 0x81, 0x37, 0x77, 0x9f, 0xad, 0x20, 0xeb, 0x56, 0x90, 0xef, 0x56, 0x90, 0x8f, 0x4e, + 0x04, 0xeb, 0x4e, 0x04, 0x5f, 0x9d, 0x08, 0x9e, 0xaf, 0xca, 0x0a, 0x5e, 0x96, 0x8b, 0x38, 0x37, + 0x3a, 0xe9, 0x17, 0xfc, 0x7b, 0x2e, 0xfd, 0x92, 0xc9, 0x2a, 0xd9, 0xde, 0x1d, 0xde, 0x1b, 0xe5, + 0x16, 0x21, 0x4e, 0x38, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xef, 0xee, 0x30, 0x21, 0x93, 0x01, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/rootupdater/types/query.pb.go b/x/rootupdater/types/query.pb.go index cb4dba15..53f102dc 100644 --- a/x/rootupdater/types/query.pb.go +++ b/x/rootupdater/types/query.pb.go @@ -114,33 +114,34 @@ func (m *QueryParamsResponse) GetParams() Params { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "rarimo.rootupdater.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "rarimo.rootupdater.QueryParamsResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "rarimo.rarimocore.rootupdater.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "rarimo.rarimocore.rootupdater.QueryParamsResponse") } func init() { proto.RegisterFile("rootupdater/query.proto", fileDescriptor_3408f22fd1bb339b) } var fileDescriptor_3408f22fd1bb339b = []byte{ - // 300 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0xb1, 0x4b, 0x03, 0x31, - 0x18, 0xc5, 0x2f, 0xa2, 0x1d, 0xe2, 0x16, 0x0b, 0x96, 0x43, 0xa2, 0xdc, 0x50, 0x8b, 0x60, 0xc2, - 0xd5, 0xc5, 0xb9, 0xab, 0x83, 0xda, 0xd1, 0x2d, 0x77, 0x86, 0x78, 0xe0, 0xdd, 0x97, 0x26, 0x39, - 0xb1, 0xab, 0x9b, 0x9b, 0xd0, 0x7f, 0xaa, 0x63, 0xc1, 0xc5, 0x49, 0xe4, 0xce, 0x3f, 0x44, 0x7a, - 0xb9, 0xa1, 0xe5, 0x0a, 0x4e, 0x09, 0xdf, 0xfb, 0xbd, 0x97, 0x97, 0x0f, 0x1f, 0x1b, 0x00, 0x57, - 0xea, 0x47, 0xe1, 0xa4, 0xe1, 0xb3, 0x52, 0x9a, 0x39, 0xd3, 0x06, 0x1c, 0x10, 0x62, 0x84, 0xc9, - 0x72, 0x60, 0x1b, 0x7a, 0xd8, 0x57, 0xa0, 0xa0, 0x91, 0xf9, 0xfa, 0xe6, 0xc9, 0xf0, 0x44, 0x01, - 0xa8, 0x67, 0xc9, 0x85, 0xce, 0xb8, 0x28, 0x0a, 0x70, 0xc2, 0x65, 0x50, 0xd8, 0x56, 0xbd, 0x48, - 0xc1, 0xe6, 0x60, 0x79, 0x22, 0xac, 0xf4, 0x0f, 0xf0, 0x97, 0x38, 0x91, 0x4e, 0xc4, 0x5c, 0x0b, - 0x95, 0x15, 0x0d, 0xdc, 0xb2, 0x83, 0xcd, 0x32, 0x5a, 0x18, 0x91, 0xb7, 0x29, 0x51, 0x1f, 0x93, - 0xfb, 0xb5, 0xf7, 0xae, 0x19, 0x4e, 0xe5, 0xac, 0x94, 0xd6, 0x45, 0xb7, 0xf8, 0x68, 0x6b, 0x6a, - 0x35, 0x14, 0x56, 0x92, 0x6b, 0xdc, 0xf3, 0xe6, 0x01, 0x3a, 0x43, 0xa3, 0xc3, 0x71, 0xc8, 0xba, - 0x7f, 0x61, 0xde, 0x33, 0xd9, 0x5f, 0x7e, 0x9f, 0x06, 0xd3, 0x96, 0x1f, 0x2f, 0x10, 0x3e, 0x68, - 0x12, 0xc9, 0x3b, 0xc2, 0x3d, 0x8f, 0x90, 0xe1, 0x2e, 0x7b, 0xb7, 0x4d, 0x78, 0xfe, 0x2f, 0xe7, - 0xfb, 0x45, 0xec, 0xed, 0xf3, 0x77, 0xb1, 0x37, 0x22, 0x43, 0xee, 0x0d, 0xed, 0x71, 0x99, 0x82, - 0x91, 0xbc, 0xbb, 0x82, 0xc9, 0xcd, 0xb2, 0xa2, 0x68, 0x55, 0x51, 0xf4, 0x53, 0x51, 0xf4, 0x51, - 0xd3, 0x60, 0x55, 0xd3, 0xe0, 0xab, 0xa6, 0xc1, 0x43, 0xac, 0x32, 0xf7, 0x54, 0x26, 0x2c, 0x85, - 0x7c, 0x57, 0xd6, 0xeb, 0x56, 0x9a, 0x9b, 0x6b, 0x69, 0x93, 0x5e, 0xb3, 0xd0, 0xab, 0xbf, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xb0, 0x88, 0x26, 0x94, 0xf9, 0x01, 0x00, 0x00, + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x90, 0xc1, 0x4a, 0xf3, 0x40, + 0x10, 0xc7, 0xb3, 0x1f, 0x9f, 0x3d, 0xac, 0xb7, 0xb5, 0x60, 0x29, 0xba, 0x4a, 0x40, 0x29, 0x82, + 0xbb, 0x24, 0xbe, 0x41, 0x3d, 0x7a, 0xd1, 0x1e, 0x7b, 0xdb, 0xc4, 0x65, 0x0d, 0x98, 0xcc, 0x76, + 0x77, 0x23, 0xf6, 0xea, 0x13, 0x08, 0x3e, 0x80, 0x67, 0xdf, 0xa4, 0xc7, 0x82, 0x17, 0x4f, 0x22, + 0x89, 0x0f, 0x22, 0xc9, 0xe6, 0xd0, 0x52, 0x51, 0x3c, 0x4d, 0x98, 0xfc, 0x7f, 0xbf, 0x9d, 0x19, + 0xbc, 0x6b, 0x00, 0x5c, 0xa9, 0xaf, 0x85, 0x93, 0x86, 0xcf, 0x4a, 0x69, 0xe6, 0x4c, 0x1b, 0x70, + 0x40, 0xf6, 0x8d, 0x30, 0x59, 0x0e, 0xcc, 0x97, 0x14, 0x8c, 0x64, 0x2b, 0xd1, 0x61, 0x5f, 0x81, + 0x82, 0x36, 0xc9, 0x9b, 0x2f, 0x0f, 0x0d, 0xf7, 0x14, 0x80, 0xba, 0x95, 0x5c, 0xe8, 0x8c, 0x8b, + 0xa2, 0x00, 0x27, 0x5c, 0x06, 0x85, 0xed, 0xfe, 0x9e, 0xa4, 0x60, 0x73, 0xb0, 0x3c, 0x11, 0x56, + 0xfa, 0xb7, 0xf8, 0x5d, 0x94, 0x48, 0x27, 0x22, 0xae, 0x85, 0xca, 0x8a, 0x36, 0xdc, 0x65, 0x07, + 0xab, 0x73, 0x69, 0x61, 0x44, 0xde, 0x59, 0xc2, 0x3e, 0x26, 0x57, 0x0d, 0x7b, 0xd9, 0x36, 0x27, + 0x72, 0x56, 0x4a, 0xeb, 0xc2, 0x29, 0xde, 0x59, 0xeb, 0x5a, 0x0d, 0x85, 0x95, 0xe4, 0x1c, 0xf7, + 0x3c, 0x3c, 0x40, 0x87, 0x68, 0xb4, 0x1d, 0x1f, 0xb1, 0x1f, 0xd7, 0x62, 0x1e, 0x1f, 0xff, 0x5f, + 0xbc, 0x1f, 0x04, 0x93, 0x0e, 0x8d, 0x5f, 0x10, 0xde, 0x6a, 0xe5, 0xe4, 0x19, 0xe1, 0x9e, 0x8f, + 0x90, 0xe8, 0x17, 0xd3, 0xe6, 0x8c, 0xc3, 0xf8, 0x2f, 0x88, 0x5f, 0x20, 0x64, 0x0f, 0xaf, 0x9f, + 0x4f, 0xff, 0x46, 0xe4, 0x98, 0x7b, 0xa8, 0x2b, 0xa7, 0x0d, 0xcc, 0x37, 0x6f, 0x34, 0xbe, 0x58, + 0x54, 0x14, 0x2d, 0x2b, 0x8a, 0x3e, 0x2a, 0x8a, 0x1e, 0x6b, 0x1a, 0x2c, 0x6b, 0x1a, 0xbc, 0xd5, + 0x34, 0x98, 0x46, 0x2a, 0x73, 0x37, 0x65, 0xc2, 0x52, 0xc8, 0xbf, 0x73, 0xdd, 0xaf, 0xd9, 0xdc, + 0x5c, 0x4b, 0x9b, 0xf4, 0xda, 0x8b, 0x9f, 0x7d, 0x05, 0x00, 0x00, 0xff, 0xff, 0xdd, 0x4b, 0x45, + 0xb2, 0x25, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -169,7 +170,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/rarimo.rootupdater.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/rarimo.rarimocore.rootupdater.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -204,7 +205,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rarimo.rootupdater.Query/Params", + FullMethod: "/rarimo.rarimocore.rootupdater.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -213,7 +214,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "rarimo.rootupdater.Query", + ServiceName: "rarimo.rarimocore.rootupdater.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/x/rootupdater/types/tx.pb.go b/x/rootupdater/types/tx.pb.go index 9a00ca5e..b0c59f37 100644 --- a/x/rootupdater/types/tx.pb.go +++ b/x/rootupdater/types/tx.pb.go @@ -26,15 +26,16 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package func init() { proto.RegisterFile("rootupdater/tx.proto", fileDescriptor_72679a1b23c83bcf) } var fileDescriptor_72679a1b23c83bcf = []byte{ - // 128 bytes of a gzipped FileDescriptorProto + // 133 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0xca, 0xcf, 0x2f, 0x29, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0x2d, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x12, 0x2a, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x43, 0x92, 0x34, 0x62, 0xe5, 0x62, 0xf6, - 0x2d, 0x4e, 0x77, 0xf2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, - 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xc3, - 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x88, 0x7e, 0x28, 0xa5, 0x9b, - 0x9c, 0x5f, 0x94, 0xaa, 0x5f, 0xa1, 0x8f, 0x62, 0x55, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, - 0x3a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9e, 0xbd, 0xae, 0x23, 0x86, 0x00, 0x00, 0x00, + 0x17, 0x92, 0x2d, 0x4a, 0x2c, 0xca, 0xcc, 0xcd, 0xd7, 0x83, 0x50, 0xc9, 0xf9, 0x45, 0xa9, 0x7a, + 0x48, 0xea, 0x8c, 0x58, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x9d, 0xbc, 0x4f, 0x3c, 0x92, 0x63, 0xbc, + 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, + 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x30, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, + 0x57, 0x1f, 0x62, 0x06, 0x94, 0xd2, 0x05, 0x99, 0xa5, 0x5f, 0xa1, 0x8f, 0x62, 0x6b, 0x65, 0x41, + 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x66, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, 0x6c, 0x08, + 0x7a, 0x91, 0x00, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -72,7 +73,7 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "rarimo.rootupdater.Msg", + ServiceName: "rarimo.rarimocore.rootupdater.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{}, From 55c86a0dc1ff1af9624182470a4136df77663af0 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Wed, 28 Aug 2024 17:48:33 +0300 Subject: [PATCH 11/14] add block height in params --- .../rarimocore/op_passport_root_update.proto | 1 + proto/rootupdater/params.proto | 1 + .../types/op_passport_root_update.pb.go | 67 ++++++++++++---- x/rootupdater/keeper/abci.go | 1 + x/rootupdater/keeper/keeper.go | 1 + x/rootupdater/types/params.pb.go | 76 ++++++++++++++----- 6 files changed, 112 insertions(+), 35 deletions(-) diff --git a/proto/rarimocore/op_passport_root_update.proto b/proto/rarimocore/op_passport_root_update.proto index 3b207190..00136478 100644 --- a/proto/rarimocore/op_passport_root_update.proto +++ b/proto/rarimocore/op_passport_root_update.proto @@ -7,6 +7,7 @@ message PassportRootUpdate { string root = 1; string contract_address = 2; int64 timestamp = 3; + uint64 block_height = 4; } diff --git a/proto/rootupdater/params.proto b/proto/rootupdater/params.proto index a5b0ac64..95a1058a 100644 --- a/proto/rootupdater/params.proto +++ b/proto/rootupdater/params.proto @@ -13,4 +13,5 @@ message Params { string last_signed_root_index = 4; string event_name = 5; int64 root_timestamp = 6; + uint64 block_height = 7; } diff --git a/x/rarimocore/types/op_passport_root_update.pb.go b/x/rarimocore/types/op_passport_root_update.pb.go index ac4c0b63..b3837831 100644 --- a/x/rarimocore/types/op_passport_root_update.pb.go +++ b/x/rarimocore/types/op_passport_root_update.pb.go @@ -26,6 +26,7 @@ type PassportRootUpdate struct { Root string `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` ContractAddress string `protobuf:"bytes,2,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + BlockHeight uint64 `protobuf:"varint,4,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` } func (m *PassportRootUpdate) Reset() { *m = PassportRootUpdate{} } @@ -82,6 +83,13 @@ func (m *PassportRootUpdate) GetTimestamp() int64 { return 0 } +func (m *PassportRootUpdate) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + func init() { proto.RegisterType((*PassportRootUpdate)(nil), "rarimo.rarimocore.rarimocore.PassportRootUpdate") } @@ -91,21 +99,23 @@ func init() { } var fileDescriptor_f6416f25faf40b9e = []byte{ - // 218 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x4a, 0x2c, 0xca, - 0xcc, 0xcd, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x88, 0x2f, 0x48, 0x2c, 0x2e, 0x2e, 0xc8, - 0x2f, 0x2a, 0x89, 0x2f, 0xca, 0xcf, 0x2f, 0x89, 0x2f, 0x2d, 0x48, 0x49, 0x2c, 0x49, 0xd5, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0xa8, 0xd4, 0x43, 0x68, 0x40, 0x62, 0x2a, 0x15, 0x72, - 0x09, 0x05, 0x40, 0xf5, 0x06, 0xe5, 0xe7, 0x97, 0x84, 0x82, 0x75, 0x0a, 0x09, 0x71, 0xb1, 0x80, - 0x0c, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x85, 0x34, 0xb9, 0x04, 0x92, 0xf3, - 0xf3, 0x4a, 0x8a, 0x12, 0x93, 0x4b, 0xe2, 0x13, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x25, 0x98, - 0xc0, 0xf2, 0xfc, 0x30, 0x71, 0x47, 0x88, 0xb0, 0x90, 0x0c, 0x17, 0x67, 0x49, 0x66, 0x6e, 0x6a, - 0x71, 0x49, 0x62, 0x6e, 0x81, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x73, 0x10, 0x42, 0xc0, 0xc9, 0xeb, - 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, - 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, - 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x21, 0x6e, 0x84, 0x52, 0xba, 0x60, 0x7f, 0x56, 0xe8, 0x23, - 0x79, 0xba, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x47, 0x63, 0x40, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xf6, 0xb5, 0x8c, 0x64, 0x0f, 0x01, 0x00, 0x00, + // 246 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4a, 0xc4, 0x30, + 0x10, 0x86, 0x1b, 0xb7, 0x08, 0x1b, 0x05, 0x25, 0xa7, 0x1e, 0x96, 0x50, 0x3d, 0xd5, 0x83, 0xad, + 0xe0, 0x13, 0xe8, 0x49, 0x3c, 0x49, 0xc1, 0x8b, 0x97, 0x90, 0xa6, 0x61, 0x5b, 0x34, 0x4e, 0x98, + 0xcc, 0x82, 0xbe, 0x85, 0x07, 0x1f, 0xca, 0xe3, 0x1e, 0x3d, 0x4a, 0xfb, 0x22, 0x62, 0xba, 0xb2, + 0x3d, 0xe5, 0xe7, 0xcb, 0xfc, 0x03, 0xf3, 0xf1, 0x02, 0x35, 0xf6, 0x0e, 0x0c, 0xa0, 0xad, 0xc0, + 0x2b, 0xaf, 0x43, 0xf0, 0x80, 0xa4, 0x10, 0x80, 0xd4, 0xc6, 0xb7, 0x9a, 0x6c, 0xe9, 0x11, 0x08, + 0xc4, 0x6a, 0x9a, 0x2c, 0xf7, 0x85, 0x59, 0x3c, 0xff, 0x64, 0x5c, 0x3c, 0xec, 0xca, 0x35, 0x00, + 0x3d, 0xc6, 0xaa, 0x10, 0x3c, 0xfd, 0xdb, 0x94, 0xb1, 0x9c, 0x15, 0xcb, 0x3a, 0x66, 0x71, 0xc1, + 0x4f, 0x0d, 0xbc, 0x12, 0x6a, 0x43, 0x4a, 0xb7, 0x2d, 0xda, 0x10, 0xb2, 0x83, 0xf8, 0x7f, 0xf2, + 0xcf, 0x6f, 0x26, 0x2c, 0x56, 0x7c, 0x49, 0xbd, 0xb3, 0x81, 0xb4, 0xf3, 0xd9, 0x22, 0x67, 0xc5, + 0xa2, 0xde, 0x03, 0x71, 0xc6, 0x8f, 0x9b, 0x17, 0x30, 0xcf, 0xaa, 0xb3, 0xfd, 0xba, 0xa3, 0x2c, + 0xcd, 0x59, 0x91, 0xd6, 0x47, 0x91, 0xdd, 0x45, 0x74, 0x7b, 0xff, 0x35, 0x48, 0xb6, 0x1d, 0x24, + 0xfb, 0x19, 0x24, 0xfb, 0x18, 0x65, 0xb2, 0x1d, 0x65, 0xf2, 0x3d, 0xca, 0xe4, 0xe9, 0x6a, 0xdd, + 0x53, 0xb7, 0x69, 0x4a, 0x03, 0xae, 0x9a, 0xee, 0xd8, 0x3d, 0x97, 0xd1, 0xc5, 0x5b, 0x35, 0x13, + 0x43, 0xef, 0xde, 0x86, 0xe6, 0x30, 0x7a, 0xb8, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x2b, + 0x93, 0x79, 0x33, 0x01, 0x00, 0x00, } func (m *PassportRootUpdate) Marshal() (dAtA []byte, err error) { @@ -128,6 +138,11 @@ func (m *PassportRootUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.BlockHeight != 0 { + i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x20 + } if m.Timestamp != 0 { i = encodeVarintOpPassportRootUpdate(dAtA, i, uint64(m.Timestamp)) i-- @@ -178,6 +193,9 @@ func (m *PassportRootUpdate) Size() (n int) { if m.Timestamp != 0 { n += 1 + sovOpPassportRootUpdate(uint64(m.Timestamp)) } + if m.BlockHeight != 0 { + n += 1 + sovOpPassportRootUpdate(uint64(m.BlockHeight)) + } return n } @@ -299,6 +317,25 @@ func (m *PassportRootUpdate) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpPassportRootUpdate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipOpPassportRootUpdate(dAtA[iNdEx:]) diff --git a/x/rootupdater/keeper/abci.go b/x/rootupdater/keeper/abci.go index 01c40db8..22dd46ae 100644 --- a/x/rootupdater/keeper/abci.go +++ b/x/rootupdater/keeper/abci.go @@ -18,6 +18,7 @@ func (k Keeper) EndBlocker(ctx sdk.Context) { ContractAddress: params.ContractAddress, Root: params.Root, Timestamp: params.RootTimestamp, + BlockHeight: params.BlockHeight, }) if err != nil { diff --git a/x/rootupdater/keeper/keeper.go b/x/rootupdater/keeper/keeper.go index 05362e84..82748759 100644 --- a/x/rootupdater/keeper/keeper.go +++ b/x/rootupdater/keeper/keeper.go @@ -94,6 +94,7 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth params.Root = hexutil.Encode(eventBody.Root[:]) params.RootTimestamp = ctx.BlockTime().Unix() + params.BlockHeight = log.BlockNumber k.Logger(ctx).Info(fmt.Sprintf("Received PostTxProcessing event in %s module: %v", types.ModuleName, eventBody)) k.SetParams(ctx, params) diff --git a/x/rootupdater/types/params.pb.go b/x/rootupdater/types/params.pb.go index a06c836e..8383ca09 100644 --- a/x/rootupdater/types/params.pb.go +++ b/x/rootupdater/types/params.pb.go @@ -31,6 +31,7 @@ type Params struct { LastSignedRootIndex string `protobuf:"bytes,4,opt,name=last_signed_root_index,json=lastSignedRootIndex,proto3" json:"last_signed_root_index,omitempty"` EventName string `protobuf:"bytes,5,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` RootTimestamp int64 `protobuf:"varint,6,opt,name=root_timestamp,json=rootTimestamp,proto3" json:"root_timestamp,omitempty"` + BlockHeight uint64 `protobuf:"varint,7,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -108,6 +109,13 @@ func (m *Params) GetRootTimestamp() int64 { return 0 } +func (m *Params) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "rarimo.rarimocore.rootupdater.Params") } @@ -115,26 +123,27 @@ func init() { func init() { proto.RegisterFile("rootupdater/params.proto", fileDescriptor_31e4e5f76db9f10e) } var fileDescriptor_31e4e5f76db9f10e = []byte{ - // 290 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x41, 0x4b, 0xc3, 0x30, - 0x18, 0x86, 0x1b, 0x37, 0x0b, 0x0b, 0x38, 0x47, 0x14, 0x09, 0xc2, 0xc2, 0x10, 0x84, 0x7a, 0xb0, - 0x45, 0xf6, 0x0b, 0xf4, 0x26, 0x82, 0x48, 0xf5, 0xe4, 0xa5, 0x64, 0x6d, 0xa8, 0x05, 0xd3, 0x94, - 0xe4, 0x9b, 0xcc, 0x7f, 0xe1, 0xcf, 0xf2, 0xb8, 0xa3, 0x47, 0x69, 0xaf, 0xfe, 0x08, 0xc9, 0x57, - 0x07, 0x73, 0xa7, 0x7c, 0x3c, 0xef, 0x93, 0xf7, 0xf0, 0x52, 0x6e, 0x8d, 0x81, 0x65, 0x53, 0x48, - 0x50, 0x36, 0x69, 0xa4, 0x95, 0xda, 0xc5, 0x8d, 0x35, 0x60, 0xd8, 0xd4, 0x4a, 0x5b, 0x69, 0x13, - 0xf7, 0x4f, 0x6e, 0xac, 0x8a, 0xb7, 0xdc, 0xd3, 0xe3, 0xd2, 0x94, 0x06, 0xcd, 0xc4, 0x5f, 0xfd, - 0xa7, 0xb3, 0x1f, 0x42, 0xc3, 0x07, 0x6c, 0x61, 0x17, 0x74, 0x92, 0x9b, 0x1a, 0xac, 0xcc, 0x21, - 0x93, 0x45, 0x61, 0x95, 0x73, 0x9c, 0xcc, 0x48, 0x34, 0x4a, 0x0f, 0x37, 0xfc, 0xba, 0xc7, 0x8c, - 0xd1, 0xa1, 0xaf, 0xe6, 0x7b, 0x18, 0xe3, 0xcd, 0x22, 0x3a, 0x79, 0x95, 0x0e, 0x32, 0x57, 0x95, - 0xb5, 0x2a, 0x32, 0xcc, 0x07, 0x98, 0x8f, 0x3d, 0x7f, 0x44, 0x9c, 0x7a, 0x73, 0x4e, 0x4f, 0x76, - 0xcd, 0xac, 0xaa, 0x0b, 0xb5, 0xe2, 0x43, 0xf4, 0x8f, 0xfe, 0xfb, 0xb7, 0x3e, 0x62, 0x53, 0x4a, - 0xd5, 0x9b, 0xaa, 0x21, 0xab, 0xa5, 0x56, 0x7c, 0x1f, 0xc5, 0x11, 0x92, 0x7b, 0xa9, 0x15, 0x3b, - 0xa7, 0x63, 0xec, 0x81, 0x4a, 0x2b, 0x07, 0x52, 0x37, 0x3c, 0x9c, 0x91, 0x68, 0x90, 0x1e, 0x78, - 0xfa, 0xb4, 0x81, 0x37, 0x77, 0x9f, 0xad, 0x20, 0xeb, 0x56, 0x90, 0xef, 0x56, 0x90, 0x8f, 0x4e, - 0x04, 0xeb, 0x4e, 0x04, 0x5f, 0x9d, 0x08, 0x9e, 0xaf, 0xca, 0x0a, 0x5e, 0x96, 0x8b, 0x38, 0x37, - 0x3a, 0xe9, 0x17, 0xfc, 0x7b, 0x2e, 0xfd, 0x92, 0xc9, 0x2a, 0xd9, 0xde, 0x1d, 0xde, 0x1b, 0xe5, - 0x16, 0x21, 0x4e, 0x38, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xef, 0xee, 0x30, 0x21, 0x93, 0x01, - 0x00, 0x00, + // 314 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xc1, 0x4a, 0x03, 0x31, + 0x10, 0x86, 0x9b, 0xb6, 0x56, 0x1a, 0xb5, 0x96, 0x28, 0x12, 0x84, 0x2e, 0x55, 0x10, 0xd6, 0x83, + 0xbb, 0x48, 0x9f, 0x40, 0x4f, 0x8a, 0x20, 0xb2, 0x7a, 0xf2, 0xb2, 0xa4, 0xbb, 0x61, 0x1b, 0x6c, + 0x36, 0x4b, 0x32, 0x95, 0xfa, 0x14, 0xfa, 0x58, 0x1e, 0x7b, 0xf4, 0x28, 0xed, 0x8b, 0x48, 0x66, + 0x2d, 0x54, 0x4f, 0x33, 0x7c, 0xff, 0x97, 0x39, 0xfc, 0xa1, 0xdc, 0x1a, 0x03, 0xb3, 0x2a, 0x17, + 0x20, 0x6d, 0x5c, 0x09, 0x2b, 0xb4, 0x8b, 0x2a, 0x6b, 0xc0, 0xb0, 0x81, 0x15, 0x56, 0x69, 0x13, + 0xd5, 0x23, 0x33, 0x56, 0x46, 0x1b, 0xee, 0xf1, 0x61, 0x61, 0x0a, 0x83, 0x66, 0xec, 0xb7, 0xfa, + 0xd1, 0xe9, 0x7b, 0x93, 0x76, 0x1e, 0xf0, 0x0a, 0x3b, 0xa7, 0xfd, 0xcc, 0x94, 0x60, 0x45, 0x06, + 0xa9, 0xc8, 0x73, 0x2b, 0x9d, 0xe3, 0x64, 0x48, 0xc2, 0x6e, 0xb2, 0xbf, 0xe6, 0x57, 0x35, 0x66, + 0x8c, 0xb6, 0xfd, 0x69, 0xde, 0xc4, 0x18, 0x77, 0x16, 0xd2, 0xfe, 0x54, 0x38, 0x48, 0x9d, 0x2a, + 0x4a, 0x99, 0xa7, 0x98, 0xb7, 0x30, 0xef, 0x79, 0xfe, 0x88, 0x38, 0xf1, 0xe6, 0x88, 0x1e, 0xfd, + 0x37, 0x53, 0x55, 0xe6, 0x72, 0xce, 0xdb, 0xe8, 0x1f, 0xfc, 0xf5, 0x6f, 0x7d, 0xc4, 0x06, 0x94, + 0xca, 0x57, 0x59, 0x42, 0x5a, 0x0a, 0x2d, 0xf9, 0x16, 0x8a, 0x5d, 0x24, 0xf7, 0x42, 0x4b, 0x76, + 0x46, 0x7b, 0x78, 0x07, 0x94, 0x96, 0x0e, 0x84, 0xae, 0x78, 0x67, 0x48, 0xc2, 0x56, 0xb2, 0xe7, + 0xe9, 0xd3, 0x1a, 0xb2, 0x13, 0xba, 0x3b, 0x9e, 0x9a, 0xec, 0x25, 0x9d, 0x48, 0x55, 0x4c, 0x80, + 0x6f, 0x0f, 0x49, 0xd8, 0x4e, 0x76, 0x90, 0xdd, 0x20, 0xba, 0xbe, 0xfb, 0x5c, 0x06, 0x64, 0xb1, + 0x0c, 0xc8, 0xf7, 0x32, 0x20, 0x1f, 0xab, 0xa0, 0xb1, 0x58, 0x05, 0x8d, 0xaf, 0x55, 0xd0, 0x78, + 0xbe, 0x2c, 0x14, 0x4c, 0x66, 0xe3, 0x28, 0x33, 0x3a, 0xae, 0x4b, 0xfe, 0x1d, 0x17, 0xbe, 0xec, + 0x78, 0x1e, 0x6f, 0x7e, 0x0d, 0xbc, 0x55, 0xd2, 0x8d, 0x3b, 0xd8, 0xf2, 0xe8, 0x27, 0x00, 0x00, + 0xff, 0xff, 0x0e, 0x6b, 0x5d, 0x49, 0xb6, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -157,6 +166,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.BlockHeight != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x38 + } if m.RootTimestamp != 0 { i = encodeVarintParams(dAtA, i, uint64(m.RootTimestamp)) i-- @@ -240,6 +254,9 @@ func (m *Params) Size() (n int) { if m.RootTimestamp != 0 { n += 1 + sovParams(uint64(m.RootTimestamp)) } + if m.BlockHeight != 0 { + n += 1 + sovParams(uint64(m.BlockHeight)) + } return n } @@ -457,6 +474,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) From 5bcd823a91ecbed84921236a388ad5e6422debe5 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Thu, 29 Aug 2024 12:46:47 +0300 Subject: [PATCH 12/14] migrations for the rootupdater module --- app/app.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/app.go b/app/app.go index 78b44d20..3a514b94 100644 --- a/app/app.go +++ b/app/app.go @@ -1100,6 +1100,29 @@ func New( }, ) + if upgradeInfo.Name == "v1.1.4-rc1" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storetypes.StoreUpgrades{ + Added: []string{rootupdatermoduletypes.ModuleName}, + })) + } + + app.UpgradeKeeper.SetUpgradeHandler( + "v1.1.4-rc1", + func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + app.RootupdaterKeeper.SetParams(ctx, rootupdatermoduletypes.Params{ + ContractAddress: "0xBF926a23B4A0bcA301F97Ccd27358b55Dc4C7D3C", + Root: "0x00", + LastSignedRoot: "", + LastSignedRootIndex: "", + EventName: "RootUpdated", + RootTimestamp: 1724316208, + }) + fromVM[rootupdatermoduletypes.ModuleName] = rootupdatermodule.AppModule{}.ConsensusVersion() + + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }, + ) + if loadLatest { if err := app.LoadLatestVersion(); err != nil { tmos.Exit(err.Error()) From 1489f80ddde8f2cd651a15501d7e95eec7d3736d Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Thu, 29 Aug 2024 13:15:39 +0300 Subject: [PATCH 13/14] update params --- app/app.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index 3a514b94..9f50c1d0 100644 --- a/app/app.go +++ b/app/app.go @@ -1111,9 +1111,9 @@ func New( func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { app.RootupdaterKeeper.SetParams(ctx, rootupdatermoduletypes.Params{ ContractAddress: "0xBF926a23B4A0bcA301F97Ccd27358b55Dc4C7D3C", - Root: "0x00", - LastSignedRoot: "", - LastSignedRootIndex: "", + Root: "0x000000", + LastSignedRoot: "0x00", + LastSignedRootIndex: "0x00", EventName: "RootUpdated", RootTimestamp: 1724316208, }) From 27cf3ba60d4e095f4334d73f859a4d1f151fb785 Mon Sep 17 00:00:00 2001 From: Mark Cherepovskyi Date: Thu, 29 Aug 2024 13:22:58 +0300 Subject: [PATCH 14/14] update root value in params --- app/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 9f50c1d0..52f26451 100644 --- a/app/app.go +++ b/app/app.go @@ -1111,7 +1111,7 @@ func New( func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { app.RootupdaterKeeper.SetParams(ctx, rootupdatermoduletypes.Params{ ContractAddress: "0xBF926a23B4A0bcA301F97Ccd27358b55Dc4C7D3C", - Root: "0x000000", + Root: "0x00", LastSignedRoot: "0x00", LastSignedRootIndex: "0x00", EventName: "RootUpdated",