Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(network): param-change apply to genesis #3208

Merged
merged 33 commits into from
Dec 8, 2022

Conversation

aljo242
Copy link
Contributor

@aljo242 aljo242 commented Nov 30, 2022

Closes #2899
Closes #3156

Adds check to verify param change before it is broadcast to the network.

@aljo242 aljo242 changed the base branch from main to chore/update-spn November 30, 2022 14:57
@aljo242 aljo242 changed the title feat(network: param-change apply to genesis feat(network): param-change apply to genesis Nov 30, 2022
@aljo242 aljo242 added the skip-changelog Don't check changelog for new entries label Nov 30, 2022
@aljo242 aljo242 marked this pull request as ready for review December 1, 2022 16:33
Copy link
Contributor

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Looks good, running some tests right now

ignite/services/network/networkchain/prepare.go Outdated Show resolved Hide resolved
ignite/pkg/cosmosutil/genesis/genesis.go Outdated Show resolved Hide resolved
@lumtis
Copy link
Contributor

lumtis commented Dec 1, 2022

@aljo242
It seems like I get some trouble when using value as JSON

ignite n request change-param 7 crisis constant_fee "{\"denom\":\"bar\",\"amount\":\"500\"}" --from alice
ignite n request approve 7 5
Source code fetched
Blockchain set up
Requests format verified
Blockchain initialized
Genesis initialized
Genesis built
Request(s) not valid: Error: error reading GenesisDoc at /var/folders/6n/c3hb98tx2sjdxbz0cg5fy2gm0000gn/T/708038360/config/genesis.json: invalid character 'd' after object key:value pair. Make sure that you have correctly migrated all Tendermint consensus params, please see the chain migration guide at https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md for more info
Usage:
  exampled validate-genesis [file] [flags]

Am I using the correct format for JSON value? "{\"denom\":\"bar\",\"amount\":\"500\"}"

@lumtis
Copy link
Contributor

lumtis commented Dec 5, 2022

This Tx will still fail because this is not a param but that's ok:

Yes, actually

Copy link
Contributor

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

It seems there is now an issue with string value

ignite n request change-param 11 staking bond_denom bar --from alice
Source code fetched
Blockchain set up
Genesis initialized
Invalid parameter change requested: Error: error reading GenesisDoc at /Users/lucas/spn/11/config/genesis.json: invalid character 'b' looking for beginning of value. Make sure that you have correctly migrated all Tendermint consensus params, please see the chain migration guide at https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md for more info
Usage:
  exampled validate-genesis [file] [flags]

Flags:
  -h, --help   help for validate-genesis

Global Flags:
      --home string         directory for config and data (default "/Users/lucas/.example")
      --log_format string   The logging format (json|plain) (default "plain")
      --log_level string    The logging level (trace|debug|info|warn|error|fatal|panic) (default "info")
      --trace               print out full stack trace on errors

: exit status 1

@aljo242
Copy link
Contributor Author

aljo242 commented Dec 5, 2022

It seems there is now an issue with string value

ignite n request change-param 11 staking bond_denom bar --from alice
Source code fetched
Blockchain set up
Genesis initialized
Invalid parameter change requested: Error: error reading GenesisDoc at /Users/lucas/spn/11/config/genesis.json: invalid character 'b' looking for beginning of value. Make sure that you have correctly migrated all Tendermint consensus params, please see the chain migration guide at https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md for more info
Usage:
  exampled validate-genesis [file] [flags]

Flags:
  -h, --help   help for validate-genesis

Global Flags:
      --home string         directory for config and data (default "/Users/lucas/.example")
      --log_format string   The logging format (json|plain) (default "plain")
      --log_level string    The logging level (trace|debug|info|warn|error|fatal|panic) (default "info")
      --trace               print out full stack trace on errors

: exit status 1

Yes, you just have to wrap the string in quotations:

ignite n request change-param 11 staking bond_denom \"bar\" --from alice

Its because we are treating everything as a []byte internally and from the cmd level.

@lumtis
Copy link
Contributor

lumtis commented Dec 5, 2022

Ok thanks, I was surprised as I used it without the quotes in previous tests

@lumtis lumtis mentioned this pull request Dec 6, 2022
2 tasks
@lumtis
Copy link
Contributor

lumtis commented Dec 6, 2022

@Pantani can you take some time to have a look at this one?

ignite/pkg/cosmosutil/genesis/genesis.go Outdated Show resolved Hide resolved
ignite/pkg/cosmosutil/genesis/genesis.go Outdated Show resolved Hide resolved
@@ -179,6 +182,16 @@ func TestJSONFile_Update(t *testing.T) {
),
},
},
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a test case for:

WithKeyValueByte(
	"app_state.crisis.params.constant_fee ",
	[]bytes("newValue"),
),

Maybe this case should fail because it will miss the "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I understand. Why would this test fail?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Because the value is a string and don't have the " in the begin and the end of the value, the JSON will break

Copy link
Collaborator

@Pantani Pantani Dec 8, 2022

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

but it's a corner case. We don't need to cover if you think don't make sense

Copy link
Contributor Author

@aljo242 aljo242 Dec 8, 2022

Choose a reason for hiding this comment

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

But in this specific test nothing will fail. We are just updating some generic []byte value here and there is no way to test if it is valid until we run validate-genesis later. So here at least, []byte("newValue") and []byte("\"newValue\"")are valid.

ignite/services/network/networkchain/prepare.go Outdated Show resolved Hide resolved
ignite/services/network/networkchain/request.go Outdated Show resolved Hide resolved
@aljo242 aljo242 requested a review from Pantani December 7, 2022 14:12
Copy link
Collaborator

@Pantani Pantani left a comment

Choose a reason for hiding this comment

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

LGMT

@aljo242
Copy link
Contributor Author

aljo242 commented Dec 8, 2022

@jeronimoalbi will merge if you approve

@aljo242 aljo242 merged commit 629920f into chore/update-spn Dec 8, 2022
@aljo242 aljo242 deleted the feat/param-change-genesis branch December 8, 2022 16:04
aljo242 added a commit that referenced this pull request Dec 8, 2022
* update spn

* import

* fix

* update mocks

* rename test

* feat(`network`): `param-change` (#3142)

* utd

* add command

* typo

* add test

* changelog

* format

* Update ignite/cmd/network_request_param_change.go

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>

* Update changelog.md

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>

* refactor: rename command `param-change` into `change-param` (#3169)

* change name

* rename file

* chore: upgrade `spn` (#3177)

* gomod

* gosum

* endpoints (#3196)

* format

* request list

* feat: add `ParamChange` to `ignite n request list/show` (#3233)

* chore: go formatting (#3232)

Co-authored-by: aljo242 <aljo242@users.noreply.github.com>

* request list

* format

* ascii

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: aljo242 <aljo242@users.noreply.github.com>

* format

* feat(`network`): param-change apply to genesis (#3208)

* stub out

* prepare logic

* fix test

* Update ignite/services/network/networkchain/prepare.go

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>

* refactor WithKeyValueByte

* add detail to error message

* const format string

* format

* add integration test and fix

* add check to command

* format

* finish check code

* improve error msg

* wip

* fix

* format

* remove incorrect test

* Update ignite/pkg/cosmosutil/genesis/genesis.go

Co-authored-by: Danilo Pantani <danpantani@gmail.com>

* rename according to review

* optimize appylParamChanges

* basic ModuleParamField test

* format

* revert errors

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
Co-authored-by: Danilo Pantani <danpantani@gmail.com>

* add test

* add test

* flesh out genesis information tests

* format

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: aljo242 <aljo242@users.noreply.github.com>
Co-authored-by: Danilo Pantani <danpantani@gmail.com>
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
* update spn

* import

* fix

* update mocks

* rename test

* feat(`network`): `param-change` (ignite#3142)

* utd

* add command

* typo

* add test

* changelog

* format

* Update ignite/cmd/network_request_param_change.go

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>

* Update changelog.md

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>

* refactor: rename command `param-change` into `change-param` (ignite#3169)

* change name

* rename file

* chore: upgrade `spn` (ignite#3177)

* gomod

* gosum

* endpoints (ignite#3196)

* format

* request list

* feat: add `ParamChange` to `ignite n request list/show` (ignite#3233)

* chore: go formatting (ignite#3232)

Co-authored-by: aljo242 <aljo242@users.noreply.github.com>

* request list

* format

* ascii

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: aljo242 <aljo242@users.noreply.github.com>

* format

* feat(`network`): param-change apply to genesis (ignite#3208)

* stub out

* prepare logic

* fix test

* Update ignite/services/network/networkchain/prepare.go

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>

* refactor WithKeyValueByte

* add detail to error message

* const format string

* format

* add integration test and fix

* add check to command

* format

* finish check code

* improve error msg

* wip

* fix

* format

* remove incorrect test

* Update ignite/pkg/cosmosutil/genesis/genesis.go

Co-authored-by: Danilo Pantani <danpantani@gmail.com>

* rename according to review

* optimize appylParamChanges

* basic ModuleParamField test

* format

* revert errors

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
Co-authored-by: Danilo Pantani <danpantani@gmail.com>

* add test

* add test

* flesh out genesis information tests

* format

Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: aljo242 <aljo242@users.noreply.github.com>
Co-authored-by: Danilo Pantani <danpantani@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Don't check changelog for new entries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants