Skip to content

Commit

Permalink
Interval tree syncing integration (#2855)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Apr 2, 2024
1 parent 9a0c852 commit 617a9e2
Show file tree
Hide file tree
Showing 10 changed files with 957 additions and 1,254 deletions.
17 changes: 4 additions & 13 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ var (
VertexDBPrefix = []byte("vertex")
VertexBootstrappingDBPrefix = []byte("vertex_bs")
TxBootstrappingDBPrefix = []byte("tx_bs")
BlockBootstrappingDBPrefix = []byte("block_bs")
BlockBootstrappingDBPrefix = []byte("interval_block_bs")

// Bootstrapping prefixes for ChainVMs
ChainBootstrappingDBPrefix = []byte("bs")
ChainBootstrappingDBPrefix = []byte("interval_bs")

errUnknownVMType = errors.New("the vm should have type avalanche.DAGVM or snowman.ChainVM")
errCreatePlatformVM = errors.New("attempted to create a chain running the PlatformVM")
Expand Down Expand Up @@ -579,10 +579,6 @@ func (m *manager) createAvalancheChain(
if err != nil {
return nil, err
}
blockBlocker, err := queue.NewWithMissing(blockBootstrappingDB, "block", ctx.Registerer)
if err != nil {
return nil, err
}

// Passes messages from the avalanche engines to the network
avalancheMessageSender, err := sender.New(
Expand Down Expand Up @@ -837,7 +833,7 @@ func (m *manager) createAvalancheChain(
BootstrapTracker: sb,
Timer: h,
AncestorsMaxContainersReceived: m.BootstrapAncestorsMaxContainersReceived,
Blocked: blockBlocker,
DB: blockBootstrappingDB,
VM: vmWrappingProposerVM,
}
var snowmanBootstrapper common.BootstrapableEngine
Expand Down Expand Up @@ -952,11 +948,6 @@ func (m *manager) createSnowmanChain(
vmDB := prefixdb.New(VMDBPrefix, prefixDB)
bootstrappingDB := prefixdb.New(ChainBootstrappingDBPrefix, prefixDB)

blocked, err := queue.NewWithMissing(bootstrappingDB, "block", ctx.Registerer)
if err != nil {
return nil, err
}

// Passes messages from the consensus engine to the network
messageSender, err := sender.New(
ctx,
Expand Down Expand Up @@ -1175,7 +1166,7 @@ func (m *manager) createSnowmanChain(
BootstrapTracker: sb,
Timer: h,
AncestorsMaxContainersReceived: m.BootstrapAncestorsMaxContainersReceived,
Blocked: blocked,
DB: bootstrappingDB,
VM: vm,
Bootstrapped: bootstrapFunc,
}
Expand Down
53 changes: 53 additions & 0 deletions snow/engine/snowman/bootstrap/acceptor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package bootstrap

import (
"context"

"github.com/prometheus/client_golang/prometheus"

"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block"
)

var (
_ block.Parser = (*parseAcceptor)(nil)
_ snowman.Block = (*blockAcceptor)(nil)
)

type parseAcceptor struct {
parser block.Parser
ctx *snow.ConsensusContext
numAccepted prometheus.Counter
}

func (p *parseAcceptor) ParseBlock(ctx context.Context, bytes []byte) (snowman.Block, error) {
blk, err := p.parser.ParseBlock(ctx, bytes)
if err != nil {
return nil, err
}
return &blockAcceptor{
Block: blk,
ctx: p.ctx,
numAccepted: p.numAccepted,
}, nil
}

type blockAcceptor struct {
snowman.Block

ctx *snow.ConsensusContext
numAccepted prometheus.Counter
}

func (b *blockAcceptor) Accept(ctx context.Context) error {
if err := b.ctx.BlockAcceptor.Accept(b.ctx, b.ID(), b.Bytes()); err != nil {
return err
}
err := b.Block.Accept(ctx)
b.numAccepted.Inc()
return err
}
113 changes: 0 additions & 113 deletions snow/engine/snowman/bootstrap/block_job.go

This file was deleted.

Loading

0 comments on commit 617a9e2

Please sign in to comment.