Skip to content

Commit

Permalink
Merge branch 'main' into test/slinky
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 authored Jun 7, 2024
2 parents e87a87a + 3916bb4 commit 0145ca9
Show file tree
Hide file tree
Showing 16 changed files with 179 additions and 159 deletions.
55 changes: 31 additions & 24 deletions .github/workflows/interchaintest.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Run InterchainTest

on:
on:
pull_request:
branches:
- main
- feature/*
- release/*

release:
types: published

workflow_dispatch:

jobs:
Expand All @@ -24,7 +24,7 @@ jobs:
- name: Set up Golang
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -35,7 +35,7 @@ jobs:
context: .
tags: publicawesome/stargaze:local-dev
outputs: type=docker,dest=/tmp/sg.tar

- name: Upload the Docker image # Uploading as artifact so that all the tests which run as different jobs can use this image
uses: actions/upload-artifact@v3
with:
Expand All @@ -51,69 +51,77 @@ jobs:
- name: Checkout strangelove-ventures/interchaintest
uses: actions/checkout@v3
with:
repository: strangelove-ventures/interchaintest
repository: public-awesome/interchaintest
ref: "8.3.0-stargaze"

- name: Set up Golang
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"

- name: Build Interchaintest
run: make interchaintest

- name: Upload binary as artifact # Uploading as artifact so that all the tests which run as different jobs can use this binary
uses: actions/upload-artifact@v3
with:
name: interchaintest
path: ./bin/interchaintest
retention-days: 1
name: interchaintest
path: ./bin/interchaintest
retention-days: 1

run_gaia_interchaintest:
name: gaia ⚛️
needs: [build_interchaintest,build_sg_image]
needs: [build_interchaintest, build_sg_image]
uses: ./.github/workflows/interchaintest_runner.yml
with:
test-matrix: 'interchain_test/gaia.matrix.json'
test-matrix: "interchain_test/gaia.matrix.json"

run_osmosis_interchaintest:
name: osmosis 🧪
needs: [build_interchaintest,build_sg_image]
needs: [build_interchaintest, build_sg_image]
uses: ./.github/workflows/interchaintest_runner.yml
with:
test-matrix: 'interchain_test/osmosis.matrix.json'
test-matrix: "interchain_test/osmosis.matrix.json"

run_ica_interchaintest:
name: ica 🔐
needs: [build_sg_image]
uses: ./.github/workflows/interchaintest_custom_runner.yml
with:
test-cmd: 'test-ica'
test-cmd: "test-ica"

run_pfm_interchaintest:
name: pfm ⏩
needs: [build_sg_image]
uses: ./.github/workflows/interchaintest_custom_runner.yml
with:
test-cmd: 'test-pfm'
test-cmd: "test-pfm"

run_chain_upgrade_interchaintest:
name: upgrade 🏆
needs: [build_sg_image]
uses: ./.github/workflows/interchaintest_custom_runner.yml
with:
test-cmd: 'test-chain-upgrade'
test-cmd: "test-chain-upgrade"

run_chain_conformance:
name: conformance 🤝
needs: [build_sg_image]
uses: ./.github/workflows/interchaintest_custom_runner.yml
with:
test-cmd: 'test-chain-conformance'

test-cmd: "test-chain-conformance"

cleanup:
name: Delete artifacts 🗑️
needs: [run_gaia_interchaintest,run_osmosis_interchaintest,run_pfm_interchaintest,run_chain_upgrade_interchaintest,run_ica_interchaintest,run_chain_conformance]
needs:
[
run_gaia_interchaintest,
run_osmosis_interchaintest,
run_pfm_interchaintest,
run_chain_upgrade_interchaintest,
run_ica_interchaintest,
run_chain_conformance,
]
runs-on: ubuntu-latest

steps:
Expand All @@ -122,10 +130,9 @@ jobs:
with:
name: interchaintest
failOnError: false

- name: Delete sg # Delete the stargaze docker image from workflow artifacts as its not needed anymore
uses: geekyeggo/delete-artifact@v2
with:
name: sg
failOnError: false

20 changes: 4 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,10 @@ COPY . /code/

# See https://github.com/CosmWasm/wasmvm/releases
# Download the correct version of libwasmvm for the given platform and verify checksum
RUN case "${TARGETPLATFORM}" in \
"linux/amd64") \
WASMVM_URL="https://github.com/CosmWasm/wasmvm/releases/download/v2.0.1/libwasmvm_muslc.x86_64.a" && \
WASMVM_CHECKSUM="85de2ab3c40236935dbd023c9211130d49c5464494c4b9b09ea33e27a2d6bf87" \
;; \
"linux/arm64") \
WASMVM_URL="https://github.com/CosmWasm/wasmvm/releases/download/v1.5.2/libwasmvm_muslc.aarch64.a" && \
WASMVM_CHECKSUM="e78b224c15964817a3b75a40e59882b4d0e06fd055b39514d61646689cef8c6e" \
;; \
*) \
echo "Unsupported platform: ${TARGETPLATFORM}" ; \
exit 1 \
;; \
esac && \
wget "${WASMVM_URL}" -O /lib/libwasmvm_muslc.x86_64.a && \
echo "${WASMVM_CHECKSUM} /lib/libwasmvm_muslc.x86_64.a" | sha256sum -c
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.0.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.0.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
RUN echo "85de2ab3c40236935dbd023c9211130d49c5464494c4b9b09ea33e27a2d6bf87 /lib/libwasmvm_muslc.x86_64.a" | sha256sum -c
RUN echo "860ba8d7ee4c89c1b0dc3abd4b3658d07ddf5531d2de970cada0699689cc1e33 /lib/libwasmvm_muslc.aarch64.a" | sha256sum -c

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build
Expand Down
51 changes: 41 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,23 @@ import (
keepers "github.com/public-awesome/stargaze/v14/app/keepers"
sgstatesync "github.com/public-awesome/stargaze/v14/internal/statesync"

"github.com/skip-mev/slinky/x/oracle"
oraclekeeper "github.com/skip-mev/slinky/x/oracle/keeper"
oracletypes "github.com/skip-mev/slinky/x/oracle/types"

// slinky
oraclepreblock "github.com/skip-mev/slinky/abci/preblock/oracle"
"github.com/skip-mev/slinky/abci/proposals"
"github.com/skip-mev/slinky/abci/strategies/aggregator"
compression "github.com/skip-mev/slinky/abci/strategies/codec"
"github.com/skip-mev/slinky/abci/strategies/currencypair"
"github.com/skip-mev/slinky/abci/ve"
oracleconfig "github.com/skip-mev/slinky/oracle/config"
"github.com/skip-mev/slinky/pkg/math/voteweighted"
oracleclient "github.com/skip-mev/slinky/service/clients/oracle"
servicemetrics "github.com/skip-mev/slinky/service/metrics"
"github.com/skip-mev/slinky/x/marketmap"
marketmapkeeper "github.com/skip-mev/slinky/x/marketmap/keeper"
marketmaptypes "github.com/skip-mev/slinky/x/marketmap/types"
"github.com/skip-mev/slinky/x/oracle"
oraclekeeper "github.com/skip-mev/slinky/x/oracle/keeper"
oracletypes "github.com/skip-mev/slinky/x/oracle/types"
)

const (
Expand Down Expand Up @@ -314,7 +324,8 @@ type App struct {
ScopedWasmKeeper capabilitykeeper.ScopedKeeper

// oracle
oracleClient oracleclient.OracleClient
oracleClient oracleclient.OracleClient
oraclePreBlocker sdk.PreBlocker
}

// NewStargazeApp returns a reference to an initialized Gaia.
Expand Down Expand Up @@ -1041,18 +1052,38 @@ func NewStargazeApp(

app.SetPreBlocker(oraclePreBlockHandler.PreBlocker())

app.oraclePreBlocker = oraclePreBlockHandler.PreBlocker()
app.SetPreBlocker(app.PreBlocker)
// Create the vote extensions handler that will be used to extend and verify
// vote extensions (i.e. oracle data).
cps := currencypair.NewDeltaCurrencyPairStrategy(app.Keepers.OracleKeeper)
veCodec := compression.NewCompressionVoteExtensionCodec(
compression.NewDefaultVoteExtensionCodec(),
compression.NewZLibCompressor(),
)
extCommitCodec := compression.NewCompressionExtendedCommitCodec(
compression.NewDefaultExtendedCommitCodec(),
compression.NewZStdCompressor(),
)
voteExtensionsHandler := ve.NewVoteExtensionHandler(
app.Logger(),
app.oracleClient,
time.Second,
currencypair.NewDeltaCurrencyPairStrategy(app.Keepers.OracleKeeper),
compression.NewCompressionVoteExtensionCodec(
compression.NewDefaultVoteExtensionCodec(),
compression.NewZLibCompressor(),
cps,
veCodec,
aggregator.NewOraclePriceApplier(
aggregator.NewDefaultVoteAggregator(
app.Logger(),
aggregatorFn,
// we need a separate price strategy here, so that we can optimistically apply the latest prices
// and extend our vote based on these prices
currencypair.NewDeltaCurrencyPairStrategy(app.Keepers.OracleKeeper),
),
app.Keepers.OracleKeeper,
veCodec,
extCommitCodec,
app.Logger(),
),
oraclePreBlockHandler.PreBlocker(),
oracleMetrics,
)
app.SetExtendVoteHandler(voteExtensionsHandler.ExtendVoteHandler())
Expand Down
18 changes: 16 additions & 2 deletions app/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@ import (
)

// PreBlocker application updates every pre block
func (a *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) {
return a.ModuleManager.PreBlock(ctx)
func (a *App) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) {
// call app's preblocker first in case there is changes made on upgrades
// that can modify state and lead to serialization/deserialization issues
resp, err := a.ModuleManager.PreBlock(ctx)
if err != nil {
return resp, err
}

// oracle preblocker sends empty response pre block so it can ignored
_, err = a.oraclePreBlocker(ctx, req)
if err != nil {
return &sdk.ResponsePreBlock{}, err
}

// return resp from app's preblocker which can return consensus param changed flag
return resp, nil
}

// Precommiter application updates every commit
Expand Down
11 changes: 5 additions & 6 deletions app/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
// CustomAppConfig defines the configuration for the Nois app.
type CustomAppConfig struct {
serverconfig.Config
Wasm wasmtypes.WasmConfig `mapstructure:"wasm" json:"wasm"`
Oracle oracleconfig.AppConfig `mapstructure:"oracle" json:"oracle"`
Wasm wasmtypes.WasmConfig `mapstructure:"wasm"`
}

func CustomconfigTemplate(config wasmtypes.WasmConfig) string {
Expand All @@ -31,17 +31,16 @@ func DefaultConfig() (string, interface{}) {
wasmConfig.MemoryCacheSize = 512
wasmConfig.ContractDebugMode = false

oracleConfig := oracleconfig.AppConfig{
Enabled: true,
oracleCfg := oracleconfig.AppConfig{
Enabled: false,
OracleAddress: "localhost:8080",
ClientTimeout: time.Second * 2,
MetricsEnabled: true,
MetricsEnabled: false,
}

customConfig := CustomAppConfig{
Config: *serverConfig,
Oracle: oracleConfig,
Wasm: wasmConfig,
Oracle: oracleCfg,
}

return CustomconfigTemplate(wasmConfig), customConfig
Expand Down
13 changes: 13 additions & 0 deletions app/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package app
import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
tokenfactorytypes "github.com/public-awesome/stargaze/v14/x/tokenfactory/types"
marketmaptypes "github.com/skip-mev/slinky/x/marketmap/types"
oracletypes "github.com/skip-mev/slinky/x/oracle/types"
)

var wasmCapabilities = []string{
Expand All @@ -12,9 +14,20 @@ var wasmCapabilities = []string{

func AcceptedStargateQueries() wasmkeeper.AcceptedQueries {
return wasmkeeper.AcceptedQueries{
// tokenfactory
"/osmosis.tokenfactory.v1beta1.Query/Params": &tokenfactorytypes.QueryParamsResponse{},
"/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata": &tokenfactorytypes.QueryDenomAuthorityMetadataResponse{},
"/osmosis.tokenfactory.v1beta1.Query/DenomsFromCreator": &tokenfactorytypes.QueryDenomsFromCreatorResponse{},

// oracle
"/slinky.oracle.v1.Query/GetAllCurrencyPairs": &oracletypes.GetAllCurrencyPairsResponse{},
"/slinky.oracle.v1.Query/GetPrice": &oracletypes.GetPriceResponse{},
"/slinky.oracle.v1.Query/GetPrices": &oracletypes.GetPricesResponse{},

// marketmap
"/slinky.marketmap.v1.Query/MarketMap": &marketmaptypes.MarketMapResponse{},
"/slinky.marketmap.v1.Query/LastUpdated": &marketmaptypes.LastUpdatedResponse{},
"/slinky.marketmap.v1.Query/Params": &marketmaptypes.ParamsResponse{},
}
}

Expand Down
Loading

0 comments on commit 0145ca9

Please sign in to comment.