mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-27 05:17:27 +08:00
* v2.1.0.19 * enhanced error logging, fix seniority marker join blocker, fix sync message size limit defaults * resolve signature failure * additional error logging for merge-related signatures * fix: one-shot sync message size, app shard TC signature size, collector/hotstuff race condition, expired joins blocking new joins due to pruning disable * remove compat with old 2.0.0 blossomsub * fix: resolve abandoned prover joins * reload prover registry * fix stale worker proposal edge * add full sanity check on join before submitting to identify bug * resolve non-fallthrough condition that should be fallthrough * fix: resolve rare SIGFPE, fix orphan expired joins blocking workers from reallocating * add reconnect fallback if no peers are found with variable reconnect time (#511) Co-authored-by: Tyler Sturos <55340199+tjsturos@users.noreply.github.com> * update base peer count to 1 (#513) * fix: expired prover join frames, starting port ranges, proposer getting stuck, and seniority on joins * fix: panic on shutdown, libp2p discovery picking inaccessible peers, coverage event check not in shutdown logic, amend app shard worker behavior to mirror global for prover root reconciliation * fix: shutdown scenario quirks, reload hanging * fix: do not bailout early on shutdown of coverage check * fix: force registry refresh on worker waiting for registration * add more logging to wait for prover * fix: worker manager refreshes the filter on allocation, snapshots blocking close on shutdown * tweak: force shutdown after five seconds for app worker * fix: don't loop when shutting down * fix: slight reordering, also added named workers to trace hanging shutdowns * use deterministic key for peer id of workers to stop flagging workers as sybil attacks * fix: remove pubsub stop from app consensus engine as it shouldn't manage pubsub lifecycle, integrate shutdown context to PerformSync to prevent stuck syncs from halting respawn * fix: blossomsub pubsub interface does not properly track subscription status * fix: subscribe order to avoid nil panic * switch from dnsaddr to dns4 * add missing quic-v1 * additional logging to isolate respawn quirks * fix: dnsaddr -> dns4 for blossomsub * sort-of fix: apply sledgehammer to restart logic * fix: restore proper respawn logic, fix frozen hypergraph post respawn, unsubscribe from bitmask previously missing --------- Co-authored-by: winged-pegasus <55340199+winged-pegasus@users.noreply.github.com> Co-authored-by: Tyler Sturos <55340199+tjsturos@users.noreply.github.com>
158 lines
3.8 KiB
Go
158 lines
3.8 KiB
Go
package hypergraph
|
|
|
|
import (
|
|
"bytes"
|
|
"math/big"
|
|
"slices"
|
|
|
|
"github.com/pkg/errors"
|
|
hgstate "source.quilibrium.com/quilibrium/monorepo/node/execution/state/hypergraph"
|
|
qcrypto "source.quilibrium.com/quilibrium/monorepo/types/crypto"
|
|
"source.quilibrium.com/quilibrium/monorepo/types/execution/intrinsics"
|
|
"source.quilibrium.com/quilibrium/monorepo/types/execution/state"
|
|
"source.quilibrium.com/quilibrium/monorepo/types/hypergraph"
|
|
"source.quilibrium.com/quilibrium/monorepo/types/keys"
|
|
)
|
|
|
|
type HyperedgeRemove struct {
|
|
Domain [32]byte
|
|
Value hypergraph.Hyperedge
|
|
Signature []byte // Ed448 signature for write authorization
|
|
keyManager keys.KeyManager
|
|
signer qcrypto.Signer
|
|
config *HypergraphIntrinsicConfiguration
|
|
}
|
|
|
|
func NewHyperedgeRemove(
|
|
domain [32]byte,
|
|
value hypergraph.Hyperedge,
|
|
signer qcrypto.Signer,
|
|
) *HyperedgeRemove {
|
|
return &HyperedgeRemove{
|
|
Domain: domain,
|
|
Value: value,
|
|
signer: signer,
|
|
}
|
|
}
|
|
|
|
// GetCost implements intrinsics.IntrinsicOperation.
|
|
func (h *HyperedgeRemove) GetCost() (*big.Int, error) {
|
|
return big.NewInt(64), nil
|
|
}
|
|
|
|
// Materialize implements intrinsics.IntrinsicOperation.
|
|
func (h *HyperedgeRemove) Materialize(
|
|
frameNumber uint64,
|
|
state state.State,
|
|
) (state.State, error) {
|
|
hypergraph, ok := state.(*hgstate.HypergraphState)
|
|
if !ok {
|
|
return nil, errors.Wrap(errors.New("invalid state"), "materialize")
|
|
}
|
|
|
|
// Get the hyperedge ID to use as the address
|
|
hyperedgeID := h.Value.GetID()
|
|
|
|
// Set the state
|
|
err := hypergraph.Delete(
|
|
h.Domain[:],
|
|
hyperedgeID[32:],
|
|
hgstate.HyperedgeRemovesDiscriminator,
|
|
frameNumber,
|
|
)
|
|
|
|
return hypergraph, errors.Wrap(err, "materialize")
|
|
}
|
|
|
|
// Prove implements intrinsics.IntrinsicOperation.
|
|
func (h *HyperedgeRemove) Prove(frameNumber uint64) error {
|
|
// For hyperedge removal, ensure the hyperedge value is valid
|
|
if h.Value == nil {
|
|
return errors.Wrap(errors.New("missing hyperedge value"), "prove")
|
|
}
|
|
|
|
hyperedgeID := h.Value.GetID()
|
|
if len(hyperedgeID) != 64 {
|
|
return errors.Wrap(errors.New("invalid hyperedge id length"), "prove")
|
|
}
|
|
|
|
message := make([]byte, 0, 64)
|
|
message = append(message, hyperedgeID[:]...)
|
|
|
|
sig, err := h.signer.SignWithDomain(
|
|
message,
|
|
slices.Concat(h.Domain[:], []byte("HYPEREDGE_REMOVE")),
|
|
)
|
|
if err != nil {
|
|
return errors.Wrap(err, "prove")
|
|
}
|
|
|
|
h.Signature = sig
|
|
|
|
return nil
|
|
}
|
|
|
|
func (h *HyperedgeRemove) GetReadAddresses(
|
|
frameNumber uint64,
|
|
) ([][]byte, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (h *HyperedgeRemove) GetWriteAddresses(
|
|
frameNumber uint64,
|
|
) ([][]byte, error) {
|
|
hyperedgeID := h.Value.GetID()
|
|
|
|
return [][]byte{
|
|
slices.Concat(
|
|
h.Domain[:],
|
|
hyperedgeID[32:],
|
|
),
|
|
}, nil
|
|
}
|
|
|
|
// Verify implements intrinsics.IntrinsicOperation.
|
|
func (h *HyperedgeRemove) Verify(frameNumber uint64) (bool, error) {
|
|
// Verify that the hyperedge is valid
|
|
if h.Value == nil {
|
|
return false, errors.Wrap(errors.New("missing hyperedge value"), "verify: invalid hyperedge remove")
|
|
}
|
|
|
|
hyperedgeID := h.Value.GetID()
|
|
if len(hyperedgeID) != 64 {
|
|
return false, errors.Wrap(
|
|
errors.New("invalid hyperedge id length"),
|
|
"verify: invalid hyperedge remove",
|
|
)
|
|
}
|
|
|
|
if !bytes.Equal(hyperedgeID[:32], h.Domain[:]) {
|
|
return false, errors.Wrap(
|
|
errors.New("hyperedge domain mismatch"),
|
|
"verify: invalid hyperedge remove",
|
|
)
|
|
}
|
|
|
|
message := make([]byte, 0, 64)
|
|
message = append(message, hyperedgeID[:]...)
|
|
|
|
valid, err := h.keyManager.ValidateSignature(
|
|
qcrypto.KeyTypeEd448,
|
|
h.config.WritePublicKey,
|
|
message,
|
|
h.Signature,
|
|
slices.Concat(h.Domain[:], []byte("HYPEREDGE_REMOVE")),
|
|
)
|
|
if err != nil {
|
|
return false, errors.Wrap(err, "verify: invalid hyperedge remove")
|
|
}
|
|
|
|
if !valid {
|
|
return false, errors.Wrap(errors.New("invalid signature"), "verify: invalid hyperedge remove")
|
|
}
|
|
|
|
return true, nil
|
|
}
|
|
|
|
var _ intrinsics.IntrinsicOperation = (*HyperedgeRemove)(nil)
|