Skip to content

polygon: delete the Polygon tree, tables, protos and chain-config hooks - #23497

Merged
AskAlexSharov merged 32 commits into
mainfrom
awskii/polygon-removal-delete-tree
Aug 22, 2026
Merged

polygon: delete the Polygon tree, tables, protos and chain-config hooks#23497
AskAlexSharov merged 32 commits into
mainfrom
awskii/polygon-removal-delete-tree

Conversation

@awskii

@awskii awskii commented Aug 22, 2026

Copy link
Copy Markdown
Member

Nothing outside polygon/ referenced it after #23495, so this deletes the tree and the hooks that existed to serve it. Last in the Polygon removal series, branched off #23495 — review the last commit only.

erigon no longer builds, reads or serves anything Polygon. Existing Polygon chaindata is rejected with a pointer to 0xPolygon/erigon rather than loaded with its consensus settings silently dropped.

Changes

  • delete polygon/ — 17 packages, ~20k lines of Go and 25.7 MB of Heimdall test fixtures
  • execution/chain: remove Config.Bor, Config.BorJSON, the BorConfig interface, BorRules, and the Bor arms of String(), getEngine() and SecondsPerSlot()
  • db/kv: remove the 13 remaining Bor* tables, the dead BorTablesCfg, and the HeimdallDB / PolygonBridgeDB labels with their table configs
  • rename kv.BorWitnesses / kv.BorWitnessSizes to kv.Witnesses / kv.WitnessSizes and gate the witness buffer on --wit-protocol instead of the chain
  • snaptype.MinBorEnum becomes MaxCaplinEnum, same value, so the on-disk enum numbering is unchanged
  • delete remote/bor.proto, its generated files, and the BorTxnLookup / BorEvents methods on ETHBACKEND; regenerate; bump EthBackendAPIVersion to 4.0.0
  • remove MimetypeBor, BorValidateHeaderTime, the Bor block-end receipt recovery in the serial and custom-trace executors, and the last Bor branches in SysCallContract and genesiswrite
  • go mod tidy drops go-merkle, ttlcache and arc/v2, which only Bor used
  • docs: remove the Polygon Bridge and Heimdall gRPC sections and the bor.* / polygon.pos.* flag reference; regenerate llms*.txt

The witness protocol

The wit/0 protocol read and wrote kv.BorWitnesses, so deleting those tables would have disabled it outright rather than removing something Polygon-specific. The protocol itself has no Polygon logic — only its table names and its buffer's chainConfig.Bor != nil gate did. The tables are renamed and the buffer now follows --wit-protocol, which is what the flag's name already implied.

That gate change is the one behaviour change here, and it is forced: there is no Bor config left to gate on. Witness ingestion is now reachable on any chain when the flag is set. No supported chain ever wrote those tables, so the rename orphans no data. If witness ingestion should stay off by default on Ethereum, that is a follow-up on the flag, not on this deletion.

Left for a follow-up

rules.EngineReader.GetPostApplyMessageFunc now returns nil from every implementation — Bor's fee-transfer logging was the only real one. Removing the hook touches four engines and two call sites in the parallel and serial executors, which does not belong in a deletion this size.

.github/workflows/scripts/test_report/generate-test-report.ts and dashboards/ keep their Polygon handling: both render historical QA results, and stripping the mappings would break display of past runs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

# Conflicts:
#	cmd/downloader/main.go
#	cmd/integration/commands/stages.go
#	node/eth/backend.go
# Conflicts:
#	cmd/integration/commands/stages.go
…ng' into HEAD

# Conflicts:
#	cmd/integration/commands/stages.go
#	cmd/rpcdaemon/cli/config.go
#	cmd/utils/app/init_cmd.go
#	cmd/utils/app/snapshots_cmd.go
@awskii

awskii commented Aug 22, 2026

Copy link
Copy Markdown
Member Author

4-agent review over the incremental range (git diff <23495 head>..HEAD), scoped to the 65 files outside polygon/. One major, three minor. Fixed in a161860, 83800ba and a51ad9c.

Major — the renamed witness tables had no schema migration. BorWitnesses/BorWitnessSizes become Witnesses/WitnessSizes at db/kv/tables.go and are listed in ChaindataTables. For any chaindata created by an earlier binary those are new table names, and the diff touched no migration file.

MdbxOpts.Open -> openDBIs (db/kv/mdbx/kv_mdbx.go:512) takes the db.View branch under Accede/Readonly; CreateTable (:1128) gets NOTFOUND from OpenDBISimple, and if !(tx.db.ReadOnly() || tx.db.Accede()) is false, so the retry omits MDBX_CREATE and fails with db-table doesn't exists: Witnesses. erigon itself opens RW non-accede and is fine; the accede consumers are not — cmd/rpcdaemon/cli/config.go:396, cmd/integration/commands/root.go:64, cmd/downloader/main.go:777, db/kv/backup/backup.go:42, cmd/utils/app/snapshots_cmd.go:3657. With no migration registered HasPendingMigrations is false, so nothing triggers the exclusive re-open that would create the table.

Fixed by drop_bor_witness_tables, following the drop_legacy_e2_tables precedent: it drops both old buckets, and registering it is what forces the exclusive open that creates the renamed ones. No rows are copied — on main StageWitnessProcessingCfg was built only when chainConfig.Bor != nil, so every existing row is on a Polygon datadir and there is nothing to preserve. BorWitnesses/BorWitnessSizes move to *Deprecated constants in ChaindataDeprecatedTables so the live schema never recreates them on a fresh DB. DropTable is a no-op on a missing DBI, so the migration is idempotent.

Worth stating explicitly, since it is the obvious question on a PR that removes Polygon: the tables are renamed rather than deleted because they belong to the WIT side-protocol, not to Bor. p2p/protocols/wit has no Polygon references and this PR keeps the protocol, renaming --polygon.wit-protocol to --wit-protocol with the old name as an alias. What was Polygon-specific was the name and the gate — the stage is now built on witnessBuffer != nil behind --wit-protocol, default off.

Minor, fixedWitnesses/WitnessSizes had been folded into AuRaTablesCfg with DupSort set. That config has one consumer, the Gnosis/Chiado remote KV handle in cmd/rpcdaemon/cli/config.go:1000, and AuRa reads only Epoch/PendingEpoch. The flag also contradicts the live schema: reinit() registers both tables into ChaindataTablesCfg as plain TableCfgItem{}, and Witnesses stores whole witness blobs that exceed the DupSort value limit. No reachable failure — remoteCursor.bucketCfg is assigned and never read — but two entries misdescribing the schema. Removed.

Minor, fixedTestTxDependencyBlockDecoding (execution/types/block_test.go:47) lost GetTxDependencyTest and GetValidatorBytesTest and no longer asserts anything about tx dependency. Its remaining value is the round trip of a nested RLP payload in Extra, which TestBlockEncoding does not cover, so it is renamed TestBlockDecodingNestedRLPExtra rather than deleted.

Minor, open — the erigon init guard at cmd/utils/app/init_cmd.go:91-99 changed from a typed BorJSON check to a raw-JSON probe and has no test, unlike the identical probe in ReadChainConfig. It is the only defence on that path: types.Genesis has no bor field, so a config written past it reads back clean and the node runs under the wrong rules with the suite green.

Also swept the tip for anything the series missed and dropped five stale references in a161860: the polygon/bor and polygon/tests entries in .golangci.yml, the eleven bor_* rows in cmd/rpcdaemon/README.md, the --chain=bor-mainnet / --bor.heimdall uploader example in cmd/utils/app/README.md, the Polygon card on the docs 404 page, and a Polygon aside in cmd/downloader/readme.md.

@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Aug 22, 2026
Merged via the queue into main with commit 502f1ab Aug 22, 2026
137 checks passed
@AskAlexSharov
AskAlexSharov deleted the awskii/polygon-removal-delete-tree branch August 22, 2026 10:04
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