Skip to content

refactor(modules): replace sequencer by rollkitmngr #114

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ proto-gen:
go tool github.com/bufbuild/buf/cmd/buf dep update
@cd modules/proto && \
go tool github.com/bufbuild/buf/cmd/buf generate
@mv modules/github.com/rollkit/go-execution-abci/modules/sequencer/types/** modules/sequencer/types/ && \
mv modules/github.com/rollkit/go-execution-abci/modules/sequencer/module/* modules/sequencer/module/
@mv modules/github.com/rollkit/go-execution-abci/modules/rollkitmngr/types/** modules/rollkitmngr/types/ && \
mv modules/github.com/rollkit/go-execution-abci/modules/rollkitmngr/module/* modules/rollkitmngr/module/
@rm -r modules/github.com

.PHONY: proto-gen
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
cosmossdk.io/errors v1.0.2
cosmossdk.io/log v1.6.0
cosmossdk.io/math v1.5.3
cosmossdk.io/store v1.1.1
github.com/cometbft/cometbft v0.38.17
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.13
Expand Down Expand Up @@ -57,7 +58,6 @@ require (
connectrpc.com/connect v1.18.1 // indirect
connectrpc.com/grpcreflect v1.3.0 // indirect
connectrpc.com/otelconnect v0.7.2 // indirect
cosmossdk.io/store v1.1.1 // indirect
cosmossdk.io/x/tx v0.13.7 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
Expand Down
10 changes: 5 additions & 5 deletions modules/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Optional Cosmos SDK modules

This package contains optional modules for the Cosmos SDK when using Rollkit.
They are meant to enhance the UX when using Rollkit by simplifying staking and the management of the sequencer(s).
They are meant to enhance the UX when using Rollkit by simplifying staking and the management of rollkit sequencer, attesters and migration from CometBFT to Rollkit.

## Staking

Expand All @@ -10,10 +10,10 @@ It changes the way the staking module works by adding No-Ops on methods that do

Think of slashing, jailing or validator updates.

## Sequencer
## Rollkit Manager

The sequencer module is a meant to easily switch between sequencers.
The `rollkitmngr` module is a meant to define attesters and sequencers in a Rollkit chain.
This is the module that handles the validator updates on the SDK side.
Additionally, it has additional queries to get the sequencer information, and the future sequencer changes.
Additionally, it has additional queries to get the sequencer information, and the attesters information.

Additionally, when added to a CometBFT chain, the sequencer module will handle the switch from a CometBFT validator set to a Rollkit sequencer at a given height.
Additionally, when added to a CometBFT chain, the `rollkitmngr` module will handle the switch from a CometBFT validator set to a Rollkit sequencer at a given height.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
syntax = "proto3";
package rollkitsdk.sequencer.module.v1;
package rollkitsdk.rollkitmngr.module.v1;

import "cosmos/app/v1alpha1/module.proto";

option go_package = "github.com/rollkit/go-execution-abci/modules/sequencer/module";
option go_package = "github.com/rollkit/go-execution-abci/modules/rollkitmngr/module";

// Module is the config object for the module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import : "github.com/rollkit/go-execution-abci/modules/sequencer"
go_import : "github.com/rollkit/go-execution-abci/modules/rollkitmngr"
};

// authority defines the custom module authority. If not set, defaults to the
Expand Down
61 changes: 61 additions & 0 deletions modules/proto/rollkitsdk/rollkitmngr/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
syntax = "proto3";
package rollkitsdk.rollkitmngr.v1;

import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "rollkitsdk/rollkitmngr/v1/types.proto";

option go_package = "github.com/rollkit/go-execution-abci/modules/rollkitmngr/types";

// Query defines the gRPC querier service.
service Query {
// IsMigrating queries the sequencer changes.
rpc IsMigrating(QueryIsMigratingRequest) returns (QueryIsMigratingResponse) {
option (google.api.http).get = "/rollkit/rollkitmngr/v1/is_migrating";
}

// Sequencer queries the sequencer.
rpc Sequencer(QuerySequencerRequest) returns (QuerySequencerResponse) {
option (google.api.http).get = "/rollkit/rollkitmngr/v1/sequencer";
}

// Attesters queries the list of attesters.
rpc Attesters(QueryAttestersRequest) returns (QueryAttestersResponse) {
option (google.api.http).get = "/rollkit/rollkitmngr/v1/attesters";
}
}

// QueryIsMigratingRequest is request type for the Query/IsMigrating RPC method.
message QueryIsMigratingRequest {}

// QueryIsMigratingResponse is response type for the Query/IsMigrating RPC method.
message QueryIsMigratingResponse {
// is_migrating indicates whether the chain is migrating to rollkit.
bool is_migrating = 1;

// start_block_height is the block height at which the migration will start.
uint64 start_block_height = 2;

// end_block_height is the block height at which the migration will end.
uint64 end_block_height = 3;
}

// QuerySequencerRequest is request type for the Query/Sequencer RPC method.
message QuerySequencerRequest {}

// QuerySequencerResponse is response type for the Query/Sequencer RPC method.
message QuerySequencerResponse {
// sequencer is the requested sequencer.
Sequencer sequencer = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

// QueryAttestersRequest is request type for the Query/Attesters RPC method.
message QueryAttestersRequest {}

// QueryAttestersResponse is response type for the Query/Attesters RPC method.
message QueryAttestersResponse {
// attesters is the list of attesters.
repeated Attester attesters = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}
66 changes: 66 additions & 0 deletions modules/proto/rollkitsdk/rollkitmngr/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
syntax = "proto3";
package rollkitsdk.rollkitmngr.v1;

import "amino/amino.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "rollkitsdk/rollkitmngr/v1/types.proto";

option go_package = "github.com/rollkit/go-execution-abci/modules/rollkitmngr/types";

// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

// MigrateToRollkit defines a (governance) operation for the migration to rollkit. The authority defaults to the x/gov module account.
rpc MigrateToRollkit(MsgMigrateToRollkit) returns (MsgMigrateToRollkitResponse);

// EditAttesters defines a governance operation to edit the list of attesters.
rpc EditAttesters(MsgEditAttesters) returns (MsgEditAttestersResponse);
}

// MsgMigrateToRollkit is the Msg/MsgMigrateToRollkit request type.
message MsgMigrateToRollkit {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "rollkitmngr/v1/MsgMigrateToRollkit";

// authority is the address that controls the module (defaults to x/gov unless
// overwritten).
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// block height that trigger the rollkit migration.
// When IBC is enabled, the migration can take several blocks to complete.
// This is the block height at which the migration will be triggered.
uint64 block_height = 2;

// sequencer is the pubkey that will become new sequencer.
Sequencer sequencer = 3
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// attesters is the list of attesters that will attest to blocks.
repeated Attester attesters = 4
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgMigrateToRollkitResponse defines the response structure for executing a
// MsgRollkitMigrate message.
message MsgMigrateToRollkitResponse {};

// MsgEditAttesters is the Msg/EditAttesters request type.
message MsgEditAttesters {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "rollkitmngr/v1/MsgEditAttesters";

// authority is the address that controls the module (defaults to x/gov unless
// overwritten).
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// attesters is the list of attesters to add or remove.
repeated Attester attesters = 2
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgEditAttestersResponse defines the response structure for executing a
// MsgEditAttesters message.
message MsgEditAttestersResponse {};
48 changes: 48 additions & 0 deletions modules/proto/rollkitsdk/rollkitmngr/v1/types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
syntax = "proto3";
package rollkitsdk.rollkitmngr.v1;

import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/rollkit/go-execution-abci/modules/rollkitmngr/types";

// RollkitMigration defines the migration state from cometbft to rollkit.
message RollkitMigration {
// block height that trigger the rollkit migration.
// When IBC is enabled, the migration can take several blocks to complete.
// This is the block height at which the migration will be triggered.
uint64 block_height = 2;

// sequencer is the pubkey that will become new sequencer.
Sequencer sequencer = 3
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// attesters is the list of attesters that will attest to blocks.
repeated Attester attesters = 4
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// Sequencer defines a sequence of instructions to be executed.
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update misleading comment for Sequencer message.

The comment "defines a sequence of instructions to be executed" is misleading. In blockchain context, a sequencer is typically an entity that orders transactions, not a sequence of instructions.

-// Sequencer defines a sequence of instructions to be executed.
+// Sequencer defines an entity responsible for ordering and producing blocks.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Sequencer defines a sequence of instructions to be executed.
// Sequencer defines an entity responsible for ordering and producing blocks.
🤖 Prompt for AI Agents
In modules/proto/rollkitsdk/rollkitmngr/v1/types.proto at line 27, update the
comment for the Sequencer message to accurately reflect its role as an entity
that orders transactions in the blockchain context, rather than describing it as
a sequence of instructions to be executed. Replace the misleading comment with
one that clearly states the Sequencer's function in ordering transactions.

message Sequencer {
// name is the human-readable name of the sequencer.
string name = 1;

// consensus_pubkey is the consensus public key of the sequencer, as a
// Protobuf Any.
google.protobuf.Any consensus_pubkey = 2
[ (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey" ];
}


// Attester defines an attester that can attest to blocks.
message Attester {
// name is the human-readable name of the attester.
string name = 1;

// consensus_pubkey is the consensus public key of the attester, as a
// Protobuf Any.
google.protobuf.Any consensus_pubkey = 2
[ (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey" ];
}
41 changes: 0 additions & 41 deletions modules/proto/rollkitsdk/sequencer/v1/query.proto

This file was deleted.

39 changes: 0 additions & 39 deletions modules/proto/rollkitsdk/sequencer/v1/tx.proto

This file was deleted.

29 changes: 0 additions & 29 deletions modules/proto/rollkitsdk/sequencer/v1/types.proto

This file was deleted.

Loading
Loading