Skip to content
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
3798bb8
Enable support for viewing peer registry details
galt-tr Oct 16, 2025
f7bd1cb
Small fixes
galt-tr Oct 17, 2025
0ed2490
Add ban manager to registry
galt-tr Oct 21, 2025
a2d816e
Refactor blockvalidation catchup to use the peer registry
galt-tr Oct 22, 2025
a144ee8
Add caching
galt-tr Oct 22, 2025
4bcd032
Refactor a bit
galt-tr Oct 22, 2025
172c4f8
Add subtree stuff
galt-tr Oct 23, 2025
bf5ca17
Fix peer ID mapping
galt-tr Oct 23, 2025
aec56db
Fix gen
galt-tr Oct 23, 2025
be4a23b
Turn off subtree reputation
galt-tr Oct 23, 2025
a38866e
Add catchup indicator
galt-tr Oct 23, 2025
0897929
Finish rebase
galt-tr Oct 27, 2025
8f6a20f
Move to constant peer IDs
galt-tr Oct 28, 2025
9d5fcae
Stable peers
galt-tr Oct 28, 2025
c5bc30a
Fix reputation system
galt-tr Oct 29, 2025
51d3d83
Properly catch sync failures
galt-tr Oct 29, 2025
e425d33
Updates
galt-tr Oct 29, 2025
af393aa
Fix table
galt-tr Oct 29, 2025
e5f422a
Fix catchup logic
galt-tr Oct 29, 2025
2706653
Change log
galt-tr Oct 29, 2025
019e679
Fix lint errors
galt-tr Oct 30, 2025
7909858
Fix format
galt-tr Oct 30, 2025
6db4722
Fix p2p tests
galt-tr Oct 30, 2025
692d95a
Fix get blocks test
galt-tr Oct 30, 2025
2f396ea
Don't reset success counter
galt-tr Oct 30, 2025
aa24b18
Move peer registry endpoint to asset service
galt-tr Oct 30, 2025
c0699f7
Fix URL construction
galt-tr Oct 30, 2025
bf2567a
Add positive reputation for subtrees
galt-tr Oct 30, 2025
3f80586
Fix peers page for container deployments
oskarszoon Oct 30, 2025
5598961
Fix catchup status for compiled svelte
oskarszoon Oct 30, 2025
33e52f8
Prevent secret mining check from triggering during catchup
oskarszoon Oct 31, 2025
3445afb
Improve catchup state block
oskarszoon Oct 31, 2025
de8c821
Switch asset to use hardened grpc connections to p2p and blockvalidation
oskarszoon Oct 31, 2025
047da04
Implement client name
galt-tr Oct 31, 2025
f635dff
Change some rendering for catchup
galt-tr Oct 31, 2025
4a9d27c
Rename
galt-tr Oct 31, 2025
1eb4e5d
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Oct 31, 2025
50c305f
Add tsts
galt-tr Nov 3, 2025
68b508b
Fix linters
galt-tr Nov 3, 2025
5e19bb5
Fix tests
galt-tr Nov 3, 2025
116d6eb
Fix another test
galt-tr Nov 3, 2025
6a14fbd
Address feedback
galt-tr Nov 3, 2025
a619618
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 3, 2025
f6c1bf3
Remove temporary doc, will be integrated into main docs seperately
oskarszoon Nov 3, 2025
3778014
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 3, 2025
f6602c7
make gen with latest protoc
oskarszoon Nov 3, 2025
bb76a1d
Fix file naming for new files
oskarszoon Nov 3, 2025
e137f00
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 3, 2025
ebf8e22
Prevent local issues being reported as peer issue
oskarszoon Nov 3, 2025
48ff56b
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 3, 2025
bd3960d
Fix race test
galt-tr Nov 3, 2025
34e7f01
Fix claude feedback
galt-tr Nov 3, 2025
50e3c57
Made creation of p2p client a singleton
icellan Nov 3, 2025
3f8cd74
Cleaned up peer_selection
icellan Nov 3, 2025
28bb439
Add locking around difficulty setting
oskarszoon Nov 3, 2025
7d4e017
Merge branch 'main' into peerRegistryViewer
galt-tr Nov 4, 2025
235e034
Add another test
galt-tr Nov 4, 2025
aa41978
Fix regex for test
galt-tr Nov 4, 2025
374c6d1
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 4, 2025
7825fd6
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 4, 2025
73b5d15
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 4, 2025
fa7284b
Update go-subtree to latest with reduced buffer sizes
oskarszoon Nov 4, 2025
74ec593
SubtreeMeta/SubtreeNode/SubtreeData was renamed in go-subtree package
oskarszoon Nov 4, 2025
c7434a9
Fix lint
oskarszoon Nov 4, 2025
f65a1c1
Remove P2P Health mechanism in favor of using only reputation
oskarszoon Nov 4, 2025
347fd44
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 4, 2025
52f721b
Fix lint
oskarszoon Nov 4, 2025
a9def97
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 4, 2025
d6e820b
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 4, 2025
f9c87f2
Merge branch 'main' into peerRegistryViewer
galt-tr Nov 5, 2025
57b7c79
Error return for catchup
galt-tr Nov 5, 2025
5d56152
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 5, 2025
461ed92
Merge branch 'main' into peerRegistryViewer
galt-tr Nov 5, 2025
225e7a7
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 6, 2025
865e541
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 6, 2025
f1863f4
Cleanup and updates on interfaces and code conventions
icellan Nov 6, 2025
cd4e972
Refactored peerID and baseURL to be passed into functions in the same…
icellan Nov 7, 2025
2c34d3d
Merge branch 'main' into peerRegistryViewer
icellan Nov 7, 2025
41d32ca
Cleanup and updates on interfaces and code conventions
icellan Nov 6, 2025
04edee7
Refactored peerID and baseURL to be passed into functions in the same…
icellan Nov 7, 2025
7065104
Merge branch 'dylan/peerRegistryViewer' of github.com:icellan/teranod…
icellan Nov 7, 2025
436aac5
Fixed order of peerID and baseURL in mock
icellan Nov 7, 2025
ad3c247
Fixed passing in p2pClient to asset repository
icellan Nov 7, 2025
2447097
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 7, 2025
4569e54
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
oskarszoon Nov 10, 2025
63ecf51
Advertise as a full node in legacy service when we have the persister
oskarszoon Nov 10, 2025
5fa2002
Decrease validation/catchup buffers and channel to improve catchup re…
oskarszoon Nov 10, 2025
a1687d3
More catchup improvements
oskarszoon Nov 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const (
loggerTransactions = "txs"
loggerTxValidator = "txval"
loggerUtxos = "utxos"
loggerAlert = "alert"

// Service names
serviceAlert = "alert"
Expand Down
56 changes: 37 additions & 19 deletions daemon/daemon_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,25 +423,25 @@ func (d *Daemon) startRPCService(ctx context.Context, appSettings *settings.Sett
return err
}

blockAssemblyClient, err := blockassembly.NewClient(ctx, createLogger("ba"), appSettings)
blockAssemblyClient, err := GetBlockAssemblyClient(ctx, createLogger("rpc"), appSettings)
if err != nil {
return err
}

peerClient, err := peer.NewClient(ctx, createLogger("peer"), appSettings)
peerClient, err := peer.NewClient(ctx, createLogger("rpc"), appSettings)
if err != nil {
return err
}

p2pClient, err := p2p.NewClient(ctx, createLogger("p2p"), appSettings)
p2pClient, err := d.daemonStores.GetP2PClient(ctx, createLogger("rpc"), appSettings)
if err != nil {
return err
}

// Create block validation client for RPC service
var blockValidationClient blockvalidation.Interface

blockValidationClient, err = d.daemonStores.GetBlockValidationClient(ctx, createLogger("blockvalidation"), appSettings)
blockValidationClient, err = d.daemonStores.GetBlockValidationClient(ctx, createLogger("rpc"), appSettings)
if err != nil {
return err
}
Expand Down Expand Up @@ -471,7 +471,7 @@ func (d *Daemon) startRPCService(ctx context.Context, appSettings *settings.Sett
}

// Add the RPC service to the ServiceManager
if err := d.ServiceManager.AddService(serviceRPCFormal, rpcServer); err != nil {
if err = d.ServiceManager.AddService(serviceRPCFormal, rpcServer); err != nil {
return err
}

Expand All @@ -480,43 +480,43 @@ func (d *Daemon) startRPCService(ctx context.Context, appSettings *settings.Sett

// startAlertService initializes and adds the Alert service to the ServiceManager.
func (d *Daemon) startAlertService(ctx context.Context, appSettings *settings.Settings,
createLogger func(string) ulogger.Logger) error {
createLogger func(string) ulogger.Logger) (err error) {
var (
blockchainClient blockchain.ClientI
utxoStore utxo.Store
blockAssemblyClient blockassembly.ClientI
peerClient peer.ClientI
p2pClient p2p.ClientI
)

// Create the blockchain client for the Alert service
blockchainClient, err := d.daemonStores.GetBlockchainClient(
blockchainClient, err = d.daemonStores.GetBlockchainClient(
ctx, createLogger(loggerBlockchainClient), appSettings, serviceAlert,
)
if err != nil {
return err
}

// Create the UTXO store for the Alert service
var utxoStore utxo.Store

utxoStore, err = d.daemonStores.GetUtxoStore(ctx, createLogger(loggerUtxos), appSettings)
utxoStore, err = d.daemonStores.GetUtxoStore(ctx, createLogger(loggerAlert), appSettings)
if err != nil {
return err
}

// Create the block assembly client for the Alert service
var blockAssemblyClient *blockassembly.Client

blockAssemblyClient, err = blockassembly.NewClient(ctx, createLogger(loggerBlockAssembly), appSettings)
blockAssemblyClient, err = GetBlockAssemblyClient(ctx, createLogger(loggerAlert), appSettings)
if err != nil {
return err
}

// Create the peer client for the Alert service
var peerClient peer.ClientI

peerClient, err = peer.NewClient(ctx, createLogger(loggerPeerClient), appSettings)
peerClient, err = peer.NewClient(ctx, createLogger(loggerAlert), appSettings)
if err != nil {
return err
}

// Create the P2P client for the Alert service
var p2pClient p2p.ClientI

p2pClient, err = p2p.NewClient(ctx, createLogger(loggerP2P), appSettings)
p2pClient, err = d.daemonStores.GetP2PClient(ctx, createLogger(loggerAlert), appSettings)
if err != nil {
return err
}
Expand Down Expand Up @@ -752,6 +752,14 @@ func (d *Daemon) startValidationService(
return err
}

// Create the P2P client for the SubtreeValidation service
var p2pClient p2p.ClientI

p2pClient, err = d.daemonStores.GetP2PClient(ctx, createLogger(loggerP2P), appSettings)
if err != nil {
return err
}

// Create the SubtreeValidation service
var service *subtreevalidation.Server

Expand All @@ -766,6 +774,7 @@ func (d *Daemon) startValidationService(
blockchainClient,
subtreeConsumerClient,
txMetaConsumerClient,
p2pClient,
)
if err != nil {
return err
Expand Down Expand Up @@ -800,6 +809,14 @@ func (d *Daemon) startValidationService(
return err
}

// Create the P2P client for the BlockValidation service
var p2pClient p2p.ClientI

p2pClient, err = d.daemonStores.GetP2PClient(ctx, createLogger(loggerP2P), appSettings)
if err != nil {
return err
}

// Create the BlockValidation service
d.blockValidationSrv = blockvalidation.New(
createLogger(loggerBlockValidation),
Expand All @@ -811,6 +828,7 @@ func (d *Daemon) startValidationService(
blockchainClient,
kafkaConsumerClient,
blockAssemblyClient,
p2pClient,
)

// Add the BlockValidation service to the ServiceManager
Expand Down
28 changes: 28 additions & 0 deletions daemon/daemon_stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/bsv-blockchain/teranode/services/blockassembly"
"github.com/bsv-blockchain/teranode/services/blockchain"
"github.com/bsv-blockchain/teranode/services/blockvalidation"
"github.com/bsv-blockchain/teranode/services/p2p"
"github.com/bsv-blockchain/teranode/services/subtreevalidation"
"github.com/bsv-blockchain/teranode/services/validator"
"github.com/bsv-blockchain/teranode/settings"
Expand All @@ -24,6 +25,7 @@ type Stores struct {
mainBlockPersisterStore blob.Store
mainBlockStore blob.Store
mainBlockValidationClient blockvalidation.Interface
mainP2PClient p2p.ClientI
mainSubtreeStore blob.Store
mainSubtreeValidationClient subtreevalidation.Interface
mainTempStore blob.Store
Expand Down Expand Up @@ -83,6 +85,31 @@ func (d *Stores) GetBlockValidationClient(ctx context.Context, logger ulogger.Lo
return d.mainBlockValidationClient, err
}

// GetP2PClient creates and returns a new P2P client instance. Unlike other store getters, this function
// always creates a new client instance to maintain source information. The source parameter
// identifies the origin or purpose of the client.
//
// Parameters:
// - ctx: The context for managing the client's lifecycle.
// - logger: The logger instance for logging client activities.
// - appSettings: The application settings containing configuration details.
//
// Returns:
// - p2p.ClientI: The newly created P2P client instance.
// - error: An error object if the client creation fails; otherwise, nil.
func (d *Stores) GetP2PClient(ctx context.Context, logger ulogger.Logger, appSettings *settings.Settings) (p2p.ClientI, error) {
if d.mainP2PClient != nil {
return d.mainP2PClient, nil
}

p2pClient, err := p2p.NewClient(ctx, logger, appSettings)
if err != nil {
return nil, err
}

return p2pClient, nil
}

// GetBlockchainClient creates and returns a new blockchain client instance. Unlike other store
// getters, this function always creates a new client instance to maintain source information.
// The source parameter identifies the origin or purpose of the client.
Expand Down Expand Up @@ -376,6 +403,7 @@ func (d *Stores) Cleanup() {
d.mainTxStore = nil
d.mainUtxoStore = nil
d.mainValidatorClient = nil
d.mainP2PClient = nil

// Reset the Aerospike cleanup service singleton if it exists
// This prevents state leakage between test runs
Expand Down
4 changes: 2 additions & 2 deletions services/alert/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Node struct {

// blockassemblyClient handles block assembly operations, allowing the
// alert system to interact with block creation processes
blockassemblyClient *blockassembly.Client
blockassemblyClient blockassembly.ClientI

// peerClient handles peer operations such as banning and unbanning peers
// based on alert system decisions
Expand Down Expand Up @@ -86,7 +86,7 @@ type Node struct {
// Returns:
// - config.NodeInterface: A fully initialized Node instance that satisfies the required interface
func NewNodeConfig(logger ulogger.Logger, blockchainClient blockchain.ClientI, utxoStore utxo.Store,
blockassemblyClient *blockassembly.Client, peerClient peer.ClientI, p2pClient p2p.ClientI, tSettings *settings.Settings) config.NodeInterface {
blockassemblyClient blockassembly.ClientI, peerClient peer.ClientI, p2pClient p2p.ClientI, tSettings *settings.Settings) config.NodeInterface {
return &Node{
logger: logger,
blockchainClient: blockchainClient,
Expand Down
4 changes: 2 additions & 2 deletions services/alert/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type Server struct {

// blockassemblyClient handles block assembly operations,
// allowing the alert system to influence block creation when necessary
blockassemblyClient *blockassembly.Client
blockassemblyClient blockassembly.ClientI

// appConfig contains alert system specific configuration loaded from
// the alert system configuration file, separate from Teranode settings
Expand Down Expand Up @@ -109,7 +109,7 @@ type Server struct {
// Returns:
// - *Server: A new Server instance configured with the provided dependencies,
// but not yet initialized or started
func New(logger ulogger.Logger, tSettings *settings.Settings, blockchainClient blockchain.ClientI, utxoStore utxo.Store, blockassemblyClient *blockassembly.Client, peerClient peer.ClientI, p2pClient p2pservice.ClientI) *Server {
func New(logger ulogger.Logger, tSettings *settings.Settings, blockchainClient blockchain.ClientI, utxoStore utxo.Store, blockassemblyClient blockassembly.ClientI, peerClient peer.ClientI, p2pClient p2pservice.ClientI) *Server {
initPrometheusMetrics()

return &Server{
Expand Down
74 changes: 74 additions & 0 deletions services/asset/httpimpl/get_catchup_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package httpimpl

import (
"context"
"net/http"
"time"

"github.com/bsv-blockchain/teranode/services/blockvalidation/blockvalidation_api"
"github.com/labstack/echo/v4"
)

// GetCatchupStatus returns the current catchup status from the BlockValidation service
func (h *HTTP) GetCatchupStatus(c echo.Context) error {
ctx, cancel := context.WithTimeout(c.Request().Context(), 5*time.Second)
defer cancel()

// Initialize persistent gRPC clients if not already done
h.initGRPCClients(ctx)

// Check if BlockValidation client connection is available
if h.blockvalClientConn == nil {
h.logger.Errorf("[GetCatchupStatus] BlockValidation gRPC client not available: %v", h.blockvalClientInitErr)
return c.JSON(http.StatusServiceUnavailable, map[string]interface{}{
"error": "BlockValidation service not available",
"is_catching_up": false,
})
}

// Create BlockValidation API client from persistent connection
client := blockvalidation_api.NewBlockValidationAPIClient(h.blockvalClientConn)
resp, err := client.GetCatchupStatus(ctx, &blockvalidation_api.EmptyMessage{})
if err != nil {
h.logger.Errorf("[GetCatchupStatus] Failed to get catchup status: %v", err)
return c.JSON(http.StatusInternalServerError, map[string]interface{}{
"error": "Failed to get catchup status",
"is_catching_up": false,
})
}

// Convert gRPC response to JSON
jsonResp := map[string]interface{}{
"is_catching_up": resp.IsCatchingUp,
"peer_id": resp.PeerId,
"peer_url": resp.PeerUrl,
"target_block_hash": resp.TargetBlockHash,
"target_block_height": resp.TargetBlockHeight,
"current_height": resp.CurrentHeight,
"total_blocks": resp.TotalBlocks,
"blocks_fetched": resp.BlocksFetched,
"blocks_validated": resp.BlocksValidated,
"start_time": resp.StartTime,
"duration_ms": resp.DurationMs,
"fork_depth": resp.ForkDepth,
"common_ancestor_hash": resp.CommonAncestorHash,
"common_ancestor_height": resp.CommonAncestorHeight,
}

// Add previous attempt if available
if resp.PreviousAttempt != nil {
jsonResp["previous_attempt"] = map[string]interface{}{
"peer_id": resp.PreviousAttempt.PeerId,
"peer_url": resp.PreviousAttempt.PeerUrl,
"target_block_hash": resp.PreviousAttempt.TargetBlockHash,
"target_block_height": resp.PreviousAttempt.TargetBlockHeight,
"error_message": resp.PreviousAttempt.ErrorMessage,
"error_type": resp.PreviousAttempt.ErrorType,
"attempt_time": resp.PreviousAttempt.AttemptTime,
"duration_ms": resp.PreviousAttempt.DurationMs,
"blocks_validated": resp.PreviousAttempt.BlocksValidated,
}
}

return c.JSON(http.StatusOK, jsonResp)
}
Loading
Loading