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

feat: add Solana chain information #2416

Merged
merged 8 commits into from
Jul 2, 2024
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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* [2339](https://github.com/zeta-chain/node/pull/2339) - add binaries related question to syncing issue form
* [2366](https://github.com/zeta-chain/node/pull/2366) - add migration script for adding authorizations table
* [2372](https://github.com/zeta-chain/node/pull/2372) - add queries for tss fund migration info
* [2416g](https://github.com/zeta-chain/node/pull/2416) - add Solana chain information

### Refactor

Expand Down
8 changes: 8 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56965,6 +56965,9 @@ definitions:
- optimism_sepolia
- base_mainnet
- base_sepolia
- solana_mainnet
- solana_devnet
- solana_localnet
default: empty
title: ChainName represents the name of the chain
chainsConsensus:
Expand All @@ -56974,6 +56977,7 @@ definitions:
- tendermint
- bitcoin
- op_stack
- solana_consensus
default: ethereum
title: |-
Consensus represents the consensus algorithm used by the chain
Expand All @@ -56989,6 +56993,7 @@ definitions:
- bsc
- optimism
- base
- solana
default: eth
title: |-
Network represents the network of the chain
Expand Down Expand Up @@ -57022,6 +57027,7 @@ definitions:
enum:
- no_vm
- evm
- svm
default: no_vm
title: |-
Vm represents the virtual machine type of the chain to support smart
Expand Down Expand Up @@ -57832,6 +57838,8 @@ definitions:
type: string
is_supported:
type: boolean
gateway_address:
type: string
observerChainParamsList:
type: object
properties:
Expand Down
8 changes: 4 additions & 4 deletions pkg/chains/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestChain_Validate(t *testing.T) {
name: "should error if chain name invalid",
chain: chains.Chain{
ChainId: 42,
ChainName: chains.ChainName_base_sepolia + 1,
ChainName: chains.ChainName_solana_localnet + 1,
Network: chains.Network_optimism,
NetworkType: chains.NetworkType_testnet,
Vm: chains.Vm_evm,
Expand All @@ -72,7 +72,7 @@ func TestChain_Validate(t *testing.T) {
chain: chains.Chain{
ChainId: 42,
ChainName: chains.ChainName_empty,
Network: chains.Network_base + 1,
Network: chains.Network_solana + 1,
NetworkType: chains.NetworkType_testnet,
Vm: chains.Vm_evm,
Consensus: chains.Consensus_op_stack,
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestChain_Validate(t *testing.T) {
ChainName: chains.ChainName_empty,
Network: chains.Network_base,
NetworkType: chains.NetworkType_devnet,
Vm: chains.Vm_evm + 1,
Vm: chains.Vm_svm + 1,
Consensus: chains.Consensus_op_stack,
IsExternal: true,
},
Expand All @@ -114,7 +114,7 @@ func TestChain_Validate(t *testing.T) {
Network: chains.Network_base,
NetworkType: chains.NetworkType_devnet,
Vm: chains.Vm_evm,
Consensus: chains.Consensus_op_stack + 1,
Consensus: chains.Consensus_solana_consensus + 1,
IsExternal: true,
},
errStr: "invalid consensus",
Expand Down
47 changes: 47 additions & 0 deletions pkg/chains/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ var (
CctxGateway: CCTXGateway_observers,
}

// SolanaMainnet is Solana mainnet
// TODO: define final chain ID
// https://github.com/zeta-chain/node/issues/2421
SolanaMainnet = Chain{
ChainName: ChainName_solana_mainnet,
ChainId: 900,
lumtis marked this conversation as resolved.
Show resolved Hide resolved
Network: Network_solana,
NetworkType: NetworkType_mainnet,
Vm: Vm_svm,
Consensus: Consensus_solana_consensus,
IsExternal: true,
CctxGateway: CCTXGateway_observers,
}

/**
* Testnet chains
*/
Expand Down Expand Up @@ -179,6 +193,22 @@ var (
CctxGateway: CCTXGateway_observers,
}

// SolanaDevnet is Solana devnet
// NOTE: Solana devnet refers to Solana testnet in our terminology
// Solana uses devnet denomitation for network for development
// TODO: define final chain ID
// https://github.com/zeta-chain/node/issues/2421
SolanaDevnet = Chain{
ChainName: ChainName_solana_devnet,
ChainId: 901,
Network: Network_solana,
NetworkType: NetworkType_testnet,
Vm: Vm_svm,
Consensus: Consensus_solana_consensus,
IsExternal: true,
CctxGateway: CCTXGateway_observers,
}

/**
* Devnet chains
*/
Expand Down Expand Up @@ -236,6 +266,20 @@ var (
CctxGateway: CCTXGateway_observers,
}

// SolanaLocalnet is Solana localnet
// TODO: define final chain ID
// https://github.com/zeta-chain/node/issues/2421
SolanaLocalnet = Chain{
ChainName: ChainName_solana_localnet,
ChainId: 902,
Network: Network_solana,
NetworkType: NetworkType_privnet,
Vm: Vm_svm,
Consensus: Consensus_solana_consensus,
IsExternal: true,
CctxGateway: CCTXGateway_observers,
}

/**
* Deprecated chains
*/
Expand Down Expand Up @@ -296,6 +340,9 @@ func DefaultChainsList() []Chain {
OptimismSepolia,
BaseMainnet,
BaseSepolia,
SolanaMainnet,
SolanaDevnet,
SolanaLocalnet,
}
}

Expand Down
127 changes: 74 additions & 53 deletions pkg/chains/chains.pb.go

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

Loading
Loading