Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Conversation

@linfeng-crypto
Copy link
Contributor

  • change enum AccountType to StakedStateDestination
  • remove struct InitialValidator and add ValidatorPubkey
  • redefine the struct InitConfig, remove launch_incentive_from,launch_incentive_to, long_term_incentive, add a field rewards_pool to store the initial token amount, change council_nodes from a vector into a BTreeMap, as below:
pub struct InitConfig {
    // initial rewards pool of CRO tokens
    pub rewards_pool: Coin,
    // Redeem mapping of ERC20 snapshot: Eth address => (StakedStateDestination,CRO tokens)
    // (doesn't include the rewards pool amount)
    pub distribution: BTreeMap<RedeemAddress, (StakedStateDestination, Coin)>,
    // initial network parameters
    pub network_params: InitNetworkParameters,
    // initial validators
    pub council_nodes: BTreeMap<RedeemAddress, ValidatorPubkey>,
}
  • simplify the function validate_config_get_genesis for InitConfig
  • Use new InitConfig in dev-util and chain-abci
  • fix test cases

@tomtau tomtau requested review from calvinaco, devashishdxt, leejw51crypto, lezzokafka and tomtau and removed request for devashishdxt and tomtau October 24, 2019 07:30
let account_key = to_stake_key(&StakedStateAddress::from(*account_address));
let state = app.last_state.clone().expect("app state");
println!("committed root hash: {:?}", &state.last_account_root_hash);
println!(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is in tests, so it won't be printed out unless the test fails

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so println! is OK

Copy link
Collaborator

@leejw51crypto leejw51crypto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm,
just fix clippy issues

Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems abci_app unit tests would require some fixing: https://travis-ci.org/crypto-com/chain/jobs/602210157#L1174

error[E0433]: failed to resolve: use of undeclared type or module `AccountType`
1175    --> chain-abci/tests/abci_app.rs:1416:48
1176     |
11771416 |     distribution.insert(address, (Coin::max(), AccountType::ExternallyOwnedAccount));
1178     |                                                ^^^^^^^^^^^ use of undeclared type or module `AccountType`
1179
1180error[E0433]: failed to resolve: use of undeclared type or module `AccountType`
1181    --> chain-abci/tests/abci_app.rs:1419:24
1182     |
11831419 |         (Coin::zero(), AccountType::Contract),
1184     |                        ^^^^^^^^^^^ use of undeclared type or module `AccountType`
1185
1186error[E0433]: failed to resolve: use of undeclared type or module `AccountType`
1187    --> chain-abci/tests/abci_app.rs:1604:48
1188     |
11891604 |     distribution.insert(address, (Coin::max(), AccountType::ExternallyOwnedAccount));
1190     |                                                ^^^^^^^^^^^ use of undeclared type or module `AccountType`
1191
1192error[E0433]: failed to resolve: use of undeclared type or module `AccountType`
1193    --> chain-abci/tests/abci_app.rs:1607:24
1194     |
11951607 |         (Coin::zero(), AccountType::Contract),
1196     |                        ^^^^^^^^^^^ use of undeclared type or module `AccountType`
1197
1198error[E0422]: cannot find struct, variant or union type `InitialValidator` in this scope
1199    --> chain-abci/tests/abci_app.rs:1444:14
1200     |
12011444 |         vec![InitialValidator {
1202     |              ^^^^^^^^^^^^^^^^ not found in this scope
1203
1204error[E0422]: cannot find struct, variant or union type `InitialValidator` in this scope
1205    --> chain-abci/tests/abci_app.rs:1632:14
1206     |
12071632 |         vec![InitialValidator {
1208     |              ^^^^^^^^^^^^^^^^ not found in this scope
1209
1210error[E0061]: this function takes 4 parameters but 6 parameters were supplied
1211    --> chain-abci/tests/abci_app.rs:1438:23
1212     |
12131438 |       let init_config = InitConfig::new(
1214     |  _______________________^
12151439 | |         distribution,
12161440 | |         RedeemAddress::default(),
12171441 | |         RedeemAddress::default(),
1218...    |
12191448 | |         }],
12201449 | |     );
1221     | |_____^ expected 4 parameters
1222
1223error[E0061]: this function takes 4 parameters but 6 parameters were supplied
1224    --> chain-abci/tests/abci_app.rs:1626:23
1225     |
12261626 |       let init_config = InitConfig::new(
1227     |  _______________________^
12281627 | |         distribution,
12291628 | |         RedeemAddress::default(),
12301629 | |         RedeemAddress::default(),
1231...    |
12321636 | |         }],
12331637 | |     );
1234     | |_____^ expected 4 parameters
1235
1236error: aborting due to 8 previous errors

Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abci app unit test fails to compile:

error[E0433]: failed to resolve: use of undeclared type or module `AccountType`
311	    --> chain-abci/tests/abci_app.rs:1416:48
312	     |
313	1416 |     distribution.insert(address, (Coin::max(), AccountType::ExternallyOwnedAccount));
314	     |                                                ^^^^^^^^^^^ use of undeclared type or module `AccountType`
315	
316	error[E0433]: failed to resolve: use of undeclared type or module `AccountType`
317	    --> chain-abci/tests/abci_app.rs:1419:24
318	     |
319	1419 |         (Coin::zero(), AccountType::Contract),
320	     |                        ^^^^^^^^^^^ use of undeclared type or module `AccountType`
321	
322	error[E0433]: failed to resolve: use of undeclared type or module `AccountType`
323	    --> chain-abci/tests/abci_app.rs:1604:48
324	     |
325	1604 |     distribution.insert(address, (Coin::max(), AccountType::ExternallyOwnedAccount));
326	     |                                                ^^^^^^^^^^^ use of undeclared type or module `AccountType`
327	
328	error[E0433]: failed to resolve: use of undeclared type or module `AccountType`
329	    --> chain-abci/tests/abci_app.rs:1607:24
330	     |
331	1607 |         (Coin::zero(), AccountType::Contract),
332	     |                        ^^^^^^^^^^^ use of undeclared type or module `AccountType`
333	
334	error[E0422]: cannot find struct, variant or union type `InitialValidator` in this scope
335	    --> chain-abci/tests/abci_app.rs:1444:14
336	     |
337	1444 |         vec![InitialValidator {
338	     |              ^^^^^^^^^^^^^^^^ not found in this scope
339	
340	error[E0422]: cannot find struct, variant or union type `InitialValidator` in this scope
341	    --> chain-abci/tests/abci_app.rs:1632:14
342	     |
343	1632 |         vec![InitialValidator {
344	     |              ^^^^^^^^^^^^^^^^ not found in this scope
345	
346	error[E0061]: this function takes 4 parameters but 6 parameters were supplied
347	    --> chain-abci/tests/abci_app.rs:1438:23
348	     |
349	1438 |       let init_config = InitConfig::new(
350	     |  _______________________^
351	1439 | |         distribution,
352	1440 | |         RedeemAddress::default(),
353	1441 | |         RedeemAddress::default(),
354	...    |
355	1448 | |         }],
356	1449 | |     );
357	     | |_____^ expected 4 parameters
358	
359	error[E0061]: this function takes 4 parameters but 6 parameters were supplied
360	    --> chain-abci/tests/abci_app.rs:1626:23
361	     |
362	1626 |       let init_config = InitConfig::new(
363	     |  _______________________^
364	1627 | |         distribution,
365	1628 | |         RedeemAddress::default(),
366	1629 | |         RedeemAddress::default(),
367	...    |
368	1636 | |         }],
369	1637 | |     );
370	     | |_____^ expected 4 parameters
371	

@codecov
Copy link

codecov bot commented Oct 24, 2019

Codecov Report

Merging #508 into master will increase coverage by 0.05%.
The diff coverage is 81.18%.

@@            Coverage Diff             @@
##           master     #508      +/-   ##
==========================================
+ Coverage   67.31%   67.37%   +0.05%     
==========================================
  Files         120      120              
  Lines       14158    14073      -85     
==========================================
- Hits         9531     9481      -50     
+ Misses       4627     4592      -35
Impacted Files Coverage Δ
dev-utils/src/commands/genesis_dev_config.rs 0% <0%> (ø) ⬆️
dev-utils/src/commands/genesis_command.rs 0% <0%> (ø) ⬆️
dev-utils/src/commands/init_command.rs 0% <0%> (ø) ⬆️
chain-abci/src/app/jail_account.rs 97.64% <100%> (-0.18%) ⬇️
chain-abci/tests/abci_app.rs 96.01% <100%> (-0.21%) ⬇️
chain-core/tests/verify_config.rs 100% <100%> (ø) ⬆️
chain-core/src/init/address.rs 73.46% <100%> (+0.55%) ⬆️
chain-abci/src/app/app_init.rs 69.4% <75%> (-0.26%) ⬇️
chain-core/src/init/config.rs 72.62% <83.01%> (+3.5%) ⬆️

@tomtau
Copy link
Contributor

tomtau commented Oct 24, 2019

bors try

bors bot added a commit that referenced this pull request Oct 24, 2019
@bors
Copy link
Contributor

bors bot commented Oct 24, 2019

try

Build failed

let bonded = match destination {
StakedStateDestination::Bonded => true,
StakedStateDestination::UnbondedFromGenesis => false,
StakedStateDestination::UnbondedFromCustomTime(_time) => false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnbondedFromCustomTime is ignored -- so I guess it'll be implemented in a different PR with new_init changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think so.

InitCommand::ask("** CAUTION **\n");
self.ask_string("validator staking addresse is special, cannot be withdrawn in single node mode (anykey)","");
self.ask_string(
"these incentive wallets are special, cannot be withdrawn (anykey)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be also removed -- did you try running the dev-utils commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I'll fix it.

@tomtau tomtau requested a review from leejw51crypto October 25, 2019 02:16
@tomtau
Copy link
Contributor

tomtau commented Oct 25, 2019

bors try

bors bot added a commit that referenced this pull request Oct 25, 2019
@bors
Copy link
Contributor

bors bot commented Oct 25, 2019

try

Build failed

@tomtau tomtau self-requested a review October 25, 2019 05:08
Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linfeng-crypto seems the integration test fails: https://travis-ci.org/crypto-com/chain/jobs/602620994#L3393
you can ask @calvinaco for help

@tomtau
Copy link
Contributor

tomtau commented Oct 28, 2019

@linfeng-crypto master changed, so there's a merge conflict with chain-abci/tests/abci_app.rs

@tomtau
Copy link
Contributor

tomtau commented Oct 28, 2019

bors try

bors bot added a commit that referenced this pull request Oct 28, 2019
@leejw51crypto
Copy link
Collaborator

i checked enclave hw, lgtm

@bors
Copy link
Contributor

bors bot commented Oct 28, 2019

@tomtau
Copy link
Contributor

tomtau commented Oct 28, 2019

@linfeng-crypto can you squash the commits (rebase on top of the latest master)?

@tomtau
Copy link
Contributor

tomtau commented Oct 28, 2019

@linfeng-crypto a conflict in chain-abci/tests/abci_app.rs -- just keep the rewards_pool in the tests, I guess

@tomtau
Copy link
Contributor

tomtau commented Oct 28, 2019

bors r+

bors bot added a commit that referenced this pull request Oct 28, 2019
508: Problem:( CRO-496) complex and inflexible initial distribution config r=tomtau a=linfeng-crypto


- change enum `AccountType` to `StakedStateDestination`
- remove struct `InitialValidator` and add `ValidatorPubkey`
- redefine the struct `InitConfig`, remove `launch_incentive_from`,`launch_incentive_to`, `long_term_incentive`, add a field `rewards_pool` to store the initial token amount, change `council_nodes` from a vector into a `BTreeMap`, as below:
```
pub struct InitConfig {
    // initial rewards pool of CRO tokens
    pub rewards_pool: Coin,
    // Redeem mapping of ERC20 snapshot: Eth address => (StakedStateDestination,CRO tokens)
    // (doesn't include the rewards pool amount)
    pub distribution: BTreeMap<RedeemAddress, (StakedStateDestination, Coin)>,
    // initial network parameters
    pub network_params: InitNetworkParameters,
    // initial validators
    pub council_nodes: BTreeMap<RedeemAddress, ValidatorPubkey>,
}
```
- simplify the function `validate_config_get_genesis` for `InitConfig`
- Use new `InitConfig` in `dev-util` and `chain-abci`
- fix test cases

Co-authored-by: linfeng <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 28, 2019

@bors bors bot merged commit a5fbf46 into crypto-com:master Oct 28, 2019
bors bot added a commit that referenced this pull request Apr 14, 2020
1418: Bump cbindgen from 0.14.0 to 0.14.1 r=tomtau a=dependabot-preview[bot]

Bumps [cbindgen](https://github.com/eqrion/cbindgen) from 0.14.0 to 0.14.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/eqrion/cbindgen/blob/master/CHANGES">cbindgen's changelog</a>.</em></p>
<blockquote>
<h2>0.14.1</h2>
<pre><code> * Handle mangling pointers. ([#508](mozilla/cbindgen#508))
 * Unconditionally generate a return statement in partialeq implementations. ([#509](mozilla/cbindgen#509))
</code></pre>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/eqrion/cbindgen/commit/0761b9bbe48d01ded1bbec45bbeea5544b3b1002"><code>0761b9b</code></a> Release 0.14.1</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/33d9ecf11f300bd03f431e9f3417c063e681380c"><code>33d9ecf</code></a> Handle mangling pointers.</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/0fed9eebc47abcd31e0e69357cd39262c8a5a6cc"><code>0fed9ee</code></a> enum: Unconditionally generate a return statement in partialeq implementations.</li>
<li><a href="https://github.com/eqrion/cbindgen/commit/a519f1bda444a0c6c01464296a052d9a05e1d9c4"><code>a519f1b</code></a> Actually use the temp dir for temporary compiled objects.</li>
<li>See full diff in <a href="https://github.com/eqrion/cbindgen/compare/v0.14.0...v0.14.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=cbindgen&package-manager=cargo&previous-version=0.14.0&new-version=0.14.1)](https://dependabot.com/compatibility-score/?dependency-name=cbindgen&package-manager=cargo&previous-version=0.14.0&new-version=0.14.1)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants