Skip to content

Block marshalling#454

Draft
hsslbchtop wants to merge 2 commits intomasterfrom
block-marshalling
Draft

Block marshalling#454
hsslbchtop wants to merge 2 commits intomasterfrom
block-marshalling

Conversation

@hsslbchtop
Copy link
Contributor

No description provided.

LastTransHash Bits256
LastTransLt uint64

accountCell *boc.Cell
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как будто бы, есть очень много мест, где ячейка может оказаться обрезанная. Может есть какой-то способ сделать это лучше (у нас есть pruned resolver, но если на этапе десериализации мы не знаем, что подставить вместо хэша, то он не поможет)

case reflect.Pointer:
if val.IsNil() && !t.IsOptional {
return fmt.Errorf("can't encode empty pointer %v if tlb scheme is not optional", val.Type())
if val.IsNil() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему это валидный кейс?

name := val.FieldByName("SumType").String()

if name == "" {
// Default to the first non-SumType field (zero variant)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем сериализовать структуру, у которой пустой SumType? Как будто бы лучше вернуть ошибку, чем пытаться сериализовать её хоть как-то

if len(h.values) == 0 || h.values == nil {
return nil
}
order := sortedIndices(h.keys)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем? Не очень понял зачем нужно сортировать ключи. И ещё анмаршалинг и маршалинг все равно не работает на достаточно большом боке


import "github.com/tonkeeper/tongo/boc"

func cloneCell(c *boc.Cell) *boc.Cell {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может стоит привязать этот метод к boc.Cell. По Аналогии с boc.Cell.CopyRemaining()

func (a MsgAddress) MarshalTLB(c *boc.Cell, encoder *Encoder) error {
switch a.SumType {
case "AddrNone":
case "AddrNone", "":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется, если у MsgAddress нет сум типа, то это ошибка и не стоит маршалить в AddrNone


func (m Magic) EncodeTag(c *boc.Cell, tag string) error {
if tag == "" {
return c.WriteUint(uint64(m), 32)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic не всегда имеет длину 32. Может быть и поменьше. Да и не очень понятно, когда такое может произойти при нормальном поведении, а даже если произошло, то скорее нужно ошибку выбросить

Left ShardStateUnsplit `tlb:"^"` // ^ but decodes manually
Right ShardStateUnsplit `tlb:"^"` // ^ but decodes manually
} `tlbSumType:"split_state#5f327da5"`

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже самое, выглядит костыльно пихать эти ячейки туда, где могут оказаться обрезанные

func (t VmStkTuple) MarshalTLB(c *boc.Cell, encoder *Encoder) error {
// TODO: implement
return fmt.Errorf("VmStkTuple TLB marshaling not implemented")
if err := c.WriteUint(uint64(t.Len), 16); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно покрыть тестами

@hsslbchtop hsslbchtop marked this pull request as draft February 20, 2026 13:35
@hsslbchtop hsslbchtop force-pushed the block-marshalling branch 5 times, most recently from 8adb081 to 792e5b2 Compare February 25, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants