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

docs: v2 #750

Merged
merged 10 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,14 @@ slashingkeeper
slashingmodulev
slashingtypes
SLf
slinkyabci
slinkyabcimocks
slinkyabcitypes
connectabci
connectabcimocks
connectabcitypes
slinkyd
slinkygrpc
connectgrpc
slinkyhttp
slinkymath
slinkytypes
connecttypes
SMOLE
solana
solanago
Expand Down
12 changes: 2 additions & 10 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
project_name: slinky
project_name: connect

release:
github:
owner: skip-mev
name: slinky
name: connect
prerelease: true

builds:
Expand All @@ -16,14 +16,6 @@ builds:
id: 'connect'
ldflags:
- "-X github.com/skip-mev/connect/v2/cmd/build.Build={{.Version}}"
- main: 'cmd/connect/main.go'
goos:
- 'linux'
- 'darwin'
binary: 'slinky'
id: 'slinky'
ldflags:
- "-X github.com/skip-mev/connect/v2/cmd/build.Build={{.Version}}"
archives:
- format: tar.gz
wrap_in_directory: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ test-cover: tidy
### Protobuf ###
###############################################################################

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

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<!-- markdownlint-disable MD041 -->

[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#wip)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue?style=flat-square&logo=go)](https://godoc.org/github.com/skip-mev/connect/v2)
[![Go Report Card](https://goreportcard.com/badge/github.com/skip-mev/connect/v2?style=flat-square)](https://goreportcard.com/report/github.com/skip-mev/connect/v2)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue?style=flat-square&logo=go)](https://godoc.org/github.com/skip-mev/connect)
[![Go Report Card](https://goreportcard.com/badge/github.com/skip-mev/connect?style=flat-square)](https://goreportcard.com/report/github.com/skip-mev/connect)
[![Version](https://img.shields.io/github/tag/skip-mev/connect.svg?style=flat-square)](https://github.com/skip-mev/connect/releases/latest)
[![Lines Of Code](https://img.shields.io/tokei/lines/github/skip-mev/connect?style=flat-square)](https://github.com/skip-mev/connect)

A general purpose price oracle leveraging ABCI++. Please visit our [docs](https://docs.skip.build/connect/introduction) page for more information!

Connect uses Vote Extensions to create an hyperperformant, extremely secure mechanism for aggregating off-chain data onto a blockchain. It is used by
Connect uses Vote Extensions to create a hyperperformant, extremely secure mechanism for aggregating off-chain data onto a blockchain. It is used by
many of the highest-performance decentralized applications today. If you would like to integrate Connect to power your use case, please contact us on our
[Discord](https://discord.gg/PeBGE9jrbu).

Expand Down
18 changes: 9 additions & 9 deletions abci/preblock/oracle/preblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
abciaggregator "github.com/skip-mev/connect/v2/abci/strategies/aggregator"
"github.com/skip-mev/connect/v2/abci/strategies/codec"
"github.com/skip-mev/connect/v2/abci/strategies/currencypair"
slinkyabcitypes "github.com/skip-mev/connect/v2/abci/types"
connectabcitypes "github.com/skip-mev/connect/v2/abci/types"
"github.com/skip-mev/connect/v2/abci/ve"
"github.com/skip-mev/connect/v2/aggregator"
slinkytypes "github.com/skip-mev/connect/v2/pkg/types"
connecttypes "github.com/skip-mev/connect/v2/pkg/types"
servicemetrics "github.com/skip-mev/connect/v2/service/metrics"
)

Expand All @@ -33,7 +33,7 @@

// keeper is the keeper for the oracle module. This is utilized to write
// oracle data to state.
keeper slinkyabcitypes.OracleKeeper
keeper connectabcitypes.OracleKeeper

// pa is the price applier that is used to decode vote-extensions, aggregate price reports, and write prices to state.
pa abciaggregator.PriceApplier
Expand All @@ -43,8 +43,8 @@
// is responsible for writing oracle data included in vote extensions to state.
func NewOraclePreBlockHandler(
logger log.Logger,
aggregateFn aggregator.AggregateFnFromContext[string, map[slinkytypes.CurrencyPair]*big.Int],
oracleKeeper slinkyabcitypes.OracleKeeper,
aggregateFn aggregator.AggregateFnFromContext[string, map[connecttypes.CurrencyPair]*big.Int],
oracleKeeper connectabcitypes.OracleKeeper,
metrics servicemetrics.Metrics,
strategy currencypair.CurrencyPairStrategy,
veCodec codec.VoteExtensionCodec,
Expand Down Expand Up @@ -93,7 +93,7 @@
}

start := time.Now()
var prices map[slinkytypes.CurrencyPair]*big.Int
var prices map[connecttypes.CurrencyPair]*big.Int
defer func() {
// only measure latency in Finalize
if ctx.ExecMode() == sdk.ExecModeFinalize {
Expand All @@ -103,7 +103,7 @@
"height", ctx.BlockHeight(),
"latency (seconds)", latency.Seconds(),
)
slinkyabcitypes.RecordLatencyAndStatus(h.metrics, latency, err, servicemetrics.PreBlock)
connectabcitypes.RecordLatencyAndStatus(h.metrics, latency, err, servicemetrics.PreBlock)

// record prices + ticker metrics per validator (only do so if there was no error writing the prices)
if err == nil && prices != nil {
Expand Down Expand Up @@ -165,7 +165,7 @@
}

start := time.Now()
var prices map[slinkytypes.CurrencyPair]*big.Int
var prices map[connecttypes.CurrencyPair]*big.Int

Check warning on line 168 in abci/preblock/oracle/preblock.go

View check run for this annotation

Codecov / codecov/patch

abci/preblock/oracle/preblock.go#L168

Added line #L168 was not covered by tests
defer func() {
// only measure latency in Finalize
if ctx.ExecMode() == sdk.ExecModeFinalize {
Expand All @@ -175,7 +175,7 @@
"height", ctx.BlockHeight(),
"latency (seconds)", latency.Seconds(),
)
slinkyabcitypes.RecordLatencyAndStatus(h.metrics, latency, err, servicemetrics.PreBlock)
connectabcitypes.RecordLatencyAndStatus(h.metrics, latency, err, servicemetrics.PreBlock)

Check warning on line 178 in abci/preblock/oracle/preblock.go

View check run for this annotation

Codecov / codecov/patch

abci/preblock/oracle/preblock.go#L178

Added line #L178 was not covered by tests

// record prices + ticker metrics per validator (only do so if there was no error writing the prices)
if err == nil && prices != nil {
Expand Down
48 changes: 24 additions & 24 deletions abci/preblock/oracle/preblock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
currencypairmock "github.com/skip-mev/connect/v2/abci/strategies/currencypair/mocks"
"github.com/skip-mev/connect/v2/abci/testutils"
"github.com/skip-mev/connect/v2/abci/types"
slinkyabcimocks "github.com/skip-mev/connect/v2/abci/types/mocks"
connectabcimocks "github.com/skip-mev/connect/v2/abci/types/mocks"
vetypes "github.com/skip-mev/connect/v2/abci/ve/types"
"github.com/skip-mev/connect/v2/aggregator"
"github.com/skip-mev/connect/v2/pkg/math/voteweighted"
voteweightedmocks "github.com/skip-mev/connect/v2/pkg/math/voteweighted/mocks"
slinkytypes "github.com/skip-mev/connect/v2/pkg/types"
connecttypes "github.com/skip-mev/connect/v2/pkg/types"
servicemetrics "github.com/skip-mev/connect/v2/service/metrics"
metricmock "github.com/skip-mev/connect/v2/service/metrics/mocks"
"github.com/skip-mev/connect/v2/x/oracle/keeper"
Expand All @@ -43,7 +43,7 @@ type PreBlockTestSuite struct {

myVal sdk.ConsAddress
ctx sdk.Context
currencyPairs []slinkytypes.CurrencyPair
currencyPairs []connecttypes.CurrencyPair
genesis oracletypes.GenesisState
key *storetypes.KVStoreKey
transientKey *storetypes.TransientStoreKey
Expand All @@ -63,7 +63,7 @@ func TestPreBlockTestSuite(t *testing.T) {
func (s *PreBlockTestSuite) SetupTest() {
s.mm = &module.Manager{Modules: map[string]interface{}{}, OrderPreBlockers: make([]string, 0)}
s.myVal = sdk.ConsAddress("myVal")
s.currencyPairs = []slinkytypes.CurrencyPair{
s.currencyPairs = []connecttypes.CurrencyPair{
{
Base: "BTC",
Quote: "ETH",
Expand Down Expand Up @@ -449,8 +449,8 @@ func (s *PreBlockTestSuite) TestPreBlockStatus() {
metrics := metricmock.NewMetrics(s.T())
handler := preblock.NewOraclePreBlockHandler(
log.NewTestLogger(s.T()),
func(_ sdk.Context) aggregator.AggregateFn[string, map[slinkytypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[slinkytypes.CurrencyPair]*big.Int]) map[slinkytypes.CurrencyPair]*big.Int {
func(_ sdk.Context) aggregator.AggregateFn[string, map[connecttypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[connecttypes.CurrencyPair]*big.Int]) map[connecttypes.CurrencyPair]*big.Int {
return nil
}
},
Expand All @@ -470,8 +470,8 @@ func (s *PreBlockTestSuite) TestPreBlockStatus() {
metrics := metricmock.NewMetrics(s.T())
handler := preblock.NewOraclePreBlockHandler(
log.NewTestLogger(s.T()),
func(_ sdk.Context) aggregator.AggregateFn[string, map[slinkytypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[slinkytypes.CurrencyPair]*big.Int]) map[slinkytypes.CurrencyPair]*big.Int {
func(_ sdk.Context) aggregator.AggregateFn[string, map[connecttypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[connecttypes.CurrencyPair]*big.Int]) map[connecttypes.CurrencyPair]*big.Int {
return nil
}
},
Expand All @@ -493,8 +493,8 @@ func (s *PreBlockTestSuite) TestPreBlockStatus() {
metrics := metricmock.NewMetrics(s.T())
handler := preblock.NewOraclePreBlockHandler(
log.NewTestLogger(s.T()),
func(_ sdk.Context) aggregator.AggregateFn[string, map[slinkytypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[slinkytypes.CurrencyPair]*big.Int]) map[slinkytypes.CurrencyPair]*big.Int {
func(_ sdk.Context) aggregator.AggregateFn[string, map[connecttypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[connecttypes.CurrencyPair]*big.Int]) map[connecttypes.CurrencyPair]*big.Int {
return nil
}
},
Expand Down Expand Up @@ -523,11 +523,11 @@ func (s *PreBlockTestSuite) TestPreBlockStatus() {
metrics := metricmock.NewMetrics(s.T())
extCodec := codecmock.NewExtendedCommitCodec(s.T())
veCodec := codecmock.NewVoteExtensionCodec(s.T())
mockOracleKeeper := slinkyabcimocks.NewOracleKeeper(s.T())
mockOracleKeeper := connectabcimocks.NewOracleKeeper(s.T())
handler := preblock.NewOraclePreBlockHandler(
log.NewTestLogger(s.T()),
func(_ sdk.Context) aggregator.AggregateFn[string, map[slinkytypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[slinkytypes.CurrencyPair]*big.Int]) map[slinkytypes.CurrencyPair]*big.Int {
func(_ sdk.Context) aggregator.AggregateFn[string, map[connecttypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[connecttypes.CurrencyPair]*big.Int]) map[connecttypes.CurrencyPair]*big.Int {
return nil
}
},
Expand Down Expand Up @@ -578,8 +578,8 @@ func (s *PreBlockTestSuite) TestValidatorReports() {
metrics := metricmock.NewMetrics(s.T())
handler := preblock.NewOraclePreBlockHandler(
log.NewTestLogger(s.T()),
func(_ sdk.Context) aggregator.AggregateFn[string, map[slinkytypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[slinkytypes.CurrencyPair]*big.Int]) map[slinkytypes.CurrencyPair]*big.Int {
func(_ sdk.Context) aggregator.AggregateFn[string, map[connecttypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[connecttypes.CurrencyPair]*big.Int]) map[connecttypes.CurrencyPair]*big.Int {
return nil
}
},
Expand All @@ -604,8 +604,8 @@ func (s *PreBlockTestSuite) TestValidatorReports() {
metrics := metricmock.NewMetrics(s.T())
handler := preblock.NewOraclePreBlockHandler(
log.NewTestLogger(s.T()),
func(_ sdk.Context) aggregator.AggregateFn[string, map[slinkytypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[slinkytypes.CurrencyPair]*big.Int]) map[slinkytypes.CurrencyPair]*big.Int {
func(_ sdk.Context) aggregator.AggregateFn[string, map[connecttypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[connecttypes.CurrencyPair]*big.Int]) map[connecttypes.CurrencyPair]*big.Int {
return nil
}
},
Expand Down Expand Up @@ -638,17 +638,17 @@ func (s *PreBlockTestSuite) TestValidatorReports() {
val2 := sdk.ConsAddress("val2")
val3 := sdk.ConsAddress("val3")

mockOracleKeeper := slinkyabcimocks.NewOracleKeeper(s.T())
mockOracleKeeper := connectabcimocks.NewOracleKeeper(s.T())
currencyPairStrategyMock := currencypairmock.NewCurrencyPairStrategy(s.T())

btcUsd := slinkytypes.NewCurrencyPair("BTC", "USD")
mogUsd := slinkytypes.NewCurrencyPair("MOG", "USD")
btcUsd := connecttypes.NewCurrencyPair("BTC", "USD")
mogUsd := connecttypes.NewCurrencyPair("MOG", "USD")

handler := preblock.NewOraclePreBlockHandler(
log.NewTestLogger(s.T()),
func(_ sdk.Context) aggregator.AggregateFn[string, map[slinkytypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[slinkytypes.CurrencyPair]*big.Int]) map[slinkytypes.CurrencyPair]*big.Int {
return map[slinkytypes.CurrencyPair]*big.Int{
func(_ sdk.Context) aggregator.AggregateFn[string, map[connecttypes.CurrencyPair]*big.Int] {
return func(_ aggregator.AggregatedProviderData[string, map[connecttypes.CurrencyPair]*big.Int]) map[connecttypes.CurrencyPair]*big.Int {
return map[connecttypes.CurrencyPair]*big.Int{
// return default values
btcUsd: big.NewInt(1),
mogUsd: maxUint256,
Expand All @@ -675,7 +675,7 @@ func (s *PreBlockTestSuite) TestValidatorReports() {
currencyPairStrategyMock.On("GetDecodedPrice", s.ctx, mogUsd, mock.Anything).Return(maxUint256, nil)

// mock oracle keeper calls
mockOracleKeeper.On("GetAllCurrencyPairs", s.ctx).Return([]slinkytypes.CurrencyPair{btcUsd, mogUsd}, nil)
mockOracleKeeper.On("GetAllCurrencyPairs", s.ctx).Return([]connecttypes.CurrencyPair{btcUsd, mogUsd}, nil)
mockOracleKeeper.On("SetPriceForCurrencyPair", s.ctx, btcUsd, mock.Anything).Return(nil)
mockOracleKeeper.On("SetPriceForCurrencyPair", s.ctx, mogUsd, mock.Anything).Return(nil)

Expand Down
4 changes: 2 additions & 2 deletions abci/preblock/oracle/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
cometproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"

slinkytypes "github.com/skip-mev/connect/v2/pkg/types"
connecttypes "github.com/skip-mev/connect/v2/pkg/types"
servicemetrics "github.com/skip-mev/connect/v2/service/metrics"
)

// recordPrice records all the given prices per ticker, and reports them as a float64.
func (h *PreBlockHandler) recordPrices(prices map[slinkytypes.CurrencyPair]*big.Int) {
func (h *PreBlockHandler) recordPrices(prices map[connecttypes.CurrencyPair]*big.Int) {
for ticker, price := range prices {
floatPrice, _ := price.Float64()
h.metrics.ObservePriceForTicker(ticker, floatPrice)
Expand Down
28 changes: 14 additions & 14 deletions abci/proposals/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/skip-mev/connect/v2/abci/strategies/codec"
"github.com/skip-mev/connect/v2/abci/strategies/currencypair"
slinkyabci "github.com/skip-mev/connect/v2/abci/types"
connectabci "github.com/skip-mev/connect/v2/abci/types"
"github.com/skip-mev/connect/v2/abci/ve"
servicemetrics "github.com/skip-mev/connect/v2/service/metrics"
)
Expand Down Expand Up @@ -114,12 +114,12 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
"slinky prepare proposal latency", (totalLatency - wrappedPrepareProposalLatency).Seconds(),
)

slinkyabci.RecordLatencyAndStatus(h.metrics, totalLatency-wrappedPrepareProposalLatency, err, servicemetrics.PrepareProposal)
connectabci.RecordLatencyAndStatus(h.metrics, totalLatency-wrappedPrepareProposalLatency, err, servicemetrics.PrepareProposal)
}()

if req == nil {
h.logger.Error("PrepareProposalHandler received a nil request")
err = slinkyabci.NilRequestError{
err = connectabci.NilRequestError{
Handler: servicemetrics.PrepareProposal,
}
return nil, err
Expand Down Expand Up @@ -162,7 +162,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
"commit_info", extInfo,
"err", err,
)
err = slinkyabci.CodecError{
err = connectabci.CodecError{
Err: err,
}

Expand Down Expand Up @@ -193,7 +193,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
wrappedPrepareProposalLatency = time.Since(wrappedPrepareProposalStartTime)
if err != nil {
h.logger.Error("failed to prepare proposal", "err", err)
err = slinkyabci.WrappedHandlerError{
err = connectabci.WrappedHandlerError{
Handler: servicemetrics.PrepareProposal,
Err: err,
}
Expand Down Expand Up @@ -267,13 +267,13 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {
"wrapped prepare proposal latency", wrappedProcessProposalLatency.Seconds(),
"slinky prepare proposal latency", (totalLatency - wrappedProcessProposalLatency).Seconds(),
)
slinkyabci.RecordLatencyAndStatus(h.metrics, totalLatency-wrappedProcessProposalLatency, err, servicemetrics.ProcessProposal)
connectabci.RecordLatencyAndStatus(h.metrics, totalLatency-wrappedProcessProposalLatency, err, servicemetrics.ProcessProposal)
}()

// this should never happen, but just in case
if req == nil {
h.logger.Error("ProcessProposalHandler received a nil request")
err = slinkyabci.NilRequestError{
err = connectabci.NilRequestError{
Handler: servicemetrics.ProcessProposal,
}
return nil, err
Expand All @@ -293,21 +293,21 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {

if voteExtensionsEnabled {
// Ensure that the commit info was correctly injected into the proposal.
if len(req.Txs) < slinkyabci.NumInjectedTxs {
if len(req.Txs) < connectabci.NumInjectedTxs {
h.logger.Error("failed to process proposal: missing commit info", "num_txs", len(req.Txs))
err = slinkyabci.MissingCommitInfoError{}
err = connectabci.MissingCommitInfoError{}
return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT},
err
}

extCommitBz := req.Txs[slinkyabci.OracleInfoIndex]
extCommitBz := req.Txs[connectabci.OracleInfoIndex]

// Validate the vote extensions included in the proposal.
var extInfo cometabci.ExtendedCommitInfo
extInfo, err = h.extendedCommitCodec.Decode(extCommitBz)
if err != nil {
h.logger.Error("failed to unmarshal commit info", "err", err)
err = slinkyabci.CodecError{
err = connectabci.CodecError{
Err: err,
}
return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT},
Expand All @@ -334,16 +334,16 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {

// Remove the extended commit info from the proposal if required
if !h.retainOracleDataInWrappedHandler {
injectedTx = req.Txs[slinkyabci.OracleInfoIndex]
req.Txs = req.Txs[slinkyabci.NumInjectedTxs:]
injectedTx = req.Txs[connectabci.OracleInfoIndex]
req.Txs = req.Txs[connectabci.NumInjectedTxs:]
}
}

// call the wrapped process-proposal
wrappedProcessProposalStartTime := time.Now()
resp, err = h.processProposalHandler(ctx, req)
if err != nil {
err = slinkyabci.WrappedHandlerError{
err = connectabci.WrappedHandlerError{
Handler: servicemetrics.ProcessProposal,
Err: err,
}
Expand Down
Loading
Loading