Skip to content

Commit

Permalink
feat: add Polygon, Base and Base Sepolia in static chain info (#2470)
Browse files Browse the repository at this point in the history
* add polygon

* base proto

* add Base

* make generate

* changelog

* update setup handler

* update upgrade dockerfile
  • Loading branch information
lumtis authored Jul 12, 2024
1 parent f85559c commit 0fa54ed
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 81 deletions.
4 changes: 2 additions & 2 deletions Dockerfile-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ WORKDIR /go/delivery/zeta-node
RUN mkdir -p $GOPATH/bin/old
RUN mkdir -p $GOPATH/bin/new

ARG OLD_VERSION=v15.0.0
ENV NEW_VERSION=v17
ARG OLD_VERSION=v17.0.1
ENV NEW_VERSION=v18

# Build new release from the current source
COPY go.mod /go/delivery/zeta-node/
Expand Down
14 changes: 2 additions & 12 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const releaseVersion = "v17"
const releaseVersion = "v18"

func SetupHandlers(app *App) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -19,23 +16,16 @@ func SetupHandlers(app *App) {
for m, mb := range app.mm.Modules {
vm[m] = mb.ConsensusVersion()
}
VersionMigrator{v: vm}.TriggerMigration(observertypes.ModuleName)

return app.mm.RunMigrations(ctx, app.configurator, vm)
})

app.UpgradeKeeper.SetUpgradeHandler("v17-athens", func(ctx sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) {
return vm, nil
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}
if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{authoritytypes.ModuleName, lightclienttypes.ModuleName},
}
storeUpgrades := storetypes.StoreUpgrades{}
// Use upgrade store loader for the initial loading of all stores when app starts,
// it checks if version == upgradeHeight and applies store upgrades before loading the stores,
// so that new stores start with the correct version (the current height of chain),
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v18.0.0

* [2470](https://github.com/zeta-chain/node/pull/2470) - add Polygon, Base and Base Sepolia in static chain info

## v17.0.1

### Fixes
Expand Down
4 changes: 4 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53612,6 +53612,10 @@ definitions:
- goerli_localnet
- btc_regtest
- amoy_testnet
- optimism_mainnet
- optimism_sepolia
- base_mainnet
- base_sepolia
default: empty
chainsReceiveStatus:
type: string
Expand Down
5 changes: 4 additions & 1 deletion pkg/chains/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ func IsZetaChain(chainID int64) bool {
func IsEVMChain(chainID int64) bool {
return chainID == 5 || // Goerli
chainID == AmoyChain().ChainId ||
chainID == SepoliaChain().ChainId || // Sepolia
chainID == PolygonChain().ChainId ||
chainID == SepoliaChain().ChainId ||
chainID == BaseMainnetChain().ChainId ||
chainID == BaseSepoliaChain().ChainId ||
chainID == 80001 || // Polygon mumbai
chainID == 97 || // BSC testnet
chainID == 1001 || // klaytn baobab
Expand Down
23 changes: 23 additions & 0 deletions pkg/chains/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ func PolygonChain() Chain {
}
}

func BaseMainnetChain() Chain {
return Chain{
ChainName: ChainName_base_mainnet,
ChainId: 8453,
}
}

// Testnet chains

func SepoliaChain() Chain {
Expand Down Expand Up @@ -106,6 +113,13 @@ func AmoyChain() Chain {
}
}

func BaseSepoliaChain() Chain {
return Chain{
ChainName: ChainName_base_sepolia,
ChainId: 84532,
}
}

// Privnet chains

func BtcRegtestChain() Chain {
Expand Down Expand Up @@ -133,12 +147,15 @@ func DefaultChainsList() []*Chain {
BtcMainnetChain(),
BscMainnetChain(),
EthChain(),
PolygonChain(),
BaseMainnetChain(),
BtcTestNetChain(),
MumbaiChain(),
AmoyChain(),
BscTestnetChain(),
GoerliChain(),
SepoliaChain(),
BaseSepoliaChain(),
BtcRegtestChain(),
GoerliLocalnetChain(),
ZetaChainMainnet(),
Expand All @@ -155,6 +172,8 @@ func MainnetChainList() []*Chain {
BtcMainnetChain(),
BscMainnetChain(),
EthChain(),
BaseMainnetChain(),
PolygonChain(),
})
}

Expand All @@ -165,6 +184,7 @@ func TestnetChainList() []*Chain {
BtcTestNetChain(),
MumbaiChain(),
AmoyChain(),
BaseSepoliaChain(),
BscTestnetChain(),
GoerliChain(),
SepoliaChain(),
Expand All @@ -186,12 +206,15 @@ func ExternalChainList() []*Chain {
BtcMainnetChain(),
BscMainnetChain(),
EthChain(),
PolygonChain(),
BaseMainnetChain(),
BtcTestNetChain(),
MumbaiChain(),
AmoyChain(),
BscTestnetChain(),
GoerliChain(),
SepoliaChain(),
BaseSepoliaChain(),
BtcRegtestChain(),
GoerliLocalnetChain(),
})
Expand Down
134 changes: 74 additions & 60 deletions pkg/chains/chains.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 65 additions & 6 deletions pkg/chains/chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,71 @@ func TestChainListFunctions(t *testing.T) {
function func() []*Chain
expected []Chain
}{
{"DefaultChainsList", DefaultChainsList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain(), ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain()}},
{"MainnetChainList", MainnetChainList, []Chain{ZetaChainMainnet(), BtcMainnetChain(), BscMainnetChain(), EthChain()}},
{"TestnetChainList", TestnetChainList, []Chain{ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain()}},
{"PrivnetChainList", PrivnetChainList, []Chain{ZetaPrivnetChain(), BtcRegtestChain(), GoerliLocalnetChain()}},
{"ExternalChainList", ExternalChainList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain()}},
{"ZetaChainList", ZetaChainList, []Chain{ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain()}},
{"DefaultChainsList", DefaultChainsList, []Chain{
BtcMainnetChain(),
BscMainnetChain(),
EthChain(),
PolygonChain(),
BaseMainnetChain(),
BtcTestNetChain(),
MumbaiChain(),
AmoyChain(),
BscTestnetChain(),
GoerliChain(),
SepoliaChain(),
BaseSepoliaChain(),
BtcRegtestChain(),
GoerliLocalnetChain(),
ZetaChainMainnet(),
ZetaTestnetChain(),
ZetaMocknetChain(),
ZetaPrivnetChain(),
}},
{"MainnetChainList", MainnetChainList, []Chain{
ZetaChainMainnet(),
BtcMainnetChain(),
BscMainnetChain(),
EthChain(),
BaseMainnetChain(),
PolygonChain(),
}},
{"TestnetChainList", TestnetChainList, []Chain{
ZetaTestnetChain(),
BtcTestNetChain(),
MumbaiChain(),
AmoyChain(),
BaseSepoliaChain(),
BscTestnetChain(),
GoerliChain(),
SepoliaChain(),
}},
{"PrivnetChainList", PrivnetChainList, []Chain{
ZetaPrivnetChain(),
BtcRegtestChain(),
GoerliLocalnetChain(),
}},
{"ExternalChainList", ExternalChainList, []Chain{
BtcMainnetChain(),
BscMainnetChain(),
EthChain(),
PolygonChain(),
BaseMainnetChain(),
BtcTestNetChain(),
MumbaiChain(),
AmoyChain(),
BscTestnetChain(),
GoerliChain(),
SepoliaChain(),
BaseSepoliaChain(),
BtcRegtestChain(),
GoerliLocalnetChain(),
}},
{"ZetaChainList", ZetaChainList, []Chain{
ZetaChainMainnet(),
ZetaTestnetChain(),
ZetaMocknetChain(),
ZetaPrivnetChain(),
}},
}

for _, lt := range listTests {
Expand Down
Loading

0 comments on commit 0fa54ed

Please sign in to comment.