Skip to content

refactor(base58): replace mr-tron/base58 with in-tree long-division encoder#425

Merged
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
sonicfromnewyoke:sonic/chore-remove-mr-tron-dep
May 8, 2026
Merged

refactor(base58): replace mr-tron/base58 with in-tree long-division encoder#425
HealthyBuilder merged 1 commit into
solana-foundation:mainfrom
sonicfromnewyoke:sonic/chore-remove-mr-tron-dep

Conversation

@sonicfromnewyoke
Copy link
Copy Markdown
Contributor

Problem

the base58 package's fast paths only covered 32/64-byte inputs, so every other length (instruction data, Base58.MarshalJSON, Data.String) had to go through the external github.com/mr-tron/base58 module - a needless dependency, and one with a latent buffer-sizing bug that panics on all-zero input
this change pulls the long-division algorithm in-tree behind a unified base58.Encode entry point and drops the external dependency

Summary of Changes

  • add base58.Encode(buf []byte) string dispatcher: 32/64-byte fast paths + vendored long-division fallback (encodeVariable) with the mr-tron buffer-sizing bug fixed
  • drop the mr-tron/base58 module dependency; rewire all callers (Base58, Data, Hash, Signature, PublicKey, PrivateKey) to base58.Encode
  • update tests/fuzzers to cross-validate the matrix-multiply fast paths against the in-tree encodeVariable - no existing exported signatures changed (gorelease -> v1.20.0, additive only)

@HealthyBuilder
Copy link
Copy Markdown
Collaborator

LGTM — removing the mr-tron dependency makes sense

@HealthyBuilder HealthyBuilder merged commit 473162d into solana-foundation:main May 8, 2026
12 checks passed
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.

2 participants