Skip to content

Commit

Permalink
review pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mvid committed Jul 13, 2023
1 parent 0a5659c commit f5a3861
Show file tree
Hide file tree
Showing 34 changed files with 2,558 additions and 641 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ endif
# The below include contains the tools target.
include contrib/devtools/Makefile

###############################################################################
### Documentation ###
###############################################################################

all: install lint test

build: go.sum
Expand Down Expand Up @@ -137,7 +141,9 @@ sync-docs:
aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ;
.PHONY: sync-docs


###############################################################################
### Tests & Simulation ###
###############################################################################

test: test-unit test-build

Expand Down Expand Up @@ -197,7 +203,7 @@ proto-all: proto-format proto-lint proto-gen format

proto-gen:
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh
sh ./scripts/protocgen.sh

proto-format:
@echo "Formatting Protobuf files"
Expand All @@ -215,6 +221,8 @@ proto-check-breaking:
proto-version:
@$(protoImage) buf --version

.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps

#####################
# Integration tests #
#####################
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/peggyjv/sommelier/v6
go 1.18

require (
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.45.13
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.7
Expand Down Expand Up @@ -160,6 +159,7 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)

Expand Down
6 changes: 1 addition & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44=
github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU=
github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o=
github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I=
github.com/cosmos/cosmos-sdk v0.45.13 h1:5eNcMBL5avM80I1Zs3uPE2Pm95O+l9iuZU/CoP9rmzc=
github.com/cosmos/cosmos-sdk v0.45.13/go.mod h1:tpDFgc98sgRcLLRiosBSyos8EZoDHv1xab9HPLGLQJ4=
github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k=
Expand All @@ -217,7 +215,6 @@ github.com/cosmos/ibc-go/v3 v3.4.0 h1:ha3cqEG36pqMWqA1D+kxDWBTZXpeFMd/aZIQF7I0xr
github.com/cosmos/ibc-go/v3 v3.4.0/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA=
github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA=
github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI=
github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
Expand Down Expand Up @@ -923,7 +920,6 @@ github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKk
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8=
Expand Down Expand Up @@ -1443,10 +1439,10 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/peggyjv/sommelier/v6/x/axelarcork/types";

message Cork {
message AxelarCork {
// call body containing the ABI encoded bytes to send to the contract
bytes encoded_contract_call = 1;
// the chain ID of the evm target chain
Expand All @@ -14,26 +14,26 @@ message Cork {
string target_contract_address = 3;
}

message ScheduledCork {
Cork cork = 1;
message ScheduledAxelarCork {
AxelarCork cork = 1;
uint64 block_height = 2;
string validator = 3;
bytes id = 4;
}

message ScheduledCorks {
repeated ScheduledCork scheduled_corks = 1;
message ScheduledAxelarCorks {
repeated ScheduledAxelarCork scheduled_corks = 1;
}

message CorkResult {
Cork cork = 1;
message AxelarCorkResult {
AxelarCork cork = 1;
uint64 block_height = 2;
bool approved = 3;
string approval_percentage = 4;
}

message CorkResults {
repeated CorkResult cork_results = 1;
message AxelarCorkResults {
repeated AxelarCorkResult cork_results = 1;
}

message CellarIDSet {
Expand Down
9 changes: 4 additions & 5 deletions proto/axelarcork/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";
package axelarcork.v1;

import "axelarcork/v1/cork.proto";
import "axelarcork/v1/axelarcork.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/peggyjv/sommelier/v6/x/axelarcork/types";
Expand All @@ -10,10 +10,9 @@ option go_package = "github.com/peggyjv/sommelier/v6/x/axelarcork/types";
message GenesisState {
Params params = 1;
ChainConfigurations chain_configurations = 2 [(gogoproto.nullable) = false];
repeated uint64 invalidation_nonces = 3;
repeated CellarIDSet cellar_ids = 4;
repeated ScheduledCorks scheduled_corks = 5;
repeated CorkResults cork_results = 6;
repeated CellarIDSet cellar_ids = 3;
repeated ScheduledAxelarCorks scheduled_corks = 4;
repeated AxelarCorkResults cork_results = 5;
}

message Params {
Expand Down
2 changes: 1 addition & 1 deletion proto/axelarcork/v1/proposal.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";
package axelarcork.v1;

import "axelarcork/v1/cork.proto";
import "axelarcork/v1/axelarcork.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

Expand Down
12 changes: 6 additions & 6 deletions proto/axelarcork/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package axelarcork.v1;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "axelarcork/v1/genesis.proto";
import "axelarcork/v1/cork.proto";
import "axelarcork/v1/axelarcork.proto";

option go_package = "github.com/peggyjv/sommelier/v6/x/axelarcork/types";

Expand Down Expand Up @@ -79,7 +79,7 @@ message QueryScheduledCorksRequest {

// QueryScheduledCorksResponse
message QueryScheduledCorksResponse {
repeated ScheduledCork corks = 1;
repeated ScheduledAxelarCork corks = 1;
}

// QueryScheduledBlockHeightsRequest
Expand All @@ -102,7 +102,7 @@ message QueryScheduledCorksByBlockHeightRequest {

// QueryScheduledCorksByBlockHeightResponse
message QueryScheduledCorksByBlockHeightResponse {
repeated ScheduledCork corks = 1;
repeated ScheduledAxelarCork corks = 1;
}

// QueryScheduledCorksByIDRequest
Expand All @@ -114,7 +114,7 @@ message QueryScheduledCorksByIDRequest {

// QueryScheduledCorksByIDResponse
message QueryScheduledCorksByIDResponse {
repeated ScheduledCork corks = 1;
repeated ScheduledAxelarCork corks = 1;
}

message QueryCorkResultRequest {
Expand All @@ -124,7 +124,7 @@ message QueryCorkResultRequest {
}

message QueryCorkResultResponse {
CorkResult corkResult = 1;
AxelarCorkResult corkResult = 1;
}

message QueryCorkResultsRequest {
Expand All @@ -133,7 +133,7 @@ message QueryCorkResultsRequest {
}

message QueryCorkResultsResponse {
repeated CorkResult corkResults = 1;
repeated AxelarCorkResult corkResults = 1;
}

message QueryChainConfigurationsRequest {}
Expand Down
4 changes: 2 additions & 2 deletions proto/axelarcork/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";
package axelarcork.v1;

import "cosmos/base/v1beta1/coin.proto";
import "axelarcork/v1/cork.proto";
import "axelarcork/v1/axelarcork.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/peggyjv/sommelier/v6/x/axelarcork/types";
Expand All @@ -17,7 +17,7 @@ service Msg {
// MsgScheduleCorkRequest - sdk.Msg for scheduling a cork request for on or after a specific block height
message MsgScheduleAxelarCorkRequest {
// the scheduled cork
Cork cork = 1;
AxelarCork cork = 1;
// the chain name
string chain_name = 2;
// the chain id
Expand Down
18 changes: 9 additions & 9 deletions scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ echo "generating proto and gRPC gateway files..."

proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
for dir in $proto_dirs; do
buf protoc \
./buf protoc \
-I "proto" \
-I "third_party/proto" \
--gocosmos_out=plugins=interfacetype+grpc,\
Expand All @@ -27,14 +27,14 @@ Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \

done

echo "generating proto docs..."
# command to generate docs using protoc-gen-doc
buf protoc \
-I "proto" \
-I "third_party/proto" \
--doc_out=./docs/core \
--doc_opt=./docs/protodoc-markdown.tmpl,proto-docs.md \
$(find "$(pwd)/proto" -maxdepth 5 -name '*.proto')
#echo "generating proto docs..."
## command to generate docs using protoc-gen-doc
#./buf protoc \
#-I "proto" \
#-I "third_party/proto" \
#--doc_out=./docs/core \
#--doc_opt=./docs/protodoc-markdown.tmpl,proto-docs.md \
#$(find "$(pwd)/proto" -maxdepth 5 -name '*.proto')
go mod tidy

echo "(re)moving proto files.."
Expand Down
31 changes: 31 additions & 0 deletions x/axelarcork/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func GetQueryCmd() *cobra.Command {
queryScheduledCorksByID(),
queryCorkResult(),
queryCorkResults(),
queryChainConfigurations(),
}...)

return corkQueryCmd
Expand Down Expand Up @@ -347,3 +348,33 @@ func queryCorkResults() *cobra.Command {

return cmd
}

func queryChainConfigurations() *cobra.Command {
cmd := &cobra.Command{
Use: "chain-configurations",
Aliases: []string{"cfgs"},
Args: cobra.NoArgs,
Short: "query axelar chain configurations",
RunE: func(cmd *cobra.Command, _ []string) error {
ctx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(ctx)
req := &types.QueryChainConfigurationsRequest{}

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

return ctx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
AddChainFlagsToCmd(cmd)

return cmd
}
8 changes: 4 additions & 4 deletions x/axelarcork/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
func GetTxCmd() *cobra.Command {
corkTxCmd := &cobra.Command{
Use: "axelar-cork",
Short: "Axelar Cork transaction subcommands",
Short: "Axelar AxelarCork transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
Expand Down Expand Up @@ -207,7 +207,7 @@ $ %s tx gov submit-proposal schedule-cork <path/to/proposal.json> --from=<key_or
Where proposal.json contains:
{
"title": "Dollary-doos LP Scheduled Cork Proposal",
"title": "Dollary-doos LP Scheduled AxelarCork Proposal",
"description": "I trust them, approve cork",
"block_height": 100000,
"target_contract_address": "0x123801a7D398351b8bE11C439e05C5B3259aeC9B",
Expand Down Expand Up @@ -250,7 +250,7 @@ The contract_call_proto_json field must be the JSON representation of a Schedule
return err
}

content := types.NewScheduledCorkProposal(proposal.Title, proposal.Description, proposal.BlockHeight, name, chainID, proposal.TargetContractAddress, proposal.ContractCallProtoJson)
content := types.NewAxelarScheduledCorkProposal(proposal.Title, proposal.Description, proposal.BlockHeight, name, chainID, proposal.TargetContractAddress, proposal.ContractCallProtoJson)
if err := content.ValidateBasic(); err != nil {
return err
}
Expand Down Expand Up @@ -333,7 +333,7 @@ Where proposal.json contains:

from := clientCtx.GetFromAddress()

content := types.NewCommunitySpendProposal(proposal.Title, proposal.Description, proposal.Recipient, proposal.ChainId, proposal.ChainName, amount)
content := types.NewAxelarCommunitySpendProposal(proposal.Title, proposal.Description, proposal.Recipient, proposal.ChainId, proposal.ChainName, amount)

msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
Expand Down
Loading

0 comments on commit f5a3861

Please sign in to comment.