Skip to content

Commit b16218c

Browse files
feat: relay to EVM via ABCI (#525)
Co-authored-by: ryanbajollari <[email protected]>
1 parent 1dc2b32 commit b16218c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+7097
-168
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
if: env.GIT_DIFF
2929
uses: actions/setup-go@v5
3030
with:
31-
go-version: '1.22.1'
31+
go-version: '1.23'
3232
cache: true
3333
env:
3434
GOOS: ${{ matrix.targetos }}

.github/workflows/code-ql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/checkout@v4
2727
- uses: actions/setup-go@v5
2828
with:
29-
go-version: '1.22.1'
29+
go-go-version: '1.23'
3030
# Initializes the CodeQL tools for scanning.
3131
- name: Initialize CodeQL
3232
uses: github/codeql-action/init@v3

.github/workflows/debug.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: '1.22.1'
16+
go-go-version: '1.23'
1717
cache: true
1818

1919
- uses: actions/checkout@v4

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/setup-go@v5
1919
with:
20-
go-version: '1.22.1'
20+
go-go-version: '1.23'
2121
- uses: actions/checkout@v4
2222
- name: golangci-lint
2323
uses: golangci/golangci-lint-action@v6

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fetch-depth: 0
2323
- uses: actions/setup-go@v5
2424
with:
25-
go-version: '1.22.1'
25+
go-go-version: '1.23'
2626
cache: true
2727

2828
- name: Set Env

.github/workflows/simulations.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/setup-go@v5
1818
with:
19-
go-version: '1.22.1'
19+
go-go-version: '1.23'
2020

2121
- name: Install runsim
2222
run: export GO111MODULE="on" && go install github.com/cosmos/tools/cmd/[email protected]
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/setup-go@v5
3939
if: env.GIT_DIFF
4040
with:
41-
go-version: '1.22.1'
41+
go-go-version: '1.23'
4242
cache: true
4343
- name: Test application non-determinism
4444
if: env.GIT_DIFF
@@ -60,7 +60,7 @@ jobs:
6060
- uses: actions/setup-go@v5
6161
if: env.GIT_DIFF
6262
with:
63-
go-version: '1.22.1'
63+
go-go-version: '1.23'
6464
cache: true
6565
- uses: actions/cache@v4
6666
if: env.GIT_DIFF
@@ -87,7 +87,7 @@ jobs:
8787
- uses: actions/setup-go@v5
8888
if: env.GIT_DIFF
8989
with:
90-
go-version: '1.22.1'
90+
go-go-version: '1.23'
9191
cache: true
9292
- uses: actions/cache@v4
9393
if: env.GIT_DIFF
@@ -113,7 +113,7 @@ jobs:
113113
- uses: actions/setup-go@v5
114114
if: env.GIT_DIFF
115115
with:
116-
go-version: '1.22.1'
116+
go-go-version: '1.23'
117117
cache: true
118118
- uses: actions/cache@v4
119119
if: env.GIT_DIFF

.github/workflows/tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- uses: actions/setup-go@v5
1414
with:
15-
go-version: '1.22.1'
15+
go-go-version: '1.23'
1616
- name: Display Go Version
1717
run: go version
1818
- uses: actions/cache@v4
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/setup-go@v5
3939
if: env.GIT_DIFF
4040
with:
41-
go-version: '1.22.1'
41+
go-go-version: '1.23'
4242
cache: true
4343
- name: Test and Create Coverage Report
4444
if: env.GIT_DIFF
@@ -100,7 +100,7 @@ jobs:
100100
- uses: actions/setup-go@v5
101101
if: env.GIT_DIFF
102102
with:
103-
go-version: '1.22.1'
103+
go-go-version: '1.23'
104104
cache: true
105105

106106
- name: Test E2E

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Builder
2-
FROM golang:1.22.1-alpine AS builder
2+
FROM golang:1.23-alpine AS builder
33

44
RUN apk add --no-cache \
55
ca-certificates \

app/app.go

+22-2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ import (
117117
gmpkeeper "github.com/ojo-network/ojo/x/gmp/keeper"
118118
gmptypes "github.com/ojo-network/ojo/x/gmp/types"
119119

120+
"github.com/ojo-network/ojo/x/gasestimate"
121+
gasestimatekeeper "github.com/ojo-network/ojo/x/gasestimate/keeper"
122+
gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"
123+
120124
"github.com/ojo-network/ojo/x/airdrop"
121125
airdropkeeper "github.com/ojo-network/ojo/x/airdrop/keeper"
122126
airdroptypes "github.com/ojo-network/ojo/x/airdrop/types"
@@ -145,6 +149,7 @@ var (
145149
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
146150
oracletypes.ModuleName: {authtypes.Minter},
147151
gmptypes.ModuleName: {authtypes.Minter},
152+
gasestimatetypes.ModuleName: {authtypes.Burner},
148153
airdroptypes.ModuleName: {authtypes.Minter},
149154
}
150155
)
@@ -201,6 +206,7 @@ type App struct {
201206
GroupKeeper groupkeeper.Keeper
202207
OracleKeeper oraclekeeper.Keeper
203208
GmpKeeper gmpkeeper.Keeper
209+
GasEstimateKeeper gasestimatekeeper.Keeper
204210
AirdropKeeper airdropkeeper.Keeper
205211
ConsensusParamsKeeper consensusparamkeeper.Keeper
206212

@@ -264,7 +270,7 @@ func New(
264270
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
265271
feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
266272
consensusparamtypes.StoreKey, group.StoreKey, oracletypes.StoreKey, gmptypes.StoreKey,
267-
airdroptypes.StoreKey,
273+
gasestimatetypes.ModuleName, airdroptypes.StoreKey,
268274
)
269275
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
270276
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
@@ -409,6 +415,12 @@ func New(
409415
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
410416
)
411417

418+
app.GasEstimateKeeper = gasestimatekeeper.NewKeeper(
419+
appCodec,
420+
keys[gasestimatetypes.ModuleName],
421+
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
422+
)
423+
412424
app.OracleKeeper = oraclekeeper.NewKeeper(
413425
appCodec,
414426
keys[oracletypes.ModuleName],
@@ -417,6 +429,7 @@ func New(
417429
app.BankKeeper,
418430
app.DistrKeeper,
419431
app.StakingKeeper,
432+
app.GasEstimateKeeper,
420433
distrtypes.ModuleName,
421434
cast.ToBool(appOpts.Get("telemetry.enabled")),
422435
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
@@ -428,6 +441,8 @@ func New(
428441
app.OracleKeeper,
429442
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
430443
app.TransferKeeper,
444+
app.BankKeeper,
445+
app.GasEstimateKeeper,
431446
)
432447

433448
app.AirdropKeeper = airdropkeeper.NewKeeper(
@@ -580,6 +595,7 @@ func New(
580595
ibctm.NewAppModule(),
581596
oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
582597
gmp.NewAppModule(appCodec, app.GmpKeeper, app.OracleKeeper),
598+
gasestimate.NewAppModule(appCodec, app.GasEstimateKeeper),
583599
airdrop.NewAppModule(appCodec, app.AirdropKeeper, app.AccountKeeper, app.BankKeeper),
584600
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
585601
)
@@ -631,6 +647,7 @@ func New(
631647
vestingtypes.ModuleName,
632648
oracletypes.ModuleName,
633649
gmptypes.ModuleName,
650+
gasestimatetypes.ModuleName,
634651
airdroptypes.ModuleName,
635652
consensusparamtypes.ModuleName,
636653
)
@@ -657,6 +674,7 @@ func New(
657674
vestingtypes.ModuleName,
658675
oracletypes.ModuleName,
659676
gmptypes.ModuleName,
677+
gasestimatetypes.ModuleName,
660678
airdroptypes.ModuleName,
661679
consensusparamtypes.ModuleName,
662680
)
@@ -672,7 +690,8 @@ func New(
672690
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, ibctransfertypes.ModuleName,
673691
ibcexported.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName,
674692
group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName,
675-
oracletypes.ModuleName, gmptypes.ModuleName, airdroptypes.ModuleName, consensusparamtypes.ModuleName,
693+
oracletypes.ModuleName, gmptypes.ModuleName, gasestimatetypes.ModuleName,
694+
airdroptypes.ModuleName, consensusparamtypes.ModuleName,
676695
}
677696
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
678697
app.mm.SetOrderExportGenesis(genesisModuleOrder...)
@@ -991,6 +1010,7 @@ func initParamsKeeper(
9911010
paramsKeeper.Subspace(govtypes.ModuleName)
9921011
paramsKeeper.Subspace(crisistypes.ModuleName)
9931012
paramsKeeper.Subspace(oracletypes.ModuleName)
1013+
paramsKeeper.Subspace(gasestimatetypes.ModuleName)
9941014

9951015
// register the key tables for legacy param subspaces
9961016
keyTable := ibcclienttypes.ParamKeyTable()

app/preblocker.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
sdk "github.com/cosmos/cosmos-sdk/types"
99
"github.com/ojo-network/ojo/x/oracle/abci"
1010
"github.com/ojo-network/ojo/x/oracle/types"
11+
12+
gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"
1113
)
1214

1315
// PreBlocker is run before finalize block to update the aggregrate exchange rate votes on the oracle module
@@ -50,9 +52,6 @@ func (app *App) PreBlocker(ctx sdk.Context, req *cometabci.RequestFinalizeBlock)
5052
app.Logger().Error("failed to decode injected vote extension tx", "err", err)
5153
return nil, err
5254
}
53-
54-
// set oracle exchange rate votes using the passed in context, which will make
55-
// these votes available in the current block.
5655
for _, exchangeRateVote := range injectedVoteExtTx.ExchangeRateVotes {
5756
valAddr, err := sdk.ValAddressFromBech32(exchangeRateVote.Voter)
5857
if err != nil {
@@ -61,10 +60,17 @@ func (app *App) PreBlocker(ctx sdk.Context, req *cometabci.RequestFinalizeBlock)
6160
}
6261
app.OracleKeeper.SetAggregateExchangeRateVote(ctx, valAddr, exchangeRateVote)
6362
}
63+
for _, gasEstimate := range injectedVoteExtTx.GasEstimateMedians {
64+
app.GasEstimateKeeper.SetGasEstimate(ctx, gasestimatetypes.GasEstimate{
65+
Network: gasEstimate.Network,
66+
GasEstimate: gasEstimate.GasEstimation,
67+
})
68+
}
69+
app.Logger().Info("gas estimates updated", "gasestimates", injectedVoteExtTx.GasEstimateMedians)
6470
}
6571

6672
app.Logger().Info(
67-
"oracle preblocker executed",
73+
"preblocker executed",
6874
"vote_extensions_enabled", voteExtensionsEnabled,
6975
)
7076

app/upgrades.go

+21
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
2525
gmptypes "github.com/ojo-network/ojo/x/gmp/types"
2626

27+
gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"
2728
oraclekeeper "github.com/ojo-network/ojo/x/oracle/keeper"
2829
oracletypes "github.com/ojo-network/ojo/x/oracle/types"
2930
)
@@ -47,6 +48,7 @@ func (app App) RegisterUpgradeHandlers() {
4748
app.registerUpgrade0_3_2(upgradeInfo)
4849
app.registerUpgrade0_4_0(upgradeInfo)
4950
app.registerUpgrade0_4_1(upgradeInfo)
51+
app.registerUpgrade0_5_0(upgradeInfo)
5052
}
5153

5254
// performs upgrade from v0.1.3 to v0.1.4
@@ -333,6 +335,25 @@ func (app *App) registerUpgrade0_4_1(upgradeInfo upgradetypes.Plan) {
333335
})
334336
}
335337

338+
// performs upgrade from v0.4.x to v0.5.0
339+
func (app *App) registerUpgrade0_5_0(upgradeInfo upgradetypes.Plan) {
340+
const planName = "v0.5.0"
341+
app.UpgradeKeeper.SetUpgradeHandler(planName,
342+
func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
343+
sdkCtx := sdk.UnwrapSDKContext(ctx)
344+
sdkCtx.Logger().Info("Upgrade handler execution", "name", planName)
345+
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
346+
},
347+
)
348+
349+
// REF: https://github.com/cosmos/cosmos-sdk/blob/a32186608aab0bd436049377ddb34f90006fcbf7/simapp/upgrades.go
350+
app.storeUpgrade(planName, upgradeInfo, storetypes.StoreUpgrades{
351+
Added: []string{
352+
gasestimatetypes.ModuleName,
353+
},
354+
})
355+
}
356+
336357
// helper function to check if the store loader should be upgraded
337358
func (app *App) storeUpgrade(planName string, ui upgradetypes.Plan, stores storetypes.StoreUpgrades) {
338359
if ui.Name == planName && !app.UpgradeKeeper.IsSkipHeight(ui.Height) {

client/query/gasestimation.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package query
2+
3+
import (
4+
"context"
5+
6+
gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"
7+
)
8+
9+
// GovQueryClient returns the govtypes.QueryClient
10+
// initialized with the clients grpc connection
11+
func (c *Client) GasEstimateClient() gasestimatetypes.QueryClient {
12+
return gasestimatetypes.NewQueryClient(c.grpcConn)
13+
}
14+
15+
func (c *Client) GetGasEstimate(ctx context.Context, network string) (int64, error) {
16+
queryClient := c.GasEstimateClient()
17+
query := &gasestimatetypes.GasEstimateRequest{
18+
Network: network,
19+
}
20+
21+
res, err := queryClient.GasEstimate(ctx, query)
22+
if err != nil {
23+
return 0, err
24+
}
25+
26+
return res.GasEstimate, nil
27+
}

client/query/gmp.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package query
2+
3+
import (
4+
"context"
5+
6+
gmptypes "github.com/ojo-network/ojo/x/gmp/types"
7+
)
8+
9+
func (c *Client) GmpQueryClient() gmptypes.QueryClient {
10+
return gmptypes.NewQueryClient(c.grpcConn)
11+
}
12+
13+
func (c *Client) QueryPayments() (*gmptypes.AllPaymentsResponse, error) {
14+
ctx, cancel := context.WithTimeout(context.Background(), queryTimeout)
15+
defer cancel()
16+
17+
queryResponse, err := c.GmpQueryClient().AllPayments(
18+
ctx,
19+
&gmptypes.AllPaymentsRequest{},
20+
)
21+
22+
return queryResponse, err
23+
}

client/tx/gmp.go

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package tx
2+
3+
import (
4+
"cosmossdk.io/math"
5+
sdk "github.com/cosmos/cosmos-sdk/types"
6+
gmptypes "github.com/ojo-network/ojo/x/gmp/types"
7+
)
8+
9+
// TxCreatePayment creates a gmp payment transaction
10+
func (c *Client) TxCreatePayment() (*sdk.TxResponse, error) {
11+
fromAddr, err := c.keyringRecord.GetAddress()
12+
if err != nil {
13+
return nil, err
14+
}
15+
16+
msg := gmptypes.NewMsgCreatePayment(
17+
fromAddr.String(),
18+
"Arbitrum",
19+
"BTC",
20+
sdk.NewCoin("uojo", math.NewInt(1_000_000_000)),
21+
math.LegacyOneDec(),
22+
100,
23+
)
24+
25+
return c.BroadcastTx(msg)
26+
}

0 commit comments

Comments
 (0)