mirror of
https://github.com/luxfi/chains.git
synced 2026-09-24 00:26:00 +00:00
Accept wrote the block, the tip pointer and the height through the version layer and never committed, so a node that had accepted a thousand blocks came back from a restart naming genesis — while its peers held it to the tip it had already told them about. The three writes were also three early returns, so a failure part-way left the block stored under a tip that named its parent. They are now one commit with a rollback, alongside the height index that makes GetBlockIDAtHeight an answer rather than a refusal. Verify checked only that the parent existed, and only above height one. A height-one block could name a parent no node has ever seen; any block could name genesis as the parent of height 500, rewind chain time to revive expired quantum stamps, or jump forward and expire every stamp in flight. It now sits on its parent in height and in time, under a skew cap — and BuildBlock never stamps behind its own parent, so a node whose clock trails a slightly fast peer does not build blocks it will itself refuse. Verify held the VM's read lock and then called GetBlock, which takes it again. Go queues a waiting writer ahead of any later reader, so a build arriving between the two acquisitions deadlocked the chain with nothing to time out. The Quasar validator id was the CHAIN id — a field never assigned — so every node signed as the empty id, each peer's signature arrived as a duplicate of the first, and no threshold above one could ever be met. It is the node id. The default threshold was derived from a committee size that had not yet been defaulted, so a config naming neither got one-of-three. Cleanup released only FINALIZED entries, which are exactly the ones that do not accumulate. Corona keyed its PRF off the first 32 bytes of the message, so any shorter message through StampBlock killed the process; the signature counts were read outside the lock that appends them. A transaction whose quantum stamp has aged out never verifies again; left in the pool it held its slot for good, and enough of them stopped the chain accepting work. BuildBlock evicts what it could not verify, and re-arms the builder when the batch limit leaves work behind — the latch holds one signal, so the remainder had nothing to wake it. A wire too short to hold the header decoded to height 0, time 0 and the empty parent rather than failing, so every truncation named one value under as many ids as an attacker cared to send. Deleted, all proven unreferenced: the dlopen GPU plugin bridge (a second way to do what quantum.ParallelVerifyWithThreshold already does through accel), the stamper package (near-verbatim copy of the signer's accel path, with a mode-confusion bug the original does not have, and the only reason the tree needed geth/core), the Q-witness adapter, the NTT helpers (whose inverse did not invert), and a signature cache that was written and never read — and whose ids.ToID over a >32-byte input gave every entry the empty id, so all ten thousand slots were one. Coverage 20.0% -> 97.0%, with every load-bearing guard mutation-checked.
29 lines
818 B
Go
29 lines
818 B
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package quantumvm
|
|
|
|
import (
|
|
"github.com/luxfi/chains/quantumvm/config"
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/log"
|
|
"github.com/luxfi/node/vms"
|
|
)
|
|
|
|
var _ vms.Factory = (*Factory)(nil)
|
|
|
|
// VMID is the unique identifier for QuantumVM (Q-Chain)
|
|
var VMID = ids.ID{'q', 'u', 'a', 'n', 't', 'u', 'm', 'v', 'm'}
|
|
|
|
// Factory implements vms.Factory interface for creating QVM instances
|
|
type Factory struct {
|
|
config.Config
|
|
}
|
|
|
|
// New creates a new QVM instance. The config is normalised and checked once,
|
|
// in Initialize, so a VM built here and a VM built by hand start from the same
|
|
// rules.
|
|
func (f *Factory) New(logger log.Logger) (interface{}, error) {
|
|
return &VM{Config: f.Config, log: logger}, nil
|
|
}
|