diff --git a/docs/common/core/003-csca-list-proposal-guide.md b/docs/common/core/003-csca-list-proposal-guide.md index e607f232..f19789ea 100644 --- a/docs/common/core/003-csca-list-proposal-guide.md +++ b/docs/common/core/003-csca-list-proposal-guide.md @@ -17,7 +17,7 @@ When obtained the passport signer's root certificate, you can check its presence stored on Rarimo chain in a decentralized manner. This is how you ensure that the passport is signed by an eligible entity. -Technical details can be found in [CSCA List Rarimo Core module](https://github.com/rarimo/rarimo-core/x/cscalist/README.md). +Technical details can be found in [CSCA List Rarimo Core module](../../../x/cscalist/README.md). The keys of CSCA signers can be compromised or updated, ergo list updates must be handled. This is done via proposals. The guide will help you in creating and verifying proposals on list changes. @@ -38,10 +38,11 @@ You can call the CLI from that dir, or add it to your `$PATH`: export PATH=$PATH:$(go env GOPATH)/bin ``` - -Some commands require network RPC in order to fetch state. -You can put it into environment variable for convenient command calls: +All commands require Rarimo home directory set. +Also, some of them require network RPC in order to fetch state. +You can put these into environment variable for convenient command calls: ```bash +export RARIMO_HOME=/path/to/your/rarimo/home export RPC=https://your-rpc ``` @@ -59,7 +60,7 @@ This is why you have to monitor the list manually if you are interested in up-to ### Compare with state ```bash -rarimo-cored --node $RPC query cscalist ldif-tree-diff your-file.ldif +rarimo-cored --home $RARIMO_HOME --node $RPC query cscalist ldif-tree-diff your-file.ldif ``` If roots are different, the list was changed and the proposal must be created to update the tree. @@ -67,54 +68,53 @@ If roots are different, the list was changed and the proposal must be created to Most likely, you have already filled basic proposal data in the block scan (title, description, etc.). You should have the file with CSCA list, see **Download the list** subsection. Assuming the file name is `your-file.ldif`. -Obtain primary data for your proposal: +Next, obtain primary data for your proposal, which depends on the proposal type. + +### ReplaceCSCAListProposal + ```bash cd ~/Downloads # or wherever you have the file -rarimo-cored query cscalist parse-ldif --output-format hash your-file.ldif your-output-file.txt +rarimo-cored --home $RARIMO_HOME query cscalist parse-ldif your-file.ldif your-output-file.txt ``` `your-output-file.txt` will contain the big list of hashes of public keys from the LDIF file. Example: ``` -0x1d4dd579478a38c00f58a4d94263ff2bb0459992c073ebb7a6991194e44157f2 -0x0dcc4019fccc7ad4fbb535a40633cc32f99a18096a736b21e695e35e964209ae -0x01a3d79b678d79a8f912b693c4d57b38cf0e44ef413b7684e92a664e98c911ed +"0x1d4dd579478a38c00f58a4d94263ff2bb0459992c073ebb7a6991194e44157f2", +"0x0dcc4019fccc7ad4fbb535a40633cc32f99a18096a736b21e695e35e964209ae", +"0x01a3d79b678d79a8f912b693c4d57b38cf0e44ef413b7684e92a664e98c911ed" ``` -If this is `ReplaceCSCAListProposal`, just copy the hashes to the proposal `leaves` field. - -For `EditCSCAListProposal` the process is more complicated: +These are the hashes of compatible public keys from the provided LDIF file. +Just copy them to the `leaves` field of your draft proposal. -### Method 1 +### EditCSCAListProposal -1. Obtain the old Master List LDIF file, which tree is stored on-chain at the moment. -If you don't have it, use **Method 2** instead. -2. Optional: ensure that the list from file is the same as on-chain: ```bash -rarimo-cored --node $RPC query cscalist ldif-tree-diff your-old-file.ldif +cd ~/Downloads # or wherever you have the file +rarimo-cored --home $RARIMO_HOME query cscalist prepare-proposal your-file.ldif your-output-file.txt ``` -You expect to see message that the trees' roots are the same. -Otherwise, seek for an actual `your-old-file.ldif`. -3. Extract the hashes from your old file: -```bash -rarimo-cored query cscalist parse-ldif --output-format hash your-old-file.ldif old-output-file.txt + +`your-output-file.txt` will contain two lists of hashes to add and remove. Example: +``` +=== To add === +"0x1d4dd579478a38c00f58a4d94263ff2bb0459992c073ebb7a6991194e44157f2", +"0x0dcc4019fccc7ad4fbb535a40633cc32f99a18096a736b21e695e35e964209ae" +=== To remove === +"0x01a3d79b678d79a8f912b693c4d57b38cf0e44ef413b7684e92a664e98c911ed" ``` -4. Compare `your-output-file.txt` and `old-output-file.txt` to find the differences. -You can use `diff`, `vimdiff` or any preferable tool. -- hashes present only in `your-output-file.txt` are to be added -- hashes present only in `old-output-file.txt` are to be removed -5. Put acquired hashes into respective fields: `toAdd`, `toRemove` +The command has fetched the current state, compared it to the tree from file and provided the differences to consume. +Copy the respective hashes to the `toAdd` and `toRemove` fields of your draft proposal. -### Method 2 +### Submit proposal -1. Fetch the current hashes from the Merkle tree: +Basically, you need a command: ```bash -rarimo-cored --node $RPC query cscalist tree > current-tree.txt +rarimo-cored --home $RARIMO_HOME --node $RPC tx gov submit-proposal draft_proposal.json --from ``` -2. Iterate over the `current-tree.txt` manually and collect `key` values. -You may put them into `old-output-file.txt`. - -3. Perform steps 4 and 5 from **Method 1**. -Congratulations! You should now have your proposal ready for submission. +Refer to Cosmos SDK documentation and other guides to get more details about: +- Account creation +- Generating and managing your keys +- Obtaining `draft_proposal.json` ## Verify proposal @@ -122,16 +122,19 @@ In order to vote for the proposal, you need to ensure that its content correspon Firstly, download the list from [ICAO website](https://pkddownloadsg.icao.int/) and prepare the list of hashes, like described in **Create proposal** section. - Secondly, check whether the proposal makes any difference to the current state: ```bash -rarimo-cored --node $RPC query cscalist ldif-tree-diff your-file.ldif +rarimo-cored --home $RARIMO_HOME --node $RPC query cscalist ldif-tree-diff your-file.ldif ``` -If there is no difference, the proposal does not make sense, and you should vote 'No' or 'NoWithVeto'. +If there is no difference, the proposal either does not make sense, or is fraudulent, and you should vote 'No' or 'NoWithVeto'. +Again, the deeper validation depends on proposal type. If this is `ReplaceCSCAListProposal`, just compare the `leaves` field with `your-output-file.txt`. It is possible that you could have the different order of hashes due to ICAO change of order. Therefore, you may wish to sort both lists, e.g. with `sort` command. -For `EditCSCAListProposal`, you need to perform the same steps as in **Create proposal** section. -Then compare the `toAdd` and `toRemove` fields with the differences between `your-output-file.txt` and `old-output-file.txt`. +For `EditCSCAListProposal`, you should additionally perform: +```bash +rarimo-cored --home $RARIMO_HOME --node $RPC query cscalist prepare-proposal your-file.ldif your-output-file.txt +``` +Then compare the `toAdd` and `toRemove` fields with the differences between `your-output-file.txt` and someone's proposal. -If you get the same results as in the proposal, it is correct, and you can vote for it. +If you get the same results as in the proposal (of any type), it is correct, and you should support it. diff --git a/docs/common/mainnet/002-upgrades.md b/docs/common/mainnet/002-upgrades.md index bea5092b..f165fafe 100644 --- a/docs/common/mainnet/002-upgrades.md +++ b/docs/common/mainnet/002-upgrades.md @@ -5,6 +5,36 @@ title: Mainnet upgrades # Mainnet upgrades +## V1.1.2 + +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. + +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. + +## V1.1.1 + +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. + +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). + ## V1.1.0 Core binary: ( @@ -22,7 +52,7 @@ Upgrade v1.1.0 introduces a couple of features for identity transfers: - New WorldCoin identity transfer - Fix for the Iden3 identity transfers: GIST and state transfers are split into two different operations. -- Double-sending of confirmation messages will not cause TX error. +- Double-sending of confirmation messages will not cause TX error. ## V1.0.7 diff --git a/go.mod b/go.mod index 7baecc31..979e6d52 100644 --- a/go.mod +++ b/go.mod @@ -40,10 +40,10 @@ require ( 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.14.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be - google.golang.org/grpc v1.63.2 - google.golang.org/protobuf v1.33.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 sigs.k8s.io/yaml v1.4.0 ) @@ -51,8 +51,7 @@ require github.com/rs/zerolog v1.29.1 // indirect require ( cloud.google.com/go v0.112.2 // indirect - cloud.google.com/go/compute v1.25.1 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/iam v1.1.7 // indirect cloud.google.com/go/storage v1.39.1 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect @@ -93,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 @@ -117,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.19.1 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.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 @@ -197,15 +197,14 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.22.0 // indirect golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect - golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/oauth2 v0.20.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/time v0.5.0 // indirect google.golang.org/api v0.170.0 // indirect - google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240415180920-8c6c420018be // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // 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 0edce5ea..f6106b77 100644 --- a/go.sum +++ b/go.sum @@ -149,13 +149,12 @@ cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x cloud.google.com/go/compute v1.13.0/go.mod h1:5aPTS0cUNMIc1CE546K+Th6weJUNQErARyZtRXDJ8GE= cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= -cloud.google.com/go/compute v1.25.1 h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU= -cloud.google.com/go/compute v1.25.1/go.mod h1:oopOIR53ly6viBYxaDhBfJwzUAxf1zE//uf3IB011ls= cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/contactcenterinsights v1.3.0/go.mod h1:Eu2oemoePuEFc/xKFPjbTuPSj0fYJcPls9TFlPNnHHY= cloud.google.com/go/contactcenterinsights v1.4.0/go.mod h1:L2YzkGbPsv+vMQMCADxJoT9YiTTnSEd6fEvCeHTYVck= cloud.google.com/go/contactcenterinsights v1.6.0/go.mod h1:IIDlT6CLcDoyv79kDv8iWxMSTZhLxSCofVV5W6YFM/w= @@ -809,6 +808,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= @@ -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.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= +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/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= @@ -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.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.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= @@ -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.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +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/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= @@ -2161,8 +2161,6 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -2296,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-20240415180920-8c6c420018be h1:Zz7rLWqp0ApfsR/l7+zSHhY3PMiH2xqgxlfYfAfNpoU= -google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be/go.mod h1:dvdCTIoAGbkWbcIKBniID56/7XHTt6WfxXNMxuziJ+w= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +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/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= @@ -2319,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.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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= diff --git a/proto/oraclemanager/tx.proto b/proto/oraclemanager/tx.proto index f4ccd6db..29e8d22b 100644 --- a/proto/oraclemanager/tx.proto +++ b/proto/oraclemanager/tx.proto @@ -13,7 +13,9 @@ service Msg { rpc Stake(MsgStake) returns (MsgStakeResponse); rpc Unstake(MsgUnstake) returns (MsgUnstakeResponse); rpc CreateTransferOperation(MsgCreateTransferOp) returns (MsgCreateTransferOpResponse); + // Deprecated: consider using separate state and gist transfer operations. rpc CreateIdentityDefaultTransferOperation(MsgCreateIdentityDefaultTransferOp) returns (MsgCreateIdentityDefaultTransferOpResponse); + rpc CreateIdentityGISTTransferOperation(MsgCreateIdentityGISTTransferOp) returns (MsgCreateIdentityGISTTransferOpResponse); rpc CreateIdentityStateTransferOperation(MsgCreateIdentityStateTransferOp) returns (MsgCreateIdentityStateTransferOpResponse); rpc CreateWorldCoinIdentityTransferOperation(MsgCreateWorldCoinIdentityTransferOp) returns (MsgCreateWorldCoinIdentityTransferOpResponse); diff --git a/proto/rarimocore/op_arbitrary.proto b/proto/rarimocore/op_arbitrary.proto new file mode 100644 index 00000000..d238aed2 --- /dev/null +++ b/proto/rarimocore/op_arbitrary.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package rarimo.rarimocore.rarimocore; + +import "rarimocore/params.proto"; + +option go_package = "github.com/rarimo/rarimo-core/x/rarimocore/types"; + +message Arbitrary { + // Hex encoded data to be signed. AWARE do not make collisions with existing operations. + string data = 1; +} + diff --git a/proto/rarimocore/operation.proto b/proto/rarimocore/operation.proto index 35eba07c..a8e91451 100644 --- a/proto/rarimocore/operation.proto +++ b/proto/rarimocore/operation.proto @@ -16,6 +16,7 @@ enum OpType { IDENTITY_STATE_TRANSFER = 7; WORLDCOIN_IDENTITY_TRANSFER = 8; CSCA_ROOT_UPDATE = 9; + ARBITRARY = 10; } enum OpStatus { diff --git a/proto/rarimocore/proposal.proto b/proto/rarimocore/proposal.proto index ea7ee515..752523e4 100644 --- a/proto/rarimocore/proposal.proto +++ b/proto/rarimocore/proposal.proto @@ -23,4 +23,11 @@ message SlashProposal { message DropPartiesProposal { string title = 1; string description = 2; +} + +message ArbitrarySigningProposal { + string title = 1; + string description = 2; + // Hex encoded data to be signed. AWARE do not make collisions with existing operations. + string data = 3; } \ No newline at end of file diff --git a/proto/tokenmanager/params.proto b/proto/tokenmanager/params.proto index e067b109..8282d716 100644 --- a/proto/tokenmanager/params.proto +++ b/proto/tokenmanager/params.proto @@ -11,6 +11,7 @@ enum NetworkType { Near = 2; Other = 3; Rarimo = 4; + RarimoEVM = 5; } enum NetworkParamType { diff --git a/x/cscalist/client/cli/ldif.go b/x/cscalist/client/cli/ldif.go index 9dd27de6..1d90fedb 100644 --- a/x/cscalist/client/cli/ldif.go +++ b/x/cscalist/client/cli/ldif.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "os" + "strings" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -21,12 +22,13 @@ const outputFormatFlag = "output-format" func cmdParseLDIF() *cobra.Command { const ( - rawFormat = "raw" - hashFormat = "hash" - rootFormat = "root" - defaultFormat = hashFormat + rawFormat = "raw" + hashFormat = "hash" + proposalFormat = "proposal" + rootFormat = "root" + defaultFormat = proposalFormat ) - outputFormatValues := fmt.Sprintf("%s, %s, %s", rawFormat, hashFormat, rootFormat) + outputFormatValues := strings.Join([]string{rawFormat, hashFormat, proposalFormat, rootFormat}, ", ") cmd := &cobra.Command{ Use: "parse-ldif [output-file]", @@ -80,12 +82,10 @@ automatically, see ldif-tree-diff)`, } case hashFormat: - for _, pk := range pubKeys { - hash := keccak256.Hash(pk) - if _, err = fmt.Fprintln(dst, hexutil.Encode(hash)); err != nil { - return fmt.Errorf("write to destination: %w", err) - } - } + return printHashes(pubKeys, dst, false) + + case proposalFormat: + return printHashes(pubKeys, dst, true) case rootFormat: sPubKeys := make([]string, len(pubKeys)) @@ -115,11 +115,10 @@ automatically, see ldif-tree-diff)`, func cmdLDIFTreeDiff() *cobra.Command { cmd := &cobra.Command{ Use: "ldif-tree-diff ", - Short: "Build one tree from LDIF file, query another tree from chain and compare roots", + Short: "Build one tree from LDIF file, query tree root from chain and compare roots", Long: `Provide a LDIF file to parse. The list can be manually retrieved from -https://pkddownloadsg.icao.int/. When the file is parsed, one tree is built, -another one is queried. Roots of 2 trees are compared. Use parse-ldif and tree -subcommands to find out the exact differences of data. +https://pkddownloadsg.icao.int/. Use parse-ldif and tree subcommands to find out +the exact differences of data. Use cases: - Automatically validate proposals: ensure that stored and proposed list differ @@ -132,34 +131,20 @@ Use cases: return fmt.Errorf("parse LDIF from file: %w", err) } - pubKeys, err := data.RawPubKeys() - if err != nil { - return fmt.Errorf("extract raw public keys: %w", err) - } - sPubKeys := make([]string, len(pubKeys)) - for i, pk := range pubKeys { - sPubKeys[i] = string(pk) - } - - tree, err := mt.BuildFromRaw(sPubKeys) - if err != nil { - return fmt.Errorf("build Merkle tree: %w", err) - } - cliCtx := client.GetClientContextFromCmd(cmd) cli := types.NewQueryClient(cliCtx) - root, err := getRootNode(cli) + + built, stored, err := getBuiltAndStoredRoots(data, cli) if err != nil { - return fmt.Errorf("get root node: %w", err) + return fmt.Errorf("get built and stored roots: %w", err) } - treeRoot := hexutil.Encode(tree.Root()) - if treeRoot != root.Hash { - fmt.Printf("Trees differ: built_root=%s stored_root=%s\n", treeRoot, root.Hash) + if built != stored { + fmt.Printf("Trees differ: built_root=%s stored_root=%s\n", built, stored) return nil } - fmt.Printf("Tree are same: root=%s\n", treeRoot) + fmt.Printf("Tree are same: root=%s\n", built) return nil }, } @@ -168,6 +153,51 @@ Use cases: return cmd } +func printHashes(pubKeys [][]byte, dst *os.File, forProposal bool) error { + for i, pk := range pubKeys { + hash := keccak256.Hash(pk) + + out := hexutil.Encode(hash) + if forProposal { + var comma string + if i < len(pubKeys)-1 { + comma = "," + } + out = fmt.Sprintf("%q%s", out, comma) + } + + if _, err := fmt.Fprintln(dst, out); err != nil { + return fmt.Errorf("write to destination: %w", err) + } + } + + return nil +} + +func getBuiltAndStoredRoots(data ldif.LDIF, cli types.QueryClient) (string, string, error) { + pubKeys, err := data.RawPubKeys() + if err != nil { + return "", "", fmt.Errorf("extract raw public keys: %w", err) + } + + sPubKeys := make([]string, len(pubKeys)) + for i, pk := range pubKeys { + sPubKeys[i] = string(pk) + } + + tree, err := mt.BuildFromRaw(sPubKeys) + if err != nil { + return "", "", fmt.Errorf("build Merkle tree: %w", err) + } + + root, err := getRootNode(cli) + if err != nil { + return "", "", fmt.Errorf("get root node: %w", err) + } + + return hexutil.Encode(tree.Root()), root.Hash, nil +} + func getRootNode(cli types.QueryClient) (*types.Node, error) { params, err := cli.Params(context.Background(), &types.QueryParamsRequest{}) if err != nil { diff --git a/x/cscalist/client/cli/proposal.go b/x/cscalist/client/cli/proposal.go new file mode 100644 index 00000000..acbf856a --- /dev/null +++ b/x/cscalist/client/cli/proposal.go @@ -0,0 +1,170 @@ +package cli + +import ( + "context" + "fmt" + "os" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/iden3/go-iden3-crypto/keccak256" + "github.com/rarimo/ldif-sdk/ldif" + "github.com/rarimo/rarimo-core/x/cscalist/types" + "github.com/spf13/cobra" + "google.golang.org/grpc" +) + +func cmdPrepareProposal() *cobra.Command { + cmd := &cobra.Command{ + Use: "prepare-proposal [output-file]", + Short: "Prepare content for EditCSCAListProposal from LDIF file", + Long: `Provide a LDIF file to parse CSCA certificates from it. The list can be manually +retrieved from https://pkddownloadsg.icao.int/. The command builds one tree from +LDIF, fetches another one from chain and selects leaves to add or remove. + +If output-file is provided, the output is written to the specified file instead +of stdout. This is useful to copy-paste from a file. + +Use cases: +- Copy-paste the output to your EditCSCAListProposal draft +- Validate editing proposals: ensure that the leaves to add and remove are the same`, + SuggestionsMinimumDistance: 2, + Args: cobra.RangeArgs(1, 2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + dst := os.Stdout + if len(args) == 2 { + dst, err = os.OpenFile(args[1], os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) + if err != nil { + return fmt.Errorf("open destination file: %w", err) + } + defer func() { _ = dst.Close() }() + } + + data, err := ldif.FromFile(args[0]) + if err != nil { + return fmt.Errorf("parse LDIF from file: %w", err) + } + + cliCtx := client.GetClientContextFromCmd(cmd) + cli := types.NewQueryClient(cliCtx) + + built, stored, err := getBuiltAndStoredRoots(data, cli) + if err != nil { + return fmt.Errorf("get built and stored roots: %w", err) + } + + if built == stored { + _, err = fmt.Fprintf(dst, "Tree are same: root=%s. Nothing to add or remove.\n", built) + if err != nil { + return fmt.Errorf("write to destination: %w", err) + } + return nil + } + + oldLeaves, err := fetchHashLeavesFromCosmos(cmd.Context(), cli) + if err != nil { + return fmt.Errorf("fetch hash leaves from cosmos: %w", err) + } + + pubKeys, _ := data.RawPubKeys() // error was handled in getBuiltAndStoredRoots + newLeaves := make([]string, len(pubKeys)) + for i, pk := range pubKeys { + newLeaves[i] = hexutil.Encode(keccak256.Hash(pk)) + } + + toAdd, toRemove := selectProposalHashes(oldLeaves, newLeaves) + + _, err = fmt.Fprintf(dst, "=== To add ===\n%s=== To remove ===\n%s", formatHashes(toAdd), formatHashes(toRemove)) + if err != nil { + return fmt.Errorf("write to destination: %w", err) + } + return nil + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// optimized copy of github.com/rarimo/ldif-sdk/utils.FetchHashLeavesFromCosmos +func fetchHashLeavesFromCosmos(ctx context.Context, client types.QueryClient) ([]string, error) { + var ( + limit = uint64(100) + offset = uint64(0) + leaves []string + ) + + for { + resp, err := client.Tree(ctx, &types.QueryTreeRequest{ + Pagination: &query.PageRequest{ + CountTotal: true, + Limit: limit, + Offset: offset, + }, + }, grpc.EmptyCallOption{}) + if err != nil { + return nil, fmt.Errorf("query paginated tree: %w", err) + } + + if cap(leaves) == 0 { + leaves = make([]string, 0, resp.Pagination.Total) + } + + for _, node := range resp.Tree { + leaves = append(leaves, node.Key) + } + + if uint64(len(leaves)) == resp.Pagination.Total { + break + } + + offset += limit + } + + return leaves, nil +} + +func selectProposalHashes(oldLeaves, newLeaves []string) (toAdd []string, toRemove []string) { + toAdd = make([]string, 0, len(newLeaves)) + toRemove = make([]string, 0, len(oldLeaves)) + + for _, leaf := range newLeaves { + if !existsInSlice(oldLeaves, leaf) { + toAdd = append(toAdd, leaf) + } + } + + for _, leaf := range oldLeaves { + if !existsInSlice(newLeaves, leaf) { + toRemove = append(toRemove, leaf) + } + } + + return +} + +func formatHashes(hashes []string) string { + var sb strings.Builder + + for i, h := range hashes { + var comma string + if i < len(hashes)-1 { + comma = "," + } + sb.WriteString(fmt.Sprintf("%q%s\n", h, comma)) + } + + return sb.String() +} + +func existsInSlice(slice []string, elem string) bool { + for _, e := range slice { + if e == elem { + return true + } + } + return false +} diff --git a/x/cscalist/client/cli/query.go b/x/cscalist/client/cli/query.go index e8731757..c2ce6849 100644 --- a/x/cscalist/client/cli/query.go +++ b/x/cscalist/client/cli/query.go @@ -36,6 +36,7 @@ func GetQueryCmd() *cobra.Command { cmdQueryTree(), cmdParseLDIF(), cmdLDIFTreeDiff(), + cmdPrepareProposal(), ) // this line is used by starport scaffolding # 1 diff --git a/x/oraclemanager/types/tx.pb.go b/x/oraclemanager/types/tx.pb.go index 9ba27c10..586f0148 100644 --- a/x/oraclemanager/types/tx.pb.go +++ b/x/oraclemanager/types/tx.pb.go @@ -1270,6 +1270,7 @@ type MsgClient interface { Stake(ctx context.Context, in *MsgStake, opts ...grpc.CallOption) (*MsgStakeResponse, error) Unstake(ctx context.Context, in *MsgUnstake, opts ...grpc.CallOption) (*MsgUnstakeResponse, error) CreateTransferOperation(ctx context.Context, in *MsgCreateTransferOp, opts ...grpc.CallOption) (*MsgCreateTransferOpResponse, error) + // Deprecated: consider using separate state and gist transfer operations. CreateIdentityDefaultTransferOperation(ctx context.Context, in *MsgCreateIdentityDefaultTransferOp, opts ...grpc.CallOption) (*MsgCreateIdentityDefaultTransferOpResponse, error) CreateIdentityGISTTransferOperation(ctx context.Context, in *MsgCreateIdentityGISTTransferOp, opts ...grpc.CallOption) (*MsgCreateIdentityGISTTransferOpResponse, error) CreateIdentityStateTransferOperation(ctx context.Context, in *MsgCreateIdentityStateTransferOp, opts ...grpc.CallOption) (*MsgCreateIdentityStateTransferOpResponse, error) @@ -1372,6 +1373,7 @@ type MsgServer interface { Stake(context.Context, *MsgStake) (*MsgStakeResponse, error) Unstake(context.Context, *MsgUnstake) (*MsgUnstakeResponse, error) CreateTransferOperation(context.Context, *MsgCreateTransferOp) (*MsgCreateTransferOpResponse, error) + // Deprecated: consider using separate state and gist transfer operations. CreateIdentityDefaultTransferOperation(context.Context, *MsgCreateIdentityDefaultTransferOp) (*MsgCreateIdentityDefaultTransferOpResponse, error) CreateIdentityGISTTransferOperation(context.Context, *MsgCreateIdentityGISTTransferOp) (*MsgCreateIdentityGISTTransferOpResponse, error) CreateIdentityStateTransferOperation(context.Context, *MsgCreateIdentityStateTransferOp) (*MsgCreateIdentityStateTransferOpResponse, error) diff --git a/x/rarimocore/crypto/operation/op_arbitrary.go b/x/rarimocore/crypto/operation/op_arbitrary.go new file mode 100644 index 00000000..03e906c5 --- /dev/null +++ b/x/rarimocore/crypto/operation/op_arbitrary.go @@ -0,0 +1,24 @@ +package operation + +import ( + "bytes" + + eth "github.com/ethereum/go-ethereum/crypto" + merkle "github.com/rarimo/go-merkle" +) + +// ArbitraryContent implements the Content interface provided by go-merkle and represents the content stored in the tree. +type ArbitraryContent struct { + Data []byte +} + +var _ merkle.Content = ArbitraryContent{} + +func (c ArbitraryContent) CalculateHash() []byte { + return eth.Keccak256(c.Data) +} + +// Equals tests for equality of two Contents +func (c ArbitraryContent) 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 b9dd493a..412f9b8d 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_ARBITRARY: + content, err := GetArbitraryContent(op) + if err != nil { + return nil, err + } + if content != nil { contents = append(contents, content) } @@ -251,3 +260,13 @@ func GetCSCARootUpdateContent(op *types.Operation) (merkle.Content, error) { content, err := pkg.GetCSCARootUpdateContent(update) return content, errors.Wrap(err, "error creating content") } + +func GetArbitraryContent(op *types.Operation) (merkle.Content, error) { + update, err := pkg.GetArbitrary(*op) + if err != nil { + return nil, errors.Wrap(err, "error parsing operation details") + } + + content, err := pkg.GetArbitraryContent(update) + return content, errors.Wrap(err, "error creating content") +} diff --git a/x/rarimocore/crypto/pkg/op_arbitrary.go b/x/rarimocore/crypto/pkg/op_arbitrary.go new file mode 100644 index 00000000..279376f2 --- /dev/null +++ b/x/rarimocore/crypto/pkg/op_arbitrary.go @@ -0,0 +1,24 @@ +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 GetArbitrary(operation types.Operation) (*types.Arbitrary, error) { + if operation.OperationType == types.OpType_ARBITRARY { + op := new(types.Arbitrary) + return op, proto.Unmarshal(operation.Details.Value, op) + } + return nil, errors.Wrap(sdkerrors.ErrInvalidType, "invalid operation type") +} + +func GetArbitraryContent(op *types.Arbitrary) (*operation.ArbitraryContent, error) { + return &operation.ArbitraryContent{ + Data: hexutil.MustDecode(op.Data), + }, nil +} diff --git a/x/rarimocore/keeper/keeper.go b/x/rarimocore/keeper/keeper.go index d2d0e51a..3f31ac31 100644 --- a/x/rarimocore/keeper/keeper.go +++ b/x/rarimocore/keeper/keeper.go @@ -292,6 +292,7 @@ func (k Keeper) CreateIdentityAggregatedTransferOperation(ctx sdk.Context, creat return operation.Index, nil } +// Deprecated: consider using separate state and gist transfer operations. func (k Keeper) CreateIdentityDefaultTransferOperation(ctx sdk.Context, creator string, transfer *types.IdentityDefaultTransfer) error { network, ok := k.tm.GetNetwork(ctx, transfer.Chain) if !ok { @@ -538,6 +539,44 @@ func (k Keeper) CreateCSCARootUpdateOperation(ctx sdk.Context, creator string, u return operation.Index, nil } +func (k Keeper) CreateArbitraryOperation(ctx sdk.Context, creator string, arbitrary *types.Arbitrary) error { + details, err := cosmostypes.NewAnyWithValue(arbitrary) + if err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidRequest, "error parsing details: %s", err.Error()) + } + + content, err := pkg.GetArbitraryContent(arbitrary) + 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_ARBITRARY, + 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 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/keeper/msg_server_confirmation.go b/x/rarimocore/keeper/msg_server_confirmation.go index 5bf747ba..72956f7c 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_ARBITRARY: + arbitrary, err := pkg.GetArbitrary(op) + if err != nil { + return nil, fmt.Errorf("%w: failed to unmarshal details: %s", sdkerrors.ErrInvalidRequest, err.Error()) + } + return pkg.GetArbitraryContent(arbitrary) default: return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid operation") } diff --git a/x/rarimocore/keeper/proposal.go b/x/rarimocore/keeper/proposal.go index 4c1ff37c..9e171ac5 100644 --- a/x/rarimocore/keeper/proposal.go +++ b/x/rarimocore/keeper/proposal.go @@ -76,3 +76,7 @@ func (k Keeper) DropPartiesProposal(ctx sdk.Context, _ *types.DropPartiesProposa k.SetParams(ctx, params) return nil } + +func (k Keeper) ArbitrarySigningProposal(ctx sdk.Context, proposal *types.ArbitrarySigningProposal) error { + return k.CreateArbitraryOperation(ctx, types.ModuleName, &types.Arbitrary{Data: proposal.Data}) +} diff --git a/x/rarimocore/proposal_handler.go b/x/rarimocore/proposal_handler.go index 3cc41b04..17229ecf 100644 --- a/x/rarimocore/proposal_handler.go +++ b/x/rarimocore/proposal_handler.go @@ -19,6 +19,8 @@ func NewProposalHandler(k keeper.Keeper) govv1beta1.Handler { return k.SlashProposal(ctx, c) case *types.DropPartiesProposal: return k.DropPartiesProposal(ctx, c) + case *types.ArbitrarySigningProposal: + return k.ArbitrarySigningProposal(ctx, c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized proposal content type: %T", c) } diff --git a/x/rarimocore/types/codec.go b/x/rarimocore/types/codec.go index c686f15e..3411be99 100644 --- a/x/rarimocore/types/codec.go +++ b/x/rarimocore/types/codec.go @@ -31,6 +31,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&ReshareKeysProposal{}, "rarimocore/ReshareKeysProposal", nil) cdc.RegisterConcrete(&SlashProposal{}, "rarimocore/SlashProposal", nil) cdc.RegisterConcrete(&DropPartiesProposal{}, "rarimocore/DropPartiesProposal", nil) + cdc.RegisterConcrete(&ArbitrarySigningProposal{}, "rarimocore/ArbitrarySigningProposal", nil) // this line is used by starport scaffolding # 2 } @@ -73,6 +74,11 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &DropPartiesProposal{}, ) + registry.RegisterImplementations( + (*govv1beta1.Content)(nil), + &ArbitrarySigningProposal{}, + ) + registry.RegisterInterface( "rarimo.rarimocore.rarimocore.Transfer", (*proto.Message)(nil), diff --git a/x/rarimocore/types/op_arbitrary.pb.go b/x/rarimocore/types/op_arbitrary.pb.go new file mode 100644 index 00000000..a7d4ff65 --- /dev/null +++ b/x/rarimocore/types/op_arbitrary.pb.go @@ -0,0 +1,316 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rarimocore/op_arbitrary.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 Arbitrary struct { + // Hex encoded data to be signed. AWARE do not make collisions with existing operations. + Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *Arbitrary) Reset() { *m = Arbitrary{} } +func (m *Arbitrary) String() string { return proto.CompactTextString(m) } +func (*Arbitrary) ProtoMessage() {} +func (*Arbitrary) Descriptor() ([]byte, []int) { + return fileDescriptor_e7f40207d02821cd, []int{0} +} +func (m *Arbitrary) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Arbitrary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Arbitrary.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 *Arbitrary) XXX_Merge(src proto.Message) { + xxx_messageInfo_Arbitrary.Merge(m, src) +} +func (m *Arbitrary) XXX_Size() int { + return m.Size() +} +func (m *Arbitrary) XXX_DiscardUnknown() { + xxx_messageInfo_Arbitrary.DiscardUnknown(m) +} + +var xxx_messageInfo_Arbitrary proto.InternalMessageInfo + +func (m *Arbitrary) GetData() string { + if m != nil { + return m.Data + } + return "" +} + +func init() { + proto.RegisterType((*Arbitrary)(nil), "rarimo.rarimocore.rarimocore.Arbitrary") +} + +func init() { proto.RegisterFile("rarimocore/op_arbitrary.proto", fileDescriptor_e7f40207d02821cd) } + +var fileDescriptor_e7f40207d02821cd = []byte{ + // 162 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0x4a, 0x2c, 0xca, + 0xcc, 0xcd, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0xcf, 0x2f, 0x88, 0x4f, 0x2c, 0x4a, 0xca, 0x2c, 0x29, + 0x4a, 0x2c, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0x48, 0xeb, 0x21, 0x54, + 0x21, 0x31, 0xa5, 0xc4, 0x91, 0x34, 0x17, 0x24, 0x16, 0x25, 0xe6, 0x16, 0x43, 0xb4, 0x29, 0xc9, + 0x73, 0x71, 0x3a, 0xc2, 0x4c, 0x12, 0x12, 0xe2, 0x62, 0x49, 0x49, 0x2c, 0x49, 0x94, 0x60, 0x54, + 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x9d, 0xbc, 0x4e, 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, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x62, + 0x3c, 0x94, 0xd2, 0x05, 0x5b, 0x53, 0xa1, 0x8f, 0x64, 0x67, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, + 0x1b, 0xd8, 0x4e, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x25, 0x3f, 0xac, 0xf4, 0xcb, 0x00, + 0x00, 0x00, +} + +func (m *Arbitrary) 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 *Arbitrary) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Arbitrary) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintOpArbitrary(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOpArbitrary(dAtA []byte, offset int, v uint64) int { + offset -= sovOpArbitrary(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Arbitrary) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovOpArbitrary(uint64(l)) + } + return n +} + +func sovOpArbitrary(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOpArbitrary(x uint64) (n int) { + return sovOpArbitrary(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Arbitrary) 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 ErrIntOverflowOpArbitrary + } + 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: Arbitrary: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Arbitrary: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOpArbitrary + } + 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 ErrInvalidLengthOpArbitrary + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOpArbitrary + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOpArbitrary(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOpArbitrary + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOpArbitrary(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, ErrIntOverflowOpArbitrary + } + 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, ErrIntOverflowOpArbitrary + } + 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, ErrIntOverflowOpArbitrary + } + 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, ErrInvalidLengthOpArbitrary + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOpArbitrary + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOpArbitrary + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOpArbitrary = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOpArbitrary = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOpArbitrary = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rarimocore/types/operation.pb.go b/x/rarimocore/types/operation.pb.go index f2c09cde..b4ab3860 100644 --- a/x/rarimocore/types/operation.pb.go +++ b/x/rarimocore/types/operation.pb.go @@ -36,19 +36,21 @@ const ( OpType_IDENTITY_STATE_TRANSFER OpType = 7 OpType_WORLDCOIN_IDENTITY_TRANSFER OpType = 8 OpType_CSCA_ROOT_UPDATE OpType = 9 + OpType_ARBITRARY OpType = 10 ) var OpType_name = map[int32]string{ - 0: "TRANSFER", - 1: "CHANGE_PARTIES", - 2: "FEE_TOKEN_MANAGEMENT", - 3: "CONTRACT_UPGRADE", - 4: "IDENTITY_DEFAULT_TRANSFER", - 5: "IDENTITY_AGGREGATED_TRANSFER", - 6: "IDENTITY_GIST_TRANSFER", - 7: "IDENTITY_STATE_TRANSFER", - 8: "WORLDCOIN_IDENTITY_TRANSFER", - 9: "CSCA_ROOT_UPDATE", + 0: "TRANSFER", + 1: "CHANGE_PARTIES", + 2: "FEE_TOKEN_MANAGEMENT", + 3: "CONTRACT_UPGRADE", + 4: "IDENTITY_DEFAULT_TRANSFER", + 5: "IDENTITY_AGGREGATED_TRANSFER", + 6: "IDENTITY_GIST_TRANSFER", + 7: "IDENTITY_STATE_TRANSFER", + 8: "WORLDCOIN_IDENTITY_TRANSFER", + 9: "CSCA_ROOT_UPDATE", + 10: "ARBITRARY", } var OpType_value = map[string]int32{ @@ -62,6 +64,7 @@ var OpType_value = map[string]int32{ "IDENTITY_STATE_TRANSFER": 7, "WORLDCOIN_IDENTITY_TRANSFER": 8, "CSCA_ROOT_UPDATE": 9, + "ARBITRARY": 10, } func (x OpType) String() string { @@ -198,39 +201,40 @@ func init() { func init() { proto.RegisterFile("rarimocore/operation.proto", fileDescriptor_4615e59ddf669d07) } var fileDescriptor_4615e59ddf669d07 = []byte{ - // 512 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x4f, 0x8f, 0xd2, 0x40, - 0x18, 0xc6, 0x29, 0x7f, 0x0a, 0xbc, 0xbb, 0xae, 0xcd, 0x1b, 0xa2, 0x5d, 0x16, 0x2b, 0x31, 0xc6, - 0x90, 0x4d, 0x2c, 0x66, 0xbd, 0x9b, 0x8c, 0x74, 0xa8, 0x5d, 0xd9, 0x29, 0x99, 0xce, 0x6a, 0xdc, - 0x4b, 0x53, 0xd8, 0x8a, 0x4d, 0x16, 0xda, 0x94, 0x92, 0x2c, 0x9f, 0xc1, 0x8b, 0x17, 0xbf, 0x93, - 0xc7, 0x3d, 0x7a,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0xdc, - 0x7c, 0xa7, 0x88, 0x00, 0xb2, 0x63, 0x99, 0x8c, 0x1a, 0x4a, 0xe9, 0xfd, 0xf9, 0xaf, 0x95, 0x26, - 0xdd, 0xad, 0x34, 0xe9, 0xcf, 0x4a, 0x93, 0x7e, 0xac, 0xb5, 0xc2, 0xdd, 0x5a, 0x2b, 0xfc, 0x5e, - 0x6b, 0x85, 0xab, 0x37, 0x93, 0x20, 0xf9, 0xb6, 0x18, 0xe9, 0xe3, 0x70, 0xda, 0xcd, 0x7e, 0xe8, - 0xfd, 0xe3, 0x75, 0x3a, 0xf0, 0xb7, 0xdd, 0xbd, 0xe9, 0x4f, 0x96, 0x91, 0x3f, 0x1f, 0xc9, 0xe9, - 0xc4, 0xbc, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xaa, 0xb1, 0xa2, 0x1c, 0x18, 0x03, 0x00, 0x00, + // 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, + 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, 0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7e, 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, } func (m *Operation) Marshal() (dAtA []byte, err error) { diff --git a/x/rarimocore/types/proposal.go b/x/rarimocore/types/proposal.go index 2a3fd8cf..476881aa 100644 --- a/x/rarimocore/types/proposal.go +++ b/x/rarimocore/types/proposal.go @@ -9,6 +9,7 @@ const ( ProposalTypeReshareKeys = "rarimocore/ReshareKeys" ProposalTypeSlash = "rarimocore/SlashProposal" ProposalTypeDropParties = "rarimocore/DropPartiesProposal" + ProposalTypeArbitrarySigning = "rarimocore/ArbitrarySigningProposal" ) func init() { @@ -16,10 +17,12 @@ func init() { govv1beta1.RegisterProposalType(ProposalTypeReshareKeys) govv1beta1.RegisterProposalType(ProposalTypeSlash) govv1beta1.RegisterProposalType(ProposalTypeDropParties) + govv1beta1.RegisterProposalType(ProposalTypeArbitrarySigning) govv1beta1.ModuleCdc.RegisterConcrete(&UnfreezeSignerPartyProposal{}, "rarimocore/UnfreezeSignerPartyProposal", nil) govv1beta1.ModuleCdc.RegisterConcrete(&ReshareKeysProposal{}, "rarimocore/ReshareKeysProposal", nil) govv1beta1.ModuleCdc.RegisterConcrete(&SlashProposal{}, "rarimocore/SlashProposal", nil) govv1beta1.ModuleCdc.RegisterConcrete(&DropPartiesProposal{}, "rarimocore/DropPartiesProposal", nil) + govv1beta1.ModuleCdc.RegisterConcrete(&ArbitrarySigningProposal{}, "rarimocore/ArbitrarySigning", nil) } // Implements Proposal Interface @@ -61,3 +64,13 @@ func (m *DropPartiesProposal) ProposalType() string { return ProposalTypeDropPa func (m *DropPartiesProposal) ValidateBasic() error { return govv1beta1.ValidateAbstract(m) } + +// Implements Proposal Interface +var _ govv1beta1.Content = &ArbitrarySigningProposal{} + +func (m *ArbitrarySigningProposal) ProposalRoute() string { return RouterKey } +func (m *ArbitrarySigningProposal) ProposalType() string { return ProposalTypeArbitrarySigning } + +func (m *ArbitrarySigningProposal) ValidateBasic() error { + return govv1beta1.ValidateAbstract(m) +} diff --git a/x/rarimocore/types/proposal.pb.go b/x/rarimocore/types/proposal.pb.go index c10cd768..051dabfe 100644 --- a/x/rarimocore/types/proposal.pb.go +++ b/x/rarimocore/types/proposal.pb.go @@ -246,34 +246,97 @@ func (m *DropPartiesProposal) GetDescription() string { return "" } +type ArbitrarySigningProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // Hex encoded data to be signed. AWARE do not make collisions with existing operations. + Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *ArbitrarySigningProposal) Reset() { *m = ArbitrarySigningProposal{} } +func (m *ArbitrarySigningProposal) String() string { return proto.CompactTextString(m) } +func (*ArbitrarySigningProposal) ProtoMessage() {} +func (*ArbitrarySigningProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_d8fc3ea03d8b2bc9, []int{4} +} +func (m *ArbitrarySigningProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ArbitrarySigningProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ArbitrarySigningProposal.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 *ArbitrarySigningProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_ArbitrarySigningProposal.Merge(m, src) +} +func (m *ArbitrarySigningProposal) XXX_Size() int { + return m.Size() +} +func (m *ArbitrarySigningProposal) XXX_DiscardUnknown() { + xxx_messageInfo_ArbitrarySigningProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_ArbitrarySigningProposal proto.InternalMessageInfo + +func (m *ArbitrarySigningProposal) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *ArbitrarySigningProposal) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *ArbitrarySigningProposal) GetData() string { + if m != nil { + return m.Data + } + return "" +} + func init() { proto.RegisterType((*UnfreezeSignerPartyProposal)(nil), "rarimo.rarimocore.rarimocore.UnfreezeSignerPartyProposal") proto.RegisterType((*ReshareKeysProposal)(nil), "rarimo.rarimocore.rarimocore.ReshareKeysProposal") proto.RegisterType((*SlashProposal)(nil), "rarimo.rarimocore.rarimocore.SlashProposal") proto.RegisterType((*DropPartiesProposal)(nil), "rarimo.rarimocore.rarimocore.DropPartiesProposal") + proto.RegisterType((*ArbitrarySigningProposal)(nil), "rarimo.rarimocore.rarimocore.ArbitrarySigningProposal") } func init() { proto.RegisterFile("rarimocore/proposal.proto", fileDescriptor_d8fc3ea03d8b2bc9) } var fileDescriptor_d8fc3ea03d8b2bc9 = []byte{ - // 257 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x4a, 0x2c, 0xca, - 0xcc, 0xcd, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc8, 0x2f, 0x4e, 0xcc, 0xd1, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0x48, 0xe9, 0x21, 0x54, 0x20, 0x31, 0x95, 0xf2, - 0xb9, 0xa4, 0x43, 0xf3, 0xd2, 0x8a, 0x52, 0x53, 0xab, 0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, 0x5e, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0xb6, 0x5a, 0xa3, 0xfb, 0x01, 0x00, - 0x00, + // 284 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xbd, 0x4a, 0xc4, 0x40, + 0x14, 0x85, 0x13, 0x75, 0x15, 0x47, 0x6c, 0xe2, 0x16, 0x11, 0x65, 0x58, 0x52, 0xd9, 0x98, 0x08, + 0x3e, 0x81, 0x62, 0xa5, 0x08, 0xcb, 0x2e, 0x36, 0x82, 0xc5, 0x24, 0x7b, 0x37, 0x19, 0xc8, 0xe6, + 0x0e, 0x77, 0xee, 0x82, 0xf1, 0x29, 0x7c, 0x2c, 0xcb, 0x2d, 0x2d, 0x25, 0x79, 0x11, 0xc9, 0x8f, + 0x98, 0x3e, 0xd5, 0xdc, 0x33, 0x67, 0x98, 0xf9, 0xe6, 0x70, 0xc4, 0x39, 0x29, 0xd2, 0x1b, 0x4c, + 0x90, 0x20, 0x32, 0x84, 0x06, 0xad, 0xca, 0x43, 0x43, 0xc8, 0xe8, 0x5d, 0x76, 0x56, 0xf8, 0x7f, + 0x62, 0x30, 0x06, 0x28, 0x2e, 0x5e, 0x8a, 0x35, 0x01, 0x7c, 0xc0, 0x52, 0xa7, 0x05, 0xd0, 0x5c, + 0x11, 0x97, 0xf3, 0xfe, 0x0a, 0x6f, 0x2a, 0x26, 0xac, 0x39, 0x07, 0xdf, 0x9d, 0xb9, 0x57, 0xc7, + 0x8b, 0x4e, 0x78, 0x33, 0x71, 0xb2, 0x02, 0x9b, 0x90, 0x36, 0xac, 0xb1, 0xf0, 0xf7, 0x5a, 0x6f, + 0xb8, 0xe5, 0xf9, 0xe2, 0x48, 0x25, 0x09, 0x6e, 0x0b, 0xf6, 0xf7, 0x5b, 0xf7, 0x4f, 0x06, 0xcf, + 0xe2, 0x6c, 0x01, 0x36, 0x53, 0x04, 0x4f, 0x50, 0xda, 0xb1, 0x0f, 0x05, 0x6f, 0xe2, 0x74, 0x99, + 0x2b, 0x9b, 0x8d, 0x26, 0x9e, 0x8a, 0x89, 0x69, 0xbe, 0xde, 0xf3, 0x76, 0xa2, 0xa1, 0x7d, 0x20, + 0x34, 0x4d, 0x28, 0x1a, 0xc6, 0xd3, 0xae, 0x85, 0x7f, 0x47, 0xb1, 0x66, 0x52, 0x54, 0x36, 0x71, + 0xeb, 0x22, 0x1d, 0x0d, 0xee, 0x89, 0x83, 0x95, 0x62, 0xd5, 0x73, 0xb7, 0xf3, 0xfd, 0xe3, 0x57, + 0x25, 0xdd, 0x5d, 0x25, 0xdd, 0x9f, 0x4a, 0xba, 0x9f, 0xb5, 0x74, 0x76, 0xb5, 0x74, 0xbe, 0x6b, + 0xe9, 0xbc, 0xde, 0xa4, 0x9a, 0xb3, 0x6d, 0x1c, 0x26, 0xb8, 0x89, 0xba, 0x1a, 0xf4, 0xcb, 0x75, + 0xdb, 0x9d, 0xf7, 0x68, 0x50, 0x24, 0x2e, 0x0d, 0xd8, 0xf8, 0xb0, 0xad, 0xd1, 0xed, 0x6f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x14, 0xad, 0x1c, 0x97, 0x63, 0x02, 0x00, 0x00, } func (m *UnfreezeSignerPartyProposal) Marshal() (dAtA []byte, err error) { @@ -438,6 +501,50 @@ func (m *DropPartiesProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ArbitrarySigningProposal) 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 *ArbitrarySigningProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ArbitrarySigningProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintProposal(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintProposal(dAtA []byte, offset int, v uint64) int { offset -= sovProposal(v) base := offset @@ -525,6 +632,27 @@ func (m *DropPartiesProposal) Size() (n int) { return n } +func (m *ArbitrarySigningProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovProposal(uint64(l)) + } + return n +} + func sovProposal(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1051,6 +1179,152 @@ func (m *DropPartiesProposal) Unmarshal(dAtA []byte) error { } return nil } +func (m *ArbitrarySigningProposal) 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 ErrIntOverflowProposal + } + 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: ArbitrarySigningProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ArbitrarySigningProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposal + } + 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 ErrInvalidLengthProposal + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProposal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProposal(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProposal + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipProposal(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tokenmanager/keeper/proposal_networks.go b/x/tokenmanager/keeper/proposal_networks.go index be6b500b..7c2aae8b 100644 --- a/x/tokenmanager/keeper/proposal_networks.go +++ b/x/tokenmanager/keeper/proposal_networks.go @@ -53,6 +53,21 @@ var upgradeVerifiers = map[types.NetworkType]func(details *types.ContractUpgrade return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid nonce") } + return nil + }, + types.NetworkType_RarimoEVM: func(details *types.ContractUpgradeDetails) error { + if _, err := hexutil.Decode(details.TargetContract); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid target contract address %s", err.Error()) + } + + if _, err := hexutil.Decode(details.NewImplementationContract); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid new contract address %s", err.Error()) + } + + if _, ok := new(big.Int).SetString(details.Nonce, 10); !ok { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid nonce") + } + return nil }, } diff --git a/x/tokenmanager/types/params.pb.go b/x/tokenmanager/types/params.pb.go index 4852a830..d4afbe9f 100644 --- a/x/tokenmanager/types/params.pb.go +++ b/x/tokenmanager/types/params.pb.go @@ -27,11 +27,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type NetworkType int32 const ( - NetworkType_EVM NetworkType = 0 - NetworkType_Solana NetworkType = 1 - NetworkType_Near NetworkType = 2 - NetworkType_Other NetworkType = 3 - NetworkType_Rarimo NetworkType = 4 + NetworkType_EVM NetworkType = 0 + NetworkType_Solana NetworkType = 1 + NetworkType_Near NetworkType = 2 + NetworkType_Other NetworkType = 3 + NetworkType_Rarimo NetworkType = 4 + NetworkType_RarimoEVM NetworkType = 5 ) var NetworkType_name = map[int32]string{ @@ -40,14 +41,16 @@ var NetworkType_name = map[int32]string{ 2: "Near", 3: "Other", 4: "Rarimo", + 5: "RarimoEVM", } var NetworkType_value = map[string]int32{ - "EVM": 0, - "Solana": 1, - "Near": 2, - "Other": 3, - "Rarimo": 4, + "EVM": 0, + "Solana": 1, + "Near": 2, + "Other": 3, + "Rarimo": 4, + "RarimoEVM": 5, } func (x NetworkType) String() string { @@ -462,39 +465,39 @@ func init() { func init() { proto.RegisterFile("tokenmanager/params.proto", fileDescriptor_55f297a3c8945a13) } var fileDescriptor_55f297a3c8945a13 = []byte{ - // 501 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4f, 0x6f, 0x12, 0x41, - 0x14, 0xdf, 0x01, 0xca, 0x9f, 0x87, 0x9a, 0xc9, 0x88, 0x86, 0x72, 0x58, 0xc9, 0x5e, 0x24, 0x35, - 0x9d, 0x35, 0x34, 0x5e, 0x35, 0x52, 0x96, 0x86, 0x68, 0xd1, 0xac, 0xc4, 0x44, 0x6f, 0x03, 0x4c, - 0xb7, 0x9b, 0xb2, 0x33, 0x64, 0x18, 0xd4, 0xfd, 0x00, 0xde, 0xfd, 0x1e, 0x7e, 0x91, 0x1e, 0x7b, - 0xf4, 0x64, 0x0c, 0x7c, 0x11, 0xb3, 0xb3, 0x4b, 0x05, 0x0f, 0x2d, 0x3d, 0xcd, 0xbc, 0xcc, 0xfb, - 0xfd, 0x7b, 0xfb, 0x16, 0xf6, 0xb5, 0xbc, 0xe0, 0x22, 0x62, 0x82, 0x05, 0x5c, 0xb9, 0x33, 0xa6, - 0x58, 0x34, 0xa7, 0x33, 0x25, 0xb5, 0x24, 0xb6, 0x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xcd, 0x92, 0x1d, 0x87, 0x49, 0x26, 0xf7, 0x9b, 0xbb, 0xf5, 0x73, 0x27, - 0xdb, 0x37, 0x1f, 0x15, 0xcd, 0x96, 0x1d, 0xfd, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xea, 0xd1, - 0xe0, 0xf9, 0x03, 0x00, 0x00, + // 508 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0x12, 0x4f, + 0x18, 0xdf, 0xe1, 0x9d, 0x87, 0x7f, 0xff, 0xd9, 0x8c, 0x68, 0x28, 0x87, 0x95, 0xec, 0x45, 0x52, + 0xd3, 0x59, 0x43, 0xe3, 0x55, 0x23, 0x02, 0x0d, 0xd1, 0xa2, 0x19, 0x89, 0x89, 0xde, 0x06, 0x98, + 0x6e, 0x37, 0x65, 0x67, 0xc8, 0x30, 0xa8, 0x7c, 0x00, 0xef, 0x7e, 0x0f, 0xbf, 0x48, 0x8f, 0x3d, + 0x7a, 0x32, 0x06, 0xbe, 0x88, 0x99, 0xd9, 0xa5, 0x82, 0x87, 0x4a, 0x4f, 0x33, 0x4f, 0xe6, 0xf9, + 0xbd, 0x3d, 0xfb, 0x2c, 0x1c, 0x6a, 0x79, 0xc9, 0x45, 0xcc, 0x04, 0x0b, 0xb9, 0x0a, 0x66, 0x4c, + 0xb1, 0x78, 0x4e, 0x66, 0x4a, 0x6a, 0x89, 0x3d, 0xc5, 0x54, 0x14, 0x4b, 0x92, 0x1c, 0x63, 0xa9, + 0x38, 0xd9, 0x6e, 0xae, 0x57, 0x43, 0x19, 0x4a, 0xdb, 0x1a, 0x98, 0x5b, 0x82, 0xaa, 0x1f, 0x86, + 0x52, 0x86, 0x53, 0x1e, 0xd8, 0x6a, 0xb4, 0x38, 0x0f, 0x98, 0x58, 0x26, 0x4f, 0xfe, 0x77, 0x04, + 0xc5, 0x01, 0xd7, 0x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 0x3e, 0x80, 0x02, 0x8b, 0xe5, 0x42, + 0xe8, 0x34, 0x6b, 0x5a, 0xf9, 0x67, 0x50, 0x48, 0x55, 0x5e, 0x42, 0x49, 0x24, 0xb2, 0xf3, 0x1a, + 0xb2, 0x29, 0x1e, 0xed, 0xf9, 0xe5, 0xe8, 0x0d, 0xf0, 0x88, 0x42, 0x65, 0x6b, 0xdd, 0x70, 0x11, + 0xb2, 0xdd, 0xf7, 0x67, 0xae, 0x83, 0x01, 0x0a, 0xef, 0xe4, 0x94, 0x09, 0xe6, 0x22, 0x5c, 0x82, + 0xdc, 0x80, 0x33, 0xe5, 0x66, 0x70, 0x19, 0xf2, 0x6f, 0xf4, 0x05, 0x57, 0x6e, 0xd6, 0x34, 0x50, + 0xab, 0xe2, 0xe6, 0xf0, 0x01, 0x94, 0x93, 0xbb, 0xc1, 0xe6, 0x8f, 0x9e, 0x82, 0xfb, 0xf7, 0x8a, + 0x98, 0xf6, 0x36, 0xed, 0x77, 0x4e, 0xbb, 0xae, 0x63, 0x44, 0x7a, 0xdd, 0xae, 0x8b, 0xf0, 0x7f, + 0x50, 0xea, 0x77, 0xba, 0x83, 0x61, 0x7f, 0xf8, 0xc1, 0xcd, 0xb4, 0x5f, 0x5f, 0xad, 0x3c, 0x74, + 0xbd, 0xf2, 0xd0, 0xaf, 0x95, 0x87, 0xbe, 0xad, 0x3d, 0xe7, 0x7a, 0xed, 0x39, 0x3f, 0xd6, 0x9e, + 0xf3, 0xb1, 0x15, 0x46, 0xfa, 0x62, 0x31, 0x22, 0x63, 0x19, 0x07, 0x49, 0xb4, 0xf4, 0x38, 0x36, + 0x11, 0x83, 0x2f, 0xc1, 0xce, 0xbf, 0x6e, 0x96, 0x71, 0x3e, 0x2a, 0xd8, 0xa5, 0x3b, 0xf9, 0x1d, + 0x00, 0x00, 0xff, 0xff, 0x46, 0x5b, 0x19, 0xad, 0x08, 0x04, 0x00, 0x00, } func (m *Network) Marshal() (dAtA []byte, err error) {