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: Oracle vote extension handler #396

Merged
merged 29 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6c75a76
feat: Oracle vote extension handler
rbajollari Mar 4, 2024
19b255e
fix preblocker init
rbajollari Mar 6, 2024
c839a04
use validator in pf config for vote extensions
rbajollari Mar 6, 2024
b4f7f25
lint
rbajollari Mar 6, 2024
c782b75
add verification in process proposal
rbajollari Mar 7, 2024
d6acf4c
process proposal verifaction
rbajollari Mar 7, 2024
d1ec5de
setup oracle abci integration test suite
rbajollari Mar 8, 2024
81cbe3c
use vote extension signer for exchange rate generation
rbajollari Mar 11, 2024
d09cbd6
add vote extention and preblocker integration tests
rbajollari Mar 27, 2024
9e234a0
fix preblocker test
rbajollari Mar 27, 2024
69ea14f
nolint spacing revert
rbajollari Mar 27, 2024
6de9f10
Merge branch 'main' into ryan/vote-extensions
rbajollari Mar 28, 2024
b96a12b
go mod tidy
rbajollari Mar 28, 2024
501537c
add abci propsal tests
rbajollari Apr 2, 2024
336f5a5
update price feeder import
rbajollari Apr 3, 2024
a8b13ec
add price feeder app config
rbajollari Apr 4, 2024
a9584fa
fix e2e test setup
rbajollari Apr 8, 2024
c5f313a
pr comments
rbajollari Apr 9, 2024
26084fb
git rm cached ignore files
rbajollari Apr 9, 2024
fd32880
lint
rbajollari Apr 9, 2024
87c9aeb
import latest pf version
rbajollari Apr 9, 2024
97c881d
Update .gitignore
rbajollari Apr 9, 2024
5ae25dd
Update x/oracle/abci/proposal.go
rbajollari Apr 9, 2024
8b67675
Update x/oracle/abci/voteextension.go
rbajollari Apr 9, 2024
e47a9e9
round 2 pr comments
rbajollari Apr 9, 2024
128313a
README update
rbajollari Apr 9, 2024
3726583
super lint
rbajollari Apr 9, 2024
07bb0ad
Merge branch 'main' into ryan/vote-extensions
rbajollari Apr 9, 2024
ed7a984
go mod tidy
rbajollari Apr 9, 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
30 changes: 29 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ import (
airdropkeeper "github.com/ojo-network/ojo/x/airdrop/keeper"
airdroptypes "github.com/ojo-network/ojo/x/airdrop/types"

"github.com/ojo-network/ojo/pricefeeder"
ojoabci "github.com/ojo-network/ojo/x/oracle/abci"

customante "github.com/ojo-network/ojo/ante"
)

Expand Down Expand Up @@ -216,6 +219,8 @@ type App struct {

// module configurator
configurator module.Configurator

PriceFeeder *pricefeeder.PriceFeeder
}

// New returns a reference to an initialized blockchain app
Expand Down Expand Up @@ -723,14 +728,37 @@ func New(
app.StateSimulationManager = module.NewSimulationManagerFromAppModules(app.mm.Modules, overrideModules)
app.StateSimulationManager.RegisterStoreDecoders()

proposalHandler := ojoabci.NewProposalHandler(
app.Logger(),
app.OracleKeeper,
app.StakingKeeper,
)
app.SetPrepareProposal(proposalHandler.PrepareProposalHandler())
app.SetProcessProposal(proposalHandler.ProcessProposalHandler())

preBlockHandler := ojoabci.NewPreBlockHandler(
app.Logger(),
app.OracleKeeper,
)
app.SetPreBlocker(preBlockHandler.PreBlocker())

// initialize empty price feeder object to pass reference into vote extension handler
app.PriceFeeder = &pricefeeder.PriceFeeder{}
voteExtensionsHandler := ojoabci.NewVoteExtensionHandler(
app.Logger(),
app.OracleKeeper,
app.PriceFeeder,
)
app.SetExtendVoteHandler(voteExtensionsHandler.ExtendVoteHandler())
app.SetVerifyVoteExtensionHandler(voteExtensionsHandler.VerifyVoteExtensionHandler())

// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
app.MountMemoryStores(memKeys)

// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetPreBlocker(app.PreBlocker)
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
app.setAnteHandler(txConfig)
Expand Down
3 changes: 3 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1
directories:
- proto
rbajollari marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 1 addition & 2 deletions cmd/ojod/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/spf13/cobra"

app "github.com/ojo-network/ojo/app"
"github.com/ojo-network/ojo/pricefeeder"
oracletypes "github.com/ojo-network/ojo/x/oracle/types"
)

Expand Down Expand Up @@ -208,7 +207,7 @@ func newApp(
var oracleGenState oracletypes.GenesisState
app.AppCodec().MustUnmarshalJSON(app.DefaultGenesis()[oracletypes.ModuleName], &oracleGenState)
go func() {
err := pricefeeder.Start(oracleGenState.Params)
err := app.PriceFeeder.Start(oracleGenState.Params)
if err != nil {
panic(err)
}
Expand Down
4 changes: 4 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ genesis:
staking:
params:
bond_denom: uojo
consensus:
params:
abci:
vote_extensions_enable_height: "2"
chain_id: ojo-testnet
validators:
- name: alice
Expand Down
29 changes: 25 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
cosmossdk.io/x/tx v0.12.0
cosmossdk.io/x/upgrade v0.1.0
github.com/armon/go-metrics v0.4.1
github.com/bufbuild/buf v1.15.1
github.com/cometbft/cometbft v0.38.5
github.com/cosmos/cosmos-db v1.0.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
Expand All @@ -32,6 +33,7 @@ require (
github.com/golangci/golangci-lint v1.55.2
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1
github.com/mgechev/revive v1.3.6
github.com/mitchellh/mapstructure v1.5.0
github.com/ojo-network/price-feeder v0.1.10-0.20240221234245-b3d7d675adc9
Expand All @@ -43,7 +45,7 @@ require (
github.com/stretchr/testify v1.8.4
golang.org/x/sync v0.5.0
golang.org/x/tools v0.16.1
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917
google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe
google.golang.org/grpc v1.61.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
google.golang.org/protobuf v1.32.0
Expand Down Expand Up @@ -97,6 +99,8 @@ require (
github.com/breml/errchkjson v0.3.6 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
github.com/bufbuild/connect-go v1.5.2 // indirect
github.com/bufbuild/protocompile v0.6.0 // indirect
github.com/butuzov/ireturn v0.2.2 // indirect
github.com/butuzov/mirror v1.1.0 // indirect
github.com/catenacyber/perfsprint v0.2.0 // indirect
Expand All @@ -120,6 +124,7 @@ require (
github.com/cosmos/iavl v1.0.0 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/creachadair/atomicfile v0.3.1 // indirect
github.com/creachadair/tomledit v0.0.24 // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect
Expand All @@ -133,7 +138,9 @@ require (
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/docker/cli v24.0.2+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v24.0.2+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
Expand All @@ -143,13 +150,16 @@ require (
github.com/ettle/strcase v0.1.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/firefart/nonamedreturns v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/getsentry/sentry-go v0.25.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/ghostiam/protogetter v0.2.3 // indirect
github.com/go-chi/chi/v5 v5.0.8 // indirect
github.com/go-critic/go-critic v0.9.0 // indirect
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -170,6 +180,7 @@ require (
github.com/gobwas/glob v0.2.3 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/uuid/v5 v5.0.0 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -186,7 +197,9 @@ require (
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-containerregistry v0.13.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.4.0 // indirect
Expand Down Expand Up @@ -222,6 +235,7 @@ require (
github.com/imdario/mergo v0.3.16 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jdxcode/netrc v0.0.0-20221124155335-4616370d1a84 // indirect
github.com/jgautheron/goconst v1.6.0 // indirect
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
Expand All @@ -233,6 +247,7 @@ require (
github.com/kisielk/gotool v1.0.0 // indirect
github.com/kkHAIKE/contextcheck v1.1.4 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kulti/thelper v0.6.3 // indirect
Expand Down Expand Up @@ -263,6 +278,7 @@ require (
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/moricho/tparallel v0.3.1 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/nakabonne/nestif v0.3.1 // indirect
github.com/nishanths/exhaustive v0.11.0 // indirect
Expand All @@ -277,7 +293,9 @@ require (
github.com/opencontainers/runc v1.1.7 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.7.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/polyfloyd/go-errorlint v1.4.5 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
Expand All @@ -293,6 +311,7 @@ require (
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/ryancurrah/gomodguard v1.3.0 // indirect
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
Expand Down Expand Up @@ -345,24 +364,26 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.tmz.dev/musttag v0.7.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.153.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
honnef.co/go/tools v0.4.6 // indirect
Expand Down
Loading
Loading