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(sequencer): doc improvement tweaks from previous merged PR feedback #526

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions x/sequencers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@

## Abstract

The Sequencers module provides a method to initialize a sequencer from Dymint for rewards. Unlike traditional Cosmos SDK chains, the proposer's source of truth is not the Cosmos SDK but the hub. Dymint is responsible for communicating with the hub and conveying the current proposer's information to the RDK.
The module houses sequencer objects which can set a reward address to receive blocks rewards.

## Overview

Currently, we use the ABCI `InitChainer` method. There are two challenges we encounter when updating a sequencer, as opposed to when creating a validator:
The ABCI InitChainer method passes a validator set. The same set needs to be returned on InitGenesis. We simply save the passed set and return it, but do not use it.

1. `InitChainer` expects the `validatorUpdates` to be identical to what it received from Dymint.
2. We need a method to set the operator address, which is the address used for sequencer rewards.

To address these challenges, we proceed as follows:

1. Upon `InitChainer`, we invoke `SetDymintSequencers` and create a dummy sequencer object with the consensus public key and power obtained from the `validatorUpdates`.
2. Upon `InitGenesis`, we construct a validator-like object where the operator address is specified in the genesis file, and the consensus public key and power are derived from the dummy sequencer object.
3. Finally, we delete the dummy sequencer object.

Subsequently, we have a sequencer structure that implements the `stakingtypes.Validator` interface, which is utilized for rewards.
The distr module will query this module for a reward address using a cons address. Sequencers should set an appropriate reward addr to be returned here.
15 changes: 4 additions & 11 deletions x/sequencers/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ Operator addr should be bech32 encoded. You may supply a different reward addr o
return fmt.Errorf("keybase key: %w", err)
}

msgs := make([]sdk.Msg, 1)
msgs := make([]sdk.Msg, 2)

msg, err := types.BuildMsgCreateSequencer(func(msg []byte) ([]byte, cryptotypes.PubKey, error) {
return txf.Keybase().Sign(keyID, msg)
msg, err := types.BuildMsgCreateSequencer(func(toSign []byte) ([]byte, cryptotypes.PubKey, error) {
return txf.Keybase().Sign(keyID, toSign)
}, sdk.ValAddress(addr))
if err != nil {
return fmt.Errorf("build create seq msg: %w", err)
Expand All @@ -75,13 +75,11 @@ Operator addr should be bech32 encoded. You may supply a different reward addr o
if rewardAddr == "" {
rewardAddr = ctx.GetFromAddress().String()
}
msgU := &types.MsgUpdateSequencer{
msgs[1] = &types.MsgUpdateSequencer{
Operator: sdk.ValAddress(ctx.GetFromAddress()).String(),
RewardAddr: rewardAddr,
}

msgs = append(msgs, msgU)

return tx.GenerateOrBroadcastTxWithFactory(ctx, txf, msgs...)
},
}
Expand All @@ -94,16 +92,11 @@ Operator addr should be bech32 encoded. You may supply a different reward addr o

func NewUpdateCmd() *cobra.Command {
short := "Update a sequencer object, to claim rewards etc."
long := strings.TrimSpace(short +
`Requires signature from consensus address public key. Specify consensus key in keyring uid.
Operator addr should be bech32 encoded.`)

cmd := &cobra.Command{
Use: "update-sequencer [reward addr]",
Example: "update-sequencer ethm1lhk5cnfrhgh26w5r6qft36qerg4dclfev9nprc --from foouser",
Args: cobra.ExactArgs(1),
Short: short,
Long: long,
RunE: func(cmd *cobra.Command, args []string) error {
ctx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand Down
28 changes: 0 additions & 28 deletions x/sequencers/handler.go

This file was deleted.

6 changes: 3 additions & 3 deletions x/sequencers/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ func (m *MsgCreateSequencer) ValidateBasic() error {
pubKey, _ := v.ConsPubKey()

// We return OK only if the key and sig contains a key and signature where the signature was produced by the key, and the signature
// is over the operator account, and the app payload data (if not empty).
// is over the operator account.
//
// The reasoning is as follows:
//
// We know from the SDK TX signing mechanism that the account originates from the operator, and on this chain ID.
// Therefore, we just need to check that the consensus private key also signed over this account and chain ID.
// That means the consensus private key owner is the same actor as the operator.
// Therefore, we just need to check that the consensus private key also over this operator. Then we know that
// the private key holder of the operator and the consensus keys is the same actor.
if !pubKey.VerifySignature(operator, m.GetSignature()) {
return errorsmod.Wrap(gerrc.ErrUnauthenticated, "priv key of pub cons key was not used to sign operator addr")
}
Expand Down
Loading