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(ton): TON observer 💎 #2896

Merged
merged 42 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9495518
Use chainParams from base observer
swift1337 Sep 17, 2024
2824c27
Improve base observer Start() semantics
swift1337 Sep 17, 2024
3e3e386
Add pkg/ticker options
swift1337 Sep 17, 2024
555d560
Add TON to pkg/chains & protos
swift1337 Sep 17, 2024
28b1298
Add liteapi wrapper client; locate first tx
swift1337 Sep 18, 2024
7cd1c06
Add TON tx scraper
swift1337 Sep 18, 2024
e0d806f
Add client.GetTransactionsUntil
swift1337 Sep 20, 2024
98a8813
Gateway WIP
swift1337 Sep 23, 2024
861cb4a
Implement Gateway inbound tx parsing
swift1337 Sep 23, 2024
a19a61b
Add Gateway tx filtration
swift1337 Sep 24, 2024
5f14515
Add GetBlockHeader cache; Add masterchain seqno. Implement watchInbound
swift1337 Sep 24, 2024
bfa9af8
Improve ton contracts pkg
swift1337 Sep 27, 2024
feda30f
Add IsTONChain()
swift1337 Sep 27, 2024
2be832f
Refactor Gateway package
swift1337 Sep 27, 2024
0688c47
Implement samples for TON
swift1337 Sep 27, 2024
1fd2cfe
Add liteClient mocks
swift1337 Sep 27, 2024
6619394
Add unit tests for inbound TON observer
swift1337 Sep 29, 2024
ccc1a9d
Localnet: add TON ZRC20
swift1337 Sep 30, 2024
9669adc
Wire the TON observer into the orchestrator
swift1337 Sep 30, 2024
2c1f47c
Add TON chain params of the fly!
swift1337 Oct 1, 2024
b19333f
TON deposits E2E wip
swift1337 Oct 2, 2024
a2acaf6
Fix bugs during cctx;
swift1337 Oct 2, 2024
2642694
TON Deposits E2E 🫡✅
swift1337 Oct 2, 2024
0a3fbad
TON Deposit And Call E2E
swift1337 Oct 3, 2024
ed1f322
Merge branch 'develop' into feat/ton-observer
swift1337 Oct 3, 2024
6eda977
Merge fixes
swift1337 Oct 3, 2024
7b2f232
Update changelog
swift1337 Oct 3, 2024
142778b
gosec
swift1337 Oct 3, 2024
3f8f989
Improve testing
swift1337 Oct 3, 2024
f5a4701
Simplify ticker.Stop(). Leverage ctx.cancel()
swift1337 Oct 3, 2024
2de851d
Simplify E2E
swift1337 Oct 4, 2024
d25a79a
Simplify liteapi semantics
swift1337 Oct 4, 2024
b313ded
Fix comments
swift1337 Oct 4, 2024
e0218c8
Update zetaclient/chains/base/observer.go
swift1337 Oct 4, 2024
cfd4728
Add gw explanatory comments; address PR comments
swift1337 Oct 7, 2024
dd04380
Merge branch 'feat/ton-observer' of github.com:zeta-chain/node into f…
swift1337 Oct 7, 2024
e16eefc
Merge branch 'develop' into feat/ton-observer
swift1337 Oct 7, 2024
c43ae26
Apply fixes for AI suggestions
swift1337 Oct 7, 2024
2bbc791
Merge branch 'develop' into feat/ton-observer
swift1337 Oct 9, 2024
126f966
Fix upgrade tests
swift1337 Oct 9, 2024
1daa056
Merge branch 'feat/ton-observer' of github.com:zeta-chain/node into f…
swift1337 Oct 9, 2024
906e8e9
Merge branch 'develop' into feat/ton-observer
swift1337 Oct 9, 2024
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: 4 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56995,7 +56995,9 @@ definitions:
- bitcoin
- op_stack
- solana_consensus
- catchain_consensus
default: ethereum
description: '- catchain_consensus: ton'
title: |-
Consensus represents the consensus algorithm used by the chain
this can represent the consensus of a L1
Expand All @@ -57011,6 +57013,7 @@ definitions:
- optimism
- base
- solana
- ton
default: eth
title: |-
Network represents the network of the chain
Expand Down Expand Up @@ -57045,6 +57048,7 @@ definitions:
- no_vm
- evm
- svm
- tvm
default: no_vm
title: |-
Vm represents the virtual machine type of the chain to support smart
Expand Down
6 changes: 3 additions & 3 deletions pkg/chains/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestChain_Validate(t *testing.T) {
chain: chains.Chain{
ChainId: 42,
Name: "foo",
Network: chains.Network_solana + 1,
Network: chains.Network_ton + 1,
NetworkType: chains.NetworkType_testnet,
Vm: chains.Vm_evm,
Consensus: chains.Consensus_op_stack,
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestChain_Validate(t *testing.T) {
Name: "foo",
Network: chains.Network_base,
NetworkType: chains.NetworkType_devnet,
Vm: chains.Vm_svm + 1,
Vm: chains.Vm_tvm + 1,
Consensus: chains.Consensus_op_stack,
IsExternal: true,
},
Expand All @@ -115,7 +115,7 @@ func TestChain_Validate(t *testing.T) {
Network: chains.Network_base,
NetworkType: chains.NetworkType_devnet,
Vm: chains.Vm_evm,
Consensus: chains.Consensus_solana_consensus + 1,
Consensus: chains.Consensus_catchain_consensus + 1,
IsExternal: true,
},
errStr: "invalid consensus",
swift1337 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
48 changes: 37 additions & 11 deletions pkg/chains/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ var (
Name: "solana_mainnet",
swift1337 marked this conversation as resolved.
Show resolved Hide resolved
}

TONMainnet = Chain{
// T[20] O[15] N[14] mainnet[0] :)
ChainId: 2015140,
Network: Network_ton,
NetworkType: NetworkType_mainnet,
Vm: Vm_tvm,
Consensus: Consensus_catchain_consensus,
IsExternal: true,
CctxGateway: CCTXGateway_observers,
Name: "ton_mainnet",
}

/**
* Testnet chains
*/
Expand Down Expand Up @@ -225,6 +237,17 @@ var (
Name: "solana_devnet",
}

TONTestnet = Chain{
ChainId: 2015141,
Network: Network_ton,
NetworkType: NetworkType_testnet,
Vm: Vm_tvm,
Consensus: Consensus_catchain_consensus,
IsExternal: true,
CctxGateway: CCTXGateway_observers,
Name: "ton_testnet",
}

/**
* Devnet chains
*/
Expand Down Expand Up @@ -301,6 +324,17 @@ var (
Name: "solana_localnet",
}

TONLocalnet = Chain{
ChainId: 2015142,
Network: Network_ton,
NetworkType: NetworkType_privnet,
Vm: Vm_tvm,
Consensus: Consensus_catchain_consensus,
IsExternal: true,
CctxGateway: CCTXGateway_observers,
Name: "ton_localnet",
}

/**
* Deprecated chains
*/
Expand Down Expand Up @@ -366,6 +400,9 @@ func DefaultChainsList() []Chain {
SolanaMainnet,
SolanaDevnet,
SolanaLocalnet,
TONMainnet,
TONTestnet,
TONLocalnet,
}
}

Expand Down Expand Up @@ -423,17 +460,6 @@ func ChainListByGateway(gateway CCTXGateway, additionalChains []Chain) []Chain {
return chainList
}

// ChainListForHeaderSupport returns a list of chains that support headers
func ChainListForHeaderSupport(additionalChains []Chain) []Chain {
var chainList []Chain
for _, chain := range CombineDefaultChainsList(additionalChains) {
if chain.Consensus == Consensus_ethereum || chain.Consensus == Consensus_bitcoin {
chainList = append(chainList, chain)
}
}
return chainList
}

// ZetaChainFromCosmosChainID returns a ZetaChain chain object from a Cosmos chain ID
func ZetaChainFromCosmosChainID(chainID string) (Chain, error) {
ethChainID, err := CosmosToEthChainID(chainID)
Expand Down
130 changes: 70 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.

17 changes: 16 additions & 1 deletion pkg/chains/chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import (
func TestChain_Name(t *testing.T) {
t.Run("new Name field is compatible with ChainName enum", func(t *testing.T) {
for _, chain := range chains.DefaultChainsList() {
require.EqualValues(t, chain.Name, chain.ChainName.String())
chainName := chain.ChainName.String()
if chainName != "empty" {
require.EqualValues(t, chain.Name, chainName)
}
}
})
}
Expand All @@ -34,6 +37,7 @@ func TestChainListByNetworkType(t *testing.T) {
chains.OptimismMainnet,
chains.BaseMainnet,
chains.SolanaMainnet,
chains.TONMainnet,
},
},
{
Expand All @@ -50,6 +54,7 @@ func TestChainListByNetworkType(t *testing.T) {
chains.OptimismSepolia,
chains.BaseSepolia,
chains.SolanaDevnet,
chains.TONTestnet,
},
},
{
Expand All @@ -60,6 +65,7 @@ func TestChainListByNetworkType(t *testing.T) {
chains.BitcoinRegtest,
chains.GoerliLocalnet,
chains.SolanaLocalnet,
chains.TONLocalnet,
},
},
}
Expand Down Expand Up @@ -156,6 +162,9 @@ func TestDefaultChainList(t *testing.T) {
chains.SolanaMainnet,
chains.SolanaDevnet,
chains.SolanaLocalnet,
chains.TONMainnet,
chains.TONTestnet,
chains.TONLocalnet,
}, chains.DefaultChainsList())
}

Expand Down Expand Up @@ -188,6 +197,9 @@ func TestChainListByGateway(t *testing.T) {
chains.SolanaMainnet,
chains.SolanaDevnet,
chains.SolanaLocalnet,
chains.TONMainnet,
chains.TONTestnet,
chains.TONLocalnet,
},
},
{
Expand Down Expand Up @@ -230,6 +242,9 @@ func TestExternalChainList(t *testing.T) {
chains.SolanaMainnet,
chains.SolanaDevnet,
chains.SolanaLocalnet,
chains.TONMainnet,
chains.TONTestnet,
chains.TONLocalnet,
}, chains.ExternalChainList([]chains.Chain{}))
}

Expand Down
Loading
Loading