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

Axelar fixes #240

Merged
merged 45 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9b75390
WIP - gravity mod update
EricBolten Dec 10, 2023
3d99161
Remove rest clients
EricBolten Dec 10, 2023
d785a6b
mod tidy and extraneous rest reference in auction
EricBolten Dec 10, 2023
af79c29
WIP - axelar fixes, upgrade stuff, SDK bump
EricBolten Dec 11, 2023
3d6c9ab
Fix cork mocks for updated staking API
EricBolten Dec 11, 2023
d852531
Fix no-longer compiling v6 upgrade
EricBolten Dec 11, 2023
6108d73
Fix cork keeper mocks package
EricBolten Dec 11, 2023
bfaa499
update cmd
EricBolten Dec 11, 2023
d36af6f
x/auction compiles
EricBolten Dec 11, 2023
efedcf5
x/axelarcork mostly compiles
EricBolten Dec 11, 2023
5b5f875
remove RegisterRESTRoutes
EricBolten Dec 11, 2023
b8ee146
x/cellarfees compiles
EricBolten Dec 11, 2023
d71e9dc
x/incentives compiles
EricBolten Dec 11, 2023
e1bc31f
x/pubsub compiles, fix proposal init()
EricBolten Dec 11, 2023
3161573
x/cork mostly compiles
EricBolten Dec 11, 2023
e83c42c
Fix staking mocks in x/cork
EricBolten Dec 11, 2023
71ba357
Fix axelarcork mocks
EricBolten Dec 12, 2023
2242515
Fix return type for SendPacket in test mock
EricBolten Dec 12, 2023
d1f102a
integration tests compile
EricBolten Dec 12, 2023
e245f7e
remove strconv and extraneous tests from cork cli
EricBolten Dec 12, 2023
3b66e7f
fix erroneous use of sdkerrors.New
EricBolten Dec 12, 2023
4d6667b
add missing expected mock in axelarcork
EricBolten Dec 12, 2023
e75e176
Update gravity deps to latest
EricBolten Dec 12, 2023
a811bb6
Update orchestrator image, TODO in v7 upgrade
EricBolten Dec 12, 2023
70ade73
Try latest version of golangci-lint
EricBolten Dec 12, 2023
7cebb4e
fix scheduled cork integration test
EricBolten Dec 12, 2023
1b66fb9
update sdkerrors wrap/register calls to errorsmod
EricBolten Dec 12, 2023
16291e9
more lint errors fixes in integration tests
EricBolten Dec 12, 2023
7fa41f6
remove deprecated functionality from cork test env
EricBolten Dec 12, 2023
807887b
fix old references to sdk.Int
EricBolten Dec 12, 2023
ca2486c
ioutil -> os
EricBolten Dec 13, 2023
af6e77f
use axelarcork module account as sender
EricBolten Dec 13, 2023
c537bca
some TODO notes as I went through the module
EricBolten Dec 13, 2023
4724323
check for module account as sender in middleware
EricBolten Dec 13, 2023
f49f5d4
Merge branch 'main' into bolten/v7-axelar-fixes
EricBolten Dec 13, 2023
42d31bb
Remove deadline from axelarcork IAVL keys
EricBolten Dec 13, 2023
aada410
remove lingering deadline reference
EricBolten Dec 13, 2023
4109176
remove incorrect TODO
EricBolten Dec 13, 2023
cd910c3
add note about genesis and WinningAxelarCorks
EricBolten Dec 13, 2023
784205d
compare addresses rather than strings for IBC txs
EricBolten Dec 13, 2023
386da75
some more validation for EVM addresses
EricBolten Dec 13, 2023
d62e8b7
Initialize axelarcork module in upgrade
EricBolten Dec 13, 2023
5e6ba94
Set chain configurations for axelarcork
EricBolten Dec 13, 2023
6fa4f9e
appease linter
EricBolten Dec 13, 2023
04aaecf
Merge branch 'main' into bolten/v7-axelar-fixes
EricBolten Dec 13, 2023
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
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ func NewSommelierApp(
keys[axelarcorktypes.StoreKey],
app.GetSubspace(axelarcorktypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
app.TransferKeeper,
app.DistrKeeper,
Expand Down Expand Up @@ -974,7 +975,7 @@ func (app *SommelierApp) setupUpgradeStoreLoaders() {

if upgradeInfo.Name == v7.UpgradeName {
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{auctiontypes.ModuleName, pubsubtypes.ModuleName},
Added: []string{auctiontypes.ModuleName, axelarcorktypes.ModuleName, pubsubtypes.ModuleName},
}
}

Expand Down Expand Up @@ -1017,6 +1018,7 @@ func (app *SommelierApp) setupUpgradeHandlers() {
app.mm,
app.configurator,
app.AuctionKeeper,
app.AxelarCorkKeeper,
app.CellarFeesKeeper,
app.ICAHostKeeper,
app.PubsubKeeper,
Expand Down
63 changes: 60 additions & 3 deletions app/upgrades/v7/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package v7

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icahostkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
auctionkeeper "github.com/peggyjv/sommelier/v7/x/auction/keeper"
auctiontypes "github.com/peggyjv/sommelier/v7/x/auction/types"
axelarcorkkeeper "github.com/peggyjv/sommelier/v7/x/axelarcork/keeper"
axelarcorktypes "github.com/peggyjv/sommelier/v7/x/axelarcork/types"
cellarfeeskeeper "github.com/peggyjv/sommelier/v7/x/cellarfees/keeper"
cellarfeestypes "github.com/peggyjv/sommelier/v7/x/cellarfees/types"
pubsubkeeper "github.com/peggyjv/sommelier/v7/x/pubsub/keeper"
Expand All @@ -18,14 +23,14 @@ func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
auctionKeeper auctionkeeper.Keeper,
axelarcorkKeeper axelarcorkkeeper.Keeper,
cellarfeesKeeper cellarfeeskeeper.Keeper,
icaHostKeeper icahostkeeper.Keeper,
pubsubKeeper pubsubkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("v7 upgrade: entering handler")

// TODO(bolten): get a sanity check on this
// 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
icaParams := icahosttypes.DefaultParams()
Expand All @@ -35,6 +40,7 @@ func CreateUpgradeHandler(
// during the upgrade process. RunMigrations will migrate to the new cork version. Setting the consensus
// version to 1 prevents RunMigrations from running InitGenesis itself.
fromVM[auctiontypes.ModuleName] = mm.Modules[auctiontypes.ModuleName].ConsensusVersion()
fromVM[axelarcorktypes.ModuleName] = mm.Modules[axelarcorktypes.ModuleName].ConsensusVersion()
fromVM[pubsubtypes.ModuleName] = mm.Modules[pubsubtypes.ModuleName].ConsensusVersion()

// Params values were introduced in this upgrade but no migration was necessary, so we initialize the
Expand All @@ -46,11 +52,12 @@ func CreateUpgradeHandler(
ctx.Logger().Info("v7 upgrade: initializing auction genesis state")
auctionInitGenesis(ctx, auctionKeeper)

ctx.Logger().Info("v7 upgrade: intializing axelarcork genesis state")
axelarcorkInitGenesis(ctx, axelarcorkKeeper)

ctx.Logger().Info("v7 upgrade: initializing pubsub genesis state")
pubsubInitGenesis(ctx, pubsubKeeper)

//TODO(bolten): axelarcork module initialization

ctx.Logger().Info("v7 upgrade: running migrations and exiting handler")
return mm.RunMigrations(ctx, configurator, fromVM)
}
Expand Down Expand Up @@ -132,6 +139,56 @@ func auctionInitGenesis(ctx sdk.Context, auctionKeeper auctionkeeper.Keeper) {
auctionkeeper.InitGenesis(ctx, auctionKeeper, genesisState)
}

// Initialize the Axelar cork module with the correct parameters.
func axelarcorkInitGenesis(ctx sdk.Context, axelarcorkKeeper axelarcorkkeeper.Keeper) {
genesisState := axelarcorktypes.DefaultGenesisState()

genesisState.Params.Enabled = true
genesisState.Params.TimeoutDuration = uint64(6 * time.Hour)
genesisState.Params.IbcChannel = "channel-5"
genesisState.Params.IbcPort = ibctransfertypes.PortID
genesisState.Params.GmpAccount = "axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5s"
genesisState.Params.ExecutorAccount = "axelar1aythygn6z5thymj6tmzfwekzh05ewg3l7d6y89"
genesisState.Params.CorkTimeoutBlocks = 5000

genesisState.ChainConfigurations = axelarcorktypes.ChainConfigurations{
Configurations: []*axelarcorktypes.ChainConfiguration{
{
Name: "arbitrum",
Id: 42161,
ProxyAddress: "0xEe75bA2C81C04DcA4b0ED6d1B7077c188FEde4d2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we use the same proxy contract for each? the proxy routes to the correct gateway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no targeting of gateways. The proxy contract is the contract we're trying to hit that is an Axelar executable. The gateway reaches out itself to call the executable (calling the execute function on the proxy contract) when the call is recorded in state on Axelar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addresses are the same because Crispy deterministically deployed it to each L2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addresses are the same because Crispy deterministically deployed it to each L2.

Is there anything expecting the casing checksum to match the respective chains?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain, we're passing along a string in the ICS-20 message and Axelar is handling it. I assume they are resolving it correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eth doesn't include chain information in the checksums for addresses like Cosmos does

},
{
Name: "Avalanche",
Id: 43114,
ProxyAddress: "0xEe75bA2C81C04DcA4b0ED6d1B7077c188FEde4d2",
},
{
Name: "base",
Id: 8453,
ProxyAddress: "0xEe75bA2C81C04DcA4b0ED6d1B7077c188FEde4d2",
},
{
Name: "binance",
Id: 56,
ProxyAddress: "0xEe75bA2C81C04DcA4b0ED6d1B7077c188FEde4d2",
},
{
Name: "optimism",
Id: 10,
ProxyAddress: "0xEe75bA2C81C04DcA4b0ED6d1B7077c188FEde4d2",
},
{
Name: "Polygon",
Id: 137,
ProxyAddress: "0xEe75bA2C81C04DcA4b0ED6d1B7077c188FEde4d2",
},
},
}

axelarcorkkeeper.InitGenesis(ctx, axelarcorkKeeper, genesisState)
}

// Set up the initial pubsub state to mirror what is currently used in practice already, with 7seas as the
// first publisher using its existing CA certificate, its default subscriptions as the already launched cellars,
// and the subscribers as reflected in the steward-registry repo.
Expand Down
8 changes: 6 additions & 2 deletions x/axelarcork/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ func (k Keeper) EndBlocker(ctx sdk.Context) {
k.Logger(ctx).Info("tallying scheduled cork votes",
"height", fmt.Sprintf("%d", ctx.BlockHeight()),
"chain id", config.Id)
// TODO(bolten): might not be a necessary fix, but GetApprovedScheduledAxelarCorks is kind of
// unexpectedly destructive -- it deletes all of the validator submitted entries for scheduled
// corks and returns a list of the winning ones, which are then set using SetWinningAxelarCork
// here, but it seems like an odd side effect of a Get function to delete stuff
winningScheduledVotes := k.GetApprovedScheduledAxelarCorks(ctx, config.Id)
if len(winningScheduledVotes) > 0 {
k.Logger(ctx).Info("marking all winning scheduled cork votes as relayable",
"winning votes", winningScheduledVotes,
"chain id", config.Id)
for _, c := range winningScheduledVotes {
k.SetWinningAxelarCork(ctx, config.Id, uint64(ctx.BlockHeight()), c.Deadline, c)
k.SetWinningAxelarCork(ctx, config.Id, uint64(ctx.BlockHeight()), c)
}
}

Expand All @@ -39,7 +43,7 @@ func (k Keeper) EndBlocker(ctx sdk.Context) {
"chain id", config.Id)

timeoutHeight := uint64(ctx.BlockHeight()) - k.GetParamSet(ctx).CorkTimeoutBlocks
k.IterateWinningAxelarCorks(ctx, config.Id, func(_ common.Address, blockHeight uint64, deadline uint64, cork types.AxelarCork) (stop bool) {
k.IterateWinningAxelarCorks(ctx, config.Id, func(_ common.Address, blockHeight uint64, cork types.AxelarCork) (stop bool) {
if blockHeight >= timeoutHeight {
k.Logger(ctx).Info("deleting expired approved scheduled axelar cork",
"scheduled height", fmt.Sprintf("%d", blockHeight),
Expand Down
3 changes: 2 additions & 1 deletion x/axelarcork/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState) {
if senderAccount == nil {
panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
}

k.accountKeeper.SetModuleAccount(ctx, senderAccount)

for i, config := range gs.ChainConfigurations.Configurations {
Expand All @@ -43,6 +42,8 @@ func InitGenesis(ctx sdk.Context, k Keeper, gs types.GenesisState) {
k.SetScheduledAxelarCork(ctx, scheduledCork.Cork.ChainId, scheduledCork.BlockHeight, valAddr, *scheduledCork.Cork)
}

// TODO(bolten): not a huge risk since they can be re-sent, but the genesis state is missing WinningAxelarCorks

for _, n := range gs.AxelarContractCallNonces {
if _, found := k.GetChainConfigurationByID(ctx, n.ChainId); !found {
panic(fmt.Sprintf("chain configuration %d not found", n.ChainId))
Expand Down
Loading
Loading