mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
Fix more imports/tests
This commit is contained in:
@@ -61,11 +61,15 @@ func TestStatusConstants(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStatusComparison(t *testing.T) {
|
||||
// Test equality
|
||||
require.True(t, Unknown == Unknown)
|
||||
require.True(t, Processing == Processing)
|
||||
require.True(t, Rejected == Rejected)
|
||||
require.True(t, Accepted == Accepted)
|
||||
// Test equality (using variables to avoid trivial comparison warnings)
|
||||
unknown := Unknown
|
||||
processing := Processing
|
||||
rejected := Rejected
|
||||
accepted := Accepted
|
||||
require.Equal(t, Unknown, unknown)
|
||||
require.Equal(t, Processing, processing)
|
||||
require.Equal(t, Rejected, rejected)
|
||||
require.Equal(t, Accepted, accepted)
|
||||
|
||||
// Test inequality
|
||||
require.True(t, Unknown != Processing)
|
||||
|
||||
@@ -8,19 +8,19 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/luxfi/consensus/utils/set"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/math/set"
|
||||
"github.com/luxfi/p2p"
|
||||
)
|
||||
|
||||
// MockWarpSender is a mock implementation of warp.Sender
|
||||
// MockWarpSender is a mock implementation of p2p.Sender (warp.Sender)
|
||||
type MockWarpSender struct {
|
||||
mu sync.RWMutex
|
||||
|
||||
SendRequestF func(context.Context, set.Set[ids.NodeID], uint32, []byte) error
|
||||
SendResponseF func(context.Context, ids.NodeID, uint32, []byte) error
|
||||
SendErrorF func(context.Context, ids.NodeID, uint32, int32, string) error
|
||||
SendGossipF func(context.Context, set.Set[ids.NodeID], []byte) error
|
||||
SendGossipSpecificF func(context.Context, set.Set[ids.NodeID], []byte) error
|
||||
SendRequestF func(context.Context, set.Set[ids.NodeID], uint32, []byte) error
|
||||
SendResponseF func(context.Context, ids.NodeID, uint32, []byte) error
|
||||
SendErrorF func(context.Context, ids.NodeID, uint32, int32, string) error
|
||||
SendGossipF func(context.Context, p2p.SendConfig, []byte) error
|
||||
}
|
||||
|
||||
// NewMockWarpSender creates a new mock WarpSender
|
||||
@@ -28,7 +28,7 @@ func NewMockWarpSender(ctrl interface{}) *MockWarpSender {
|
||||
return &MockWarpSender{}
|
||||
}
|
||||
|
||||
// SendRequest implements warp.Sender
|
||||
// SendRequest implements p2p.Sender
|
||||
func (m *MockWarpSender) SendRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, requestBytes []byte) error {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
@@ -38,7 +38,7 @@ func (m *MockWarpSender) SendRequest(ctx context.Context, nodeIDs set.Set[ids.No
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendResponse implements warp.Sender
|
||||
// SendResponse implements p2p.Sender
|
||||
func (m *MockWarpSender) SendResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, responseBytes []byte) error {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
@@ -48,7 +48,7 @@ func (m *MockWarpSender) SendResponse(ctx context.Context, nodeID ids.NodeID, re
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendError implements warp.Sender
|
||||
// SendError implements p2p.Sender
|
||||
func (m *MockWarpSender) SendError(ctx context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
@@ -58,22 +58,12 @@ func (m *MockWarpSender) SendError(ctx context.Context, nodeID ids.NodeID, reque
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendGossip implements warp.Sender
|
||||
func (m *MockWarpSender) SendGossip(ctx context.Context, nodeIDs set.Set[ids.NodeID], gossipBytes []byte) error {
|
||||
// SendGossip implements p2p.Sender
|
||||
func (m *MockWarpSender) SendGossip(ctx context.Context, config p2p.SendConfig, gossipBytes []byte) error {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
if m.SendGossipF != nil {
|
||||
return m.SendGossipF(ctx, nodeIDs, gossipBytes)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendGossipSpecific implements warp.Sender
|
||||
func (m *MockWarpSender) SendGossipSpecific(ctx context.Context, nodeIDs set.Set[ids.NodeID], gossipBytes []byte) error {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
if m.SendGossipSpecificF != nil {
|
||||
return m.SendGossipSpecificF(ctx, nodeIDs, gossipBytes)
|
||||
return m.SendGossipF(ctx, config, gossipBytes)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
+7
-4
@@ -103,10 +103,13 @@ func TestHealthStatus_Values(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHealthStatus_Comparison(t *testing.T) {
|
||||
// Test equality
|
||||
require.True(t, HealthHealthy == HealthHealthy)
|
||||
require.True(t, HealthUnhealthy == HealthUnhealthy)
|
||||
require.True(t, HealthUnknown == HealthUnknown)
|
||||
// Test equality (using variables to avoid trivial comparison warnings)
|
||||
healthy := HealthHealthy
|
||||
unhealthy := HealthUnhealthy
|
||||
unknown := HealthUnknown
|
||||
require.Equal(t, HealthHealthy, healthy)
|
||||
require.Equal(t, HealthUnhealthy, unhealthy)
|
||||
require.Equal(t, HealthUnknown, unknown)
|
||||
|
||||
// Test inequality
|
||||
require.True(t, HealthHealthy != HealthUnhealthy)
|
||||
|
||||
@@ -112,6 +112,8 @@ func (m MessageType) String() string {
|
||||
return "WarpResponse"
|
||||
case WarpGossip:
|
||||
return "WarpGossip"
|
||||
case StateSyncDone:
|
||||
return "StateSyncDone"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
@@ -152,6 +154,8 @@ const (
|
||||
WarpResponse
|
||||
// WarpGossip indicates warp gossip
|
||||
WarpGossip
|
||||
// StateSyncDone indicates state sync completed
|
||||
StateSyncDone
|
||||
)
|
||||
|
||||
// Fx defines a feature extension
|
||||
|
||||
@@ -427,11 +427,7 @@ func validateBlockStructure(blockData []byte) bool {
|
||||
|
||||
// Validate block size is reasonable for tx count
|
||||
minSize := 4 + (txCount * 32) // Minimum 32 bytes per tx
|
||||
if len(blockData) < minSize {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return len(blockData) >= minSize
|
||||
}
|
||||
|
||||
// BenchmarkSignatureAggregator specifically tests SignatureAggregator performance
|
||||
|
||||
+12
-13
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
consensuscontext "github.com/luxfi/consensus/context"
|
||||
"github.com/luxfi/consensus/engine/core"
|
||||
"github.com/luxfi/database/manager"
|
||||
"github.com/luxfi/ids"
|
||||
)
|
||||
@@ -44,17 +45,15 @@ type ChainContext struct {
|
||||
// DBManager manages databases
|
||||
type DBManager = manager.Manager
|
||||
|
||||
// MessageType defines the type of a message
|
||||
type MessageType = uint32
|
||||
// Re-export core types for backwards compatibility
|
||||
type (
|
||||
MessageType = core.MessageType
|
||||
Message = core.Message
|
||||
Fx = core.Fx
|
||||
)
|
||||
|
||||
// Message represents a message to the VM
|
||||
type Message struct {
|
||||
Type MessageType
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// Fx represents a feature extension
|
||||
type Fx struct {
|
||||
ID ids.ID
|
||||
Fx interface{}
|
||||
}
|
||||
// Message type constants re-exported from core
|
||||
const (
|
||||
PendingTxs = core.PendingTxs
|
||||
StateSyncDone = core.StateSyncDone
|
||||
)
|
||||
|
||||
+11
-13
@@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/luxfi/consensus/config"
|
||||
"github.com/luxfi/consensus/engine/core"
|
||||
"github.com/luxfi/ids"
|
||||
)
|
||||
|
||||
@@ -23,20 +24,17 @@ type Engine interface {
|
||||
IsBootstrapped() bool
|
||||
}
|
||||
|
||||
// MessageType represents the type of VM notification message
|
||||
type MessageType uint32
|
||||
|
||||
const (
|
||||
// PendingTxs indicates the VM has pending transactions ready for block building
|
||||
PendingTxs MessageType = iota
|
||||
// StateSyncDone indicates state sync has completed
|
||||
StateSyncDone
|
||||
// Re-export core message types
|
||||
type (
|
||||
MessageType = core.MessageType
|
||||
Message = core.Message
|
||||
)
|
||||
|
||||
// VMMessage represents a message from the VM to the consensus engine
|
||||
type VMMessage struct {
|
||||
Type MessageType
|
||||
}
|
||||
// Message type constants
|
||||
const (
|
||||
PendingTxs = core.PendingTxs
|
||||
StateSyncDone = core.StateSyncDone
|
||||
)
|
||||
|
||||
// BlockBuilder is the interface for VMs that can build blocks
|
||||
type BlockBuilder interface {
|
||||
@@ -165,7 +163,7 @@ func (t *Transitive) SetVM(vm BlockBuilder) {
|
||||
}
|
||||
|
||||
// Notify handles VM notifications (e.g., pending transactions)
|
||||
func (t *Transitive) Notify(ctx context.Context, msg VMMessage) error {
|
||||
func (t *Transitive) Notify(ctx context.Context, msg Message) error {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package core
|
||||
|
||||
// cgoAvailable returns true when CGO is enabled (but ZMQ is not required)
|
||||
func cgoAvailable() bool {
|
||||
// CgoAvailable returns true when CGO is enabled (but ZMQ is not required)
|
||||
func CgoAvailable() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
// Package common provides common types for consensus engines.
|
||||
// This package aliases types from other packages for backwards compatibility.
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/luxfi/consensus/engine/chain/block"
|
||||
"github.com/luxfi/consensus/engine/core"
|
||||
"github.com/luxfi/warp"
|
||||
)
|
||||
|
||||
// Message represents a message to the VM
|
||||
type Message = block.Message
|
||||
|
||||
// Fx represents a feature extension
|
||||
type Fx = block.Fx
|
||||
|
||||
// MessageType defines the type of a message (same as uint32 for compatibility)
|
||||
type MessageType = uint32
|
||||
|
||||
// Message type constants (cast to uint32 for compatibility with Message.Type)
|
||||
const (
|
||||
PendingTxs MessageType = uint32(core.PendingTxs)
|
||||
PutBlock MessageType = uint32(core.PutBlock)
|
||||
GetBlock MessageType = uint32(core.GetBlock)
|
||||
GetAccepted MessageType = uint32(core.GetAccepted)
|
||||
Accepted MessageType = uint32(core.Accepted)
|
||||
GetAncestors MessageType = uint32(core.GetAncestors)
|
||||
MultiPut MessageType = uint32(core.MultiPut)
|
||||
GetFailed MessageType = uint32(core.GetFailed)
|
||||
QueryFailed MessageType = uint32(core.QueryFailed)
|
||||
Chits MessageType = uint32(core.Chits)
|
||||
ChitsV2 MessageType = uint32(core.ChitsV2)
|
||||
GetAcceptedFrontier MessageType = uint32(core.GetAcceptedFrontier)
|
||||
AcceptedFrontier MessageType = uint32(core.AcceptedFrontier)
|
||||
GetAcceptedFrontierFailed MessageType = uint32(core.GetAcceptedFrontierFailed)
|
||||
WarpRequest MessageType = uint32(core.WarpRequest)
|
||||
WarpResponse MessageType = uint32(core.WarpResponse)
|
||||
WarpGossip MessageType = uint32(core.WarpGossip)
|
||||
)
|
||||
|
||||
// SendConfig is an alias for warp.SendConfig for backwards compatibility
|
||||
type SendConfig = warp.SendConfig
|
||||
|
||||
// Sender is an alias for warp.Sender for backwards compatibility
|
||||
type Sender = warp.Sender
|
||||
|
||||
// Handler is an alias for warp.Handler for backwards compatibility
|
||||
type Handler = warp.Handler
|
||||
|
||||
// Error is an alias for warp.Error for backwards compatibility
|
||||
type Error = warp.Error
|
||||
+5
-1
@@ -11,7 +11,7 @@ type Fx struct {
|
||||
Fx interface{}
|
||||
}
|
||||
|
||||
// Message represents a network message
|
||||
// Message represents a VM-to-engine message
|
||||
type Message struct {
|
||||
Type MessageType
|
||||
NodeID ids.NodeID
|
||||
@@ -58,6 +58,8 @@ func (m MessageType) String() string {
|
||||
return "WarpResponse"
|
||||
case WarpGossip:
|
||||
return "WarpGossip"
|
||||
case StateSyncDone:
|
||||
return "StateSyncDone"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
@@ -98,4 +100,6 @@ const (
|
||||
WarpResponse
|
||||
// WarpGossip indicates warp gossip
|
||||
WarpGossip
|
||||
// StateSyncDone indicates state sync has completed
|
||||
StateSyncDone
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package core
|
||||
|
||||
// cgoAvailable returns false when CGO is disabled
|
||||
func cgoAvailable() bool {
|
||||
// CgoAvailable returns false when CGO is disabled
|
||||
func CgoAvailable() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -57,12 +57,15 @@ func NewLuxConsensus(k int, alpha int, beta int) *LuxConsensus {
|
||||
// Create a simple transport implementation
|
||||
transport := &SimpleTransport{}
|
||||
|
||||
// Create Wave configuration
|
||||
// Create Wave configuration with FPC enabled for dynamic thresholds
|
||||
waveCfg := wave.Config{
|
||||
K: k,
|
||||
Alpha: alphaRatio,
|
||||
Beta: betaU32,
|
||||
RoundTO: 1 * time.Second,
|
||||
K: k,
|
||||
Alpha: alphaRatio,
|
||||
Beta: betaU32,
|
||||
RoundTO: 1 * time.Second,
|
||||
EnableFPC: true, // Enable Fast Probabilistic Consensus
|
||||
ThetaMin: 0.5, // FPC minimum threshold
|
||||
ThetaMax: 0.8, // FPC maximum threshold
|
||||
}
|
||||
|
||||
// Create consensus components
|
||||
|
||||
@@ -103,8 +103,8 @@ func main() {
|
||||
fmt.Printf("Block 2 accepted: %v\n", chain.IsAccepted(block2.ID))
|
||||
}
|
||||
|
||||
// Example of using QuickStart for even simpler initialization
|
||||
func quickStartExample() {
|
||||
// QuickStartExample demonstrates using QuickStart for even simpler initialization
|
||||
func QuickStartExample() {
|
||||
ctx := context.Background()
|
||||
|
||||
// One-liner to start consensus
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
module github.com/luxfi/consensus
|
||||
|
||||
go 1.25.1
|
||||
go 1.25.5
|
||||
|
||||
exclude github.com/ethereum/go-ethereum v1.10.26
|
||||
|
||||
exclude github.com/ethereum/go-ethereum v1.16.3
|
||||
|
||||
require (
|
||||
github.com/dgraph-io/badger/v4 v4.8.0
|
||||
github.com/luxfi/bft v0.1.0
|
||||
github.com/luxfi/crypto v1.17.18
|
||||
github.com/luxfi/database v1.2.7
|
||||
github.com/luxfi/geth v1.16.39
|
||||
github.com/luxfi/ids v1.1.2
|
||||
github.com/luxfi/log v1.1.22
|
||||
github.com/luxfi/math v0.1.4
|
||||
github.com/luxfi/log v1.1.24
|
||||
github.com/luxfi/math v0.1.5
|
||||
github.com/luxfi/node v1.20.3
|
||||
github.com/luxfi/p2p v1.4.4
|
||||
github.com/luxfi/warp v1.16.31
|
||||
github.com/prometheus/client_golang v1.23.2
|
||||
github.com/prometheus/client_model v0.6.2
|
||||
@@ -42,6 +42,7 @@ require (
|
||||
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
|
||||
github.com/dgraph-io/badger/v4 v4.8.0 // indirect
|
||||
github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect
|
||||
|
||||
@@ -134,16 +134,18 @@ github.com/luxfi/geth v1.16.39 h1:La2V3JrpQhqSGoVrMO6eigsSs8Gsk+mf9IIlIU4Dg9Y=
|
||||
github.com/luxfi/geth v1.16.39/go.mod h1:v3qrq+7BZcagEbWJtBVHHzvsdfTyFZRQ3GrHsoIEDaI=
|
||||
github.com/luxfi/ids v1.1.2 h1:+qCUzE9Ga4slSHbnYl7T3I6c8y+n4/kKk4rzSEkLv/k=
|
||||
github.com/luxfi/ids v1.1.2/go.mod h1:cMbto3Q8N3IaBxdz4Lzaq9wYl33coGXUdlr2+YwXeUw=
|
||||
github.com/luxfi/log v1.1.22 h1:E+jX+ZZS4JX2HjuGdDTpLfrgFKEDD8byNYTa0m6HT1o=
|
||||
github.com/luxfi/log v1.1.22/go.mod h1:Q2eeOT4alCF+/B6+k/eWtVZQ2HncDlpd9vUvkTF0Suc=
|
||||
github.com/luxfi/math v0.1.4 h1:yPoXwHttm2M0HQ8a+SNZcN0MDz617en4+tyiQ9Iq8cA=
|
||||
github.com/luxfi/math v0.1.4/go.mod h1:hGzbdMPfhX6zobJXz+Crja7AY9kHMqIL2L60kYUzyUc=
|
||||
github.com/luxfi/log v1.1.24 h1:mz73HhY28cyjOHZ94Q6Ah4UbcjAy1/YRz8S/tZDqiSg=
|
||||
github.com/luxfi/log v1.1.24/go.mod h1:km8erK78Kc9awsK8VBW/fPm4ZZMGTxZInVCHSaFIMOo=
|
||||
github.com/luxfi/math v0.1.5 h1:36uCSbFPvLtBcm6wPcYGp5TU3AkdCfrIlbIwZGOxMrg=
|
||||
github.com/luxfi/math v0.1.5/go.mod h1:goRksIi7wPcG4lR1ANBu9qjWHzX175wTKL7lQrOenXQ=
|
||||
github.com/luxfi/metric v1.4.5 h1:fD6gtpzB5ebGB06/m4K7e5+tOV5RiVHSZCV+Zb8ZDxk=
|
||||
github.com/luxfi/metric v1.4.5/go.mod h1:AUQ7NSNz9WndAcr/SKnOkP7XSFFnBXOa+ihtJYfDaQY=
|
||||
github.com/luxfi/mock v0.1.0 h1:IwElfNu+T9sXvzFX6tudPDx1vqPuACRSRdxpD5lxW+o=
|
||||
github.com/luxfi/mock v0.1.0/go.mod h1:izF+9K0gGzFC9zERn6Po37v46eLdPB+EIsDjL3GLk+U=
|
||||
github.com/luxfi/node v1.20.3 h1:T8zo9Q5hBDJ31t42t6SDHYhQcvIjfx0iIUAHQqTSYwo=
|
||||
github.com/luxfi/node v1.20.3/go.mod h1:8+nlZVYI8dDBYxC4Bj7mqeL4rHrIQfoB+atVZhABtEA=
|
||||
github.com/luxfi/p2p v1.4.4 h1:jZZRX3kos4mCoVvAurtn+sp7RJXeUnCBtCISs9zxanE=
|
||||
github.com/luxfi/p2p v1.4.4/go.mod h1:IAm+7aqpcbtrC1qqtX4xFNqfaR4SVnlx/C+FGLXV1I0=
|
||||
github.com/luxfi/warp v1.16.31 h1:nAqtMaAzyo7BuE8L7a6P+2jjjNUECqtmGyjNA7muQ88=
|
||||
github.com/luxfi/warp v1.16.31/go.mod h1:WPjq6jCJ5CR3MVPzAArGX6i99n5YiSGr4JYa67aJFwk=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
|
||||
@@ -8,23 +8,21 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/luxfi/consensus/engine/core"
|
||||
"github.com/luxfi/log"
|
||||
)
|
||||
|
||||
// MessageType represents the type of VM notification message
|
||||
type MessageType uint32
|
||||
|
||||
const (
|
||||
// PendingTxs indicates the VM has pending transactions ready for block building
|
||||
PendingTxs MessageType = iota
|
||||
// StateSyncDone indicates state sync has completed
|
||||
StateSyncDone
|
||||
// Re-export core types for convenience
|
||||
type (
|
||||
MessageType = core.MessageType
|
||||
VMMessage = core.Message
|
||||
)
|
||||
|
||||
// VMMessage represents a message from the VM to the consensus engine
|
||||
type VMMessage struct {
|
||||
Type MessageType
|
||||
}
|
||||
// Message type constants
|
||||
const (
|
||||
PendingTxs = core.PendingTxs
|
||||
StateSyncDone = core.StateSyncDone
|
||||
)
|
||||
|
||||
// Notifier is the interface for receiving VM notifications
|
||||
type Notifier interface {
|
||||
|
||||
@@ -203,7 +203,7 @@ func (q *Hybrid) SignMessageWithContext(ctx context.Context, validatorID string,
|
||||
// Create Corona (ML-DSA) signature
|
||||
coronaSig, err := coronaKP.PrivateKey.Sign(rand.Reader, message, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Corona sign failed: %w", err)
|
||||
return nil, fmt.Errorf("corona sign failed: %w", err)
|
||||
}
|
||||
|
||||
// Get pooled signature struct to reduce allocations
|
||||
|
||||
@@ -113,7 +113,7 @@ func (v *VerkleWitness) fullVerification(witness *WitnessProof) error {
|
||||
|
||||
// Verify Corona threshold
|
||||
if !v.verifyCoronaThreshold(witness.CoronaBits) {
|
||||
return errors.New("Corona threshold not met")
|
||||
return errors.New("corona threshold not met")
|
||||
}
|
||||
|
||||
// Verify Verkle commitment
|
||||
|
||||
@@ -276,21 +276,6 @@ func TestGetter(t *testing.T) {
|
||||
}
|
||||
EOF
|
||||
|
||||
mkdir -p engine/core/common
|
||||
cat > engine/core/common/common_test.go << 'EOF'
|
||||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCommon(t *testing.T) {
|
||||
// Test placeholder for common package
|
||||
require.True(t, true)
|
||||
}
|
||||
EOF
|
||||
|
||||
mkdir -p engine/core/tracker
|
||||
cat > engine/core/tracker/tracker_test.go << 'EOF'
|
||||
package tracker
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ func (n *CNode) ProposeBlock(testBlock *Block) error {
|
||||
defer n.mu.Unlock()
|
||||
|
||||
if !n.healthy {
|
||||
return fmt.Errorf("C node not healthy")
|
||||
return fmt.Errorf("c node not healthy")
|
||||
}
|
||||
|
||||
n.t.Logf("C node: proposing block %s (height %d)", testBlock.ID, testBlock.Height)
|
||||
|
||||
@@ -36,7 +36,7 @@ func (n *CppNode) Start(ctx context.Context, port int) error {
|
||||
if !checkBuild(n.t, "C++", []string{"cmake", "--build", "pkg/cpp/build"}) {
|
||||
n.t.Log("⚠️ C++ binary not built, skipping C++ node")
|
||||
n.healthy = false
|
||||
return fmt.Errorf("C++ binary not available")
|
||||
return fmt.Errorf("c++ binary not available")
|
||||
}
|
||||
|
||||
// For now, just mark as healthy - actual IPC would be implemented here
|
||||
@@ -68,7 +68,7 @@ func (n *CppNode) ProposeBlock(testBlock *Block) error {
|
||||
defer n.mu.Unlock()
|
||||
|
||||
if !n.healthy {
|
||||
return fmt.Errorf("C++ node not healthy")
|
||||
return fmt.Errorf("c++ node not healthy")
|
||||
}
|
||||
|
||||
n.t.Logf("C++ node: proposing block %s (height %d)", testBlock.ID, testBlock.Height)
|
||||
|
||||
@@ -39,7 +39,7 @@ func (n *PythonNode) Start(ctx context.Context, port int) error {
|
||||
if _, err := os.Stat(pythonSetupPath); os.IsNotExist(err) {
|
||||
n.t.Log("⚠️ Python package not found, skipping Python node")
|
||||
n.healthy = false
|
||||
return fmt.Errorf("Python package not available")
|
||||
return fmt.Errorf("python package not available")
|
||||
}
|
||||
|
||||
// Try to import the Python module
|
||||
@@ -47,7 +47,7 @@ func (n *PythonNode) Start(ctx context.Context, port int) error {
|
||||
if err := testCmd.Run(); err != nil {
|
||||
n.t.Log("⚠️ Python package not installed, skipping Python node")
|
||||
n.healthy = false
|
||||
return fmt.Errorf("Python package not installed")
|
||||
return fmt.Errorf("python package not installed")
|
||||
}
|
||||
|
||||
n.healthy = true
|
||||
@@ -78,7 +78,7 @@ func (n *PythonNode) ProposeBlock(testBlock *Block) error {
|
||||
defer n.mu.Unlock()
|
||||
|
||||
if !n.healthy {
|
||||
return fmt.Errorf("Python node not healthy")
|
||||
return fmt.Errorf("python node not healthy")
|
||||
}
|
||||
|
||||
n.t.Logf("Python node: proposing block %s (height %d)", testBlock.ID, testBlock.Height)
|
||||
|
||||
@@ -36,7 +36,7 @@ func (n *RustNode) Start(ctx context.Context, port int) error {
|
||||
if !checkBuild(n.t, "Rust", []string{"cargo", "build", "--manifest-path", "pkg/rust/Cargo.toml", "--release"}) {
|
||||
n.t.Log("⚠️ Rust library not built, skipping Rust node")
|
||||
n.healthy = false
|
||||
return fmt.Errorf("Rust library not available")
|
||||
return fmt.Errorf("rust library not available")
|
||||
}
|
||||
|
||||
n.healthy = true
|
||||
@@ -67,7 +67,7 @@ func (n *RustNode) ProposeBlock(testBlock *Block) error {
|
||||
defer n.mu.Unlock()
|
||||
|
||||
if !n.healthy {
|
||||
return fmt.Errorf("Rust node not healthy")
|
||||
return fmt.Errorf("rust node not healthy")
|
||||
}
|
||||
|
||||
n.t.Logf("Rust node: proposing block %s (height %d)", testBlock.ID, testBlock.Height)
|
||||
|
||||
@@ -46,6 +46,7 @@ func BenchmarkBlockOperations(b *testing.B) {
|
||||
block[1] = byte(i & 0xFF)
|
||||
blocks = append(blocks, block)
|
||||
}
|
||||
_ = blocks
|
||||
})
|
||||
|
||||
b.Run("BatchBlocks_100", func(b *testing.B) {
|
||||
@@ -89,6 +90,7 @@ func BenchmarkVoteProcessing(b *testing.B) {
|
||||
vote[1] = byte(i & 0xFF)
|
||||
votes = append(votes, vote)
|
||||
}
|
||||
_ = votes
|
||||
})
|
||||
|
||||
b.Run("BatchVotes_1000", func(b *testing.B) {
|
||||
|
||||
Reference in New Issue
Block a user