Files
coreth/sync/atomic/summary_parser.go
zeekay 0bfbe1a491 coreth/atomic-tx: complete codec rip Wave 2B
Drop github.com/luxfi/codec from the atomic-tx subsystem and replace
the reflection-based polymorphic registry with a hand-rolled binary
encoder. Type IDs preserved from the legacy linearcodec registration
order (UnsignedImportTx=0, UnsignedExportTx=1, TransferInput=5,
TransferOutput=7, secp256k1fx.Credential=9) so on-disk blobs and
p2p gossip framing stay byte-equal to legacy.

New atomic.Manager interface mirrors the message.Manager pattern
shipped in Wave 1C — Marshal/Unmarshal only, no reflection registry.
The atomic.Codec singleton is the only Manager exported from the
package; downstream code (state/, vm/, sync/atomic, tests/warp,
plugin/evm/vm.go, plugin/evm/network_handler.go) holds an
atomic.Manager (or message.Manager for the wire codec) instead of
the legacy codec.Manager.

Tx.Sign drops its codec.Manager argument and uses the package-local
atomic.Codec singleton. A new Tx.initializeBytes(c Manager) helper
re-marshals a freshly-unmarshaled tx through whatever Manager
produced the bytes — keeps the atomictest harness disjoint from
production Codec while round-tripping correctly.

sync/atomic.Summary picks up its own marshal/unmarshal (4 fixed
fields, no codec needed) so plugin/evm/message doesn't have to
know about syncable summary shape.

The secp256k1fx.VM contract still requires codec.Registry — extracted
to a new plugin/evm/secpfx/ adapter so the only remaining codec
dependency in the atomic-tx universe lives outside plugin/evm/atomic/.

Tests pass: plugin/evm/atomic/..., sync/atomic/..., tests/warp/...
2026-06-06 00:42:16 -07:00

36 lines
938 B
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package atomic
import (
"fmt"
"github.com/luxfi/coreth/plugin/evm/message"
"github.com/luxfi/crypto"
"github.com/luxfi/ids"
)
var _ message.SyncableParser = (*summaryParser)(nil)
type summaryParser struct{}
func NewSummaryParser() *summaryParser {
return &summaryParser{}
}
func (a *summaryParser) Parse(summaryBytes []byte, acceptImpl message.AcceptImplFn) (message.Syncable, error) {
summary := Summary{}
if err := unmarshalSummary(summaryBytes, &summary); err != nil {
return nil, fmt.Errorf("failed to parse syncable summary: %w", err)
}
summary.bytes = summaryBytes
summaryID, err := ids.ToID(crypto.Keccak256(summaryBytes))
if err != nil {
return nil, fmt.Errorf("failed to compute summary ID: %w", err)
}
summary.summaryID = summaryID
summary.acceptImpl = acceptImpl
return &summary, nil
}