tendermint / spn

A blockchain to launch blockchains.
Other
112 stars 43 forks source link

feat(`launch`): default chain account balances #936

Closed aljo242 closed 2 years ago

aljo242 commented 2 years ago

Closes #927

What does this PR do?

Adds the DefaultAccountBalance field to Chain and MsgCreateChain. If this field is empty (sdk.NewCoins()). the behavior is unchanged. However, if it is populated, the balances of accounts that are created during keeper.ApplyRequest() are set to chain.DefaultAccountBalance.

How to test?

ignite chain serve --skip-proto -r
spnd tx profile create-coordinator --from alice   
spnd tx launch create-chain chain-1 "" "" --from alice --default-account-balance 1000test
spnd tx launch request-add-account 1 20000othercoins --from alice     
spnd q  launch list-genesis-account 1                             
aljo242 commented 2 years ago

I regenerated the proto files using make proto-gen and make proto-format so many of them were modified.

codecov[bot] commented 2 years ago

Codecov Report

Merging #936 (3d631b3) into develop (ae4ee27) will increase coverage by 0.02%. The diff coverage is 18.70%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #936      +/-   ##
===========================================
+ Coverage    10.75%   10.77%   +0.02%     
===========================================
  Files          280      280              
  Lines        66957    67091     +134     
===========================================
+ Hits          7199     7227      +28     
- Misses       59595    59702     +107     
+ Partials       163      162       -1     
Impacted Files Coverage Δ
pkg/types/monitoring.pb.go 0.79% <ø> (ø)
x/campaign/types/events.pb.go 0.55% <ø> (ø)
x/campaign/types/mainnet_account.pb.go 0.75% <ø> (ø)
x/campaign/types/params.pb.go 0.88% <ø> (ø)
x/campaign/types/query.pb.go 0.66% <ø> (ø)
x/campaign/types/query.pb.gw.go 0.00% <ø> (ø)
x/launch/types/chain.pb.go 1.53% <0.00%> (-0.07%) :arrow_down:
x/launch/types/events.pb.go 0.49% <ø> (ø)
x/launch/types/genesis_account.pb.go 0.98% <ø> (ø)
x/launch/types/genesis_validator.pb.go 0.56% <ø> (ø)
... and 28 more
lumtis commented 2 years ago

What's your reasoning to consider it should be named DefaultAccountBalance?

To me, it's a balance imposed by the coordinator. Default would mean this is the value set if the account doesn't provide a specific amount.

But it can be argued as well we can name it to "default" because this the balance that will be defined by default or accounts at first before the chain is launched and coins are moving

aljo242 commented 2 years ago

What's your reasoning to consider it should be named DefaultAccountBalance?

To me, it's a balance imposed by the coordinator. Default would mean this is the value set if the account doesn't provide a specific amount.

But it can be argued as well we can name it to "default" because this the balance that will be defined by default or accounts at first before the chain is launched and coins are moving

Yeah, I agree default doesn't make as much sense as I originally thought. I'm going to change it back to AccountBalance

lumtis commented 2 years ago

Hey @aljo242 is it ready for reviews?

I also wanted to add that we should add a test case in TestApplyRequest for the particular case the balance is defined

But I realize the current structure of TestApplyRequest is hard to maintain and should be improved first https://github.com/tendermint/spn/issues/944