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(rollapp): move DRS version to be part of the block descriptor #1311

Merged
merged 5 commits into from
Oct 21, 2024

Conversation

srene
Copy link
Contributor

@srene srene commented Oct 11, 2024

Description


Closes #1295

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.

@srene srene self-assigned this Oct 11, 2024
@srene srene requested a review from a team as a code owner October 11, 2024 11:49
Copy link
Contributor

@omritoptix omritoptix left a comment

Choose a reason for hiding this comment

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

unbound iteration and missing validateBasic validation to the DRS.
related to https://github.com/dymensionxyz/research/issues/426

update: I see there is a todo about the DRS version validation. not sure why as we can still support for backeward compatability as it will be empty in the backward case.

// TODO: add a validation for DrsVersion once empty DRS version is marked vulnerable
	//  https://github.com/dymensionxyz/dymension/issues/1233

@srene srene marked this pull request as draft October 14, 2024 12:22
@srene srene marked this pull request as ready for review October 14, 2024 13:02
omritoptix
omritoptix previously approved these changes Oct 16, 2024
@omritoptix
Copy link
Contributor

waiting to merge until dymensionxyz/dymint#1130 is merged

@omritoptix omritoptix changed the title feat(rollapp): drs version moved to bds feat(rollapp): move DRS version to be part of the block descriptor Oct 16, 2024
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.

Bit dubious IMO

Comment on lines 37 to 56
// We only check first and last BD to avoid DoS attack related to iterating big number of BDs (taking into account a state update can be submitted with any numblock value)
// It is assumed there cannot be two upgrades in the same state update (since it requires gov proposal), if this happens it will be a fraud caught by Rollapp validators.
// Therefore checking first and last BD for deprecated DRS version should be enough.
var bdsToCheck []*types.BlockDescriptor
bdsToCheck = append(bdsToCheck, &msg.BDs.BD[0])
if msg.NumBlocks > 1 {
bdsToCheck = append(bdsToCheck, &msg.BDs.BD[len(msg.BDs.BD)-1])
}
for _, bd := range bdsToCheck {
// verify the DRS version is not vulnerable
if k.IsDRSVersionVulnerable(ctx, bd.DrsVersion) {
// the rollapp is not marked as vulnerable yet, mark it now
err := k.MarkRollappAsVulnerable(ctx, msg.RollappId)
if err != nil {
return nil, fmt.Errorf("mark rollapp vulnerable: %w", err)
}
k.Logger(ctx).With("rollapp_id", msg.RollappId, "drs_version", bd.DrsVersion).
Info("non-frozen rollapp tried to submit MsgUpdateState with the vulnerable DRS version, mark the rollapp as vulnerable")
// we must return non-error if we want the changes to be saved
return &types.MsgUpdateStateResponse{}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can this be DRYer wrt to the mark_vulnerable.. ?
lots of dupe here
also ditto my comment about checking first and last

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure what you mean by DRYer here...

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Approved but could micro optimize the state update check if we really want to

Comment on lines +40 to +41
// the rollapp is not marked as vulnerable yet, mark it now
err := k.MarkRollappAsVulnerable(ctx, msg.RollappId)
Copy link
Contributor

Choose a reason for hiding this comment

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

ah I guess this is a store read
could do a happy path optimization to avoid rechecking ones which are already seenf
but IDK if we want to microoptimize

@omritoptix omritoptix merged commit 8fb2d25 into main Oct 21, 2024
5 checks passed
@omritoptix omritoptix deleted the srene/1295-drs-version-per-bd branch October 21, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add DRS version for each block descriptor in state info
3 participants