-
Notifications
You must be signed in to change notification settings - Fork 2
Extend cldf timelock converter logic for TON #628
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
Changes from all commits
3261478
ce292f9
76f7941
6b03e06
bb6622b
564f880
fa6aa6c
580e5c7
d139579
e0493eb
8c9b9ff
b703c08
a68db89
d440c1d
060c95e
4a13173
5f800a9
02d0258
588016c
3d3a6ba
95337bb
c434940
781a16b
284e77e
2e6c227
06dd941
4168b5e
120f23b
d58f919
ad23d0e
8dcbd7a
022e0df
075de4e
e5efbd0
b25e6bc
42d488c
ced4bfd
62b9727
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,8 +13,6 @@ import ( | |||||
| "github.com/avast/retry-go/v4" | ||||||
| "github.com/testcontainers/testcontainers-go" | ||||||
|
|
||||||
| "github.com/xssnick/tonutils-go/address" | ||||||
| "github.com/xssnick/tonutils-go/tlb" | ||||||
| "github.com/xssnick/tonutils-go/ton" | ||||||
| "github.com/xssnick/tonutils-go/ton/wallet" | ||||||
|
|
||||||
|
|
@@ -126,17 +124,11 @@ func (p *CTFChainProvider) Initialize(ctx context.Context) (chain.BlockChain, er | |||||
| return nil, fmt.Errorf("failed to create wallet: %w", err) | ||||||
| } | ||||||
|
|
||||||
| // airdrop the deployer wallet | ||||||
| ferr := fundTonWallets(ctx, nodeClient, []*address.Address{tonWallet.Address()}, []tlb.Coins{tlb.MustFromTON("1000")}) | ||||||
| if ferr != nil { | ||||||
| return nil, fmt.Errorf("failed to fund wallet: %w", ferr) | ||||||
| } | ||||||
|
|
||||||
| p.chain = &cldf_ton.Chain{ | ||||||
| ChainMetadata: cldf_ton.ChainMetadata{Selector: p.selector}, | ||||||
| Client: nodeClient, | ||||||
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| Wallet: tonWallet, | ||||||
| WalletAddress: tonWallet.Address(), | ||||||
| WalletAddress: tonWallet.WalletAddress(), | ||||||
|
||||||
| WalletAddress: tonWallet.WalletAddress(), | |
| WalletAddress: tonWallet.Address(), |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -89,6 +89,22 @@ func Test_RPCChainProvider_Initialize(t *testing.T) { | |||||
| assert.Equal(t, existingChain.Selector, gotChain.Selector) | ||||||
| } | ||||||
|
|
||||||
| func Test_RPCChainProvider_Initialize_InvalidConfig(t *testing.T) { | ||||||
| t.Parallel() | ||||||
|
|
||||||
| p := &RPCChainProvider{ | ||||||
| selector: 123, | ||||||
| config: RPCChainProviderConfig{ | ||||||
| HTTPURL: "", // invalid - missing URL | ||||||
|
||||||
| HTTPURL: "", // invalid - missing URL | |
| HTTPURL: "", // invalid: empty URL to test validation of missing/empty configuration |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,9 +28,11 @@ import ( | |||||||||||||||||||||||||
| "github.com/smartcontractkit/mcms/sdk/evm/bindings" | ||||||||||||||||||||||||||
| "github.com/smartcontractkit/mcms/sdk/solana" | ||||||||||||||||||||||||||
| "github.com/smartcontractkit/mcms/sdk/sui" | ||||||||||||||||||||||||||
| "github.com/smartcontractkit/mcms/sdk/ton" | ||||||||||||||||||||||||||
| "github.com/smartcontractkit/mcms/types" | ||||||||||||||||||||||||||
| "github.com/spf13/cobra" | ||||||||||||||||||||||||||
| "github.com/spf13/pflag" | ||||||||||||||||||||||||||
| "github.com/xssnick/tonutils-go/tlb" | ||||||||||||||||||||||||||
| "go.uber.org/zap" | ||||||||||||||||||||||||||
| "go.uber.org/zap/zapcore" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -56,6 +58,11 @@ const ( | |||||||||||||||||||||||||
| indexFlag = "index" | ||||||||||||||||||||||||||
| forkFlag = "fork" | ||||||||||||||||||||||||||
| defaultProposalValidity = 72 * time.Hour | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // defaultTONExecutorAmount is the default amount of TON for MCMS/Timelock executor transactions. | ||||||||||||||||||||||||||
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
| // This is a static estimate that should be sufficient for most operations. | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| // This is a static estimate that should be sufficient for most operations. | |
| // This is a conservative static estimate intended to cover the gas and storage fees for a | |
| // typical MCMS/Timelock executor flow on TON (e.g. submitting and executing a proposal with | |
| // a small to medium number of actions) under current mainnet fee conditions, with an extra | |
| // safety buffer. The 0.1 TON value was chosen based on observed costs for common operations | |
| // plus headroom to account for moderate message size growth and fee fluctuations. | |
| // | |
| // IMPORTANT: This may be insufficient for unusually large/complex proposals, for networks | |
| // or environments with significantly higher fees, or if TON fee dynamics change over time. | |
| // Operators who routinely submit high-complexity proposals should consider overriding this | |
| // default with a higher value until a dynamic gas estimation mechanism is available. | |
| // |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TON timelock converter initialization lacks test coverage. Consider adding a test case similar to the existing Sui test case at line 1136-1138 to verify the converter is created correctly for TON chains.
gustavogama-cll marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message for TON encoder type validation is more detailed than the equivalent error messages for EVM (line 1451), Solana (line 1460), Aptos (line 1468), and Sui (line 1481) chains, which only say 'invalid encoder type: %T'. Consider making error messages consistent across all chain families.
| return nil, fmt.Errorf("invalid encoder type for TON chain %d: expected *ton.Encoder, got %T", chainSelector, encoder) | |
| return nil, fmt.Errorf("invalid encoder type: %T", encoder) |
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TON executor creation in getExecutorWithChainOverride lacks test coverage. Add test cases to verify the executor is created correctly with the expected options, including the Amount field set to defaultTONExecutorAmount.
github-code-quality[bot] marked this conversation as resolved.
Fixed
Show fixed
Hide fixed
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TON timelock executor creation in getTimelockExecutorWithChainOverride lacks test coverage. Add test cases to verify the timelock executor is created correctly with the expected options, similar to other chain family test cases.
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
huangzhen1997 marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable 'chain' should be renamed to 'c' for consistency with the naming pattern used in the same function for other chain families (lines 1535, 1539, 1542, 1545).
| chain := cfg.blockchains.TonChains()[cfg.chainSelector] | |
| inspector = ton.NewInspector(chain.Client) | |
| c := cfg.blockchains.TonChains()[cfg.chainSelector] | |
| inspector = ton.NewInspector(c.Client) |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TON inspector creation in getInspectorFromChainSelector lacks test coverage. Add test cases to verify the inspector is created correctly for TON chains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omitting fund logic from network setup makes sense to me(if I am reading it right), but just a reminder that integration tests in core and chainlink-ton are relying on the deployer wallet to fund transmitters:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, think we removed this as we discussed that the integration tests already funded the deployer wallet