Skip to content

revert: feat: add binary codec with backward-compatible migration (#5419)#5501

Merged
gacevicljubisa merged 1 commit into
masterfrom
revert-5419-binary-codec
Jun 12, 2026
Merged

revert: feat: add binary codec with backward-compatible migration (#5419)#5501
gacevicljubisa merged 1 commit into
masterfrom
revert-5419-binary-codec

Conversation

@gacevicljubisa

Copy link
Copy Markdown
Member

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Reverts #5419 (commit f53887f). Conflicts in accounting.go and migration.go from later commits (#5439, #5415, #5477) were resolved manually.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.

@gacevicljubisa gacevicljubisa marked this pull request as ready for review June 12, 2026 09:24
@gacevicljubisa gacevicljubisa changed the title Revert "feat: add binary codec with backward-compatible migration (#5419)" revert: feat: add binary codec with backward-compatible migration (#5419) Jun 12, 2026
@gacevicljubisa

gacevicljubisa commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

Reasons for reverts are bellow.

Here are issues that are detected in the logs of the public-testnet related to this:

"time"="2026-06-12 09:45:02.942100" "level"="warning" "logger"="node/accounting" "msg"="accounting: notifyrefreshmentsent failed to decrease originated balance" "error"="failed to load originated balance: failed decoding value Int.GobDecode: encoding version 24 not supported"
"time"="2026-06-12 09:45:02.945626" "level"="warning" "logger"="node/accounting" "msg"="increase balance; failed to decrease originated balance" "error"="failed to load originated balance: failed decoding value Int.GobDecode: encoding version 22 not supported"
"time"="2026-06-12 09:45:02.974804" "level"="warning" "logger"="node/accounting" "msg"="increase balance; failed to decrease originated balance" "error"="failed to load originated balance: failed decoding value Int.GobDecode: encoding version 24 not supported"

And if we run this tests, they will fail:

// TestUnmarshalBinaryLegacyFormats verifies that UnmarshalBinary accepts the
// two legacy on-disk encodings the statestore produced before the Gob codec:
// unquoted decimals from json.Marshal(*big.Int) (including negatives, which
// triggered "encoding version 22 not supported") and quoted decimal strings
// from json.Marshal(bigint.BigInt). This is the backward-compatibility path
// that lets nodes read balances written by older code regardless of migration.
func TestUnmarshalBinaryLegacyFormats(t *testing.T) {
    t.Parallel()

    tests := []struct {
        name string
        data []byte
        want *big.Int
    }{
        {"decimal positive", []byte("123456"), big.NewInt(123456)},
        {"decimal negative", []byte("-123456"), big.NewInt(-123456)},
        {"decimal zero", []byte("0"), big.NewInt(0)},
        {"quoted positive", []byte(`"123456"`), big.NewInt(123456)},
        {"quoted negative", []byte(`"-987654321"`), big.NewInt(-987654321)},
    }

    for _, tc := range tests {
        t.Run(tc.name, func(t *testing.T) {
            t.Parallel()

            var got bigint.BigInt
            if err := got.UnmarshalBinary(tc.data); err != nil {
                t.Fatalf("UnmarshalBinary(%q): %v", tc.data, err)
            }
            if got.Cmp(tc.want) != 0 {
                t.Fatalf("got %v, want %v", got.Int, tc.want)
            }
        })
    }
}

func TestUnmarshalBinaryInvalidDecimal(t *testing.T) {
    t.Parallel()

    var w bigint.BigInt
    if err := w.UnmarshalBinary([]byte("not-a-number")); err == nil {
        t.Fatal("expected error on invalid decimal data, got nil")
    }
}

@gacevicljubisa gacevicljubisa merged commit 73e5683 into master Jun 12, 2026
16 checks passed
@gacevicljubisa gacevicljubisa deleted the revert-5419-binary-codec branch June 12, 2026 11:38
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