From 43db5fdd831f0b78578bdc1a7f0f45f7a43af783 Mon Sep 17 00:00:00 2001 From: faultytolly <137398096+faultytolly@users.noreply.github.com> Date: Tue, 29 Oct 2024 18:03:22 +0100 Subject: [PATCH] feat(sequencer): support rotation misbehavior detection (#1345) Co-authored-by: unknown Co-authored-by: Faulty Tolly <@faulttolerance.net> Co-authored-by: Omri --- .../dymension/rollapp/state_info.proto | 3 + .../{types => keeper}/expected_keepers.go | 4 +- x/rollapp/keeper/keeper.go | 28 ++-- x/rollapp/keeper/liveness_test.go | 5 + x/rollapp/keeper/msg_server_update_state.go | 10 +- x/rollapp/types/state_info.go | 2 + x/rollapp/types/state_info.pb.go | 124 +++++++++++++----- 7 files changed, 125 insertions(+), 51 deletions(-) rename x/rollapp/{types => keeper}/expected_keepers.go (87%) diff --git a/proto/dymensionxyz/dymension/rollapp/state_info.proto b/proto/dymensionxyz/dymension/rollapp/state_info.proto index 1794e2224..bba1383d2 100644 --- a/proto/dymensionxyz/dymension/rollapp/state_info.proto +++ b/proto/dymensionxyz/dymension/rollapp/state_info.proto @@ -53,6 +53,9 @@ message StateInfo { (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"created_at\"" ]; + + // next sequencer is the bech32-encoded address of the next sequencer after the current sequencer + string nextProposer = 11; } // StateInfoSummary is a compact representation of StateInfo diff --git a/x/rollapp/types/expected_keepers.go b/x/rollapp/keeper/expected_keepers.go similarity index 87% rename from x/rollapp/types/expected_keepers.go rename to x/rollapp/keeper/expected_keepers.go index 5286cb3d1..c039c51d1 100644 --- a/x/rollapp/types/expected_keepers.go +++ b/x/rollapp/keeper/expected_keepers.go @@ -1,8 +1,9 @@ -package types +package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v7/modules/core/exported" + "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) type AccountKeeper interface { @@ -21,6 +22,7 @@ type ChannelKeeper interface { type SequencerKeeper interface { SlashLiveness(ctx sdk.Context, rollappID string) error JailLiveness(ctx sdk.Context, rollappID string) error + GetProposer(ctx sdk.Context, rollappId string) (val types.Sequencer, found bool) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/rollapp/keeper/keeper.go b/x/rollapp/keeper/keeper.go index 542b057ea..d81ef7ae9 100644 --- a/x/rollapp/keeper/keeper.go +++ b/x/rollapp/keeper/keeper.go @@ -22,12 +22,12 @@ type Keeper struct { paramstore paramtypes.Subspace authority string // authority is the x/gov module account - accKeeper types.AccountKeeper - ibcClientKeeper types.IBCClientKeeper - canonicalClientKeeper types.CanonicalLightClientKeeper - channelKeeper types.ChannelKeeper - sequencerKeeper types.SequencerKeeper - bankKeeper types.BankKeeper + accKeeper AccountKeeper + ibcClientKeeper IBCClientKeeper + canonicalClientKeeper CanonicalLightClientKeeper + channelKeeper ChannelKeeper + sequencerKeeper SequencerKeeper + bankKeeper BankKeeper vulnerableDRSVersions collections.KeySet[string] registeredRollappDenoms collections.KeySet[collections.Pair[string, string]] @@ -39,13 +39,13 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ps paramtypes.Subspace, - ak types.AccountKeeper, - channelKeeper types.ChannelKeeper, - ibcclientKeeper types.IBCClientKeeper, - sequencerKeeper types.SequencerKeeper, - bankKeeper types.BankKeeper, + ak AccountKeeper, + channelKeeper ChannelKeeper, + ibcclientKeeper IBCClientKeeper, + sequencerKeeper SequencerKeeper, + bankKeeper BankKeeper, authority string, - canonicalClientKeeper types.CanonicalLightClientKeeper, + canonicalClientKeeper CanonicalLightClientKeeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -94,11 +94,11 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k *Keeper) SetSequencerKeeper(sk types.SequencerKeeper) { +func (k *Keeper) SetSequencerKeeper(sk SequencerKeeper) { k.sequencerKeeper = sk } -func (k *Keeper) SetCanonicalClientKeeper(kk types.CanonicalLightClientKeeper) { +func (k *Keeper) SetCanonicalClientKeeper(kk CanonicalLightClientKeeper) { k.canonicalClientKeeper = kk } diff --git a/x/rollapp/keeper/liveness_test.go b/x/rollapp/keeper/liveness_test.go index 870403b6c..96693362e 100644 --- a/x/rollapp/keeper/liveness_test.go +++ b/x/rollapp/keeper/liveness_test.go @@ -14,6 +14,7 @@ import ( keepertest "github.com/dymensionxyz/dymension/v3/testutil/keeper" "github.com/dymensionxyz/dymension/v3/x/rollapp/keeper" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" + seqtypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types" ) func TestLivenessArithmetic(t *testing.T) { @@ -207,6 +208,10 @@ func (l livenessMockSequencerKeeper) JailLiveness(ctx sdk.Context, rollappID str return nil } +func (l livenessMockSequencerKeeper) GetProposer(ctx sdk.Context, rollappId string) (val seqtypes.Sequencer, found bool) { + return seqtypes.Sequencer{}, false +} + func (l livenessMockSequencerKeeper) clear(rollappID string) { delete(l.slashes, rollappID) delete(l.jails, rollappID) diff --git a/x/rollapp/keeper/msg_server_update_state.go b/x/rollapp/keeper/msg_server_update_state.go index 25b752383..0d6299ca6 100644 --- a/x/rollapp/keeper/msg_server_update_state.go +++ b/x/rollapp/keeper/msg_server_update_state.go @@ -97,6 +97,11 @@ func (k msgServer) UpdateState(goCtx context.Context, msg *types.MsgUpdateState) Index: newIndex, }) + // it takes the actual proposer because the next one have already been set + // by the sequencer rotation in k.hooks.BeforeUpdateState + // the proposer we get is the one that will propose the next block. + val, _ := k.sequencerKeeper.GetProposer(ctx, msg.RollappId) + creationHeight := uint64(ctx.BlockHeight()) blockTime := ctx.BlockTime() stateInfo := types.NewStateInfo( @@ -109,6 +114,7 @@ func (k msgServer) UpdateState(goCtx context.Context, msg *types.MsgUpdateState) creationHeight, msg.BDs, blockTime, + val.Address, ) // Write new state information to the store indexed by k.SetStateInfo(ctx, *stateInfo) @@ -138,9 +144,11 @@ func (k msgServer) UpdateState(goCtx context.Context, msg *types.MsgUpdateState) // https://github.com/dymensionxyz/dymension/issues/1085 k.IndicateLiveness(ctx, &rollapp) + events := stateInfo.GetEvents() + ctx.EventManager().EmitEvent( sdk.NewEvent(types.EventTypeStateUpdate, - stateInfo.GetEvents()..., + events..., ), ) diff --git a/x/rollapp/types/state_info.go b/x/rollapp/types/state_info.go index b724eb545..b4909796d 100644 --- a/x/rollapp/types/state_info.go +++ b/x/rollapp/types/state_info.go @@ -19,6 +19,7 @@ func NewStateInfo( height uint64, BDs BlockDescriptors, createdAt time.Time, + nextProposer string, ) *StateInfo { stateInfoIndex := StateInfoIndex{RollappId: rollappId, Index: newIndex} status := common.Status_PENDING @@ -32,6 +33,7 @@ func NewStateInfo( Status: status, BDs: BDs, CreatedAt: createdAt, + NextProposer: nextProposer, } } diff --git a/x/rollapp/types/state_info.pb.go b/x/rollapp/types/state_info.pb.go index 6c357435a..1a9a963f6 100644 --- a/x/rollapp/types/state_info.pb.go +++ b/x/rollapp/types/state_info.pb.go @@ -112,6 +112,9 @@ type StateInfo struct { BDs BlockDescriptors `protobuf:"bytes,9,opt,name=BDs,proto3" json:"BDs"` // created_at is the timestamp at which the StateInfo was created CreatedAt time.Time `protobuf:"bytes,10,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at" yaml:"created_at"` + // next sequencer is the bech32-encoded address of the next sequencer after the current sequencer + // if empty, it means there is no change in the sequencer + NextProposer string `protobuf:"bytes,11,opt,name=nextProposer,proto3" json:"nextProposer,omitempty"` } func (m *StateInfo) Reset() { *m = StateInfo{} } @@ -210,6 +213,13 @@ func (m *StateInfo) GetCreatedAt() time.Time { return time.Time{} } +func (m *StateInfo) GetNextProposer() string { + if m != nil { + return m.NextProposer + } + return "" +} + // StateInfoSummary is a compact representation of StateInfo type StateInfoSummary struct { // stateInfoIndex defines what rollapp the state belongs to @@ -343,42 +353,43 @@ func init() { } var fileDescriptor_750f3a9f16533ec4 = []byte{ - // 549 bytes of a gzipped FileDescriptorProto + // 567 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x41, 0x6a, 0xdb, 0x40, - 0x14, 0xf5, 0xd8, 0x8e, 0x13, 0x4d, 0xc0, 0x24, 0x43, 0x28, 0xc2, 0xb4, 0xb2, 0x11, 0xb4, 0x98, - 0x2e, 0xa4, 0x92, 0xb4, 0x9b, 0x42, 0x17, 0x31, 0xa6, 0xc4, 0x5d, 0x94, 0x56, 0xc9, 0xa2, 0x94, - 0x82, 0x19, 0x5b, 0x63, 0x79, 0xa8, 0x34, 0xa3, 0x6a, 0x46, 0xc5, 0xca, 0x29, 0x72, 0x90, 0x1e, - 0x24, 0xcb, 0xec, 0xda, 0x55, 0x5a, 0xec, 0x0b, 0x94, 0x9e, 0xa0, 0x68, 0xa4, 0x48, 0x89, 0x63, - 0x37, 0x10, 0xe8, 0x4e, 0xff, 0xeb, 0xbf, 0xc7, 0xfb, 0xef, 0x7d, 0x06, 0xda, 0x6e, 0x12, 0x10, - 0x26, 0x28, 0x67, 0xb3, 0xe4, 0xb4, 0x2c, 0xec, 0x88, 0xfb, 0x3e, 0x0e, 0x43, 0x5b, 0x48, 0x2c, - 0xc9, 0x90, 0xb2, 0x09, 0xb7, 0xc2, 0x88, 0x4b, 0x8e, 0x8c, 0xeb, 0x00, 0xab, 0x28, 0xac, 0x1c, - 0xd0, 0xda, 0xf3, 0xb8, 0xc7, 0xd5, 0xa8, 0x9d, 0x7e, 0x65, 0xa8, 0x56, 0xdb, 0xe3, 0xdc, 0xf3, - 0x89, 0xad, 0xaa, 0x51, 0x3c, 0xb1, 0x25, 0x0d, 0x88, 0x90, 0x38, 0x08, 0xf3, 0x81, 0x17, 0x77, - 0xe8, 0x18, 0xf9, 0x7c, 0xfc, 0x79, 0xe8, 0x12, 0x31, 0x8e, 0x68, 0x28, 0x79, 0x94, 0xc3, 0x9e, - 0xae, 0x81, 0x8d, 0x79, 0x10, 0x70, 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05, 0x05, 0x00, 0x00, + 0x14, 0xf5, 0xc4, 0x8e, 0x13, 0x8d, 0x8b, 0x49, 0x86, 0x50, 0x84, 0x69, 0x65, 0x23, 0x68, 0x31, + 0x5d, 0x48, 0x25, 0x69, 0x37, 0x85, 0x2e, 0x62, 0x4c, 0x89, 0xbb, 0x28, 0xa9, 0x92, 0x45, 0x29, + 0x05, 0x33, 0xb6, 0xc7, 0xf2, 0x50, 0x69, 0x46, 0x9d, 0x19, 0x15, 0x3b, 0xa7, 0xc8, 0xa2, 0xc7, + 0xe8, 0x41, 0xb2, 0xcc, 0xae, 0x5d, 0xa5, 0xc5, 0xbe, 0x41, 0x4f, 0x50, 0x34, 0x52, 0xac, 0xd8, + 0xb1, 0x1b, 0x08, 0x74, 0xa7, 0xff, 0xf4, 0xdf, 0xe3, 0xfd, 0xf7, 0x3f, 0x03, 0xdd, 0xc1, 0x24, + 0x24, 0x4c, 0x52, 0xce, 0xc6, 0x93, 0xb3, 0xbc, 0x70, 0x05, 0x0f, 0x02, 0x1c, 0x45, 0xae, 0x54, + 0x58, 0x91, 0x2e, 0x65, 0x43, 0xee, 0x44, 0x82, 0x2b, 0x8e, 0xac, 0x9b, 0x04, 0x67, 0x5e, 0x38, + 0x19, 0xa1, 0xb6, 0xe7, 0x73, 0x9f, 0xeb, 0x56, 0x37, 0xf9, 0x4a, 0x59, 0xb5, 0xba, 0xcf, 0xb9, + 0x1f, 0x10, 0x57, 0x57, 0xbd, 0x78, 0xe8, 0x2a, 0x1a, 0x12, 0xa9, 0x70, 0x18, 0x65, 0x0d, 0x2f, + 0xef, 0xf0, 0xd1, 0x0b, 0x78, 0xff, 0x73, 0x77, 0x40, 0x64, 0x5f, 0xd0, 0x48, 0x71, 0x91, 0xd1, + 0x9e, 0xad, 0xa1, 0xf5, 0x79, 0x18, 0x72, 0xa6, 0xdd, 0xc7, 0x32, 0xed, 0xb5, 0xdb, 0xb0, 0x7a, + 0x92, 0x4c, 0xd3, 0x61, 0x43, 0xde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 0x05, 0x00, 0x00, } func (m *StateInfoIndex) Marshal() (dAtA []byte, err error) { @@ -436,6 +447,13 @@ func (m *StateInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.NextProposer) > 0 { + i -= len(m.NextProposer) + copy(dAtA[i:], m.NextProposer) + i = encodeVarintStateInfo(dAtA, i, uint64(len(m.NextProposer))) + i-- + dAtA[i] = 0x5a + } n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CreatedAt, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CreatedAt):]) if err1 != nil { return 0, err1 @@ -645,6 +663,10 @@ func (m *StateInfo) Size() (n int) { n += 1 + l + sovStateInfo(uint64(l)) l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CreatedAt) n += 1 + l + sovStateInfo(uint64(l)) + l = len(m.NextProposer) + if l > 0 { + n += 1 + l + sovStateInfo(uint64(l)) + } return n } @@ -1058,6 +1080,38 @@ func (m *StateInfo) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextProposer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStateInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStateInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStateInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NextProposer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStateInfo(dAtA[iNdEx:])