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

chore: backport attestation enforcement #1098

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions proto/palomachain/paloma/consensus/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package palomachain.paloma.consensus;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "palomachain/paloma/consensus/consensus_queue.proto";
import "palomachain/paloma/consensus/params.proto";
import "google/protobuf/any.proto";

Expand Down Expand Up @@ -42,6 +43,13 @@ service Query {
"/palomachain/paloma/consensus/messages_in_queue/{queueTypeName}";
}

// Queries one message by ID.
rpc MessageByID(QueryMessageByIDRequest)
returns (MessageWithSignatures) {
option (google.api.http).get =
"/palomachain/paloma/consensus/{queueTypeName}/message/{id}";
}

// Queries a list of GetAllQueueNames items.
rpc GetAllQueueNames(QueryGetAllQueueNamesRequest)
returns (QueryGetAllQueueNamesResponse) {
Expand Down Expand Up @@ -94,6 +102,12 @@ message MessageWithSignatures {
bytes bytesToSign = 5;
bytes publicAccessData = 6;
bytes errorData = 7;
repeated Evidence evidence = 8;
}

message QueryMessageByIDRequest {
string queueTypeName = 1;
uint64 id = 2;
}

message QueryMessagesInQueueRequest {
Expand Down
13 changes: 0 additions & 13 deletions proto/palomachain/paloma/consensus/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ option go_package = "github.com/palomachain/paloma/x/consensus/types";
service Msg {
rpc AddMessagesSignatures(MsgAddMessagesSignatures)
returns (MsgAddMessagesSignaturesResponse);
rpc DeleteJob(MsgDeleteJob) returns (MsgDeleteJobResponse);
rpc AddEvidence(MsgAddEvidence) returns (MsgAddEvidenceResponse);
rpc SetPublicAccessData(MsgSetPublicAccessData)
returns (MsgSetPublicAccessDataResponse);
Expand All @@ -37,18 +36,6 @@ message ConsensusMessageSignature {

message MsgAddMessagesSignaturesResponse {}

message MsgDeleteJob {
option (cosmos.msg.v1.signer) = "metadata";
reserved 1;
reserved "creator";
string queueTypeName = 2;
uint64 messageID = 3;
palomachain.paloma.valset.MsgMetadata metadata = 4
[ (gogoproto.nullable) = false ];
}

message MsgDeleteJobResponse {}

message MsgAddEvidence {
option (cosmos.msg.v1.signer) = "metadata";
reserved 1;
Expand Down
3 changes: 2 additions & 1 deletion testutil/keeper/concensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/palomachain/paloma/x/consensus/keeper"
"github.com/palomachain/paloma/x/consensus/types"
"github.com/palomachain/paloma/x/consensus/types/mocks"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -44,7 +45,7 @@ func ConsensusKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
appCodec,
runtime.NewKVStoreService(storeKey),
paramsSubspace,
nil,
mocks.NewValsetKeeper(t),
keeper.NewRegistry(),
)

Expand Down
7 changes: 5 additions & 2 deletions testutil/keeper/evm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package keeper

import (
"testing"

"cosmossdk.io/log"
"cosmossdk.io/store"
"cosmossdk.io/store/metrics"
Expand All @@ -15,10 +17,11 @@ import (
params2 "github.com/palomachain/paloma/app/params"
"github.com/palomachain/paloma/x/evm/keeper"
"github.com/palomachain/paloma/x/evm/types"
"github.com/palomachain/paloma/x/evm/types/mocks"
"github.com/stretchr/testify/require"
)

func EvmKeeper(t require.TestingT) (*keeper.Keeper, sdk.Context) {
func EvmKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
storeKey := storetypes.NewKVStoreKey(types.StoreKey)
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)

Expand All @@ -35,7 +38,7 @@ func EvmKeeper(t require.TestingT) (*keeper.Keeper, sdk.Context) {
cdc,
runtime.NewKVStoreService(storeKey),
nil,
nil,
mocks.NewValsetKeeper(t),
authcodec.NewBech32Codec(params2.ValidatorAddressPrefix),
)

Expand Down
12 changes: 12 additions & 0 deletions util/liblog/liblog.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package liblog

import (
"context"

"cosmossdk.io/log"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type Logr interface {
Expand All @@ -12,6 +15,15 @@ type Logr interface {
WithValidator(string) Logr
}

type LogProvider interface {
Logger(sdk.Context) log.Logger
}

func FromKeeper(ctx context.Context, p LogProvider) Logr {
sdkCtx := sdk.UnwrapSDKContext(ctx)
return FromSDKLogger(p.Logger(sdkCtx))
}

func FromSDKLogger(l log.Logger) Logr {
return &lgwr{l}
}
Expand Down
2 changes: 1 addition & 1 deletion x/consensus/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
cmd.AddCommand(CmdQueryParams())
cmd.AddCommand(CmdQueuedMessagesForSigning())
cmd.AddCommand(CmdMessagesInQueue())

cmd.AddCommand(CmdMessageByID())
cmd.AddCommand(CmdGetAllQueueNames())

return cmd
Expand Down
38 changes: 38 additions & 0 deletions x/consensus/client/cli/query_messages_in_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,41 @@ func CmdMessagesInQueue() *cobra.Command {

return cmd
}

func CmdMessageByID() *cobra.Command {
cmd := &cobra.Command{
Use: "message-by-id [queue-type-name] [message-id]",
Short: "Query a message by queue name and ID",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
reqQueueTypeName := args[0]
reqID, err := strconv.ParseUint(args[1], 10, 64)
if err != nil {
return err
}

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryMessageByIDRequest{
QueueTypeName: reqQueueTypeName,
Id: reqID,
}

res, err := queryClient.MessageByID(cmd.Context(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
1 change: 0 additions & 1 deletion x/consensus/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func GetTxCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

cmd.AddCommand(CmdDeleteJob())
cmd.AddCommand(CmdSetPublicAccessData())

return cmd
Expand Down
48 changes: 0 additions & 48 deletions x/consensus/client/cli/tx_delete_job.go

This file was deleted.

2 changes: 1 addition & 1 deletion x/consensus/keeper/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (k Keeper) PruneOldMessages(ctx sdk.Context, blocksAgo int64) error {
}

for _, msg := range msgs {
err = k.DeleteJob(ctx, opt.QueueTypeName, msg.GetId())
err = k.PruneJob(ctx, opt.QueueTypeName, msg.GetId())
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion x/consensus/keeper/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/palomachain/paloma/x/consensus/keeper/consensus"
"github.com/palomachain/paloma/x/consensus/types"
valsettypes "github.com/palomachain/paloma/x/valset/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

Expand All @@ -21,7 +23,7 @@ func TestDeleteOldMessages(t *testing.T) {
name: "deletes messages over a number of blocks ago, but not messages under",
blocksAgo: 50,
setup: func() (Keeper, sdk.Context, string) {
k, _, ctx := newConsensusKeeper(t)
k, ms, ctx := newConsensusKeeper(t)
queue := types.Queue(defaultQueueName, chainType, chainReferenceID)

msgType := &types.SimpleMessage{}
Expand Down Expand Up @@ -62,6 +64,7 @@ func TestDeleteOldMessages(t *testing.T) {

// Advance to block 61
ctx = ctx.WithBlockHeight(61)
ms.ValsetKeeper.On("GetCurrentSnapshot", mock.Anything).Return(&valsettypes.Snapshot{}, nil)

return *k, ctx, queue
},
Expand Down
Loading
Loading