tychoclient

package
v1.18.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultEndpoint is the testnet endpoint provided by the team
	DefaultEndpoint = "tonapi-testnet.tychoprotocol.com:443"

	// DefaultTimeout for gRPC calls
	DefaultTimeout = 30 * time.Second
)

Variables

View Source
var BlockNotFoundErr = errors.New("block not found")

Functions

func GetParents

func GetParents(i TychoBlockInfo) ([]ton.BlockIDExt, error)

func ParseShardAccount

func ParseShardAccount(state, proof, accountAddress []byte) (tlb.ShardAccount, uint64, error)

ParseShardAccount parses BOC-encoded ShardAccount data

func ShardIDs

func ShardIDs(extra McBlockExtraTycho) []ton.BlockIDExt

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides access to Tycho blockchain data via gRPC

func NewClient

func NewClient() (*Client, error)

NewClient creates a new Tycho client with default settings

func NewClientWithEndpoint

func NewClientWithEndpoint(endpoint string, disableTLS bool) (*Client, error)

NewClientWithEndpoint creates a new Tycho client with a custom endpoint

func (*Client) Close

func (c *Client) Close() error

Close closes the gRPC connection

func (*Client) GetLibraries

func (c *Client) GetLibraries(ctx context.Context, libraryList []ton.Bits256) (map[ton.Bits256]*boc.Cell, error)

GetLibraries fetches library cells by hash

func (*Client) GetLibraryCell

func (c *Client) GetLibraryCell(ctx context.Context, hash []byte) ([]byte, error)

GetLibraryCell fetches a library cell by hash

func (*Client) GetRawBlockData

func (c *Client) GetRawBlockData(ctx context.Context, workchain int32, shard uint64, seqno uint32) ([]byte, error)

GetRawBlockData fetches raw BOC data for debugging purposes

func (*Client) GetShardAccount

func (c *Client) GetShardAccount(ctx context.Context, workchain int32, address []byte) (*ShardAccountInfo, uint64, error)

GetShardAccount gets account state and proof LT from a specific shard at the latest block

func (*Client) GetShardAccountAtSeqno

func (c *Client) GetShardAccountAtSeqno(ctx context.Context, workchain int32, address []byte, blockWorkchain int32, shard uint64, seqno uint32) (*ShardAccountInfo, uint64, error)

GetShardAccountAtSeqno gets account state and proof LT at a specific block seqno

func (*Client) GetShardAccountByBlockId

func (c *Client) GetShardAccountByBlockId(ctx context.Context, workchain int32, address []byte, blockId *proto.BlockId) (*ShardAccountInfo, uint64, error)

GetShardAccountByBlockId gets account state and proof LT at a specific block

func (*Client) GetShardAccountRaw

func (c *Client) GetShardAccountRaw(ctx context.Context, workchain int32, address []byte, withProof bool) (*ShardAccountInfo, error)

GetShardAccountRaw gets account state without parsing - used for debugging

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context) (*proto.GetStatusResponse, error)

GetStatus returns the current status of the Tycho node

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, payload []byte) (uint32, error)

SendMessage sends a message to the blockchain

type ConsensusInfo

type ConsensusInfo struct {
	VsetSwitchRound         uint32
	PrevVsetSwitchRound     uint32
	GenesisInfo             GenesisInfo
	PrevShuffleMcValidators bool
}

type ExternalsProcessedUpto

type ExternalsProcessedUpto struct {
	ProcessedToAnchorId   uint32
	ProcessedToMsgsOffset uint64
	Ranges                tlb.HashmapE[tlb.Uint32, ExternalsRange]
}

ExternalsProcessedUpto - external messages processing status externalsProcessedUpto#00 processed_to_anchor_id:uint32 processed_to_msgs_offset:uint64 ranges:(HashmapE 32 ExternalsRange) = ExternalsProcessedUpto;

type ExternalsRange

type ExternalsRange struct {
	FromAnchorId    uint32
	FromMsgsOffset  uint64
	ToAnchorId      uint32
	ToMsgsOffset    uint64
	ChainTime       uint64
	SkipOffset      uint32
	ProcessedOffset uint32
}

ExternalsRange - range of external messages externalsRange#00 from_anchor_id:uint32 from_msgs_offset:uint64 to_anchor_id:uint32 to_msgs_offset:uint64 chain_time:uint64 skip_offset:uint32 processed_offset:uint32 = ExternalsRange;

type GenesisInfo

type GenesisInfo struct {
	StartRound    uint32
	GenesisMillis uint64
}

type InternalsProcessedUpto

type InternalsProcessedUpto struct {
	ProcessedTo tlb.HashmapE[tlb.Bits96, tlb.ProcessedUpto]
	Ranges      tlb.HashmapE[tlb.Uint32, InternalsRange]
}

InternalsProcessedUpto - internal messages processing status internalsProcessedUpto#00 processed_to:(HashmapE 96 ProcessedUpto) ranges:(HashmapE 32 InternalsRange) = InternalsProcessedUpto;

type InternalsRange

type InternalsRange struct {
	SkipOffset      uint32
	ProcessedOffset uint32
	Shards          tlb.HashmapE[tlb.Bits96, ShardRange]
}

InternalsRange - range of internal messages internalsRange#00 skip_offset:uint32 processed_offset:uint32 shards:(HashmapE 96 ShardRange) = InternalsRange;

type McBlockExtraTycho

type McBlockExtraTycho struct {
	Magic        tlb.Magic `tlb:"masterchain_block_extra#cca5"`
	KeyBlock     bool
	ShardHashes  tlb.HashmapE[tlb.Uint32, tlb.Ref[TychoShardInfoBinTree]] // Use Tycho version
	ShardFees    tlb.ShardFees
	McExtraOther struct {
		PrevBlkSignatures tlb.HashmapE[tlb.Uint16, tlb.CryptoSignaturePair]
		RecoverCreate     tlb.Maybe[tlb.Ref[tlb.InMsg]]
		MintMsg           tlb.Maybe[tlb.Ref[tlb.InMsg]]
	} `tlb:"^"`
	Config tlb.ConfigParams
}

McBlockExtraTycho - Tycho's masterchain block extra with TychoShardDescr masterchain_block_extra#cca5 key_block:Bool shard_hashes:ShardHashes shard_fees:ShardFees ^[ prev_blk_signatures:(HashmapE 16 CryptoSignaturePair)

recover_create_msg:(Maybe ^InMsg)
mint_msg:(Maybe ^InMsg) ]

config:key_block?ConfigParams = McBlockExtra;

func (*McBlockExtraTycho) UnmarshalTLB

func (m *McBlockExtraTycho) UnmarshalTLB(c *boc.Cell, decoder *tlb.Decoder) error

type McStateExtraOtherTycho

type McStateExtraOtherTycho struct {
	Flags            uint16
	ValidatorInfo    tlb.ValidatorInfo
	PrevBlocks       tlb.HashmapAugE[tlb.Uint32, tlb.KeyExtBlkRef, tlb.KeyMaxLt]
	AfterKeyBlock    bool
	LastKeyBlock     tlb.Maybe[tlb.ExtBlkRef]
	BlockCreateStats *tlb.BlockCreateStats
	ConsensusInfo    *ConsensusInfo
}

func (*McStateExtraOtherTycho) UnmarshalTLB

func (m *McStateExtraOtherTycho) UnmarshalTLB(c *boc.Cell, decoder *tlb.Decoder) error

type McStateExtraTycho

type McStateExtraTycho struct {
	Magic         tlb.Magic `tlb:"masterchain_state_extra#cc26"`
	ShardHashes   tlb.HashmapE[tlb.Uint32, tlb.Ref[TychoShardInfoBinTree]]
	Config        tlb.ConfigParams
	Other         McStateExtraOtherTycho `tlb:"^"`
	GlobalBalance tlb.CurrencyCollection
}

McStateExtra masterchain_state_extra#cc26 shard_hashes:ShardHashes config:ConfigParams ^[ flags:(## 16) { flags <= 1 } validator_info:ValidatorInfo prev_blocks:OldMcBlocksInfo after_key_block:Bool last_key_block:(Maybe ExtBlkRef) block_create_stats:(flags . 0)?BlockCreateStats ] global_balance:CurrencyCollection = McStateExtra;

type MsgsExecutionParams

type MsgsExecutionParams struct {
	BufferLimit            uint32
	GroupLimit             uint16
	GroupVertSize          uint16
	ExternalsExpireTimeout uint16
	OpenRangesLimit        uint16
	Par0IntMsgsCountLimit  uint32
	Par0ExtMsgsCountLimit  uint32
	GroupSlotsFractions    tlb.HashmapE[tlb.Uint16, uint8]
	RangeMessagesLimit     uint32 // Only in v2 (#01)
}

MsgsExecutionParams - message execution parameters msgs_execution_params_tycho#00 or #01

type OutMsgQueueUpdates

type OutMsgQueueUpdates struct {
	Magic    tlb.Magic `tlb:"#1"`
	DiffHash tlb.Bits256
	TailLen  uint32
}

OutMsgQueueUpdates - Tycho's queue update tracking out_msg_queue_updates#1 diff_hash:bits256 tail_len:uint32 = OutMsgQueueUpdates;

type ProcessedUptoInfo

type ProcessedUptoInfo struct {
	Partitions     tlb.HashmapE[tlb.Uint16, ProcessedUptoPartition]
	MsgsExecParams tlb.Maybe[tlb.Ref[MsgsExecutionParams]]
}

ProcessedUptoInfo - Tycho's processed messages tracking processed_upto_info#00 partitions:(HashmapE 16 ProcessedUptoPartition) msgs_exec_params:(Maybe ^MsgsExecutionParams) = ProcessedUptoInfo;

type ProcessedUptoPartition

type ProcessedUptoPartition struct {
	Externals ExternalsProcessedUpto
	Internals InternalsProcessedUpto
}

ProcessedUptoPartition - per-partition processing status processedUptoPartition#00 externals:ExternalsProcessedUpto internals:InternalsProcessedUpto = ProcessedUptoPartition;

type ShardAccountInfo

type ShardAccountInfo struct {
	McStateInfo        *proto.McStateInfo
	AccountState       []byte            // BOC-encoded ShardAccount (if found)
	Proof              []byte            // BOC-encoded collection of proofs (if withProof was true)
	ParsedAccountState *tlb.ShardAccount // Parsed TLB ShardAccount
}

ShardAccountInfo contains account state information

func (*ShardAccountInfo) String

func (s *ShardAccountInfo) String() string

String returns a human-readable representation of ShardAccountInfo

type ShardRange

type ShardRange struct {
	From uint64
	To   uint64
}

ShardRange - range within a shard shardRange#00 from:uint64 to:uint64 = ShardRange;

type TychoBlock

type TychoBlock struct {
	Magic     tlb.Magic `tlb:"block_tycho#11ef55bb"`
	GlobalId  int32
	Info      TychoBlockInfo `tlb:"^"`
	ValueFlow tlb.ValueFlow  `tlb:"^"`
	Other     struct {
		StateUpdate        tlb.MerkleUpdate[TychoShardState] `tlb:"^"`
		OutMsgQueueUpdates OutMsgQueueUpdates
	} `tlb:"^"`
	Extra TychoBlockExtra `tlb:"^"`
}

Tycho Block - uses automatic TLB parsing with struct tags block_tycho#11ef55bb global_id:int32 info:^BlockInfo value_flow:^ValueFlow ^[

state_update:^(MERKLE_UPDATE ShardState)
out_msg_queue_updates:OutMsgQueueUpdates

] extra:^BlockExtra = Block;

func ParseTychoBlock

func ParseTychoBlock(bocData []byte) (*TychoBlock, error)

ParseTychoBlock parses a Tycho block from BOC data

func (*TychoBlock) AllTransactions

func (b *TychoBlock) AllTransactions() []*tlb.Transaction

func (*TychoBlock) TransactionsQuantity

func (b *TychoBlock) TransactionsQuantity() int

type TychoBlockExtra

type TychoBlockExtra struct {
	Magic           tlb.Magic                                                              `tlb:"block_extra_tycho#4a33f6fc"`
	InMsgDescrCell  boc.Cell                                                               `tlb:"^"`
	OutMsgDescrCell boc.Cell                                                               `tlb:"^"`
	AccountBlocks   tlb.HashmapAugE[tlb.Bits256, tlb.AccountBlock, tlb.CurrencyCollection] `tlb:"^"`
	RandSeed        tlb.Bits256
	CreatedBy       tlb.Bits256
	Custom          tlb.Maybe[tlb.Ref[McBlockExtraTycho]]
}

Tycho BlockExtra block_extra_tycho#4a33f6fc in_msg_descr:^InMsgDescr out_msg_descr:^OutMsgDescr account_blocks:^ShardAccountBlocks rand_seed:bits256 created_by:bits256 custom:(Maybe ^McBlockExtra) = BlockExtra;

func (*TychoBlockExtra) InMsgDescr

func (extra *TychoBlockExtra) InMsgDescr() (tlb.HashmapAugE[tlb.Bits256, tlb.InMsg, tlb.ImportFees], error)

InMsgDescr returns the parsed InMsgDescr hashmap

func (*TychoBlockExtra) InMsgDescrLength

func (extra *TychoBlockExtra) InMsgDescrLength() (int, error)

func (*TychoBlockExtra) OutMsgDescr

OutMsgDescr returns the parsed OutMsgDescr hashmap

func (*TychoBlockExtra) OutMsgDescrLength

func (extra *TychoBlockExtra) OutMsgDescrLength() (int, error)

type TychoBlockInfo

type TychoBlockInfo struct {
	TychoBlockInfoPart
	GenSoftware *tlb.GlobalVersion
	MasterRef   *tlb.BlkMasterInfo
	PrevRef     tlb.BlkPrevInfo
	PrevVertRef *tlb.BlkPrevInfo
}

Tycho BlockInfo - adds gen_utime_ms field block_info_tycho#9bc7a988 version:uint32 not_master:(## 1) after_merge:(## 1) before_split:(## 1) after_split:(## 1) want_split:Bool want_merge:Bool key_block:Bool vert_seqno_incr:(## 1) flags:(## 8) { flags <= 1 } seq_no:# vert_seq_no:# shard:ShardIdent gen_utime:uint32 gen_utime_ms:uint16 start_lt:uint64 end_lt:uint64 gen_validator_list_hash_short:uint32 gen_catchain_seqno:uint32 min_ref_mc_seqno:uint32 prev_key_block_seqno:uint32 gen_software:flags . 0?GlobalVersion master_ref:not_master?^BlkMasterInfo prev_ref:^(BlkPrevInfo after_merge) prev_vert_ref:vert_seqno_incr?^(BlkPrevInfo 0) = BlockInfo;

func (*TychoBlockInfo) UnmarshalTLB

func (i *TychoBlockInfo) UnmarshalTLB(c *boc.Cell, decoder *tlb.Decoder) error

UnmarshalTLB implements custom TLB unmarshaling for Tycho BlockInfo

type TychoBlockInfoPart

type TychoBlockInfoPart struct {
	Version                   uint32
	NotMaster                 bool
	AfterMerge                bool
	BeforeSplit               bool
	AfterSplit                bool
	WantSplit                 bool
	WantMerge                 bool
	KeyBlock                  bool
	VertSeqnoIncr             bool
	Flags                     uint8
	SeqNo                     uint32
	VertSeqNo                 uint32
	Shard                     tlb.ShardIdent
	GenUtime                  uint32
	GenUtimeMs                uint16 // NEW in Tycho: millisecond precision
	StartLt                   uint64
	EndLt                     uint64
	GenValidatorListHashShort uint32
	GenCatchainSeqno          uint32
	MinRefMcSeqno             uint32
	PrevKeyBlockSeqno         uint32
}

type TychoShardDescr

type TychoShardDescr struct {
	Magic                  tlb.Magic `tlb:"shard_descr_tycho#a"`
	SeqNo                  uint32
	RegMcSeqno             uint32
	StartLT                uint64
	EndLT                  uint64
	RootHash               tlb.Bits256
	FileHash               tlb.Bits256
	BeforeSplit            bool
	BeforeMerge            bool
	WantSplit              bool
	WantMerge              bool
	NXCCUpdated            bool
	TopScBlockUpdated      bool // NEW in Tycho
	Flags                  tlb.Uint2
	NextCatchainSeqNo      uint32
	ExtProcessedToAnchorId uint32 // NEW in Tycho (replaces NextValidatorShard)
	MinRefMcSeqNo          uint32
	GenUTime               uint32
	// TODO: split_merge_at:FutureSplitMerge - not implemented yet
	FeesCollectedFundsCreated struct {
		FeesCollected tlb.CurrencyCollection
		FundsCreated  tlb.CurrencyCollection
	} `tlb:"^"`
}

TychoShardDescr - Tycho's shard descriptor shard_descr_tycho#a seq_no:uint32 reg_mc_seqno:uint32 start_lt:uint64 end_lt:uint64 root_hash:bits256 file_hash:bits256 before_split:Bool before_merge:Bool want_split:Bool want_merge:Bool nx_cc_updated:Bool top_sc_block_updated:Bool flags:(## 2) { flags = 0 } next_catchain_seqno:uint32 ext_processed_to_anchor_id:uint32 min_ref_mc_seqno:uint32 gen_utime:uint32 split_merge_at:FutureSplitMerge ^[ fees_collected:CurrencyCollection

funds_created:CurrencyCollection ] = ShardDescr;

type TychoShardInfoBinTree

type TychoShardInfoBinTree struct {
	BinTree tlb.BinTree[TychoShardDescr]
}

TychoShardInfoBinTree - Binary tree of Tycho shard descriptors

type TychoShardState

type TychoShardState struct {
	tlb.SumType
	UnsplitState struct {
		Value TychoShardStateUnsplit
	} `tlbSumType:"_"`
	SplitState struct {
		Left  TychoShardStateUnsplit `tlb:"^"`
		Right TychoShardStateUnsplit `tlb:"^"`
	} `tlbSumType:"split_state#5f327da5"`
}

TychoShardState - Tycho's shard state with ProcessedUptoInfo shard_state_tycho#9023aeee global_id:int32 shard_id:ShardIdent seq_no:uint32 vert_seq_no:# gen_utime:uint32 gen_utime_ms:uint16 gen_lt:uint64 min_ref_mc_seqno:uint32 processed_upto:^ProcessedUptoInfo before_split:(## 1) accounts:^ShardAccounts ^[ overload_history:uint64 underload_history:uint64 total_balance:CurrencyCollection total_validator_fees:CurrencyCollection libraries:(HashmapE 256 LibDescr) master_ref:(Maybe BlkMasterInfo) ] custom:(Maybe ^McStateExtra) = ShardStateUnsplit;

func (*TychoShardState) AccountBalances

func (s *TychoShardState) AccountBalances() map[tlb.Bits256]tlb.CurrencyCollection

func (*TychoShardState) UnmarshalTLB

func (s *TychoShardState) UnmarshalTLB(c *boc.Cell, decoder *tlb.Decoder) error

type TychoShardStateUnsplit

type TychoShardStateUnsplit struct {
	Magic         tlb.Magic `tlb:"shard_state_tycho#9023aeee"`
	GlobalId      int32
	ShardId       tlb.ShardIdent
	SeqNo         uint32
	VertSeqNo     uint32
	GenUtime      uint32
	GenUtimeMs    uint16 // Tycho-specific millisecond precision
	GenLt         uint64
	MinRefMcSeqno uint32
	ProcessedUpto ProcessedUptoInfo `tlb:"^"`
	BeforeSplit   bool
	Accounts      tlb.HashmapAugE[tlb.Bits256, tlb.ShardAccount, tlb.DepthBalanceInfo] `tlb:"^"`
	Other         TychoShardStateUnsplitOther                                          `tlb:"^"`
	Custom        tlb.Maybe[tlb.Ref[McStateExtraTycho]]
}

TychoShardStateUnsplit - Tycho's unsplit shard state

type TychoShardStateUnsplitOther

type TychoShardStateUnsplitOther struct {
	OverloadHistory    uint64
	UnderloadHistory   uint64
	TotalBalance       tlb.CurrencyCollection
	TotalValidatorFees tlb.CurrencyCollection
	Libraries          tlb.HashmapE[tlb.Bits256, tlb.LibDescr]
	MasterRef          tlb.Maybe[tlb.BlkMasterInfo]
}

TychoShardStateUnsplitOther - nested cell in TychoShardStateUnsplit

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL