Skip to content

Commit

Permalink
Merge pull request #23 from gobicycle/develop
Browse files Browse the repository at this point in the history
allow to set forward amount for external withdrawals to zero
  • Loading branch information
gobicycle authored Oct 6, 2024
2 parents a6fe44b + 538bd48 commit 9138f5f
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Install libs
run: |
wget -O libemulator.so https://github.com/ton-blockchain/ton/releases/download/v2024.02/libemulator-linux-x86-64.so
wget -O libemulator.so https://github.com/ton-blockchain/ton/releases/download/v2024.09/libemulator-linux-x86_64.so
sudo cp libemulator.so /lib
- name: Update Library Cache
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ For more information on Jettons compatibility, see [Jettons compatibility](/jett
| `WEBHOOK_ENDPOINT` | endpoint to send webhooks, example: `http://hostname:3333/webhook`. If the value is not set, then webhooks are not sent. |
| `WEBHOOK_TOKEN` | Bearer token for webhook request. If not set then not used. |
| `ALLOWABLE_LAG` | allowable time lag between service time and last block time in seconds, default: 15 |
| `FORWARD_TON_AMOUNT` | forward ton amount for jetton withdrawals, default: 20000000 nanoton |
| `FORWARD_TON_AMOUNT` | forward ton amount for jetton withdrawals, default: 1 nanoton |
| `PROOF_CHECK_ENABLED` | enable verification of all proofs to securely connect to an untrusted node, default: `false`. Also you need to define `NETWORK_CONFIG_URL`. |
| `NETWORK_CONFIG_URL` | the path to load the network configuration to get the trusted key block from it. This is necessary for proof verification, example: `https://ton.org/global.config.json` |

Expand Down
63 changes: 53 additions & 10 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import (
"github.com/tonkeeper/tongo/tvm"
"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/liteclient"
"github.com/xssnick/tonutils-go/tl"
"github.com/xssnick/tonutils-go/tlb"
"github.com/xssnick/tonutils-go/ton"
"github.com/xssnick/tonutils-go/ton/dns"
"github.com/xssnick/tonutils-go/ton/jetton"
"github.com/xssnick/tonutils-go/ton/wallet"
"github.com/xssnick/tonutils-go/tvm/cell"
"math"
"math/big"
"sort"
Expand Down Expand Up @@ -90,43 +92,59 @@ func NewConnection(addr, key string) (*Connection, error) {
}

// TODO: replace after tonutils fix
root, err := getRootContractAddr(ctx, wrappedClient)
rootDNS, bcConfig, err := getConfigData(ctx, wrappedClient)
if err != nil {
return nil, fmt.Errorf("get DNS root contract err: %s", err.Error())
return nil, fmt.Errorf("get config data err: %s", err.Error())
}

resolver := dns.NewDNSClient(wrappedClient, root)
config.Config.BlockchainConfig = bcConfig
resolver := dns.NewDNSClient(wrappedClient, rootDNS)

return &Connection{
client: wrappedClient,
resolver: resolver,
}, nil
}

func getRootContractAddr(ctx context.Context, api ton.APIClientWrapped) (*address.Address, error) {
func getConfigData(ctx context.Context, api ton.APIClientWrapped) (*address.Address, *boc.Cell, error) {

// TODO: remove after tonutils fix
b, err := api.CurrentMasterchainInfo(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get masterchain info: %w", err)
return nil, nil, fmt.Errorf("failed to get masterchain info: %w", err)
}

cfg, err := api.GetBlockchainConfig(ctx, b, 4)
if err != nil {
return nil, fmt.Errorf("failed to get root address from network config: %w", err)
return nil, nil, fmt.Errorf("failed to get blockchain config: %w", err)
}

cfgDict, err := getBlockchainConfig(ctx, api.Client(), b)
if err != nil {
return nil, nil, fmt.Errorf("failed to get config dict: %w", err)
}
cfgCell, err := tlb.ToCell(cfgDict)
if err != nil {
return nil, nil, fmt.Errorf("failed to serialize blockchain config: %w", err)
}
configCell, err := boc.DeserializeBoc(cfgCell.ToBOC())
if err != nil {
return nil, nil, fmt.Errorf("failed to deserialize blockchain config: %w", err)
}
if len(configCell) != 1 {
return nil, nil, fmt.Errorf("blockchain config must conatins only one cell")
}

data := cfg.Get(4)
if data == nil {
return nil, fmt.Errorf("failed to get root address from network config")
return nil, nil, fmt.Errorf("failed to get root address from blockchain config")
}

hash, err := data.BeginParse().LoadSlice(256)
if err != nil {
return nil, fmt.Errorf("failed to get root address from network config 4, failed to load hash: %w", err)
return nil, nil, fmt.Errorf("failed to get root address from blockchain config 4, failed to load hash: %w", err)
}

return address.NewAddress(0, 255, hash), nil
return address.NewAddress(0, 255, hash), configCell[0], nil
}

// GenerateDefaultWallet generates HighloadV2R2 or V3R2 TON wallet with
Expand Down Expand Up @@ -614,3 +632,28 @@ func (c *Connection) GetMasterchainInfo(ctx context.Context) (*ton.BlockIDExt, e
func (c *Connection) SendExternalMessageWaitTransaction(ctx context.Context, ext *tlb.ExternalMessage) (*tlb.Transaction, *ton.BlockIDExt, []byte, error) {
return c.client.SendExternalMessageWaitTransaction(ctx, ext)
}

func getBlockchainConfig(ctx context.Context, client ton.LiteClient, block *ton.BlockIDExt) (*cell.Dictionary, error) {
var resp tl.Serializable
var err error
err = client.QueryLiteserver(ctx, ton.GetConfigAll{
Mode: 0b1111111111,
BlockID: block,
}, &resp)
if err != nil {
return nil, err
}

switch t := resp.(type) {
case ton.ConfigAll:
stateExtra, err := ton.CheckShardMcStateExtraProof(block, []*cell.Cell{t.StateProof, t.ConfigProof})
if err != nil {
return nil, fmt.Errorf("incorrect proof: %w", err)
}

return stateExtra.ConfigParams.Config.Params, nil
case ton.LSError:
return nil, t
}
return nil, fmt.Errorf("unexpected response from node")
}
10 changes: 0 additions & 10 deletions blockchain/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package blockchain
import (
"bytes"
"context"
"github.com/gobicycle/bicycle/config"
"github.com/gobicycle/bicycle/core"
"github.com/tonkeeper/tongo/boc"
"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/tlb"
"github.com/xssnick/tonutils-go/ton/jetton"
Expand All @@ -23,14 +21,6 @@ var (
notActiveAccount, _ = address.ParseAddr("kQAkRRJ1RiViVHY2UmUhWCFjdiZBeEYnhkhxI1JTJFNUNG9v")
)

func init() {
conf, err := boc.DeserializeBocBase64(config.TestnetConfig)
if err != nil {
panic(err)
}
config.Config.BlockchainConfig = conf[0]
}

func connect(t *testing.T) *Connection {
server := os.Getenv("SERVER")
if server == "" {
Expand Down
33 changes: 8 additions & 25 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import (
"time"
)

const DefaultJettonForwardTonAmount = 20_000_000
const MaxJettonForwardTonAmount = 20_000_000

var (
JettonTransferTonAmount = tlb.FromNanoTONU(100_000_000)
JettonForwardAmount = tlb.FromNanoTONU(DefaultJettonForwardTonAmount) // must be < JettonTransferTonAmount
JettonTransferTonAmount = tlb.FromNanoTONU(100_000_000)
JettonForwardAmount = tlb.FromNanoTONU(MaxJettonForwardTonAmount) // must be < JettonTransferTonAmount
JettonInternalForwardAmount = tlb.FromNanoTONU(1)

DefaultHotWalletHysteresis = decimal.NewFromFloat(0.95) // `hot_wallet_residual_balance` = `hot_wallet_max_balance` * `hysteresis`

Expand All @@ -33,10 +34,6 @@ var (
// JettonProxyContractCode source code at https://github.com/gobicycle/ton-proxy-contract
const JettonProxyContractCode = "B5EE9C72410102010037000114FF00F4A413F4BCF2C80B010050D33331D0D3030171B0915BE0FA4030ED44D0FA4030C705F2E1939320D74A97D4018100A0FB00E8301E8A9040"

const (
TestnetConfig = "te6ccgICAQIAAQAAFzMAAAIBIAABAPMCB7AAAAEAAgDbAgEgAAMAlAIBIAAEAG4CASAABQAWAgEgAAYADgIBIAAHAAwCASAACAAKAQEgAAkAQFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVAQEgAAsAQDMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzAQFIAA0AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgEgAA8AEQEBSAAQAEDv5x0Thgr6pq6ur2NvkWhIf4DxAxsL+Nk5rknT6n99oAEBWAASAQHAABMCASAAF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MaxCommentLength = 1000 // qty in chars

var Config = struct {
Expand All @@ -59,7 +56,7 @@ var Config = struct {
WebhookEndpoint string `env:"WEBHOOK_ENDPOINT"`
WebhookToken string `env:"WEBHOOK_TOKEN"`
AllowableLaggingSec int `env:"ALLOWABLE_LAG"`
ForwardTonAmount int `env:"FORWARD_TON_AMOUNT"`
ForwardTonAmount int `env:"FORWARD_TON_AMOUNT" envDefault:"1"`
Jettons map[string]Jetton
Ton Cutoffs
ColdWallet *address.Address
Expand Down Expand Up @@ -88,9 +85,9 @@ func GetConfig() {
Config.Jettons = parseJettonString(Config.JettonString)
Config.Ton = parseTonString(Config.TonString)

if Config.ForwardTonAmount < 0 || Config.ForwardTonAmount > DefaultJettonForwardTonAmount {
log.Fatalf("Forward TON amount for jetton transfer must be positive and less than %d", DefaultJettonForwardTonAmount)
} else if Config.ForwardTonAmount > 0 {
if Config.ForwardTonAmount < 0 || Config.ForwardTonAmount > MaxJettonForwardTonAmount {
log.Fatalf("Forward TON amount for jetton transfer must be positive and less than %d", MaxJettonForwardTonAmount)
} else {
JettonForwardAmount = tlb.FromNanoTONU(uint64(Config.ForwardTonAmount))
}

Expand All @@ -108,20 +105,6 @@ func GetConfig() {
Config.ColdWallet = coldAddr
}

if Config.Testnet {
config, err := boc.DeserializeBocBase64(TestnetConfig)
if err != nil {
log.Fatalf("Can not parse testnet blockchain config: %v", err)
}
Config.BlockchainConfig = config[0]
} else {
config, err := boc.DeserializeBocBase64(MainnetConfig)
if err != nil {
log.Fatalf("Can not parse mainnet blockchain config: %v", err)
}
Config.BlockchainConfig = config[0]
}

if Config.AllowableLaggingSec != 0 {
AllowableBlockchainLagging = time.Second * time.Duration(Config.AllowableLaggingSec)
}
Expand Down
3 changes: 0 additions & 3 deletions config/network_config.go

This file was deleted.

2 changes: 1 addition & 1 deletion core/withdrawal_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (p *WithdrawalsProcessor) buildJettonInternalWithdrawalMessage(
*proxy,
jettonWalletAddress,
p.wallets.TonHotWallet.Address(),
config.JettonForwardAmount,
config.JettonInternalForwardAmount,
balance,
memo.String(),
)
Expand Down
12 changes: 11 additions & 1 deletion manual_testing_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Template:
- COMMENT :

4. -[X] Checked
- TEST : Set invalid `FORWARD_TON_AMOUNT` env (negative, > default value)
- TEST : Set invalid `FORWARD_TON_AMOUNT` env (negative, > max value)
- RESULT : Service failed with load config error.
- COMMENT :

Expand All @@ -379,6 +379,16 @@ Template:
- RESULT : All withdrawals must be successful and confirmed.
- COMMENT :

6. -[X] Checked
- TEST : Not set `FORWARD_TON_AMOUNT` env. And check external withdrawals and internal withdrawals.
- RESULT : All withdrawals must be successful and confirmed. Forward ton amount must be 1 nanoton.
- COMMENT :

7. -[X] Checked
- TEST : Set `FORWARD_TON_AMOUNT` env to 0 nanoton. And check external withdrawals and internal withdrawals.
- RESULT : All withdrawals must be successful and confirmed and there is no transfer notification message for external withdrawals and 1 nanoton forward amount for internal transfer.
- COMMENT :

### Deploy

1. -[X] Checked
Expand Down
Loading

0 comments on commit 9138f5f

Please sign in to comment.