Handle guardianSet by p2p enviroment in fly/api (#112)
This commit is contained in:
parent
f65796b0fc
commit
1c7e58a27a
|
@ -4,111 +4,147 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/certusone/wormhole/node/pkg/common"
|
||||
|
||||
eth_common "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/api/internal/config"
|
||||
)
|
||||
|
||||
var ByIndex = []common.GuardianSet{gs0, gs1, gs2, gs3}
|
||||
var ExpirationTimeByIndex = []time.Time{gs0ValidUntil, gs1ValidUntil, gs2ValidUntil, gs3ValidUntil}
|
||||
// GuardianSet definition.
|
||||
type GuardianSet struct {
|
||||
GstByIndex []common.GuardianSet
|
||||
ExpirationTimeByIndex []time.Time
|
||||
}
|
||||
|
||||
func IsValid(gsIx uint32, t time.Time) bool {
|
||||
if gsIx < 0 || int(gsIx) > len(ByIndex) {
|
||||
// Get get guardianset config by enviroment.
|
||||
func GetByEnv(enviroment string) GuardianSet {
|
||||
switch enviroment {
|
||||
case config.P2pTestNet:
|
||||
return getTestnetGuardianSet()
|
||||
default:
|
||||
return getMainnetGuardianSet()
|
||||
}
|
||||
}
|
||||
|
||||
// IsValid check if a guardianSet is valid.
|
||||
func (gs GuardianSet) IsValid(gsIx uint32, t time.Time) bool {
|
||||
if gsIx < 0 || int(gsIx) > len(gs.GstByIndex) {
|
||||
return false
|
||||
}
|
||||
|
||||
return ExpirationTimeByIndex[gsIx].After(t)
|
||||
return gs.ExpirationTimeByIndex[gsIx].After(t)
|
||||
}
|
||||
|
||||
func GetLatest() common.GuardianSet {
|
||||
return ByIndex[len(ByIndex)-1]
|
||||
// GetLatest get the lastest guardianset.
|
||||
func (gs GuardianSet) GetLatest() common.GuardianSet {
|
||||
return gs.GstByIndex[len(gs.GstByIndex)-1]
|
||||
}
|
||||
|
||||
var gs0ValidUntil = time.Unix(1628599904, 0) // Tue Aug 10 2021 12:51:44 GMT+0000
|
||||
var gs0 = common.GuardianSet{
|
||||
Index: 0,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
},
|
||||
func getTestnetGuardianSet() GuardianSet {
|
||||
const tenYears = time.Hour * 24 * 365 * 10
|
||||
gs0TestValidUntil := time.Now().Add(tenYears)
|
||||
gstest0 := common.GuardianSet{
|
||||
Index: 0,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x13947Bd48b18E53fdAeEe77F3473391aC727C638"), //
|
||||
},
|
||||
}
|
||||
return GuardianSet{
|
||||
GstByIndex: []common.GuardianSet{gstest0},
|
||||
ExpirationTimeByIndex: []time.Time{gs0TestValidUntil},
|
||||
}
|
||||
}
|
||||
|
||||
var gs1ValidUntil = time.Unix(1650566103, 0) // Thu Apr 21 2022 18:35:03 GMT+0000
|
||||
var gs1 = common.GuardianSet{
|
||||
Index: 1,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0xeB5F7389Fa26941519f0863349C223b73a6DDEE7"), // DokiaCapital
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
},
|
||||
}
|
||||
func getMainnetGuardianSet() GuardianSet {
|
||||
gs0ValidUntil := time.Unix(1628599904, 0) // Tue Aug 10 2021 12:51:44 GMT+0000
|
||||
gs0 := common.GuardianSet{
|
||||
Index: 0,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
},
|
||||
}
|
||||
|
||||
const tenYears = time.Hour * 24 * 365 * 10
|
||||
gs1ValidUntil := time.Unix(1650566103, 0) // Thu Apr 21 2022 18:35:03 GMT+0000
|
||||
gs1 := common.GuardianSet{
|
||||
Index: 1,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0xeB5F7389Fa26941519f0863349C223b73a6DDEE7"), // DokiaCapital
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
},
|
||||
}
|
||||
|
||||
var gs2ValidUntil = time.Now().Add(tenYears) // still valid so we add 10 years
|
||||
var gs2 = common.GuardianSet{
|
||||
Index: 2,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0x66B9590e1c41e0B226937bf9217D1d67Fd4E91F5"), // FTX
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
// devnet
|
||||
// eth_common.HexToAddress("0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe"),
|
||||
},
|
||||
}
|
||||
const tenYears = time.Hour * 24 * 365 * 10
|
||||
gs2ValidUntil := time.Now().Add(tenYears) // still valid so we add 10 years
|
||||
gs2 := common.GuardianSet{
|
||||
Index: 2,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0x66B9590e1c41e0B226937bf9217D1d67Fd4E91F5"), // FTX
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
// devnet
|
||||
// eth_common.HexToAddress("0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe"),
|
||||
},
|
||||
}
|
||||
|
||||
var gs3ValidUntil = time.Now().Add(tenYears) // still valid so we add 10 years
|
||||
var gs3 = common.GuardianSet{
|
||||
Index: 3,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20"), // xLabs
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
},
|
||||
gs3ValidUntil := time.Now().Add(tenYears) // still valid so we add 10 years
|
||||
gs3 := common.GuardianSet{
|
||||
Index: 3,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20"), // xLabs
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
return GuardianSet{
|
||||
GstByIndex: []common.GuardianSet{gs0, gs1, gs2, gs3},
|
||||
ExpirationTimeByIndex: []time.Time{gs0ValidUntil, gs1ValidUntil, gs2ValidUntil, gs3ValidUntil},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,13 @@ const (
|
|||
RunModeDevelopmernt = "DEVELOPMENT"
|
||||
)
|
||||
|
||||
// p2p network constants.
|
||||
const (
|
||||
P2pMainNet = "mainnet"
|
||||
P2pTestNet = "testnet"
|
||||
P2pDevNet = "devnet"
|
||||
)
|
||||
|
||||
// AppConfig defines the configuration for the app.
|
||||
type AppConfig struct {
|
||||
DB struct {
|
||||
|
@ -28,9 +35,10 @@ type AppConfig struct {
|
|||
URL string
|
||||
Enabled bool
|
||||
}
|
||||
PORT int
|
||||
LogLevel string
|
||||
RunMode string
|
||||
PORT int
|
||||
LogLevel string
|
||||
RunMode string
|
||||
P2pNetwork string
|
||||
}
|
||||
|
||||
// GetLogLevel get zapcore.Level define in the configuraion.
|
||||
|
@ -42,7 +50,7 @@ func init() {
|
|||
viper.SetDefault("port", 8000)
|
||||
viper.SetDefault("loglevel", "INFO")
|
||||
viper.SetDefault("runmode", "PRODUCTION")
|
||||
|
||||
viper.SetDefault("p2pnetwork", P2pMainNet)
|
||||
// Consider environment variables in unmarshall doesn't work unless doing this: https://github.com/spf13/viper/issues/188#issuecomment-1168898503
|
||||
b, err := json.Marshal(AppConfig{})
|
||||
if err != nil {
|
||||
|
|
|
@ -132,10 +132,10 @@ func main() {
|
|||
// Set up route handlers
|
||||
app.Get("/swagger.json", GetSwagger)
|
||||
wormscan.RegisterRoutes(app, rootLogger, vaaService, obsService, governorService, infrastructureService)
|
||||
guardian.RegisterRoutes(app, rootLogger, vaaService, governorService, heartbeatsService)
|
||||
guardian.RegisterRoutes(cfg, app, rootLogger, vaaService, governorService, heartbeatsService)
|
||||
|
||||
// Set up gRPC handlers
|
||||
handler := rpcApi.NewHandler(vaaService, heartbeatsService, governorService, rootLogger)
|
||||
handler := rpcApi.NewHandler(vaaService, heartbeatsService, governorService, rootLogger, cfg.P2pNetwork)
|
||||
grpcServer := rpcApi.NewServer(handler, rootLogger)
|
||||
grpcWebServer := grpcweb.WrapServer(grpcServer)
|
||||
app.Use(
|
||||
|
|
|
@ -9,12 +9,14 @@ import (
|
|||
|
||||
// Controller definition.
|
||||
type Controller struct {
|
||||
gs guardian.GuardianSet
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
// NewController create a new controler.
|
||||
func NewController(logger *zap.Logger) *Controller {
|
||||
return &Controller{logger: logger.With(zap.String("module", "GuardianController"))}
|
||||
func NewController(logger *zap.Logger, p2pNetwork string) *Controller {
|
||||
return &Controller{gs: guardian.GetByEnv(p2pNetwork),
|
||||
logger: logger.With(zap.String("module", "GuardianController"))}
|
||||
}
|
||||
|
||||
// GuardianSetResponse response definition.
|
||||
|
@ -38,12 +40,13 @@ type GuardianSet struct {
|
|||
// @Router /v1/guardianset/current [get]
|
||||
func (c *Controller) GetGuardianSet(ctx *fiber.Ctx) error {
|
||||
// check guardianSet exists.
|
||||
if len(guardian.ByIndex) == 0 {
|
||||
if len(c.gs.GstByIndex) == 0 {
|
||||
return response.NewApiError(ctx, fiber.StatusServiceUnavailable, response.Unavailable,
|
||||
"guardian set not fetched from chain yet", nil)
|
||||
}
|
||||
|
||||
// get lasted guardianSet.
|
||||
guardinSet := guardian.GetLatest()
|
||||
guardinSet := c.gs.GetLatest()
|
||||
|
||||
// get guardian addresses.
|
||||
addresses := make([]string, len(guardinSet.Keys))
|
||||
|
|
|
@ -14,13 +14,15 @@ import (
|
|||
type Controller struct {
|
||||
srv *heartbeats.Service
|
||||
logger *zap.Logger
|
||||
gs guardian.GuardianSet
|
||||
}
|
||||
|
||||
// NewController create a new controler.
|
||||
func NewController(srv *heartbeats.Service, logger *zap.Logger) *Controller {
|
||||
func NewController(srv *heartbeats.Service, logger *zap.Logger, p2pNetwork string) *Controller {
|
||||
return &Controller{
|
||||
srv: srv,
|
||||
logger: logger.With(zap.String("module", "HeartbeatsController")),
|
||||
gs: guardian.GetByEnv(p2pNetwork),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,12 +66,12 @@ type HeartbeatNetworkResponse struct {
|
|||
// @Router /v1/heartbeats [get]
|
||||
func (c *Controller) GetLastHeartbeats(ctx *fiber.Ctx) error {
|
||||
// check guardianSet exists.
|
||||
if len(guardian.ByIndex) == 0 {
|
||||
if len(c.gs.GstByIndex) == 0 {
|
||||
return response.NewApiError(ctx, fiber.StatusServiceUnavailable, response.Unavailable,
|
||||
"guardian set not fetched from chain yet", nil)
|
||||
}
|
||||
// get lasted guardianSet.
|
||||
guardianSet := guardian.GetLatest()
|
||||
guardianSet := c.gs.GetLatest()
|
||||
guardianAddresses := guardianSet.KeysAsHexStrings()
|
||||
|
||||
// get last heartbeats by ids.
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
govsvc "github.com/wormhole-foundation/wormhole-explorer/api/handlers/governor"
|
||||
heartbeatssvc "github.com/wormhole-foundation/wormhole-explorer/api/handlers/heartbeats"
|
||||
vaasvc "github.com/wormhole-foundation/wormhole-explorer/api/handlers/vaa"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/api/internal/config"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/api/routes/guardian/governor"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/api/routes/guardian/guardian"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/api/routes/guardian/heartbeats"
|
||||
|
@ -14,6 +15,7 @@ import (
|
|||
|
||||
// RegisterRoutes sets up the handlers for the Guardian API.
|
||||
func RegisterRoutes(
|
||||
cfg *config.AppConfig,
|
||||
app *fiber.App,
|
||||
rootLogger *zap.Logger,
|
||||
vaaService *vaasvc.Service,
|
||||
|
@ -24,8 +26,8 @@ func RegisterRoutes(
|
|||
// Set up controllers
|
||||
vaaCtrl := vaa.NewController(vaaService, rootLogger)
|
||||
governorCtrl := governor.NewController(governorService, rootLogger)
|
||||
guardianCtrl := guardian.NewController(rootLogger)
|
||||
heartbeatsCtrl := heartbeats.NewController(heartbeatsService, rootLogger)
|
||||
guardianCtrl := guardian.NewController(rootLogger, cfg.P2pNetwork)
|
||||
heartbeatsCtrl := heartbeats.NewController(heartbeatsService, rootLogger, cfg.P2pNetwork)
|
||||
|
||||
// Set up route handlers
|
||||
apiV1 := app.Group("/v1")
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
// Handler rpc handler.
|
||||
type Handler struct {
|
||||
publicrpcv1.UnimplementedPublicRPCServiceServer
|
||||
gs guardian.GuardianSet
|
||||
vaaSrv *vaaservice.Service
|
||||
hbSrv *heartbeats.Service
|
||||
govSrv *governor.Service
|
||||
|
@ -30,8 +31,8 @@ type Handler struct {
|
|||
}
|
||||
|
||||
// NewHandler create a new rpc Handler.
|
||||
func NewHandler(vaaSrv *vaaservice.Service, hbSrv *heartbeats.Service, govSrv *governor.Service, logger *zap.Logger) *Handler {
|
||||
return &Handler{vaaSrv: vaaSrv, hbSrv: hbSrv, govSrv: govSrv, logger: logger}
|
||||
func NewHandler(vaaSrv *vaaservice.Service, hbSrv *heartbeats.Service, govSrv *governor.Service, logger *zap.Logger, p2pNetwork string) *Handler {
|
||||
return &Handler{gs: guardian.GetByEnv(p2pNetwork), vaaSrv: vaaSrv, hbSrv: hbSrv, govSrv: govSrv, logger: logger}
|
||||
}
|
||||
|
||||
// GetSignedVAA get signedVAA by chainID, address, sequence.
|
||||
|
@ -85,12 +86,12 @@ func (h *Handler) GetSignedBatchVAA(ctx context.Context, _ *publicrpcv1.GetSigne
|
|||
// GetLastHeartbeats get last heartbeats.
|
||||
func (h *Handler) GetLastHeartbeats(ctx context.Context, request *publicrpcv1.GetLastHeartbeatsRequest) (*publicrpcv1.GetLastHeartbeatsResponse, error) {
|
||||
// check guardianSet exists.
|
||||
if len(guardian.ByIndex) == 0 {
|
||||
if len(h.gs.GstByIndex) == 0 {
|
||||
return nil, status.Error(codes.Unavailable, "guardian set not fetched from chain yet")
|
||||
}
|
||||
|
||||
// get lasted guardianSet.
|
||||
guardianSet := guardian.GetLatest()
|
||||
guardianSet := h.gs.GetLatest()
|
||||
guardianAddresses := guardianSet.KeysAsHexStrings()
|
||||
|
||||
// get last heartbeats by ids.
|
||||
|
@ -138,11 +139,11 @@ func (h *Handler) GetLastHeartbeats(ctx context.Context, request *publicrpcv1.Ge
|
|||
// GetCurrentGuardianSet get current guardian set.
|
||||
func (h *Handler) GetCurrentGuardianSet(ctx context.Context, request *publicrpcv1.GetCurrentGuardianSetRequest) (*publicrpcv1.GetCurrentGuardianSetResponse, error) {
|
||||
// check guardianSet exists.
|
||||
if len(guardian.ByIndex) == 0 {
|
||||
if len(h.gs.GstByIndex) == 0 {
|
||||
return nil, status.Error(codes.Unavailable, "guardian set not fetched from chain yet")
|
||||
}
|
||||
// get lasted guardianSet.
|
||||
guardinSet := guardian.GetLatest()
|
||||
guardinSet := h.gs.GetLatest()
|
||||
|
||||
// get guardian addresses.
|
||||
addresses := make([]string, len(guardinSet.Keys))
|
||||
|
|
|
@ -62,6 +62,8 @@ spec:
|
|||
value: {{ .WORMSCAN_LOGLEVEL }}
|
||||
- name: WORMSCAN_RUNMODE
|
||||
value: {{ .WORMSCAN_RUNMODE }}
|
||||
- name: WORMSCAN_P2PNETWORK
|
||||
value: {{ .WORMSCAN_P2PNETWORK }}
|
||||
- name: WORMSCAN_DB_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
|
|
@ -9,4 +9,5 @@ RESOURCES_REQUESTS_MEMORY=128Mi
|
|||
RESOURCES_REQUESTS_CPU=250m
|
||||
WORMSCAN_RUNMODE=DEVELOPMENT
|
||||
WORMSCAN_LOGLEVEL=INFO
|
||||
WORMSCAN_P2PNETWORK=
|
||||
HOSTNAME=api.staging.wormscan.io
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
)
|
||||
|
||||
// p2p network constants.
|
||||
const (
|
||||
P2pMainNet = "mainnet"
|
||||
P2pTestNet = "testnet"
|
||||
P2pDevNet = "devnet"
|
||||
)
|
||||
|
||||
// p2p network configuration constants.
|
||||
const (
|
||||
// mainnet p2p config.
|
||||
MainNetP2ppNetworkID = "/wormhole/mainnet/2"
|
||||
MainNetP2pBootstrap = "/dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7"
|
||||
MainNetP2pPort uint = 8999
|
||||
|
||||
// testnet p2p config.
|
||||
TestNetP2ppNetworkID = "/wormhole/testnet/2/1"
|
||||
TestNetP2pBootstrap = "/dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWAkB9ynDur1Jtoa97LBUp8RXdhzS5uHgAfdTquJbrbN7i"
|
||||
TestNetP2pPort uint = 8999
|
||||
|
||||
// devnet p2p config.
|
||||
DevNetP2ppNetworkID = "/wormhole/dev"
|
||||
DevNetP2pBootstrap = "/dns4/guardian-0.guardian/udp/8999/quic/p2p/12D3KooWL3XJ9EMCyZvmmGXL2LMiVBtrVa2BuESsJiXkSj7333Jw"
|
||||
DevNetP2pPort uint = 8999
|
||||
)
|
||||
|
||||
// P2pNetworkConfig config struct.
|
||||
type P2pNetworkConfig struct {
|
||||
Enviroment string
|
||||
P2pNetworkID string
|
||||
P2pBootstrap string
|
||||
P2pPort uint
|
||||
}
|
||||
|
||||
// GetP2pNetwork get p2p network config.
|
||||
func GetP2pNetwork() (*P2pNetworkConfig, error) {
|
||||
p2pEnviroment := os.Getenv("P2P_NETWORK")
|
||||
switch p2pEnviroment {
|
||||
case P2pMainNet:
|
||||
return &P2pNetworkConfig{P2pMainNet, MainNetP2ppNetworkID, MainNetP2pBootstrap, MainNetP2pPort}, nil
|
||||
case P2pTestNet:
|
||||
return &P2pNetworkConfig{P2pTestNet, TestNetP2ppNetworkID, TestNetP2pBootstrap, TestNetP2pPort}, nil
|
||||
case P2pDevNet:
|
||||
return &P2pNetworkConfig{P2pDevNet, DevNetP2ppNetworkID, DevNetP2pBootstrap, DevNetP2pPort}, nil
|
||||
default:
|
||||
return nil, errors.New("invalid P2P_NETWORK enviroment variable")
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
// Package guardiansets contains historical guardian set information.
|
||||
// TODO: HARDCODING for now. Let's get this from an ethereum node later.
|
||||
package guardiansets
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/certusone/wormhole/node/pkg/common"
|
||||
eth_common "github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
var ByIndex = []common.GuardianSet{gs0, gs1, gs2, gs3}
|
||||
var ExpirationTimeByIndex = []time.Time{gs0ValidUntil, gs1ValidUntil, gs2ValidUntil, gs3ValidUntil}
|
||||
|
||||
func IsValid(gsIx uint32, t time.Time) bool {
|
||||
if gsIx < 0 || int(gsIx) > len(ByIndex) {
|
||||
return false
|
||||
}
|
||||
|
||||
return ExpirationTimeByIndex[gsIx].After(t)
|
||||
}
|
||||
|
||||
func GetLatest() common.GuardianSet {
|
||||
return ByIndex[len(ByIndex)-1]
|
||||
}
|
||||
|
||||
var gs0ValidUntil = time.Unix(1628599904, 0) // Tue Aug 10 2021 12:51:44 GMT+0000
|
||||
var gs0 = common.GuardianSet{
|
||||
Index: 0,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
},
|
||||
}
|
||||
|
||||
var gs1ValidUntil = time.Unix(1650566103, 0) // Thu Apr 21 2022 18:35:03 GMT+0000
|
||||
var gs1 = common.GuardianSet{
|
||||
Index: 1,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0xeB5F7389Fa26941519f0863349C223b73a6DDEE7"), // DokiaCapital
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
},
|
||||
}
|
||||
|
||||
const tenYears = time.Hour * 24 * 365 * 10
|
||||
|
||||
var gs2ValidUntil = time.Now().Add(tenYears) // still valid so we add 10 years
|
||||
var gs2 = common.GuardianSet{
|
||||
Index: 2,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0x66B9590e1c41e0B226937bf9217D1d67Fd4E91F5"), // FTX
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
// devnet
|
||||
// eth_common.HexToAddress("0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe"),
|
||||
},
|
||||
}
|
||||
|
||||
var gs3ValidUntil = time.Now().Add(tenYears) // still valid so we add 10 years
|
||||
var gs3 = common.GuardianSet{
|
||||
Index: 3,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20"), // xLabs
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
|
||||
},
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
package guardiansets
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/certusone/wormhole/node/pkg/common"
|
||||
eth_common "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/fly/config"
|
||||
)
|
||||
|
||||
// GuardianSet definition.
|
||||
type GuardianSet struct {
|
||||
GstByIndex []common.GuardianSet
|
||||
ExpirationTimeByIndex []time.Time
|
||||
}
|
||||
|
||||
// Get get guardianset config by enviroment.
|
||||
func GetByEnv(enviroment string) GuardianSet {
|
||||
switch enviroment {
|
||||
case config.P2pTestNet:
|
||||
return getTestnetGuardianSet()
|
||||
default:
|
||||
return getMainnetGuardianSet()
|
||||
}
|
||||
}
|
||||
|
||||
// IsValid check if a guardianSet is valid.
|
||||
func (gs GuardianSet) IsValid(gsIx uint32, t time.Time) bool {
|
||||
if gsIx < 0 || int(gsIx) > len(gs.GstByIndex) {
|
||||
return false
|
||||
}
|
||||
return gs.ExpirationTimeByIndex[gsIx].After(t)
|
||||
}
|
||||
|
||||
// GetLatest get the lastest guardianset.
|
||||
func (gs GuardianSet) GetLatest() common.GuardianSet {
|
||||
return gs.GstByIndex[len(gs.GstByIndex)-1]
|
||||
}
|
||||
|
||||
func getTestnetGuardianSet() GuardianSet {
|
||||
const tenYears = time.Hour * 24 * 365 * 10
|
||||
gs0TestValidUntil := time.Now().Add(tenYears)
|
||||
gstest0 := common.GuardianSet{
|
||||
Index: 0,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x13947Bd48b18E53fdAeEe77F3473391aC727C638"), //
|
||||
},
|
||||
}
|
||||
return GuardianSet{
|
||||
GstByIndex: []common.GuardianSet{gstest0},
|
||||
ExpirationTimeByIndex: []time.Time{gs0TestValidUntil},
|
||||
}
|
||||
}
|
||||
|
||||
func getMainnetGuardianSet() GuardianSet {
|
||||
gs0ValidUntil := time.Unix(1628599904, 0) // Tue Aug 10 2021 12:51:44 GMT+0000
|
||||
gs0 := common.GuardianSet{
|
||||
Index: 0,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
},
|
||||
}
|
||||
|
||||
gs1ValidUntil := time.Unix(1650566103, 0) // Thu Apr 21 2022 18:35:03 GMT+0000
|
||||
gs1 := common.GuardianSet{
|
||||
Index: 1,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0xeB5F7389Fa26941519f0863349C223b73a6DDEE7"), // DokiaCapital
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
},
|
||||
}
|
||||
|
||||
const tenYears = time.Hour * 24 * 365 * 10
|
||||
gs2ValidUntil := time.Now().Add(tenYears) // still valid so we add 10 years
|
||||
gs2 := common.GuardianSet{
|
||||
Index: 2,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0x66B9590e1c41e0B226937bf9217D1d67Fd4E91F5"), // FTX
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
// devnet
|
||||
// eth_common.HexToAddress("0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe"),
|
||||
},
|
||||
}
|
||||
|
||||
gs3ValidUntil := time.Now().Add(tenYears) // still valid so we add 10 years
|
||||
gs3 := common.GuardianSet{
|
||||
Index: 3,
|
||||
Keys: []eth_common.Address{
|
||||
eth_common.HexToAddress("0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"), // Certus One
|
||||
eth_common.HexToAddress("0xfF6CB952589BDE862c25Ef4392132fb9D4A42157"), // Staked
|
||||
eth_common.HexToAddress("0x114De8460193bdf3A2fCf81f86a09765F4762fD1"), // Figment
|
||||
eth_common.HexToAddress("0x107A0086b32d7A0977926A205131d8731D39cbEB"), // ChainodeTech
|
||||
eth_common.HexToAddress("0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2"), // Inotel
|
||||
eth_common.HexToAddress("0x11b39756C042441BE6D8650b69b54EbE715E2343"), // HashQuark
|
||||
eth_common.HexToAddress("0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd"), // ChainLayer
|
||||
eth_common.HexToAddress("0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20"), // xLabs
|
||||
eth_common.HexToAddress("0x74a3bf913953D695260D88BC1aA25A4eeE363ef0"), // Forbole
|
||||
eth_common.HexToAddress("0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e"), // Staking Fund
|
||||
eth_common.HexToAddress("0xAF45Ced136b9D9e24903464AE889F5C8a723FC14"), // MoonletWallet
|
||||
eth_common.HexToAddress("0xf93124b7c738843CBB89E864c862c38cddCccF95"), // P2P Validator
|
||||
eth_common.HexToAddress("0xD2CC37A4dc036a8D232b48f62cDD4731412f4890"), // 01node
|
||||
eth_common.HexToAddress("0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811"), // MCF-V2-MAINNET
|
||||
eth_common.HexToAddress("0x71AA1BE1D36CaFE3867910F99C09e347899C19C3"), // Everstake
|
||||
eth_common.HexToAddress("0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf"), // Chorus One
|
||||
eth_common.HexToAddress("0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8"), // syncnode
|
||||
eth_common.HexToAddress("0x5E1487F35515d02A92753504a8D75471b9f49EdB"), // Triton
|
||||
eth_common.HexToAddress("0x6FbEBc898F403E4773E95feB15E80C9A99c8348d"), // Staking Facilities
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
return GuardianSet{
|
||||
GstByIndex: []common.GuardianSet{gs0, gs1, gs2, gs3},
|
||||
ExpirationTimeByIndex: []time.Time{gs0ValidUntil, gs1ValidUntil, gs2ValidUntil, gs3ValidUntil},
|
||||
}
|
||||
}
|
56
fly/main.go
56
fly/main.go
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
|
||||
"fmt"
|
||||
|
@ -12,6 +11,7 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/fly/config"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/fly/deduplicator"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/fly/guardiansets"
|
||||
"github.com/wormhole-foundation/wormhole-explorer/fly/internal/sqs"
|
||||
|
@ -39,31 +39,6 @@ import (
|
|||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
// p2p network constants.
|
||||
const (
|
||||
p2pMainNet = "mainnet"
|
||||
p2pTestNet = "testnet"
|
||||
p2pDevNet = "devnet"
|
||||
)
|
||||
|
||||
// p2p network configuration constants.
|
||||
const (
|
||||
// mainnet p2p config.
|
||||
MainNetP2ppNetworkID = "/wormhole/mainnet/2"
|
||||
MainNetP2pBootstrap = "/dns4/wormhole-mainnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWQp644DK27fd3d4Km3jr7gHiuJJ5ZGmy8hH4py7fP4FP7"
|
||||
MainNetP2pPort uint = 8999
|
||||
|
||||
// testnet p2p config.
|
||||
TestNetP2ppNetworkID = "/wormhole/testnet/2/1"
|
||||
TestNetP2pBootstrap = "/dns4/wormhole-testnet-v2-bootstrap.certus.one/udp/8999/quic/p2p/12D3KooWAkB9ynDur1Jtoa97LBUp8RXdhzS5uHgAfdTquJbrbN7i"
|
||||
TestNetP2pPort uint = 8999
|
||||
|
||||
// devnet p2p config.
|
||||
DevNetP2ppNetworkID = "/wormhole/dev"
|
||||
DevNetP2pBootstrap = "/dns4/guardian-0.guardian/udp/8999/quic/p2p/12D3KooWL3XJ9EMCyZvmmGXL2LMiVBtrVa2BuESsJiXkSj7333Jw"
|
||||
DevNetP2pPort uint = 8999
|
||||
)
|
||||
|
||||
var (
|
||||
rootCtx context.Context
|
||||
rootCtxCancel context.CancelFunc
|
||||
|
@ -74,13 +49,6 @@ var (
|
|||
logLevel string
|
||||
)
|
||||
|
||||
// P2pNetworkConfig config struct.
|
||||
type P2pNetworkConfig struct {
|
||||
P2pNetworkID string
|
||||
P2pBootstrap string
|
||||
P2pPort uint
|
||||
}
|
||||
|
||||
func getenv(key string) (string, error) {
|
||||
v := os.Getenv(key)
|
||||
if v == "" {
|
||||
|
@ -89,20 +57,6 @@ func getenv(key string) (string, error) {
|
|||
return v, nil
|
||||
}
|
||||
|
||||
func getP2pNetwork() (*P2pNetworkConfig, error) {
|
||||
p2pEnviroment := os.Getenv("P2P_NETWORK")
|
||||
switch p2pEnviroment {
|
||||
case p2pMainNet:
|
||||
return &P2pNetworkConfig{MainNetP2ppNetworkID, MainNetP2pBootstrap, MainNetP2pPort}, nil
|
||||
case p2pTestNet:
|
||||
return &P2pNetworkConfig{TestNetP2ppNetworkID, TestNetP2pBootstrap, TestNetP2pPort}, nil
|
||||
case p2pDevNet:
|
||||
return &P2pNetworkConfig{DevNetP2ppNetworkID, DevNetP2pBootstrap, DevNetP2pPort}, nil
|
||||
default:
|
||||
return nil, errors.New("invalid P2P_NETWORK enviroment variable")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO refactor to another file/package
|
||||
func newAwsSession() (*session.Session, error) {
|
||||
region, err := getenv("AWS_REGION")
|
||||
|
@ -214,7 +168,7 @@ func main() {
|
|||
defer rootCtxCancel()
|
||||
|
||||
// get p2p values to connect p2p network
|
||||
p2pNetworkConfig, err := getP2pNetwork()
|
||||
p2pNetworkConfig, err := config.GetP2pNetwork()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
|
@ -296,10 +250,12 @@ func main() {
|
|||
|
||||
// Governor status
|
||||
govStatusC := make(chan *gossipv1.SignedChainGovernorStatus, 50)
|
||||
|
||||
// Bootstrap guardian set, otherwise heartbeats would be skipped
|
||||
// TODO: fetch this and probably figure out how to update it live
|
||||
gs := guardiansets.GetLatest()
|
||||
gst.Set(&gs)
|
||||
gs := guardiansets.GetByEnv(p2pNetworkConfig.Enviroment)
|
||||
gsLastet := gs.GetLatest()
|
||||
gst.Set(&gsLastet)
|
||||
|
||||
// Ignore observation requests
|
||||
// Note: without this, the whole program hangs on observation requests
|
||||
|
|
Loading…
Reference in New Issue