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

GMP message handler #27

Merged
merged 44 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f2aa6db
Update Makefile
lukitsbrian Sep 25, 2023
de15c99
update address prefix
lukitsbrian Sep 26, 2023
aa8ee79
Update Makefile
lukitsbrian Oct 3, 2023
f371980
update readme
lukitsbrian Oct 18, 2023
9e24948
Revert "Add provider module (#1)"
lukitsbrian Oct 18, 2023
3b1fa8f
Merge branch 'main' into mainnet-v1
lukitsbrian Oct 18, 2023
0805f08
update readme.md
lukitsbrian Oct 18, 2023
5da58ef
use tsaga denom
lukitsbrian Oct 19, 2023
bbd4602
[readme] Fix wrong min go version in readme
emanuelconunaemme Oct 24, 2023
ab6d59c
[docker] Add Dockerfile (#4)
emanuelconunaemme Oct 24, 2023
9a8eb25
Bump ibc-go dependency (#5)
luckychess Oct 26, 2023
d4e3e66
versioning (#6)
lukitsbrian Oct 30, 2023
32aa4da
[docker] Add bash to docker image (#7)
emanuelconunaemme Mar 21, 2024
98d3e34
[ci][docker] Push multi-platform docker image (#8)
emanuelconunaemme Mar 21, 2024
96d4c4c
Fix hardcoded version in the build command (#9)
rkollar Apr 1, 2024
26aaa98
Enable ledger by default in Makefile (#10)
lukitsbrian Apr 1, 2024
94b3353
Initial commit for public repo standards (#15)
ashishchandr70 Jul 12, 2024
18af01b
Upgrade to cosmos-sdk v0.50
rkollar Sep 17, 2024
6bc6398
Feature/ibc packet forward (#22)
luckychess Sep 19, 2024
e6a8ea2
Update commands setup
rkollar Sep 20, 2024
5ed7a57
First test of gmp module
luckychess Nov 12, 2024
2a81e3c
app.go fixes again
luckychess Nov 18, 2024
6ef92d8
A proper GMP message processing
luckychess Nov 19, 2024
81b99e9
base64 payload decoding
luckychess Nov 19, 2024
bbae37b
fix base64 payload decoding
luckychess Nov 20, 2024
7ff7011
fix payload decoding
luckychess Nov 20, 2024
1556e15
Fix payload handling
luckychess Nov 20, 2024
05f80cb
code cleanup
luckychess Nov 26, 2024
587e4ca
Fix GMP module initialization
luckychess Nov 28, 2024
029b459
even more debug logs (and fix attempt)
luckychess Nov 28, 2024
387923b
Do not do any additional checks in gmp module
luckychess Nov 28, 2024
5651a10
Fix GMP payload encoding
luckychess Dec 5, 2024
7322d57
Fix GMP payload encoding (again)
luckychess Dec 5, 2024
cb8aa32
Fix GMP payload encoding (with padding)
luckychess Dec 5, 2024
86fcb74
Simplify payload parsing
luckychess Dec 5, 2024
2107947
Code clean up
luckychess Dec 5, 2024
626a2d6
Some logs
luckychess Dec 6, 2024
d9994bc
Some more logs
luckychess Dec 6, 2024
ae46844
Merge branch 'release/0.2' into feature/gmp2
luckychess Dec 6, 2024
ba4eea0
Remove TODO about axelar GMP account
luckychess Dec 6, 2024
b5af954
Add missing ssc/tx.proto and fix annotation warnings
luckychess Dec 6, 2024
aed673f
Handler for 0.1->0.2 upgrade (#28)
luckychess Dec 11, 2024
a5ccc7a
Review fixes
luckychess Dec 11, 2024
ae37042
Do not do padding in GMP handler
luckychess Dec 11, 2024
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
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
ARG GO_VERSION="1.20"
ARG RUNNER_IMAGE="golang:${GO_VERSION}-alpine3.17"
ARG GO_VERSION="1.22.5"
FROM golang:${GO_VERSION}-bookworm AS build-env
ARG GITHUB_USER
ARG GITHUB_TOKEN

FROM golang:${GO_VERSION}-bullseye AS build-env

WORKDIR /go/src/github.com/sagaxyz/sagacli
WORKDIR /root

RUN apt-get update -y

COPY . .

RUN git config --global --add url."https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
RUN make build

FROM ${RUNNER_IMAGE}
FROM golang:${GO_VERSION}-alpine3.20

COPY --from=build-env /go/src/github.com/sagaxyz/sagacli/build/sscd /usr/bin/sscd
COPY --from=build-env /root/build/sscd /usr/bin/

RUN apk add gcompat bash
RUN apk add gcompat bash curl

EXPOSE 26656
EXPOSE 26660
Expand Down
59 changes: 49 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ import (
"github.com/cosmos/ibc-go/modules/capability"
ibccapabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ibccapabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
"github.com/spf13/cast"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/types"
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host"
Expand All @@ -131,6 +133,12 @@ import (
sscmodulekeeper "github.com/sagaxyz/ssc/x/ssc/keeper"
sscmoduletypes "github.com/sagaxyz/ssc/x/ssc/types"

gmpmodule "github.com/sagaxyz/ssc/x/gmp"
gmpmodulekeeper "github.com/sagaxyz/ssc/x/gmp/keeper"
gmpmoduletypes "github.com/sagaxyz/ssc/x/gmp/types"

upgrade02 "github.com/sagaxyz/ssc/app/upgrades/0.2"

// this line is used by starport scaffolding # stargate/app/moduleImport

ante "github.com/sagaxyz/ssc/app/ante"
Expand Down Expand Up @@ -189,6 +197,7 @@ var (
vesting.AppModuleBasic{},
consensus.AppModuleBasic{},
sscmodule.AppModuleBasic{},
gmpmodule.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
)

Expand Down Expand Up @@ -263,7 +272,9 @@ type App struct {
ScopedTransferKeeper ibccapabilitykeeper.ScopedKeeper
ScopedICAHostKeeper ibccapabilitykeeper.ScopedKeeper

SscKeeper sscmodulekeeper.Keeper
SscKeeper sscmodulekeeper.Keeper
ScopedGmpKeeper ibccapabilitykeeper.ScopedKeeper
GmpKeeper gmpmodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

// mm is the module manager
Expand Down Expand Up @@ -320,7 +331,7 @@ func New(
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey,
ibccapabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, consensusparamtypes.StoreKey,
sscmoduletypes.StoreKey, packetforwardtypes.StoreKey,
sscmoduletypes.StoreKey, packetforwardtypes.StoreKey, gmpmoduletypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -508,7 +519,6 @@ func New(
keys[packetforwardtypes.StoreKey],
app.TransferKeeper, // will be zero-value here, reference is set later on with SetTransferKeeper.
app.IBCKeeper.ChannelKeeper,
app.DistrKeeper,
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
govModuleAddress,
Expand All @@ -535,7 +545,6 @@ func New(
app.PacketForwardKeeper,
0, // retries on timeout
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, // forward timeout
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, // refund timeout
)
app.PacketForwardKeeper.SetTransferKeeper(app.TransferKeeper)

Expand Down Expand Up @@ -611,16 +620,32 @@ func New(
)
sscModule := sscmodule.NewAppModule(appCodec, app.SscKeeper, app.AccountKeeper, app.BankKeeper)

scopedGmpKeeper := app.CapabilityKeeper.ScopeToModule(gmpmoduletypes.ModuleName)
app.ScopedGmpKeeper = scopedGmpKeeper
app.GmpKeeper = *gmpmodulekeeper.NewKeeper(
appCodec,
keys[gmpmoduletypes.StoreKey],
keys[gmpmoduletypes.MemStoreKey],
app.GetSubspace(gmpmoduletypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
scopedGmpKeeper,
)
gmpModule := gmpmodule.NewAppModule(appCodec, app.GmpKeeper, app.AccountKeeper, app.BankKeeper)
transferIBCModule = gmpmodule.NewIBCModule(transferIBCModule)

// this line is used by starport scaffolding # stargate/app/keeperDefinition

/**** IBC Routing ****/

// Sealing prevents other modules from creating scoped sub-keepers
app.CapabilityKeeper.Seal()

icaControllerStack := icacontroller.NewIBCMiddleware(nil, icaControllerKeeper)
// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)
Expand Down Expand Up @@ -674,6 +699,7 @@ func New(
transferModule,
icaModule,
sscModule,
gmpModule,
// this line is used by starport scaffolding # stargate/app/appModule

crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
Expand Down Expand Up @@ -728,6 +754,7 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
sscmoduletypes.ModuleName,
gmpmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -757,6 +784,7 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
sscmoduletypes.ModuleName,
gmpmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -789,6 +817,7 @@ func New(
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
sscmoduletypes.ModuleName,
gmpmoduletypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -1038,6 +1067,8 @@ func (app *App) RegisterNodeService(clientCtx client.Context, cfg config.Config)
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

keyTable := ibcclienttypes.ParamKeyTable()
keyTable.RegisterParamSet(&ibcconnectiontypes.Params{})
paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName)
Expand All @@ -1046,12 +1077,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable())
paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable())
paramsKeeper.Subspace(sscmoduletypes.ModuleName)
paramsKeeper.Subspace(gmpmoduletypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand All @@ -1068,7 +1099,8 @@ func (app *App) ModuleManager() *module.Manager {
}

func (app *App) RegisterUpgradeHandlers() {
//app.UpgradeKeeper.SetUpgradeHandler(upgrade1.Name, upgrade1.UpgradeHandler(app.mm, app.configurator, app.ParamsKeeper, &app.ConsensusParamsKeeper))
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
app.UpgradeKeeper.SetUpgradeHandler(upgrade02.Name, upgrade02.UpgradeHandler(app.mm, app.configurator, app.ParamsKeeper, &app.ConsensusParamsKeeper, app.IBCKeeper.ClientKeeper, baseAppLegacySS))

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
Expand All @@ -1080,6 +1112,13 @@ func (app *App) RegisterUpgradeHandlers() {
}
var storeUpgrades *storetypes.StoreUpgrades
switch upgradeInfo.Name {
case upgrade02.Name:
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{
gmpmoduletypes.StoreKey,
packetforwardtypes.StoreKey,
},
}
default:
}
if storeUpgrades != nil {
Expand Down
32 changes: 32 additions & 0 deletions app/upgrades/0.2/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package v02

import (
"context"
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
ibcclientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper"
)

const Name = "0.1-to-0.2"

func UpgradeHandler(mm *module.Manager, configurator module.Configurator, paramsKeeper paramskeeper.Keeper, consensusKeeper *consensuskeeper.Keeper, clientKeeper ibcclientkeeper.Keeper, baseAppLegacySS paramstypes.Subspace) upgradetypes.UpgradeHandler {
return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
cp := baseapp.GetConsensusParams(sdkCtx, baseAppLegacySS)
if cp == nil {
return nil, fmt.Errorf("consensus parameters are undefined")
}
err := consensusKeeper.ParamsStore.Set(ctx, *cp)
if err != nil {
return nil, fmt.Errorf("failed to set consensus params: %w", err)
}
return mm.RunMigrations(ctx, configurator, vm)
}
}
18 changes: 0 additions & 18 deletions app/upgrades/v1/upgrades.go

This file was deleted.

20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ require (
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/cosmos-sdk v0.50.8
github.com/cosmos/gogoproto v1.5.0
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.1.0
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/v8 v8.3.2
github.com/ethereum/go-ethereum v1.14.12
github.com/golang/protobuf v1.5.4
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand Down Expand Up @@ -51,21 +52,22 @@ require (
github.com/99designs/keyring v1.2.2 // indirect
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/aws/aws-sdk-go v1.44.224 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/bits-and-blooms/bitset v1.8.0 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/pebble v1.1.2 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft-db v0.12.0 // indirect
Expand Down Expand Up @@ -129,6 +131,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
Expand Down Expand Up @@ -169,7 +172,6 @@ require (
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
Expand All @@ -189,19 +191,17 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/api v0.171.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down
Loading
Loading