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(sequencers): added MsgUpsertSequencer #568

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

keruch
Copy link

@keruch keruch commented Oct 4, 2024

Description


ADR link https://www.notion.so/dymension/ADR-x-Sequencer-Reward-Address-On-Rollapp-da84af6888c141d0a4c1a8df256a5025
Closes dymensionxyz/dymension#1248

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
  • 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.

@danwt
Copy link
Contributor

danwt commented Oct 7, 2024

build fail

Base automatically changed from feat/consensus-messages to main October 8, 2024 16:47
@keruch keruch changed the base branch from main to feat/consensus-messages October 9, 2024 10:27
Base automatically changed from feat/consensus-messages to main October 9, 2024 16:28
@@ -28,10 +29,26 @@ message MsgCreateSequencerResponse {

}

message MsgUpsertSequencer {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we call this msg ConsensusMsgUpsertSequencer or something?

return nil, err
}

ctx.EventManager().EmitEvent(sdk.NewEvent(
Copy link
Contributor

Choose a reason for hiding this comment

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

Better create an event proto for this and use the EmitTypedEvent from sdk-utils. The version of sdk-utils doesn't have it, it should be added there. I wrote it because the default EmitTypedEvent from the sdk has a bug with the quotes. We use it in the hub

Copy link
Author

Choose a reason for hiding this comment

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

we can't import sdk-utils in this repo since the cosmos versions are different. i did a copy of uevent and added a todo to replace it once the rdk version is updated.

"github.com/cosmos/cosmos-sdk/types/bech32"
)

func BytesToBech32(addr []byte) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this could maybe be moved to sdk-utils

Copy link
Author

Choose a reason for hiding this comment

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

it can't temporarily, see my comment above

@keruch keruch requested a review from zale144 October 10, 2024 10:02
@@ -0,0 +1,71 @@
// Package uevent is a copy of https://github.com/dymensionxyz/sdk-utils/tree/main/utils/uevent.
// TODO: import sdk-utils directly when the RDK is updated to SDK v0.47 and further.
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have sdk-util's branch dedicated for the RDK (based on v0.46)

Copy link
Author

Choose a reason for hiding this comment

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

it's deeply outdated :(

// all must-methods are safe to use since they're validated in ValidateBasic

v := msg.MustValidator()
m.SetSequencer(ctx, v)
Copy link
Collaborator

Choose a reason for hiding this comment

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

validate it's not already exists?

Copy link
Author

Choose a reason for hiding this comment

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

in the next PR (for Whitelisted Relayer ADR) we'll assume that the hub is the source of truth, so the upsert will become an honest upsert independently of the record existence. i'll keep this code as it is for now if you don't mind, just not to do the extra work of reverting it in the next PR.

@@ -12,6 +11,8 @@ option go_package = "github.com/dymensionxyz/dymension-rdk/x/sequencers/types";
service Msg {
rpc CreateSequencer(MsgCreateSequencer) returns (MsgCreateSequencerResponse);
Copy link
Collaborator

Choose a reason for hiding this comment

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

CreateSequencer should be removed if there's no use case for it

Copy link
Author

Choose a reason for hiding this comment

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

i'll remove it in the next PR as well if you don't mind. i'm gonna refactor the whole msg server there.

"github.com/cosmos/cosmos-sdk/types/bech32"
)

func Bech32ToAddr[T sdk.AccAddress | sdk.ValAddress](addr string) (T, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

move to utils/addressutils

Copy link
Author

Choose a reason for hiding this comment

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

done!

@keruch keruch requested a review from mtsitrin October 10, 2024 15:54
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.

Sequencer Reward Address On Rollapp - Impl
4 participants