Skip to content

Commit

Permalink
Merge pull request #569 from PeggyJV/collin/v5-upgrade
Browse files Browse the repository at this point in the history
v5 Upgrade
  • Loading branch information
cbrit authored Oct 9, 2024
2 parents 93e4d83 + 01d5b58 commit 198cad6
Show file tree
Hide file tree
Showing 62 changed files with 291 additions and 249 deletions.
8 changes: 4 additions & 4 deletions integration_tests/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"
"github.com/peggyjv/gravity-bridge/module/v4/app"
"github.com/peggyjv/gravity-bridge/module/v4/app/params"
gravityclient "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/client"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/app"
"github.com/peggyjv/gravity-bridge/module/v5/app/params"
gravityclient "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/client"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

type EthereumConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/happy_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/ethereum/go-ethereum/common"
"github.com/ory/dockertest/v3"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

func (s *IntegrationTestSuite) TestHappyPath() {
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
"github.com/spf13/viper"
"github.com/stretchr/testify/suite"
)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/transaction_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/ethereum/go-ethereum/common"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

// We have 4 validators running so this totals to 100 tx's
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/peggyjv/gravity-bridge/module/v4/app"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/app"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

type validator struct {
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/validator_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/ethereum/go-ethereum/common"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

// Validator out tests a validator that is not running the mandatory Ethereum node. This validator will be slashed and the bridge will remain functioning.
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/valset_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
gravity "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravity "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

// call stress_test for a range of nonce values
Expand Down
2 changes: 1 addition & 1 deletion module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ lint:
### Protobuf ###
###############################################################################

protoVer=0.13.1
protoVer=0.15.1
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

Expand Down
19 changes: 13 additions & 6 deletions module/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ import (
icaexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/gorilla/mux"
gravityparams "github.com/peggyjv/gravity-bridge/module/v4/app/params"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity"
gravityclient "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/client"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/keeper"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravityparams "github.com/peggyjv/gravity-bridge/module/v5/app/params"
v5 "github.com/peggyjv/gravity-bridge/module/v5/app/upgrades/v5"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity"
gravityclient "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/client"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/keeper"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

Expand Down Expand Up @@ -922,5 +923,11 @@ func (app *Gravity) setupUpgradeStoreLoaders() {
}

func (app *Gravity) setupUpgradeHandlers() {

app.upgradeKeeper.SetUpgradeHandler(
v5.UpgradeName,
v5.CreateUpgradeHandler(
app.mm,
app.configurator,
),
)
}
2 changes: 1 addition & 1 deletion module/app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package app

import (
"github.com/cosmos/cosmos-sdk/std"
gravityparams "github.com/peggyjv/gravity-bridge/module/v4/app/params"
gravityparams "github.com/peggyjv/gravity-bridge/module/v5/app/params"
)

// MakeEncodingConfig creates an EncodingConfig for gravity.
Expand Down
2 changes: 1 addition & 1 deletion module/app/upgrades/v2/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

func CreateUpgradeHandler(
Expand Down
4 changes: 2 additions & 2 deletions module/app/upgrades/v2/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 4 additions & 0 deletions module/app/upgrades/v5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# v5 upgrade

This upgrade simply fixes the bug in the `SubmitEthereumTxConfirmation` message handler where `CompletedOutgoingTx`s were not checked and therefore could not be signed by orchestrators that failed to sign before the transaction was completed, resulting in jailing and slashing. Because this is a state breaking change, we bump the consensus version of the module.

4 changes: 4 additions & 0 deletions module/app/upgrades/v5/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package v5

// UpgradeName defines the on-chain upgrade name for the Gravity v5 upgrade
const UpgradeName = "v5"
18 changes: 18 additions & 0 deletions module/app/upgrades/v5/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v5

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("v5 upgrade: entering handler")

return mm.RunMigrations(ctx, configurator, fromVM)
}
}
2 changes: 1 addition & 1 deletion module/cmd/gravity/cmd/gentx.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/cosmos/cosmos-sdk/x/staking/client/cli"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

// GenTxCmd builds the application's gentx command.
Expand Down
4 changes: 2 additions & 2 deletions module/cmd/gravity/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/spf13/cast"
"github.com/spf13/cobra"

"github.com/peggyjv/gravity-bridge/module/v4/app"
"github.com/peggyjv/gravity-bridge/module/v4/app/params"
"github.com/peggyjv/gravity-bridge/module/v5/app"
"github.com/peggyjv/gravity-bridge/module/v5/app/params"
)

// NewRootCmd creates a new root command for simd. It is called once in the
Expand Down
2 changes: 1 addition & 1 deletion module/cmd/gravity/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/peggyjv/gravity-bridge/module/v4/app"
"github.com/peggyjv/gravity-bridge/module/v5/app"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion module/cmd/gravity/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"

"github.com/cosmos/cosmos-sdk/server"
"github.com/peggyjv/gravity-bridge/module/v4/cmd/gravity/cmd"
"github.com/peggyjv/gravity-bridge/module/v5/cmd/gravity/cmd"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion module/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/peggyjv/gravity-bridge/module/v4
module github.com/peggyjv/gravity-bridge/module/v5

go 1.22

Expand Down
4 changes: 2 additions & 2 deletions module/proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 4ed3bc159a8b4ac68fe253218760d035
digest: shake256:7149cf5e9955c692d381e557830555d4e93f205a0f1b8e2dfdae46d029369aa3fc1980e35df0d310f7cc3b622f93e19ad276769a283a967dd3065ddfd3a40e13
commit: e7f8d366f5264595bcc4cd4139af9973
digest: shake256:e5e5f1c12f82e028ea696faa43b4f9dc6258a6d1226282962a8c8b282e10946281d815884f574bd279ebd9cd7588629beb3db17b892af6c33b56f92f8f67f509
2 changes: 1 addition & 1 deletion module/proto/gravity/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "gravity/v1/gravity.proto";
import "gravity/v1/msgs.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types";
option go_package = "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types";
option (gogoproto.messagename_all) = true;

// Params represent the Gravity genesis and store parameters
Expand Down
2 changes: 1 addition & 1 deletion module/proto/gravity/v1/gravity.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types";
option go_package = "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types";
option (gogoproto.messagename_all) = true;

// EthereumEventVoteRecord is an event that is pending of confirmation by 2/3 of
Expand Down
6 changes: 3 additions & 3 deletions module/proto/gravity/v1/msgs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types";
option go_package = "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types";
option (gogoproto.messagename_all) = true;

// Msg defines the state transitions possible within gravity
service Msg {
option (cosmos.msg.v1.service) = true;

rpc SendToEthereum(MsgSendToEthereum) returns (MsgSendToEthereumResponse) {
// option (google.api.http).post = "/gravity/v1/send_to_ethereum";
}
Expand Down Expand Up @@ -129,7 +129,7 @@ message MsgSubmitEthereumEventResponse {}
// to a given orchestrator address. This key is then used as an optional
// authentication method for attesting events from Ethereum.
message MsgDelegateKeys {
option (cosmos.msg.v1.signer) = "validator_address";
option (cosmos.msg.v1.signer) = "validator_address";
option (amino.name) = "gravity/MsgDelegateKeys";

string validator_address = 1;
Expand Down
4 changes: 2 additions & 2 deletions module/proto/gravity/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "gravity/v1/genesis.proto";
import "gravity/v1/gravity.proto";
import "gravity/v1/msgs.proto";

option go_package = "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types";
option go_package = "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types";
option (gogoproto.messagename_all) = true;

// Query defines the gRPC querier service
Expand All @@ -30,7 +30,7 @@ service Query {
option (google.api.http).get = "/gravity/v1/signer_set_txs/latest";
}
rpc BatchTx(BatchTxRequest) returns (BatchTxResponse) {
option (google.api.http).get = "/gravity/v1/batch_txs/{token_contract}/{batch_nonce}";
option (google.api.http).get = "/gravity/v1/batch_txs/{token_contract}/{batch_nonce}";
}
rpc ContractCallTx(ContractCallTxRequest) returns (ContractCallTxResponse) {
option (google.api.http).get = "/gravity/v1/contract_call_txs/{invalidation_scope}/{invalidation_nonce}";
Expand Down
4 changes: 2 additions & 2 deletions module/x/gravity/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

// BeginBlocker is called at the beginning of every block
Expand Down
6 changes: 3 additions & 3 deletions module/x/gravity/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"

"github.com/peggyjv/gravity-bridge/module/v4/x/gravity"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

func TestSignerSetTxCreationIfNotAvailable(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion module/x/gravity/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion module/x/gravity/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/spf13/cobra"

"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

func GetTxCmd(storeKey string) *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion module/x/gravity/client/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io/ioutil"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

// ParseCommunityPoolEthereumSpendProposal reads and parses a CommunityPoolEthereumSpendProposalForCLI from a file.
Expand Down
2 changes: 1 addition & 1 deletion module/x/gravity/client/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package client

import (
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/client/cli"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/client/cli"
)

// ProposalHandler is the community Ethereum spend proposal handler.
Expand Down
8 changes: 4 additions & 4 deletions module/x/gravity/cosmos_originated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/peggyjv/gravity-bridge/module/v4/app"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/app"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

// Have the validators put in a erc20<>denom relation with ERC20DeployedEvent
Expand Down
4 changes: 2 additions & 2 deletions module/x/gravity/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

// NewHandler returns a handler for "Gravity" type messages.
Expand Down
8 changes: 4 additions & 4 deletions module/x/gravity/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"github.com/stretchr/testify/require"

ethCrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/peggyjv/gravity-bridge/module/v4/app"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/app"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/keeper"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

func TestHandleMsgSendToEthereum(t *testing.T) {
Expand Down
Loading

0 comments on commit 198cad6

Please sign in to comment.