From 1f089ca6ad2ca73a4241640771f6f30b67afcea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Wed, 9 Oct 2024 15:03:34 +0100 Subject: [PATCH] regenerated contract schema and made the migration data optional --- .../mixnet-contract/src/msg.rs | 2 +- .../mixnet/schema/nym-mixnet-contract.json | 56 ++++++++++++++++++- contracts/mixnet/schema/raw/migrate.json | 54 +++++++++++++++++- contracts/mixnet/schema/raw/query.json | 2 +- contracts/mixnet/src/contract.rs | 4 +- .../src/manager/network_init.rs | 1 + 6 files changed, 113 insertions(+), 6 deletions(-) diff --git a/common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs b/common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs index d78584406a..81c214b1ca 100644 --- a/common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs +++ b/common/cosmwasm-smart-contracts/mixnet-contract/src/msg.rs @@ -804,5 +804,5 @@ impl AffectedNode { #[cw_serde] pub struct MigrateMsg { pub vesting_contract_address: Option, - pub fix_nodes: Vec, + pub fix_nodes: Option>, } diff --git a/contracts/mixnet/schema/nym-mixnet-contract.json b/contracts/mixnet/schema/nym-mixnet-contract.json index c754e65fdb..926d840d25 100644 --- a/contracts/mixnet/schema/nym-mixnet-contract.json +++ b/contracts/mixnet/schema/nym-mixnet-contract.json @@ -2150,7 +2150,7 @@ "minimum": 0.0 }, "owner": { - "description": "The address of the owner of the the mixnodes used for the query.", + "description": "The address of the owner of the mixnodes used for the query.", "type": "string" }, "start_after": { @@ -2961,6 +2961,15 @@ "title": "MigrateMsg", "type": "object", "properties": { + "fix_nodes": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/AffectedNode" + } + }, "vesting_contract_address": { "type": [ "string", @@ -2968,7 +2977,50 @@ ] } }, - "additionalProperties": false + "additionalProperties": false, + "definitions": { + "AffectedDelegator": { + "type": "object", + "required": [ + "address", + "missing_ratio" + ], + "properties": { + "address": { + "type": "string" + }, + "missing_ratio": { + "$ref": "#/definitions/Decimal" + } + }, + "additionalProperties": false + }, + "AffectedNode": { + "type": "object", + "required": [ + "delegators", + "mix_id" + ], + "properties": { + "delegators": { + "type": "array", + "items": { + "$ref": "#/definitions/AffectedDelegator" + } + }, + "mix_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + } + } }, "sudo": null, "responses": { diff --git a/contracts/mixnet/schema/raw/migrate.json b/contracts/mixnet/schema/raw/migrate.json index e9962aaf92..b78992418b 100644 --- a/contracts/mixnet/schema/raw/migrate.json +++ b/contracts/mixnet/schema/raw/migrate.json @@ -3,6 +3,15 @@ "title": "MigrateMsg", "type": "object", "properties": { + "fix_nodes": { + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/AffectedNode" + } + }, "vesting_contract_address": { "type": [ "string", @@ -10,5 +19,48 @@ ] } }, - "additionalProperties": false + "additionalProperties": false, + "definitions": { + "AffectedDelegator": { + "type": "object", + "required": [ + "address", + "missing_ratio" + ], + "properties": { + "address": { + "type": "string" + }, + "missing_ratio": { + "$ref": "#/definitions/Decimal" + } + }, + "additionalProperties": false + }, + "AffectedNode": { + "type": "object", + "required": [ + "delegators", + "mix_id" + ], + "properties": { + "delegators": { + "type": "array", + "items": { + "$ref": "#/definitions/AffectedDelegator" + } + }, + "mix_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + } + } } diff --git a/contracts/mixnet/schema/raw/query.json b/contracts/mixnet/schema/raw/query.json index c938a56f64..8bfd134606 100644 --- a/contracts/mixnet/schema/raw/query.json +++ b/contracts/mixnet/schema/raw/query.json @@ -438,7 +438,7 @@ "minimum": 0.0 }, "owner": { - "description": "The address of the owner of the the mixnodes used for the query.", + "description": "The address of the owner of the mixnodes used for the query.", "type": "string" }, "start_after": { diff --git a/contracts/mixnet/src/contract.rs b/contracts/mixnet/src/contract.rs index 9913da3265..67cabed152 100644 --- a/contracts/mixnet/src/contract.rs +++ b/contracts/mixnet/src/contract.rs @@ -558,7 +558,9 @@ pub fn migrate( let mut response = Response::new(); - queued_migrations::restore_vested_delegations(&mut response, deps, env, msg.fix_nodes)?; + if let Some(nodes_to_fix) = msg.fix_nodes { + queued_migrations::restore_vested_delegations(&mut response, deps, env, nodes_to_fix)?; + } Ok(response) } diff --git a/tools/internal/testnet-manager/src/manager/network_init.rs b/tools/internal/testnet-manager/src/manager/network_init.rs index 568632f734..38135424e1 100644 --- a/tools/internal/testnet-manager/src/manager/network_init.rs +++ b/tools/internal/testnet-manager/src/manager/network_init.rs @@ -108,6 +108,7 @@ impl NetworkManager { ) -> Result { Ok(nym_mixnet_contract_common::MigrateMsg { vesting_contract_address: Some(ctx.network.contracts.vesting.address()?.to_string()), + fix_nodes: None, }) }