Skip to content

Commit

Permalink
bump slinky to latest and use hash strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed May 10, 2024
1 parent 9fcbdb3 commit b24107f
Show file tree
Hide file tree
Showing 11 changed files with 2,882 additions and 538 deletions.
27 changes: 22 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ import (
auctionante "github.com/skip-mev/block-sdk/v2/x/auction/ante"
auctionkeeper "github.com/skip-mev/block-sdk/v2/x/auction/keeper"
auctiontypes "github.com/skip-mev/block-sdk/v2/x/auction/types"
marketmap "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"
Expand Down Expand Up @@ -229,6 +232,7 @@ type MinitiaApp struct {
AuctionKeeper *auctionkeeper.Keeper // x/auction keeper used to process bids for POB auctions
PacketForwardKeeper *packetforwardkeeper.Keeper
OracleKeeper *oraclekeeper.Keeper // x/oracle keeper used for the slinky oracle
MarketMapKeeper *marketmapkeeper.Keeper
IBCHooksKeeper *ibchookskeeper.Keeper
ForwardingKeeper *forwardingkeeper.Keeper

Expand Down Expand Up @@ -284,7 +288,7 @@ func NewMinitiaApp(
icahosttypes.StoreKey, icacontrollertypes.StoreKey, icaauthtypes.StoreKey,
ibcfeetypes.StoreKey, evmtypes.StoreKey, opchildtypes.StoreKey,
auctiontypes.StoreKey, packetforwardtypes.StoreKey, oracletypes.StoreKey,
ibchookstypes.StoreKey, forwardingtypes.StoreKey,
marketmaptypes.StoreKey, ibchookstypes.StoreKey, forwardingtypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(forwardingtypes.TransientStoreKey)
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -366,14 +370,25 @@ func NewMinitiaApp(
////////////////////////////////

// initialize oracle keeper
marketMapKeeper := marketmapkeeper.NewKeeper(
runtime.NewKVStoreService(keys[marketmaptypes.StoreKey]),
appCodec,
authorityAccAddr,
)
app.MarketMapKeeper = marketMapKeeper

oracleKeeper := oraclekeeper.NewKeeper(
runtime.NewKVStoreService(keys[oracletypes.StoreKey]),
appCodec,
nil,
marketMapKeeper,
authorityAccAddr,
)
app.OracleKeeper = &oracleKeeper

// Add the oracle keeper as a hook to market map keeper so new market map entries can be created
// and propogated to the oracle keeper.
app.MarketMapKeeper.SetHooks(app.OracleKeeper.Hooks())

app.OPChildKeeper = opchildkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[opchildtypes.StoreKey]),
Expand Down Expand Up @@ -719,6 +734,7 @@ func NewMinitiaApp(
forwarding.NewAppModule(app.ForwardingKeeper),
// slinky modules
oracle.NewAppModule(appCodec, *app.OracleKeeper),
marketmap.NewAppModule(appCodec, app.MarketMapKeeper),
)

// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
Expand Down Expand Up @@ -748,6 +764,7 @@ func NewMinitiaApp(
authz.ModuleName,
ibcexported.ModuleName,
oracletypes.ModuleName,
marketmaptypes.ModuleName,
)

app.ModuleManager.SetOrderEndBlockers(
Expand All @@ -756,6 +773,7 @@ func NewMinitiaApp(
feegrant.ModuleName,
group.ModuleName,
oracletypes.ModuleName,
marketmaptypes.ModuleName,
forwardingtypes.ModuleName,
)

Expand All @@ -769,9 +787,8 @@ func NewMinitiaApp(
opchildtypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, group.ModuleName,
upgradetypes.ModuleName, feegrant.ModuleName, consensusparamtypes.ModuleName, ibcexported.ModuleName,
ibctransfertypes.ModuleName, ibcnfttransfertypes.ModuleName, icatypes.ModuleName, icaauthtypes.ModuleName,
ibcfeetypes.ModuleName, auctiontypes.ModuleName, oracletypes.ModuleName,
packetforwardtypes.ModuleName, forwardingtypes.ModuleName,
ibchookstypes.ModuleName,
ibcfeetypes.ModuleName, auctiontypes.ModuleName, oracletypes.ModuleName, marketmaptypes.ModuleName,
packetforwardtypes.ModuleName, forwardingtypes.ModuleName, ibchookstypes.ModuleName,
}

app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down
60 changes: 54 additions & 6 deletions app/genesis.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package app

import (
"encoding/hex"
"encoding/json"

"cosmossdk.io/core/address"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
Expand All @@ -14,9 +16,11 @@ import (

l2slinky "github.com/initia-labs/OPinit/x/opchild/l2slinky"
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
"github.com/initia-labs/initia/app/genesis_markets"

auctiontypes "github.com/skip-mev/block-sdk/v2/x/auction/types"
slinkytypes "github.com/skip-mev/slinky/pkg/types"
marketmaptypes "github.com/skip-mev/slinky/x/marketmap/types"
oracletypes "github.com/skip-mev/slinky/x/oracle/types"
)

Expand All @@ -30,29 +34,73 @@ import (
type GenesisState map[string]json.RawMessage

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState(cdc codec.JSONCodec, mbm module.BasicManager, denom string) GenesisState {
func NewDefaultGenesisState(cdc codec.Codec, mbm module.BasicManager, denom string) GenesisState {
return GenesisState(mbm.DefaultGenesis(cdc)).
ConfigureMinGasPrices(cdc).
ConfigureICA(cdc).
ConfigureIBCAllowedClients(cdc).
ConfigureAuctionFee(cdc, denom).
AddTimestampCurrencyPair(cdc)
AddMarketData(cdc, cdc.InterfaceRegistry().SigningContext().AddressCodec())
}

func (genState GenesisState) AddTimestampCurrencyPair(cdc codec.JSONCodec) GenesisState {
func (genState GenesisState) AddMarketData(cdc codec.JSONCodec, ac address.Codec) GenesisState {
var oracleGenState oracletypes.GenesisState
cdc.MustUnmarshalJSON(genState[oracletypes.ModuleName], &oracleGenState)

cp, err := slinkytypes.CurrencyPairFromString(l2slinky.ReservedCPTimestamp)
var marketGenState marketmaptypes.GenesisState
cdc.MustUnmarshalJSON(genState[marketmaptypes.ModuleName], &marketGenState)

// Load initial markets
markets, err := genesis_markets.ReadMarketsFromFile(genesis_markets.GenesisMarkets)
if err != nil {
panic(err)

Check warning on line 56 in app/genesis.go

View check run for this annotation

Codecov / codecov/patch

app/genesis.go#L56

Added line #L56 was not covered by tests
}
marketGenState.MarketMap = genesis_markets.ToMarketMap(markets)

// Skip Admin account.
adminAddrBz, err := hex.DecodeString("51B89E89D58FFB3F9DB66263FF10A216CF388A0E")
if err != nil {
panic(err)
}

oracleGenState.CurrencyPairGenesis = append(oracleGenState.CurrencyPairGenesis, oracletypes.CurrencyPairGenesis{
adminAddr, err := ac.BytesToString(adminAddrBz)
if err != nil {
panic(err)

Check warning on line 68 in app/genesis.go

View check run for this annotation

Codecov / codecov/patch

app/genesis.go#L68

Added line #L68 was not covered by tests
}

marketGenState.Params.MarketAuthorities = []string{adminAddr}
marketGenState.Params.Admin = adminAddr

var id uint64

// Initialize all markets plus ReservedCPTimestamp
currencyPairGenesis := make([]oracletypes.CurrencyPairGenesis, len(markets)+1)
cp, err := slinkytypes.CurrencyPairFromString(l2slinky.ReservedCPTimestamp)
if err != nil {
panic(err)

Check warning on line 80 in app/genesis.go

View check run for this annotation

Codecov / codecov/patch

app/genesis.go#L80

Added line #L80 was not covered by tests
}
currencyPairGenesis[id] = oracletypes.CurrencyPairGenesis{
CurrencyPair: cp,
CurrencyPairPrice: nil,
Nonce: 0,
})
Id: id,
}
id++
for i, market := range markets {
currencyPairGenesis[i+1] = oracletypes.CurrencyPairGenesis{
CurrencyPair: market.Ticker.CurrencyPair,
CurrencyPairPrice: nil,
Nonce: 0,
Id: id,
}
id++
}

oracleGenState.CurrencyPairGenesis = currencyPairGenesis
oracleGenState.NextId = id

// write the updates to genState
genState[marketmaptypes.ModuleName] = cdc.MustMarshalJSON(&marketGenState)
genState[oracletypes.ModuleName] = cdc.MustMarshalJSON(&oracleGenState)
return genState
}
Expand Down
11 changes: 11 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@
"Params": "EVMParams"
}
}
},
{
"url": "./tmp-swagger-gen/slinky/oracle/v1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/slinky/marketmap/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "MarketMapParams"
}
}
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit b24107f

Please sign in to comment.