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

fix(rollapp): missing rollappid validation on rollapp creation #712

Merged
merged 10 commits into from
Mar 27, 2024

Conversation

mtsitrin
Copy link
Contributor

@mtsitrin mtsitrin commented Mar 21, 2024

Description


Closes #710

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow-up issues.

PR review checkboxes:

I have...

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Targeted PR against the correct branch
  • included the correct type prefix in the PR title
  • Linked to the GitHub issue with discussion and accepted design
  • Targets only one GitHub issue
  • Wrote unit and integration tests
  • Wrote relevant migration scripts if necessary
  • All CI checks have passed
  • Added relevant godoc comments
  • Updated the scripts for local run, e.g genesis_config_commands.sh if the PR changes parameters
  • Add an issue in the e2e-tests repo if necessary

SDK Checklist

  • Import/Export Genesis
  • Registered Invariants
  • Registered Events
  • Updated openapi.yaml
  • No usage of go map
  • No usage of time.Now()
  • Used fixed point arithmetic and not float arithmetic
  • Avoid panicking in Begin/End block as much as possible
  • No unexpected math Overflow
  • Used sendCoin and not SendCoins
  • Out-of-block compute is bounded
  • No serialized ID at the end of store keys
  • UInt to byte conversion should use BigEndian

Full security checklist here

----;

For Reviewer:

  • Confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • Confirmed all author checklist items have been addressed

---;

After reviewer approval:

  • In case the PR targets the main branch, PR should not be squash merge in order to keep meaningful git history.
  • In case the PR targets a release branch, PR must be rebased.

@mtsitrin mtsitrin requested a review from a team as a code owner March 21, 2024 10:06
@mtsitrin mtsitrin linked an issue Mar 21, 2024 that may be closed by this pull request
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 97.53086% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 30.72%. Comparing base (5890b2c) to head (e7087fb).
Report is 1 commits behind head on main.

Files Patch % Lines
x/rollapp/keeper/msg_server_create_rollapp.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #712      +/-   ##
==========================================
+ Coverage   30.64%   30.72%   +0.07%     
==========================================
  Files         233      234       +1     
  Lines       32580    32603      +23     
==========================================
+ Hits         9984    10017      +33     
+ Misses      21031    21022       -9     
+ Partials     1565     1564       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

x/rollapp/types/message_create_rollapp_test.go Outdated Show resolved Hide resolved
x/rollapp/types/message_create_rollapp_test.go Outdated Show resolved Hide resolved
x/rollapp/types/message_create_rollapp_test.go Outdated Show resolved Hide resolved
x/rollapp/types/message_create_rollapp_test.go Outdated Show resolved Hide resolved
x/rollapp/types/rollapp.go Outdated Show resolved Hide resolved
x/rollapp/types/rollapp.go Show resolved Hide resolved
x/rollapp/types/message_create_rollapp.go Outdated Show resolved Hide resolved
x/rollapp/types/rollapp.go Outdated Show resolved Hide resolved
@mtsitrin mtsitrin self-assigned this Mar 24, 2024
@omritoptix omritoptix changed the title fix: missing rollappid validation on rollapp creation fix(rollapp): missing rollappid validation on rollapp creation Mar 25, 2024
@danwt
Copy link
Contributor

danwt commented Mar 26, 2024

There's a decent amount of duping here

// Build the genesis state from the genesis accounts
var rollappGenesisState *types.RollappGenesisState
if len(msg.GenesisAccounts) > 0 {
rollappGenesisState = &types.RollappGenesisState{
GenesisAccounts: msg.GenesisAccounts,
IsGenesisEvent: false,
}
}
// copy TokenMetadata
metadata := make([]*types.TokenMetadata, len(msg.Metadatas))
for i := range msg.Metadatas {
metadata[i] = &msg.Metadatas[i]
}
// Create an updated rollapp record
rollapp := types.NewRollapp(msg.Creator, msg.RollappId, msg.MaxSequencers, msg.PermissionedAddresses, metadata, rollappGenesisState)

// Build the genesis state from the genesis accounts
var rollappGenesisState *RollappGenesisState
if len(msg.GenesisAccounts) > 0 {
rollappGenesisState = &RollappGenesisState{
GenesisAccounts: msg.GenesisAccounts,
IsGenesisEvent: false,
}
}
// copy TokenMetadata
metadata := make([]*TokenMetadata, len(msg.Metadatas))
for i := range msg.Metadatas {
metadata[i] = &msg.Metadatas[i]
}
rollapp := NewRollapp(msg.Creator, msg.RollappId, msg.MaxSequencers, msg.PermissionedAddresses, metadata, rollappGenesisState)

It's not the end of the world but might be good to cleanup

x/rollapp/types/rollapp.go Outdated Show resolved Hide resolved
x/rollapp/keeper/rollapp.go Show resolved Hide resolved
app/apptesting/test_suite.go Outdated Show resolved Hide resolved
@mtsitrin mtsitrin requested a review from danwt March 27, 2024 12:12
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

gj

@mtsitrin mtsitrin merged commit e0c6cc3 into main Mar 27, 2024
17 of 26 checks passed
@mtsitrin mtsitrin deleted the 710-missing-rollappid-validation-on-rollapp-creation branch March 27, 2024 13:07
return sdkerrors.Wrapf(ErrInvalidAddress, "invalid creator address (%s)", err)
func (msg *MsgCreateRollapp) GetRollapp() Rollapp {
// Build the genesis state from the genesis accounts
var rollappGenesisState *RollappGenesisState
Copy link
Contributor

Choose a reason for hiding this comment

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

if genesis state remains nil I think we would get an error in the genesis event later on:
https://github.com/dymensionxyz/dymension/blob/main/x/rollapp/keeper/keeper.go#L68
Not sure if that's expected, if not, we should instantiate rollappGenesisState regardless of genesis accounts being empty or not.
Unless it's expected that for some reason we enforce genesis accounts not being empty. In that case, we should probably fail on validation or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

missing rollappID validation on rollapp creation
5 participants