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

feat: relay to EVM via ABCI #525

Merged
merged 23 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
14c03f3
feat: add relayer payments
adamewozniak Sep 29, 2024
16f6d71
vote extensions w/o app wiring
adamewozniak Sep 29, 2024
8169491
consolidate vote extensions to the oracle module
adamewozniak Sep 29, 2024
b1dde6c
remove some ugly prints
adamewozniak Sep 29, 2024
a9ca02d
move gas estimation params & registry to new module
adamewozniak Sep 30, 2024
b4639dc
use gas estimate in gmp abci endblocker
adamewozniak Sep 30, 2024
9156064
implement deviation & heartbeat logic
adamewozniak Sep 30, 2024
734aec2
fix the go build
adamewozniak Sep 30, 2024
7e73d40
update all go versions for build pipeline
adamewozniak Sep 30, 2024
6ea5f0f
lint fixes
adamewozniak Sep 30, 2024
c549b49
go lint & protobuf lint fixes
adamewozniak Sep 30, 2024
eb46516
update go version in dockerfile
adamewozniak Sep 30, 2024
5550d05
Update proto/ojo/gasestimate/v1/gasestimate.proto
adamewozniak Oct 1, 2024
8386576
Update x/gmp/module.go
adamewozniak Oct 1, 2024
16240b5
move calculateMedian func to utils
adamewozniak Oct 1, 2024
5fab69f
fix some tests
adamewozniak Oct 1, 2024
ea8fa68
add upgrade
adamewozniak Oct 1, 2024
e2df41f
upgrades.go lint fix
adamewozniak Oct 2, 2024
8530d29
fix liveness test
adamewozniak Oct 2, 2024
14e6e9f
cleanup + fix tx processing issue
adamewozniak Oct 2, 2024
e26d2f4
add MakePayment to e2e test suite
adamewozniak Oct 2, 2024
d57edd6
add gas estimate e2e test
adamewozniak Oct 2, 2024
22c2860
add buffer time to e2e gov props + reduce tokens used for gmp txs tests
adamewozniak Oct 2, 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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
if: env.GIT_DIFF
uses: actions/setup-go@v5
with:
go-version: '1.22.1'
go-version: '1.23'
cache: true
env:
GOOS: ${{ matrix.targetos }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-ql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22.1'
go-go-version: '1.23'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.22.1'
go-go-version: '1.23'
cache: true

- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.22.1'
go-go-version: '1.23'
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.22.1'
go-go-version: '1.23'
cache: true

- name: Set Env
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/simulations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.22.1'
go-go-version: '1.23'

- name: Install runsim
run: export GO111MODULE="on" && go install github.com/cosmos/tools/cmd/[email protected]
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.22.1'
go-go-version: '1.23'
cache: true
- name: Test application non-determinism
if: env.GIT_DIFF
Expand All @@ -60,7 +60,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.22.1'
go-go-version: '1.23'
cache: true
- uses: actions/cache@v4
if: env.GIT_DIFF
Expand All @@ -87,7 +87,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.22.1'
go-go-version: '1.23'
cache: true
- uses: actions/cache@v4
if: env.GIT_DIFF
Expand All @@ -113,7 +113,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.22.1'
go-go-version: '1.23'
cache: true
- uses: actions/cache@v4
if: env.GIT_DIFF
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.22.1'
go-go-version: '1.23'
- name: Display Go Version
run: go version
- uses: actions/cache@v4
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.22.1'
go-go-version: '1.23'
cache: true
- name: Test and Create Coverage Report
if: env.GIT_DIFF
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
- uses: actions/setup-go@v5
if: env.GIT_DIFF
with:
go-version: '1.22.1'
go-go-version: '1.23'
cache: true

- name: Test E2E
Expand Down
24 changes: 22 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ import (
gmpkeeper "github.com/ojo-network/ojo/x/gmp/keeper"
gmptypes "github.com/ojo-network/ojo/x/gmp/types"

"github.com/ojo-network/ojo/x/gasestimate"
gasestimatekeeper "github.com/ojo-network/ojo/x/gasestimate/keeper"
gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"

"github.com/ojo-network/ojo/x/airdrop"
airdropkeeper "github.com/ojo-network/ojo/x/airdrop/keeper"
airdroptypes "github.com/ojo-network/ojo/x/airdrop/types"
Expand Down Expand Up @@ -145,6 +149,7 @@ var (
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
oracletypes.ModuleName: {authtypes.Minter},
gmptypes.ModuleName: {authtypes.Minter},
gasestimatetypes.ModuleName: {authtypes.Burner},
airdroptypes.ModuleName: {authtypes.Minter},
}
)
Expand Down Expand Up @@ -201,6 +206,7 @@ type App struct {
GroupKeeper groupkeeper.Keeper
OracleKeeper oraclekeeper.Keeper
GmpKeeper gmpkeeper.Keeper
GasEstimateKeeper gasestimatekeeper.Keeper
AirdropKeeper airdropkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper

Expand Down Expand Up @@ -264,7 +270,7 @@ func New(
govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
consensusparamtypes.StoreKey, group.StoreKey, oracletypes.StoreKey, gmptypes.StoreKey,
airdroptypes.StoreKey,
gasestimatetypes.ModuleName, airdroptypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -409,6 +415,12 @@ func New(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.GasEstimateKeeper = gasestimatekeeper.NewKeeper(
appCodec,
keys[gasestimatetypes.ModuleName],
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.OracleKeeper = oraclekeeper.NewKeeper(
appCodec,
keys[oracletypes.ModuleName],
Expand All @@ -417,6 +429,7 @@ func New(
app.BankKeeper,
app.DistrKeeper,
app.StakingKeeper,
app.GasEstimateKeeper,
distrtypes.ModuleName,
cast.ToBool(appOpts.Get("telemetry.enabled")),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Expand All @@ -428,6 +441,8 @@ func New(
app.OracleKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
app.TransferKeeper,
app.BankKeeper,
app.GasEstimateKeeper,
)

app.AirdropKeeper = airdropkeeper.NewKeeper(
Expand Down Expand Up @@ -580,6 +595,7 @@ func New(
ibctm.NewAppModule(),
oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
gmp.NewAppModule(appCodec, app.GmpKeeper, app.OracleKeeper),
gasestimate.NewAppModule(appCodec, app.GasEstimateKeeper),
airdrop.NewAppModule(appCodec, app.AirdropKeeper, app.AccountKeeper, app.BankKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
)
Expand Down Expand Up @@ -631,6 +647,7 @@ func New(
vestingtypes.ModuleName,
oracletypes.ModuleName,
gmptypes.ModuleName,
gasestimatetypes.ModuleName,
airdroptypes.ModuleName,
consensusparamtypes.ModuleName,
)
Expand All @@ -657,6 +674,7 @@ func New(
vestingtypes.ModuleName,
oracletypes.ModuleName,
gmptypes.ModuleName,
gasestimatetypes.ModuleName,
airdroptypes.ModuleName,
consensusparamtypes.ModuleName,
)
Expand All @@ -672,7 +690,8 @@ func New(
minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, ibctransfertypes.ModuleName,
ibcexported.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName,
group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName,
oracletypes.ModuleName, gmptypes.ModuleName, airdroptypes.ModuleName, consensusparamtypes.ModuleName,
oracletypes.ModuleName, gmptypes.ModuleName, gasestimatetypes.ModuleName,
airdroptypes.ModuleName, consensusparamtypes.ModuleName,
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
app.mm.SetOrderExportGenesis(genesisModuleOrder...)
Expand Down Expand Up @@ -991,6 +1010,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(govtypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(oracletypes.ModuleName)
paramsKeeper.Subspace(gasestimatetypes.ModuleName)

// register the key tables for legacy param subspaces
keyTable := ibcclienttypes.ParamKeyTable()
Expand Down
39 changes: 24 additions & 15 deletions app/preblocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ojo-network/ojo/x/oracle/abci"
"github.com/ojo-network/ojo/x/oracle/types"

gasestimatetypes "github.com/ojo-network/ojo/x/gasestimate/types"
)

// PreBlocker is run before finalize block to update the aggregrate exchange rate votes on the oracle module
Expand Down Expand Up @@ -45,26 +47,33 @@
}
voteExtensionsEnabled := abci.VoteExtensionsEnabled(ctx)
if voteExtensionsEnabled {
var injectedVoteExtTx types.InjectedVoteExtensionTx
if err := injectedVoteExtTx.Unmarshal(req.Txs[0]); err != nil {
app.Logger().Error("failed to decode injected vote extension tx", "err", err)
return nil, err
}

// set oracle exchange rate votes using the passed in context, which will make
// these votes available in the current block.
for _, exchangeRateVote := range injectedVoteExtTx.ExchangeRateVotes {
valAddr, err := sdk.ValAddressFromBech32(exchangeRateVote.Voter)
if err != nil {
app.Logger().Error("failed to get voter address", "err", err)
continue
for _, tx := range req.Txs {
var injectedVoteExtTx types.InjectedVoteExtensionTx
if err := injectedVoteExtTx.Unmarshal(tx); err != nil {
app.Logger().Error("failed to decode injected vote extension tx", "err", err)
return nil, err
} else {

Check failure on line 55 in app/preblocker.go

View workflow job for this annotation

GitHub Actions / lint

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
for _, exchangeRateVote := range injectedVoteExtTx.ExchangeRateVotes {
valAddr, err := sdk.ValAddressFromBech32(exchangeRateVote.Voter)
if err != nil {
app.Logger().Error("failed to get voter address", "err", err)
continue
}
app.OracleKeeper.SetAggregateExchangeRateVote(ctx, valAddr, exchangeRateVote)
}
for _, gasEstimate := range injectedVoteExtTx.GasEstimateMedians {
app.GasEstimateKeeper.SetGasEstimate(ctx, gasestimatetypes.GasEstimate{
Network: gasEstimate.Network,
GasEstimate: gasEstimate.GasEstimation,
})
}
app.Logger().Info("gas estimates updated", "gasestimates", injectedVoteExtTx.GasEstimateMedians)
}
app.OracleKeeper.SetAggregateExchangeRateVote(ctx, valAddr, exchangeRateVote)
}
}

app.Logger().Info(
"oracle preblocker executed",
"preblocker executed",
"vote_extensions_enabled", voteExtensionsEnabled,
)

Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/ojo-network/ojo

go 1.22.1

toolchain go1.22.5
go 1.23

require (
cosmossdk.io/api v0.7.4
Expand Down Expand Up @@ -37,6 +35,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1
github.com/mgechev/revive v1.3.9
github.com/mitchellh/mapstructure v1.5.0
github.com/ojo-network/ojo-evm/relayer v0.0.0-20240904192312-acda927a5d24
github.com/ojo-network/price-feeder v0.2.1-rc1
github.com/ory/dockertest/v3 v3.10.0
github.com/rs/zerolog v1.32.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,8 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q=
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s=
github.com/ojo-network/ojo-evm/relayer v0.0.0-20240904192312-acda927a5d24 h1:t0E41HkLJJmyh8rCwNjGQPoHfQSH4QHDTg51UawFKyA=
github.com/ojo-network/ojo-evm/relayer v0.0.0-20240904192312-acda927a5d24/go.mod h1:dW6/pQ+hNtC6955jQUR1cUJrGWcQ6fNEjeSLJCJPz3A=
github.com/ojo-network/price-feeder v0.2.1-rc1 h1:m9vgR9DYuXhM5f2DQX/wewihzkPVAVdVjZgtr/gB6bs=
github.com/ojo-network/price-feeder v0.2.1-rc1/go.mod h1:CSdgh7XiOMLGQwRW8OqbL5FlkE5Mc3+fDZEMRN8JkYY=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
Expand Down
30 changes: 30 additions & 0 deletions proto/ojo/gasestimate/v1/gasestimate.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";
package ojo.gasestimate.v1;

import "gogoproto/gogo.proto";

option go_package = "github.com/ojo-network/ojo/x/gasestimate/types";

option (gogoproto.goproto_getters_all) = false;

// Params defines the parameters for the gasestimate module.
message Params {
// The contracts we'll send gasestimate messages to.
repeated Contract contract_registry = 1;
// The gas limit for the gasestimate messages. E.x., "1000000"
string gas_limit = 2;
// The gas adjustment multiplier for the gasestimate messages. E.x., "1.5"
string gas_adjustment = 3;
}

// Contract defines a contract that we
adamewozniak marked this conversation as resolved.
Show resolved Hide resolved
message Contract {
string address = 1;
string network = 2;
}

// GasEstimate is the gas estimate for a given network.
message GasEstimate {
string network = 1;
int64 gas_estimate = 2;
}
12 changes: 12 additions & 0 deletions proto/ojo/gasestimate/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package ojo.gasestimate.v1;

import "gogoproto/gogo.proto";
import "ojo/gasestimate/v1/gasestimate.proto";

option go_package = "github.com/ojo-network/ojo/x/gasestimate/types";

// GenesisState represents the genesis state of the gasestimate module.
message GenesisState {
Params params = 1 [ (gogoproto.nullable) = false ];
}
39 changes: 39 additions & 0 deletions proto/ojo/gasestimate/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
syntax = "proto3";
package ojo.gasestimate.v1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "ojo/gasestimate/v1/gasestimate.proto";

option go_package = "github.com/ojo-network/ojo/x/gasestimate/types";

// Query defines the gRPC querier service for the gasestimate module
service Query {
// Params queries all parameters.
rpc Params(ParamsRequest) returns (ParamsResponse) {
option (google.api.http).get = "/ojo/gasestimate/v1/params";
}
// GasEstimate queries the gas estimate for a given network.
rpc GasEstimate(GasEstimateRequest) returns (GasEstimateResponse) {
option (google.api.http).get = "/ojo/gasestimate/v1/gasestimate";
}
}

// ParamsRequest is the request type for the Query/Params RPC method.
message ParamsRequest {}

// ParamsResponse is the response type for the Query/Params RPC method.
message ParamsResponse {
// params defines the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
}

// GasEstimateRequest is the request type for the Query/GasEstimate RPC method.
message GasEstimateRequest {
string network = 1;
}

// GasEstimateResponse is the response type for the Query/GasEstimate RPC method.
message GasEstimateResponse {
int64 gas_estimate = 1;
}
Loading
Loading