diff --git a/CHANGELOG.md b/CHANGELOG.md index 27d02308e..0695a848e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,49 @@ # Changelog +## 0.7.0 + +*November 22th, 2018* + +- Add broadcast command in bank +- Update iris.toml +- Improve user documents + +## 0.7.0-rc0 + +*November 19th, 2018* + +BREAKING CHANGES: +* [iris] New genesis workflow +* [iris] Validator.Owner renamed to Validator. Validator operator type has now changed to sdk.ValAddress +* [iris] unsafe_reset_all, show_validator, and show_node_id have been renamed to unsafe-reset-all, show-validator, and show-node-id +* [iris]Rename "revoked" to "jailed" +* [iris]Removed CompleteUnbonding and CompleteRedelegation Msg types, and instead added unbonding/redelegation queues to endblocker +* [iris]Removed slashing for governance non-voting validators +* [iris]Validators are no longer deleted until they can no longer possibly be slashed +* [iris]Remove ibc module +* [iris]Validator set updates delayed by one block +* [iris]Drop GenesisTx in favor of a signed StdTx with only one MsgCreateValidator message + +FEATURES: +* Upgrade cosmos-sdk denpendency to v0.26.0 +* Upgrade tendermint denpendency to v0.26.1-rc0 +* [docs]Improve docs +* [iris]Add token inflation +* [iris]Add distribution module to distribute inflation token and collected transaction fee +* [iriscli] --from can now be either an address or a key name +* [iriscli] Passing --gas=simulate triggers a simulation of the tx before the actual execution. The gas estimate obtained via the simulation will be used as gas limit in the actual execution. +* [iriscli]Add --bech to gaiacli keys show and respective REST endpoint to +* [iriscli]Introduced new commission flags for validator commands create-validator and edit-validator +* [iriscli]Add commands to query validator unbondings and redelegations +* [iriscli]Add rest apis and commands for distribution + +BUG FIXES: +* [iriscli]Mark --to and --amount as required flags for iriscli bank send +* [iris]Add general merkle absence proof (also for empty substores) +* [iris]Fix issue about consumed gas increasing rapidly +* [iris]Return correct Tendermint validator update set on EndBlocker by not including non previously bonded validators that have zero power +* [iris]Add commission data to MsgCreateValidator signature bytes + ## 0.6.0 *November 1st, 2018* diff --git a/Gopkg.lock b/Gopkg.lock index 4de10c8e2..de6c7706d 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -69,7 +69,7 @@ revision = "d4cc87b860166d00d6b5b9e0d3b3d71d6088d4d4" [[projects]] - digest = "1:06d4b3860be91d8d0bf1933758dda2ce0b5709506343c0656e033d2b69ffd776" + digest = "1:d7d3961eba6b55235b397574fa7915b0cf51148cb7eff2fcb36f249704ff02ba" name = "github.com/cosmos/cosmos-sdk" packages = [ "baseapp", @@ -113,9 +113,9 @@ "x/stake/types", ] pruneopts = "UT" - revision = "b352686dab3f9976be1347a860c7aba28c22abe0" + revision = "c9d5ede3272b9285b030c4fef92c0209e80d28bf" source = "https://github.com/irisnet/cosmos-sdk.git" - version = "v0.26.0-iris" + version = "v0.26.0-iris0.7.0" [[projects]] digest = "1:e8a3550c8786316675ff54ad6f09d265d129c9d986919af7f541afba50d87ce2" @@ -677,7 +677,7 @@ version = "v0.11.1" [[projects]] - digest = "1:83882681ddd65a2de8c1be7eae0f48075601077d85cc37050f343d00ab862bac" + digest = "1:945fd3f74b35e13f1f61883be160692d81ab0c168c812771c2e44ed9c12f9ae3" name = "github.com/tendermint/tendermint" packages = [ "abci/client", diff --git a/Gopkg.toml b/Gopkg.toml index 784f727db..77715ada9 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -29,7 +29,7 @@ [[constraint]] name = "github.com/cosmos/cosmos-sdk" source = "https://github.com/irisnet/cosmos-sdk.git" - version = "=v0.26.0-iris" + version = "=v0.26.0-iris0.7.0" [[override]] name = "github.com/tendermint/iavl" diff --git a/app/app.go b/app/app.go index dc010b699..ea12f30bc 100644 --- a/app/app.go +++ b/app/app.go @@ -139,7 +139,7 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio app.cdc, app.keyStake, app.tkeyStake, app.bankKeeper, app.paramsKeeper.Subspace(stake.DefaultParamspace), - app.RegisterCodespace(stake.DefaultCodespace), + stake.DefaultCodespace, ) app.mintKeeper = mint.NewKeeper(app.cdc, app.keyMint, app.paramsKeeper.Subspace(mint.DefaultParamspace), @@ -150,32 +150,32 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio app.keyDistr, app.paramsKeeper.Subspace(distr.DefaultParamspace), app.bankKeeper, &stakeKeeper, app.feeCollectionKeeper, - app.RegisterCodespace(stake.DefaultCodespace), + distr.DefaultCodespace, ) app.slashingKeeper = slashing.NewKeeper( app.cdc, app.keySlashing, &stakeKeeper, app.paramsKeeper.Subspace(slashing.DefaultParamspace), - app.RegisterCodespace(slashing.DefaultCodespace), + slashing.DefaultCodespace, ) app.govKeeper = gov.NewKeeper( app.cdc, app.keyGov, app.bankKeeper, &stakeKeeper, - app.RegisterCodespace(gov.DefaultCodespace), + gov.DefaultCodespace, ) app.recordKeeper = record.NewKeeper( app.cdc, app.keyRecord, - app.RegisterCodespace(record.DefaultCodespace), + record.DefaultCodespace, ) app.serviceKeeper = service.NewKeeper( app.cdc, app.keyService, app.bankKeeper, - app.RegisterCodespace(service.DefaultCodespace), + service.DefaultCodespace, ) // register the staking hooks diff --git a/docs/software/cli-client.md b/docs/software/cli-client.md index e69de29bb..8ff96b9c6 100644 --- a/docs/software/cli-client.md +++ b/docs/software/cli-client.md @@ -0,0 +1,103 @@ +# IRIS Command Line Client + +## Introduction + +`iriscli` is a client for the IRISnet network. IRISnet users can use `iriscli` to send different transactions and query the blockchain data. + +## iriscli Work Directory + +The work directory for the `iriscli` is `$HOME/.iriscli`, which is mainly used to save configuration files and data. The IRISnet `key` data is saved in the work directory of `iriscli`. You can also specify the `iriscli` work directory by `--home`. + + +## iriscli --node + +The rpc address of the tendermint node. Transactions and query requests are sent to the process listening to this port. The default is `tcp://localhost:26657`, and the rpc address can also be specified by `--node`. + +## iriscli config command + +The `iriscli config` command interactively configures some default parameters, such as chain-id, home, fee, and node. + +## Fee and Gas + +`iriscli` can send a transaction with the fee specified by `--fee` and gas(the default is 200000) specified by `--gas` . The gas divided by the fee is gas price, and the gas price can't be less than the minimum value set by the blockchain. The remaining fees after the completion of the entire transaction will be returned to the user. You can set `--gas="simulate"`, which can estimate the gas consumed by the transaction through the simulation run, and multiply the coefficient specified by `--gas-adjustment` to get the final gas as the transaction gas. Finally, the transaction will be broadcast. + +## Dry-run Mode + +`iriscli` turns off dry-run mode by default. If you want to open the dry-run mode, you can use `--dry-run`. It is similar to the simulation processing logic, and can calculate the gas that needs to be consumed, but then it will not broadcast to the full node, directly return and print the gas consumed this time. + +Example: Send a command using dry-run mode + +``` +iriscli gov submit-proposal --title="ABC" --description="test" --type=Text --deposit=1iris --from=x --chain-id=gov-test --fee=0.05iris --gas=200000 --dry-run +``` + +Print: + +``` +estimated gas = 8370 +``` + +## Asynchronous Mode + +The transaction sent by iriscli defaults to synchronous mode. Synchronous mode refers to sending a transaction and then blocking it until the reply is received or the entire command is timed out. If you want to open asynchronous mode, you can use `--async`. After sending the transaction, the transaction hash will be returned immediately. + + +## Generate Only + +`generate-only` is turned off by default, but `--generate-only` can be enabled to send the transaction, and then the unsigned transaction generated by the command line will be printed. + +Example: Enable generate-only to generate unsigned transactions + +``` +iriscli gov submit-proposal --title="ABC" --description="test" --type=Text --deposit=1iris --from=x --chain-id=gov-test --fee=0.05iris --gas=200000 --generate-only +``` + +Print: + +```json +{ + "type": "auth/StdTx", + "value": { + "msg": [ + { + "type": "cosmos-sdk/MsgSubmitProposal", + "value": { + "title": "ABC", + "description": "test", + "proposal_type": "Text", + "proposer": "faa1k47r0nxd6ec8n6sc6tzvk2053u4eff0vx99755", + "initial_deposit": [ + { + "denom": "iris-atto", + "amount": "1000000000000000000" + } + ], + "Param": { + "key": "", + "value": "", + "op": "" + } + } + } + ], + "fee": { + "amount": [ + { + "denom": "iris-atto", + "amount": "50000000000000000" + } + ], + "gas": "200000" + }, + "signatures": null, + "memo": "" + } +} + +``` + +## Trust Node + +The trust-node is true by default. When the trust-node is true, the `iriscli` only queries the data and does not perform a Merkle verification on the data. You can also use the `--trust-node=false` to perform Merkle verification on the data obtained by the query. + + diff --git a/docs/software/node.md b/docs/software/node.md index e69de29bb..316a4252d 100644 --- a/docs/software/node.md +++ b/docs/software/node.md @@ -0,0 +1,109 @@ + +# IRIS Daemon + +## Introduction + +The iris executable is the entry point for running a IRISnet network node. All the validator nodes and full nodes need to install the iris command and launching the daemon to join the IRISnet network. You can also use this command to start your own test network locally. If you need to join the IRISnet testnet, please refer to [get-started](../get-started/README.md). + +## How to start an IRISnet network locally + +### Initialize node + +First you need to create a account as the corresponding validator operator for yourself. +```bash +iriscli keys add {account_name} +``` +You can get the account information, including account address, public key address and mnemonic +``` +NAME: TYPE: ADDRESS: PUBKEY: +account_name local faa13t6jugwm5uu3h835s5d4zggkklz6rpns59keju fap1addwnpepqdne60eyssj2plrsusd8049cs5hhhl5alcxv2xu0xmzlhphy9lyd5kpsyzu +**Important** write this seed phrase in a safe place. +It is the only way to recover your account if you ever forget your password. + +witness exotic fantasy gaze brass zebra adapt guess drip quote space payment farm argue pear actress garage smile hawk bid bag screen wonder person +``` + +Initialize the configuration files such as genesis.json and config.toml +```bash +iris init --home={path_to_your_home} --chain-id={your_chain_id} +``` +This command will create the corresponding files in the home directory. + +Create the `CreateValidator` transaction and sign the transaction by the validator operator account you just created +```bash +iris gentx --name={account_name} --home={path_to_your_home} +``` +This commond will generate the transaction in the directory:{path_to_your_home}/config/gentx + +### Config genesis + +Manually modify the genesis.json file to assign the initial account balance to the above validator operator account, such as: 150 iris +```json +"accounts": [ + { + "address": "faa13t6jugwm5uu3h835s5d4zggkklz6rpns59keju", + "coins": [ + { + "denom": "iris-atto", + "amount": "150000000000000000000" + } + ], + "sequence_number": "0", + "account_number": "0" + } +], +``` + +Configuring validator information +```bash +iris collect-gentxs --home={path_to_your_home} +``` +This command reads the `CreateValidator` transaction under folder {path_to_your_home}/config/gentx and writes it to genesis.json to complete the assignment of the initial validators in the Genesis block. + +### Boot node + +After completing the above configuration, start the node with the following command +```bash +iris start --home {path_to_your_home} +``` +After the command is executed, iris generate the genesis block according to the genesis.json configured under the home and update the application state. Then, according to the current block height of the chain pointed by the chain-id, it either starts to synchronize with other peers, or enter the process of produce the first block. + +## Start a multi-node network + +To start a multi-node IRISnet network locally, you need to follow the steps below: + +* Prepare home directory: create a unique home directory for each node +* Initialization: according to the above `Initialize node` steps, initialize each node in the respective home directory (note that you need to use the same chain-id) +* Configure genesis: select the home directory of one of the nodes to configure the genesis, refer to the `Config genesis` steps, configure the account address and initial balance of each node, and copy the files from each node {path_to_your_home}/config/gentx to the current one. Execute `iris collect-gentxs` to generate the final genesis.json. Finally, copy the genesis.json to the home directory of each node, overwriting the original genesis.json. +* Configure config.toml: modify {path_to_your_home}/config/config.toml in the home directory of each node, assign different ports to each node, query the node-id of each node through `iris tendermint show-node-id`, and then add the `node-id@ip:port` of other nodes in `persistent_peers` so that nodes can connect to each other. + +In order to simplify the above configuration process, you can use the following commands to automate the initialization of local multi-node and the configuration of genesis and config.toml: +```bash +iris testnet --v 4 --output-dir ./output --chain-id irishub-test --starting-ip-address 127.0.0.1 +``` + +To start the node to join the public IRIS Testnet, please refer to [Full-Node](../get-started/Full-Node.md) + +## Introduction of home directory + +The home directory is the working directory of the iris node. The home directory contains all the configuration information and all the data that the node runs. + +In the iris command, you can specify the home directory of the node by using flag `--home`. If you run multiple nodes on the same machine, you need to specify a different home directory for them. If the `--home` flag is not specified in the iris command, the default value `$HOME/.iris` is used as the home directory used by this iris command. + +The data of the iris node is stored in the `data` directory of the home, including blockchain data, application layer data, and index data. All configuration files are stored in the home/`config` directory: + +### genesis.json + +genesis.json defines the genesis block data, which specifies the system parameters such as chain_id, consensus parameters, initial account token allocation, creation of validators, and parameters for stake/slashing/gov/upgrade. See [genesis-file](../features/basic-concepts/genesis-file.md) for details. + +### node_key.json + +node_key.json is used to store the node's key. The node-id queried by `iris tendermint show-node-id` is derived by the key, which is used to indicate the unique identity of the node. It is used in p2p connection. + +### pri_validator.json + +pri_validator.json is the key that the validator will use to sign Pre-vote/Pre-commit in each round of consensus voting. As the consensus progresses, the tendermint consensus engine will continuously update `last_height`/`last_round`/ `last_step` and other data. + +### config.toml + +config.toml is the non-consensus configuration information of the node. Different nodes can configure themselves according to their own situation. Common modifications are `persistent_peers`/`moniker`/`laddr`. diff --git a/docs/zh/software/cli-client.md b/docs/zh/software/cli-client.md index e69de29bb..5b95a6ceb 100644 --- a/docs/zh/software/cli-client.md +++ b/docs/zh/software/cli-client.md @@ -0,0 +1,100 @@ +# IRIS Command Line Client + +## 介绍 + +iriscli是参与IRISnet网络的客户端。IRISnet的用户都可以通过iriscli来发送各种不同的交易或者进行各种查询。 + +## iriscli目录 + +iriscli客户端的默认目录是`$HOME/.iriscli`,主要用来保存配置文件和数据。 IRISnet `key` 的数据就保存在iriscli的HOME目录下。也可以通过`--home`来指定客户端的HOME目录。 + +## iriscli --node + +tendermint节点的rpc地址,交易和查询的消息都发送到监听这个端口的进程。默认是`tcp://localhost:26657`,也可以通过`--node`指定rpc地址。 + +## iriscli config命令 + +iriscli config命令可以交互式地配置一些默认参数,例如chain-id,home,fee 和 node。 + +## 手续费和燃料 + +iriscli发送交易可以通过`--fee`指定手续费和`--gas`指定燃料(默认值是200000)。燃料除以手续费就是Gas Price,Gas Price不能小于区块链设定的最小值。执行完整个交易以后剩余的手续费会返还给用户。可以设置`--gas="simulate"`, 它可以通过仿真运行估算出交易大致所需要消耗的Gas,并且乘以一个由`--gas-adjustment`指定的系数得到最终的Gas,作为这次交易的gas。最后交易才会被广播出去。 + +## dry-run模式 + +iriscli默认关闭dry-run模式。如果想打开dry-run模式,就可以使用`--dry-run`。它和simulate处理逻辑类似,可以计算出需要消耗的gas,但是之后它不会广播给全节点,直接返回并打印此次消耗的gas。 + +例子:使用dry-run模式发送命令 + +``` +iriscli gov submit-proposal --title="ABC" --description="test" --type=Text --deposit=1iris --from=x --chain-id=gov-test --fee=0.05iris --gas=200000 --dry-run +``` + +返回: + +``` +estimated gas = 8370 +``` + +## 异步模式 + +iriscli发送的交易默认是同步模式。同步模式指的是发送交易,然后会堵塞,直到收到回复或者超时整个命令才结束。如果想打开异步模式,就可以使用`--async`。发送交易之后,会立马返回交易的hash。 + +## generate-only + +`generate-only`默认是关闭的,但可以使能`--generate-only`,然后会打印命令行生成的未签名交易。 + +例子:使能generate-only生成未签名交易 + +``` +iriscli gov submit-proposal --title="ABC" --description="test" --type=Text --deposit=1iris --from=x --chain-id=gov-test --fee=0.05iris --gas=200000 --generate-only +``` + +返回: + +```json +{ + "type": "auth/StdTx", + "value": { + "msg": [ + { + "type": "cosmos-sdk/MsgSubmitProposal", + "value": { + "title": "ABC", + "description": "test", + "proposal_type": "Text", + "proposer": "faa1k47r0nxd6ec8n6sc6tzvk2053u4eff0vx99755", + "initial_deposit": [ + { + "denom": "iris-atto", + "amount": "1000000000000000000" + } + ], + "Param": { + "key": "", + "value": "", + "op": "" + } + } + } + ], + "fee": { + "amount": [ + { + "denom": "iris-atto", + "amount": "50000000000000000" + } + ], + "gas": "200000" + }, + "signatures": null, + "memo": "" + } +} + +``` + +## trust-node + +trust-node默认为true。当trust-node是true时, iriscli的客户端只查询数据并不对数据进行默克尔证明。你也可以通过`--trust-node=false`, 对查询得到的数据进行默克尔证明。 + diff --git a/docs/zh/software/node.md b/docs/zh/software/node.md index e69de29bb..9925cb558 100644 --- a/docs/zh/software/node.md +++ b/docs/zh/software/node.md @@ -0,0 +1,109 @@ +# IRIS Daemon + +## 介绍 + +iris可执行文件是运行IRISnet网络节点的入口,包括验证人节点和其他全节点都需要通过安装iris命令并启动守护进程来加入到IRISnet网络。也可以使用该命令在本地启动自己的测试网络,如需加入IRISnet测试网请参阅[get-started](../get-started/README.md)。 + +## 如何在本地启动一个IRISnet网络 + +### 初始化节点 + +首先需要为自己创建对应的验证人账户 +```bash +iriscli keys add {account_name} +``` +得到账户信息,包括账户地址、公钥地址、助记词 +``` +NAME: TYPE: ADDRESS: PUBKEY: +account_name local faa13t6jugwm5uu3h835s5d4zggkklz6rpns59keju fap1addwnpepqdne60eyssj2plrsusd8049cs5hhhl5alcxv2xu0xmzlhphy9lyd5kpsyzu +**Important** write this seed phrase in a safe place. +It is the only way to recover your account if you ever forget your password. + +witness exotic fantasy gaze brass zebra adapt guess drip quote space payment farm argue pear actress garage smile hawk bid bag screen wonder person +``` + +初始化genesis.json和config.toml等配置文件 +```bash +iris init --home={path_to_your_home} --chain-id={your_chain_id} +``` +该命令会在home目录下创建相应文件 + +创建申请成为验证人的交易,并使用刚才创建的验证人账户对交易进行签名 +```bash +iris gentx --name={account_name} --home={path_to_your_home} +``` +生成好的交易数据存放在目录:{path_to_your_home}/config/gentx + +### 配置genesis + +手动修改genesis.json文件,为上述验证人账户分配初始账户余额,如:150个iris +```json +"accounts": [ + { + "address": "faa13t6jugwm5uu3h835s5d4zggkklz6rpns59keju", + "coins": [ + { + "denom": "iris-atto", + "amount": "150000000000000000000" + } + ], + "sequence_number": "0", + "account_number": "0" + } +], +``` + +配置验证人信息 +```bash +iris collect-gentxs --home={path_to_your_home} +``` +该命令读取 {path_to_your_home}/config/gentx 下的 `CreateValidator` 交易,并将其写入到genesis.json中,完成在创世块中对初始验证人的指定。 + +### 启动节点 + +完成上述配置后,通过以下命令启动全节点。 +```bash +iris start --home {path_to_your_home} +``` +该命令执行后,iris使用home下面所配置的genesis.json来生成创世区块并更新应用状态,后续根据chain-id所指链的当前区块高度,要么开始和其他peer同步区块,要么进入等待首次出块的流程。 + +## 启动多节点网络 + +如需在本地启动一个多节点的IRISnet网络,需要按下列步骤操作: + +* 准备home目录:为每个节点创建各自独有的home目录 +* 初始化:按照上述 `初始化节点` 步骤,在各自的home目录下为各节点完成初始化(注意需要使用同一个chain-id) +* 配置genesis:选择其中一个节点的home目录来配置genesis,参考`配置genesis`步骤,把各个节点的账户地址和初始余额配置进来,再把各个节点{path_to_your_home}/config/gentx下的文件拷贝到当前节点的{path_to_your_home}/config/gentx目录下,然后执行`iris collect-gentxs`来生成最终genesis.json,最后把该genesis.json拷贝到各个节点的home目录下,覆盖原有genesis.json +* 配置config.toml:修改各个节点home目录下的{path_to_your_home}/config/config.toml,为各个节点分配不同的端口,通过`iris tendermint show-node-id`查询各个节点的node-id,然后在`persistent_peers`中加入其它节点的`node-id@ip:port`,使得节点之间能够相互连接 + +为了简化上面的配置流程,可以使用下面命令来自动完成本地多节点的初始化和genesis、config的配置: +```bash +iris testnet --v 4 --output-dir ./output --chain-id irishub-test --starting-ip-address 127.0.0.1 +``` + +启动节点加入公共测试网络Testnet的方法可参阅[Full-Node](../get-started/Full-Node.md) + +## home目录介绍 + +home目录为iris节点的工作目录,home目录下包含了所有的配置信息和节点运行的所有数据。 + +在iris命令中可以通过flag `--home` 来指定该节点的home目录,如果在同一台机器上运行多个节点,则需要为他们指定不同的home目录。如果在iris命令中没有指定`--home` flag,则使用默认值 `$HOME/.iris` 作为本次iris命令所使用的home目录。 + +home的`data`目录下存放iris节点运行的数据,包括区块链数据、应用层数据、索引数据等。home的`config`目录下存放所有配置文件: + +### genesis.json + +genesis.json为创世块数据,指定了chain_id、共识参数、初始账户代币分配、创建验证人、stake/slashing/gov/upgrade等系统参数。详见[genesis-file](../features/basic-concepts/genesis-file.md) + +### node_key.json + +node_key.json用来存放节点的密钥,通过`iris tendermint show-node-id`查询到的node-id就是通过该密钥计算得来的,用来表示节点的唯一身份,在p2p连接中使用。 + +### pri_validator.json + +pri_validator.json为验证人在每一轮出块共识投票中对Pre-vote/Pre-commit等进行签名的密钥,随着共识的进行,tendermint共识引擎会不断更新`last_height`/`last_round`/`last_step`等数据。 + +### config.toml + +config.toml为该节点的非共识的配置信息,不同节点可根据自己的情况自行配置。常见修改项有`persistent_peers`/`moniker`/`laddr`等。 + diff --git a/modules/gov/errors.go b/modules/gov/errors.go index 0ea96d2dc..32be61fdf 100644 --- a/modules/gov/errors.go +++ b/modules/gov/errors.go @@ -24,6 +24,7 @@ const ( //////////////////// iris begin /////////////////////////// CodeInvalidParam sdk.CodeType = 12 CodeInvalidParamOp sdk.CodeType = 13 + CodeSwitchPeriodInProcess sdk.CodeType = 14 //////////////////// iris end ///////////////////////////// ) @@ -78,4 +79,8 @@ func ErrInvalidParam(codespace sdk.CodespaceType) sdk.Error { func ErrInvalidParamOp(codespace sdk.CodespaceType, opStr string) sdk.Error { return sdk.NewError(codespace, CodeInvalidParamOp, fmt.Sprintf("Op '%s' is not valid", opStr)) } + +func ErrSwitchPeriodInProcess(codespace sdk.CodespaceType) sdk.Error { + return sdk.NewError(codespace, CodeSwitchPeriodInProcess, fmt.Sprintf("Software Upgrade Switch Period is in process.")) +} //////////////////// iris end ///////////////////////////// diff --git a/modules/gov/handler.go b/modules/gov/handler.go index 031d832ef..0e02467e9 100644 --- a/modules/gov/handler.go +++ b/modules/gov/handler.go @@ -8,6 +8,7 @@ import ( "strconv" "encoding/json" "github.com/irisnet/irishub/modules/gov/params" + "github.com/irisnet/irishub/modules/upgrade/params" ) // Handle all "gov" type messages. @@ -30,9 +31,13 @@ func NewHandler(keeper Keeper) sdk.Handler { func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitProposal) sdk.Result { //////////////////// iris begin /////////////////////////// proposal := keeper.NewProposal(ctx, msg.Title, msg.Description, msg.ProposalType,msg.Param) + if msg.ProposalType == ProposalTypeSoftwareUpgrade { + if upgradeparams.GetCurrentUpgradeProposalId(ctx) != 0 { + return ErrSwitchPeriodInProcess(keeper.codespace).Result() + } + } //////////////////// iris end ///////////////////////////// - err, votingStarted := keeper.AddDeposit(ctx, proposal.GetProposalID(), msg.Proposer, msg.InitialDeposit) if err != nil { return err.Result() diff --git a/modules/gov/proposal_upgrade.go b/modules/gov/proposal_upgrade.go index 220e193c1..851190b8e 100644 --- a/modules/gov/proposal_upgrade.go +++ b/modules/gov/proposal_upgrade.go @@ -14,10 +14,14 @@ type SoftwareUpgradeProposal struct { func (sp *SoftwareUpgradeProposal) Execute(ctx sdk.Context, k Keeper) error { logger := ctx.Logger().With("module", "x/gov") - logger.Info("Execute SoftwareProposal begin", "info", fmt.Sprintf("current height:%d", ctx.BlockHeight())) - upgradeparams.SetCurrentUpgradeProposalId(ctx,sp.ProposalID) - upgradeparams.SetProposalAcceptHeight(ctx,ctx.BlockHeight()) + if upgradeparams.GetCurrentUpgradeProposalId(ctx) == 0 { + upgradeparams.SetCurrentUpgradeProposalId(ctx,sp.ProposalID) + upgradeparams.SetProposalAcceptHeight(ctx,ctx.BlockHeight()) + logger.Info("Execute SoftwareProposal begin", "info", fmt.Sprintf("current height:%d", ctx.BlockHeight())) + } else { + logger.Info("Software Upgrade Switch Period is in process.", "info", fmt.Sprintf("current height:%d", ctx.BlockHeight())) + } return nil } diff --git a/modules/service/error.go b/modules/service/error.go index b65c9c6f1..32bcc81a4 100644 --- a/modules/service/error.go +++ b/modules/service/error.go @@ -6,7 +6,7 @@ import ( ) const ( - DefaultCodespace sdk.CodespaceType = 6 + DefaultCodespace sdk.CodespaceType = 8 CodeInvalidIDL sdk.CodeType = 100 CodeSvcDefExists sdk.CodeType = 101 diff --git a/version/version.go b/version/version.go index 47f64586c..f4fc18f5d 100644 --- a/version/version.go +++ b/version/version.go @@ -7,7 +7,7 @@ import ( ) // Version - Iris Version -const Version = "0.7.0-Alpha" +const Version = "0.7.0" // GitCommit set by build flags var GitCommit = ""