forked from palomachain/paloma
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: store lightnode activations (#1309)
# Related Github tickets - Closes #2250 - Closes #2251 - Closes #2252 # Background Keep an on-chain list of activated lightnodes. When a new node is activated, we add it to the list. To bootstrap the list with the existing lightnodes, we add a new transaction. This is instead of a governance vote, so we don't waste more time. The transaction can be executed at any time after the upgrade. For each lightnode we keep track of: address, activated timestamp, last authentication timestamp. This way we can also know which nodes are active and performing authentications. # Testing completed - [ ] test coverage exists or has been added/updated - [x] tested in a private testnet # Breaking changes - [x] I have checked my code for breaking changes - [x] If there are breaking changes, there is a supporting migration.
- Loading branch information
Showing
21 changed files
with
1,741 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
package palomachain.paloma.paloma; | ||
|
||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
option go_package = "github.com/palomachain/paloma/v2/x/paloma/types"; | ||
|
||
message LightNodeClient { | ||
string client_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
google.protobuf.Timestamp activated_at = 2 | ||
[ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; | ||
google.protobuf.Timestamp last_auth_at = 3 | ||
[ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/palomachain/paloma/v2/x/paloma/types" | ||
"github.com/spf13/cobra" | ||
"google.golang.org/protobuf/types/known/emptypb" | ||
) | ||
|
||
func CmdQueryLightNodeClients() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "light-node-clients", | ||
Short: "Shows information about all activated lightnode clients", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx := client.GetClientContextFromCmd(cmd) | ||
|
||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
params := &emptypb.Empty{} | ||
res, err := queryClient.GetLightNodeClients( | ||
context.Background(), params) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/palomachain/paloma/v2/x/paloma/types" | ||
"google.golang.org/protobuf/types/known/emptypb" | ||
) | ||
|
||
func (k Keeper) GetLightNodeClients( | ||
c context.Context, | ||
_ *emptypb.Empty, | ||
) (*types.QueryLightNodeClientsResponse, error) { | ||
ctx := sdk.UnwrapSDKContext(c) | ||
|
||
clients, err := k.AllLightNodeClients(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &types.QueryLightNodeClientsResponse{ | ||
LightNodeClients: clients, | ||
}, nil | ||
} |
Oops, something went wrong.