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

Further v7 upgrade updates #246

Merged
merged 18 commits into from
Dec 14, 2023
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
97 changes: 68 additions & 29 deletions app/upgrades/v7/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v7

import (
"fmt"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -33,6 +34,7 @@ func CreateUpgradeHandler(

// Now that we're on IBC V6, we can update the ICA host module to allow all message types rather than
// the list we specified in the v6 upgrade -- a default of HostEnabled: true and the string "*" for messages
ctx.Logger().Info("v7 upgrade: setting ICA host params to allow all messages")
icaParams := icahosttypes.DefaultParams()
icaHostKeeper.SetParams(ctx, icaParams)

Expand All @@ -48,7 +50,6 @@ func CreateUpgradeHandler(
ctx.Logger().Info("v7 upgrading: setting cellarfees default params")
cellarfeesKeeper.SetParams(ctx, cellarfeestypes.DefaultParams())

//TODO(bolten): verify that the default params are fine or if we need to customize them for auction and pubsub
ctx.Logger().Info("v7 upgrade: initializing auction genesis state")
auctionInitGenesis(ctx, auctionKeeper)

Expand All @@ -72,8 +73,8 @@ func auctionInitGenesis(ctx sdk.Context, auctionKeeper auctionkeeper.Keeper) {
btc52WeekHigh := sdk.MustNewDecFromStr("44202.18")
oneDollar := sdk.MustNewDecFromStr("1.0")

// TODO(bolten): update LastUpdatedBlock to the upgrade height when finalized
var lastUpdatedBlock uint64 = 1
// Setting this to a block on 12/14/23 -- just means token price will get stale 4 days faster post-upgrade
var lastUpdatedBlock uint64 = 12187266

usommPrice := auctiontypes.TokenPrice{
Denom: "usomm",
Expand Down Expand Up @@ -136,6 +137,10 @@ func auctionInitGenesis(ctx sdk.Context, auctionKeeper auctionkeeper.Keeper) {
&wbtcPrice,
}

if err := genesisState.Validate(); err != nil {
panic(fmt.Errorf("auction genesis state invalid: %s", err))
}

auctionkeeper.InitGenesis(ctx, auctionKeeper, genesisState)
}

Expand Down Expand Up @@ -186,6 +191,34 @@ func axelarcorkInitGenesis(ctx sdk.Context, axelarcorkKeeper axelarcorkkeeper.Ke
},
}

// InitGenesis reads through each chain configuration in order and sets the cellar ID set
// for it based on index, so this list must be of the same size and order as the respective
// chain configurations above
genesisState.CellarIds = []*axelarcorktypes.CellarIDSet{
{
Ids: []string{"0x438087f7c226A89762a791F187d7c3D4a0e95ae6"}, // arbitrum test cellar
},
{
Ids: []string{},
},
{
Ids: []string{},
},
{
Ids: []string{},
},
{
Ids: []string{},
},
{
Ids: []string{},
},
}

if err := genesisState.Validate(); err != nil {
panic(fmt.Errorf("axelarcork genesis state invalid: %s", err))
}

axelarcorkkeeper.InitGenesis(ctx, axelarcorkKeeper, genesisState)
}

Expand All @@ -204,33 +237,35 @@ func pubsubInitGenesis(ctx sdk.Context, pubsubKeeper pubsubkeeper.Keeper) {
publishers := []*pubsubtypes.Publisher{&publisher}

cellars := []string{
"0x7bAD5DF5E11151Dc5Ee1a648800057C5c934c0d5", // Aave V2
"0x03df2A53Cbed19B824347D6a45d09016C2D1676a", // DeFi Stars
"0x6c51041A91C91C86f3F08a72cB4D3F67f1208897", // ETH Trend Growth
"0x6b7f87279982d919bbf85182ddeab179b366d8f2", // ETH-BTC Trend
"0x6e2dac3b9e9adc0cbbae2d0b9fd81952a8d33872", // ETH-BTC Momentum
"0xDBe19d1c3F21b1bB250ca7BDaE0687A97B5f77e6", // Fraximal
"0xC7b69E15D86C5c1581dacce3caCaF5b68cd6596F", // Real Yield 1INCH
"0x0274a704a6D9129F90A62dDC6f6024b33EcDad36", // Real Yield BTC
"0x18ea937aba6053bC232d9Ae2C42abE7a8a2Be440", // Real Yield ENS
"0xb5b29320d2Dde5BA5BAFA1EbcD270052070483ec", // Real Yield ETH
"0x4068BDD217a45F8F668EF19F1E3A1f043e4c4934", // Real Yield LINK
"0xcBf2250F33c4161e18D4A2FA47464520Af5216b5", // Real Yield SNX
"0x6A6AF5393DC23D7e3dB28D28Ef422DB7c40932B6", // Real Yield UNI
"0x97e6E0a40a3D02F12d1cEC30ebfbAE04e37C119E", // Real Yield USD
"0x3F07A84eCdf494310D397d24c1C78B041D2fa622", // Steady ETH
"0x4986fD36b6b16f49b43282Ee2e24C5cF90ed166d", // Steady BTC
"0x05641a27C82799AaF22b436F20A3110410f29652", // Steady MATIC
"0x6f069f711281618467dae7873541ecc082761b33", // Steady UNI
"0x0C190DEd9Be5f512Bd72827bdaD4003e9Cc7975C", // Turbo GHO
"0x5195222f69c5821f8095ec565E71e18aB6A2298f", // Turbo SOMM
"0xc7372Ab5dd315606dB799246E8aA112405abAeFf", // Turbo stETH (stETH deposit)
"0xfd6db5011b171B05E1Ea3b92f9EAcaEEb055e971", // Turbo stETH (WETH deposit)
"0xd33dAd974b938744dAC81fE00ac67cb5AA13958E", // Turbo swETH
"1:0x7bAD5DF5E11151Dc5Ee1a648800057C5c934c0d5", // Aave V2
"1:0x03df2A53Cbed19B824347D6a45d09016C2D1676a", // DeFi Stars
"1:0x6c51041A91C91C86f3F08a72cB4D3F67f1208897", // ETH Trend Growth
"1:0x6b7f87279982d919Bbf85182DDeAB179B366D8f2", // ETH-BTC Trend
"1:0x6E2dAc3b9E9ADc0CbbaE2D0B9Fd81952a8D33872", // ETH-BTC Momentum
"1:0xDBe19d1c3F21b1bB250ca7BDaE0687A97B5f77e6", // Fraximal
"1:0xC7b69E15D86C5c1581dacce3caCaF5b68cd6596F", // Real Yield 1INCH
"1:0x0274a704a6D9129F90A62dDC6f6024b33EcDad36", // Real Yield BTC
"1:0x18ea937aba6053bC232d9Ae2C42abE7a8a2Be440", // Real Yield ENS
"1:0xb5b29320d2Dde5BA5BAFA1EbcD270052070483ec", // Real Yield ETH
"1:0x4068BDD217a45F8F668EF19F1E3A1f043e4c4934", // Real Yield LINK
"1:0xcBf2250F33c4161e18D4A2FA47464520Af5216b5", // Real Yield SNX
"1:0x6A6AF5393DC23D7e3dB28D28Ef422DB7c40932B6", // Real Yield UNI
"1:0x97e6E0a40a3D02F12d1cEC30ebfbAE04e37C119E", // Real Yield USD
"1:0x3F07A84eCdf494310D397d24c1C78B041D2fa622", // Steady ETH
"1:0x4986fD36b6b16f49b43282Ee2e24C5cF90ed166d", // Steady BTC
"1:0x05641a27C82799AaF22b436F20A3110410f29652", // Steady MATIC
"1:0x6F069F711281618467dAe7873541EcC082761B33", // Steady UNI
"1:0x9a7b4980C6F0FCaa50CD5f288Ad7038f434c692e", // Turbo EETH
"1:0x0C190DEd9Be5f512Bd72827bdaD4003e9Cc7975C", // Turbo GHO
"1:0x5195222f69c5821f8095ec565E71e18aB6A2298f", // Turbo SOMM
"1:0xc7372Ab5dd315606dB799246E8aA112405abAeFf", // Turbo stETH (stETH deposit)
"1:0xfd6db5011b171B05E1Ea3b92f9EAcaEEb055e971", // Turbo stETH (WETH deposit)
"1:0xd33dAd974b938744dAC81fE00ac67cb5AA13958E", // Turbo swETH
"42161:0x438087f7c226A89762a791F187d7c3D4a0e95ae6", // Arbitrum test cellar
}

// Set 7seas publisher intents for existing cellars
publisherIntents := make([]*pubsubtypes.PublisherIntent, 23)
publisherIntents := make([]*pubsubtypes.PublisherIntent, 25)
for _, cellar := range cellars {
publisherIntents = append(publisherIntents, &pubsubtypes.PublisherIntent{
SubscriptionId: cellar,
Expand All @@ -241,7 +276,7 @@ func pubsubInitGenesis(ctx sdk.Context, pubsubKeeper pubsubkeeper.Keeper) {
}

// Set default subscriptions for 7seas as the publisher for existing cellars
defaultSubscriptions := make([]*pubsubtypes.DefaultSubscription, 23)
defaultSubscriptions := make([]*pubsubtypes.DefaultSubscription, 25)
for _, cellar := range cellars {
defaultSubscriptions = append(defaultSubscriptions, &pubsubtypes.DefaultSubscription{
SubscriptionId: cellar,
Expand All @@ -251,7 +286,7 @@ func pubsubInitGenesis(ctx sdk.Context, pubsubKeeper pubsubkeeper.Keeper) {

// Create subscribers and intents for existing validators
subscribers := createSubscribers()
subscriberIntents := make([]*pubsubtypes.SubscriberIntent, 805)
subscriberIntents := make([]*pubsubtypes.SubscriberIntent, 875)
for _, subscriber := range subscribers {
for _, cellar := range cellars {
subscriberIntents = append(subscriberIntents, &pubsubtypes.SubscriberIntent{
Expand All @@ -268,6 +303,10 @@ func pubsubInitGenesis(ctx sdk.Context, pubsubKeeper pubsubkeeper.Keeper) {
genesisState.Subscribers = subscribers
genesisState.SubscriberIntents = subscriberIntents

if err := genesisState.Validate(); err != nil {
panic(fmt.Errorf("pubsub genesis state invalid: %s", err))
}

pubsubkeeper.InitGenesis(ctx, pubsubKeeper, genesisState)
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/ory/dockertest/v3 v3.10.0
github.com/peggyjv/gravity-bridge/module/v4 v4.0.0-20231211214131-bf2a31eb986f
github.com/peggyjv/gravity-bridge/module/v4 v4.0.0
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/spf13/cast v1.5.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,8 @@ github.com/peggyjv/gravity-bridge/module/v4 v4.0.0-20231130211750-e1fa9902c9d9 h
github.com/peggyjv/gravity-bridge/module/v4 v4.0.0-20231130211750-e1fa9902c9d9/go.mod h1:biwoVDKWggMYtzuUZOuqaJD8B40XHrXg3zOJjeAhT78=
github.com/peggyjv/gravity-bridge/module/v4 v4.0.0-20231211214131-bf2a31eb986f h1:xaVjypGpS3+VUXzEb2YFaTK632Id6jVWY1ViS4nljJs=
github.com/peggyjv/gravity-bridge/module/v4 v4.0.0-20231211214131-bf2a31eb986f/go.mod h1:n8Jj3X+w6q0Xz19w8feRRl2sfIGV+3FGU4anzXBQGbA=
github.com/peggyjv/gravity-bridge/module/v4 v4.0.0 h1:jH10FodlMxzGdbxAxeNpsql9qhYDlmwqciwOuwuU0LQ=
github.com/peggyjv/gravity-bridge/module/v4 v4.0.0/go.mod h1:n8Jj3X+w6q0Xz19w8feRRl2sfIGV+3FGU4anzXBQGbA=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
Expand Down
2 changes: 2 additions & 0 deletions x/auction/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ func (k Keeper) BeginAuction(ctx sdk.Context,
// determine how many usomm each sale token min unit costs
saleTokenPriceInUsomm := saleTokenMinUnitValue.Quo(usommMinUnitValue)

// TODO(bolten): we are not inspecting the MinimumSaleTokensUsdValue param and using it -- implement later?

auctionID := k.GetLastAuctionID(ctx) + 1
auction := types.Auction{
Id: auctionID,
Expand Down
4 changes: 4 additions & 0 deletions x/auction/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func (p *Params) ValidateBasic() error {
return err
}

if err := validateMinimumSaleTokensUSDValue(p.MinimumSaleTokensUsdValue); err != nil {
return err
}

if err := validateAuctionMaxBlockAge(p.AuctionMaxBlockAge); err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions x/auction/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestParamsValidate(t *testing.T) {
params: Params{
PriceMaxBlockAge: uint64(1000),
MinimumBidInUsomm: uint64(500),
MinimumSaleTokensUsdValue: sdk.MustNewDecFromStr("1.0"),
AuctionMaxBlockAge: uint64(100),
AuctionPriceDecreaseAccelerationRate: sdk.MustNewDecFromStr("0.1"),
},
Expand All @@ -37,6 +38,7 @@ func TestParamsValidate(t *testing.T) {
params: Params{
PriceMaxBlockAge: uint64(0),
MinimumBidInUsomm: uint64(500),
MinimumSaleTokensUsdValue: sdk.MustNewDecFromStr("1.0"),
AuctionMaxBlockAge: uint64(100),
AuctionPriceDecreaseAccelerationRate: sdk.MustNewDecFromStr("0.1"),
},
Expand All @@ -48,6 +50,7 @@ func TestParamsValidate(t *testing.T) {
params: Params{
PriceMaxBlockAge: uint64(1000),
MinimumBidInUsomm: uint64(500),
MinimumSaleTokensUsdValue: sdk.MustNewDecFromStr("1.0"),
AuctionMaxBlockAge: uint64(100),
AuctionPriceDecreaseAccelerationRate: sdk.MustNewDecFromStr("-0.01"),
},
Expand All @@ -59,6 +62,7 @@ func TestParamsValidate(t *testing.T) {
params: Params{
PriceMaxBlockAge: uint64(1000),
MinimumBidInUsomm: uint64(500),
MinimumSaleTokensUsdValue: sdk.MustNewDecFromStr("1.0"),
AuctionMaxBlockAge: uint64(100),
AuctionPriceDecreaseAccelerationRate: sdk.MustNewDecFromStr("1.1"),
},
Expand Down
24 changes: 24 additions & 0 deletions x/cork/types/codec.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
package types

import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

// RegisterLegacyAminoCodec registers the vesting interfaces and concrete types on the
// provided LegacyAmino codec. These types are used for Amino JSON serialization
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgScheduleCorkRequest{}, "cork/MsgScheduleCorkRequest", nil)
}

var (
amino = codec.NewLegacyAmino()
// ModuleCdc Note, the codec should ONLY be used in certain instances of tests and for
// JSON encoding as Amino is still used for that purpose.
//
// The actual codec used for serialization should be provided to x/staking and
// defined at the application level.
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
amino.Seal()
}

// RegisterInterfaces registers the cork proto files
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations(
Expand Down
2 changes: 1 addition & 1 deletion x/cork/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (m *MsgScheduleCorkRequest) ValidateBasic() error {

// GetSignBytes implements sdk.Msg
func (m *MsgScheduleCorkRequest) GetSignBytes() []byte {
panic("amino support disabled")
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m))
}

// GetSigners implements sdk.Msg
Expand Down
7 changes: 4 additions & 3 deletions x/pubsub/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ func ValidateProofURL(proofURL string, domain string, address string) error {
return err
}

validProofURL := fmt.Sprintf("https://%s/%s/cacert.pem", domain, address)
if proofURL != validProofURL {
return fmt.Errorf("invalid proof URL format, should be: %s", validProofURL)
validProofURL := fmt.Sprintf("%s/%s/cacert.pem", domain, address)
validProofURLWithHTTPS := fmt.Sprintf("https://%s", validProofURL)
if proofURL != validProofURL && proofURL != validProofURLWithHTTPS {
return fmt.Errorf("invalid proof URL format, should be: %s", validProofURLWithHTTPS)
}

return nil
Expand Down
Loading