Skip to content

Commit

Permalink
Merge branch 'main' into feat/block-height-staleness
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 authored Aug 26, 2024
2 parents d99c86e + 26f2c7e commit 3274608
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ go.work*

# Testing script folders
/tests/.slinkyd
/tests/.connectd

# build dir
/build/
Expand Down
94 changes: 89 additions & 5 deletions docs/developers/integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -369,22 +369,21 @@ Finally, call these methods back in `app.go`, directly after setting the `x/mark
app.initializeABCIExtensions(client, metrics)
```

## Starting the Application
## Initializing Modules

In order for the application to use Connect properly, the following is required:

- Set the consensus parameters to enable vote extensions
- Initialize `x/marketmap` with initial markets

The following code can be executed within an upgrade handler for chains that are already live or in `InitChainer` for new chains:

```go
```go oracle.go
package app

import (
"slices"

tmtypes "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/skip-mev/connect/v2/cmd/constants/marketmaps"
Expand Down Expand Up @@ -439,7 +438,92 @@ func (app *App) setupMarkets(ctx sdk.Context) error {
}
```

With the Connect sidecar running, the application can now be started and will begin receiving price data at the configured `VoteExtensionsEnableHeight`.
For new chains, or to test the integration, the method above can be called in `InitChainer`. Connect will begin posting prices to the chain once the `VoteExtensionsEnabledHeight` is reached.

```go app.go
package app

func NewApp(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
// ...

// initialize the chain with markets in state.
app.SetInitChainer(func(ctx sdk.Context, req *types.RequestInitChain) (*types.ResponseInitChain, error) {
err := app.setupMarkets(ctx)
if err != nil {
return nil, err
}
})

// ...
}
```

For live running chains, use an upgrade handler. Note: Connect will not post prices to the chain until the upgrade is executed.

```go app.go
package app

func NewApp(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
// ...

connectUpgradeName := "connect-upgrade" // placeholder value, use a real upgrade name.

app.UpgradeKeeper.SetUpgradeHandler(connectUpgradeName, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
migrations, err := app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
if err != nil {
return nil, err
}

// add the markets to the chain state.
err := app.setupMarkets(ctx)
if err != nil {
return migrations, err
}

return migrations, nil
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("failed to read upgrade info from disk: %w", err))
}


// add the x/marketmap and x/oracle stores.
if upgradeInfo.Name == connectUpgradeName {
app.SetStoreLoader(
upgradetypes.UpgradeStoreLoader(
upgradeInfo.Height,
&storetypes.StoreUpgrades{
Added: []string{marketmaptypes.ModuleName, oracletypes.ModuleName},
Renamed: nil,
Deleted: nil,
},
),
)
}

// ...
}
```

## Running the Node

Once the chain is properly configured, head over to the [Quickstart](../validators/quickstart) guide to learn how to start the node with a Connect sidecar.

## Need Help?

Expand Down
4 changes: 4 additions & 0 deletions docs/validators/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ icon: circle-question
Yes, you can run it anywhere - but please defer to any chain-specific recommendations if there are any!
</Accordion>

<Accordion title="Can I use IPv6?">
No, IPv6 is currently not supported for sidecar-node communication.
</Accordion>

<Accordion title="Can I use the same Connect sidecar for different chains?">
We are currently working on supporting this feature. It will be available in a future release.
</Accordion>
Expand Down

0 comments on commit 3274608

Please sign in to comment.