mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
Two-tier finality (Nova = local majority accept, drives VM.Accept; Quasar = ⅔-by-stake export) requires that NO export surface ever names a block above the served accept tip. RED's final pass approved SHIP with three LOW items to close first. LOW-1 — DRY the accept-tip clamp into ONE place. New eth.Ethereum.ClampedQuasarHeight() = min(LastQuasarHeight, LastAccepted.Number) is the single clamp; BOTH export surfaces read it: EthAPIBackend.quasarHeight() (RPC finalized/safe) and warpBlockClient.LastQuasarHeight() (warp export gate, via the BlockClient interface). Removes the second inlined clamp copy that could drift. LastQuasarHeight() is documented as RAW (node boot re-seed only, where reconcile has already run). LOW-2 — exactly ONE admin_importChain. Deleted the eth-package AdminAPI.ImportChain (which neither reconciled the export height nor skipped <=head blocks); the plugin VM's (plugin/evm/admin_api.go) is the sole one — it runs under vmLock and calls reconcileQuasarWithAccept after each SetLastAcceptedBlockDirect. Left a NOTE so it is not re-added and reopens the rewind hole. Dropped the now-unused rlp import. LOW-3 — exclude concurrent export-height writers + prove the real boot wiring. SetLastQuasarFinalized now takes vmLock (the same lock reconcileQuasarWithAccept's admin_importChain caller holds), so the observer callback's durable Put+Store can never interleave with a re-import's Reset(0)+Delete on the same key. Fixed a boot ordering gap: the startup auto-import (importBlocksFromFile) runs AFTER initializeChain's reconcile, so a --import-chain-data rewind could leave a stale export height — added a reconcile right after the auto-import. New eth.NewTestEthereum test-support ctor. Tests (all green): eth -race adds TestClampedQuasarHeight_RealRewind (genuine SetLastAcceptedBlockDirect rewind; belt clamps finalized/safe to the rewound tip while raw is unchanged); plugin/evm adds TestBootReconcile_RealLastAccepted_ClearsStaleQuasarOnRewind (drives the REAL restored LastAcceptedBlock through belt + suspenders) and TestSetLastQuasarFinalized_LockedAgainstReconcile (concurrency: durable key <-> in-mem always consistent). gofmt/vet/ontology clean. Co-authored-by: Hanzo Dev <[email protected]>