Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Kim <20001595+joshua-kim@users.noreply.github.com>
  • Loading branch information
joshua-kim committed Oct 2, 2024
1 parent 2a0771c commit e81fe3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions vm/syncervm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func (s *stateSyncerClient) AcceptedSyncableBlock(
s.syncManager, err = avasync.NewManager(avasync.ManagerConfig{
BranchFactor: s.vm.genesis.GetStateBranchFactor(),
DB: s.vm.stateDB,
RangeProofClient: s.vm.p2pNetwork.NewClient(rangeProofHandlerID),
ChangeProofClient: s.vm.p2pNetwork.NewClient(changeProofHandlerID),
RangeProofClient: s.vm.network.NewClient(rangeProofHandlerID),
ChangeProofClient: s.vm.network.NewClient(changeProofHandlerID),
SimultaneousWorkLimit: s.vm.config.StateSyncParallelism,
Log: s.vm.snowCtx.Log,
TargetRoot: sb.StateRoot,
Expand Down
27 changes: 13 additions & 14 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
avatrace "github.com/ava-labs/avalanchego/trace"
avautils "github.com/ava-labs/avalanchego/utils"
avasync "github.com/ava-labs/avalanchego/x/sync"

internalfees "github.com/ava-labs/hypersdk/internal/fees"
)

Expand Down Expand Up @@ -98,7 +99,7 @@ type VM struct {
authRegistry chain.AuthRegistry
outputRegistry chain.OutputRegistry
authEngine map[uint8]AuthEngine
p2pNetwork *p2p.Network
network *p2p.Network

tracer avatrace.Tracer
mempool *mempool.Mempool[*chain.Transaction]
Expand Down Expand Up @@ -211,13 +212,11 @@ func (vm *VM) Initialize(
vm.metrics = metrics
vm.proposerMonitor = validators.NewProposerMonitor(vm, vm.snowCtx)

p2pNetwork, err := p2p.NewNetwork(vm.snowCtx.Log, appSender, defaultRegistry, "p2p")
vm.network, err = p2p.NewNetwork(vm.snowCtx.Log, appSender, defaultRegistry, "p2p")
if err != nil {
return fmt.Errorf("failed to initialize p2p: %w", err)
}

vm.p2pNetwork = p2pNetwork

pebbleConfig := pebble.NewDefaultConfig()
vm.vmDB, err = storage.New(pebbleConfig, vm.snowCtx.ChainDataDir, blockDB, vm.snowCtx.Metrics)
if err != nil {
Expand Down Expand Up @@ -432,21 +431,21 @@ func (vm *VM) Initialize(
// Setup state syncing
vm.stateSyncClient = vm.NewStateSyncClient(vm.snowCtx.Metrics)

if err := vm.p2pNetwork.AddHandler(
if err := vm.network.AddHandler(
rangeProofHandlerID,
avasync.NewGetRangeProofHandler(vm.snowCtx.Log, vm.stateDB),
); err != nil {
return err
}

if err := vm.p2pNetwork.AddHandler(
if err := vm.network.AddHandler(
changeProofHandlerID,
avasync.NewGetChangeProofHandler(vm.snowCtx.Log, vm.stateDB),
); err != nil {
return err
}

if err := vm.p2pNetwork.AddHandler(
if err := vm.network.AddHandler(
txGossipHandlerID,
NewTxGossipHandler(vm),
); err != nil {
Expand All @@ -455,7 +454,7 @@ func (vm *VM) Initialize(

// Startup block builder and gossiper
go vm.builder.Run()
go vm.gossiper.Run(vm.p2pNetwork.NewClient(txGossipHandlerID))
go vm.gossiper.Run(vm.network.NewClient(txGossipHandlerID))

// Wait until VM is ready and then send a state sync message to engine
go vm.markReady()
Expand Down Expand Up @@ -1000,7 +999,7 @@ func (vm *VM) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) erro
ctx, span := vm.tracer.Start(ctx, "VM.AppGossip")
defer span.End()

return vm.p2pNetwork.AppGossip(ctx, nodeID, msg)
return vm.network.AppGossip(ctx, nodeID, msg)
}

// implements "block.ChainVM.commom.VM.AppHandler"
Expand All @@ -1014,15 +1013,15 @@ func (vm *VM) AppRequest(
ctx, span := vm.tracer.Start(ctx, "VM.AppRequest")
defer span.End()

return vm.p2pNetwork.AppRequest(ctx, nodeID, requestID, deadline, request)
return vm.network.AppRequest(ctx, nodeID, requestID, deadline, request)
}

// implements "block.ChainVM.commom.VM.AppHandler"
func (vm *VM) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, err *common.AppError) error {
ctx, span := vm.tracer.Start(ctx, "VM.AppRequestFailed")
defer span.End()

return vm.p2pNetwork.AppRequestFailed(ctx, nodeID, requestID, err)
return vm.network.AppRequestFailed(ctx, nodeID, requestID, err)
}

// implements "block.ChainVM.commom.VM.AppHandler"
Expand All @@ -1035,23 +1034,23 @@ func (vm *VM) AppResponse(
ctx, span := vm.tracer.Start(ctx, "VM.AppResponse")
defer span.End()

return vm.p2pNetwork.AppResponse(ctx, nodeID, requestID, response)
return vm.network.AppResponse(ctx, nodeID, requestID, response)
}

// implements "block.ChainVM.commom.VM.validators.Connector"
func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, v *version.Application) error {
ctx, span := vm.tracer.Start(ctx, "VM.Connected")
defer span.End()

return vm.p2pNetwork.Connected(ctx, nodeID, v)
return vm.network.Connected(ctx, nodeID, v)
}

// implements "block.ChainVM.commom.VM.validators.Connector"
func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error {
ctx, span := vm.tracer.Start(ctx, "VM.Disconnected")
defer span.End()

return vm.p2pNetwork.Disconnected(ctx, nodeID)
return vm.network.Disconnected(ctx, nodeID)
}

// VerifyHeightIndex implements snowmanblock.HeightIndexedChainVM
Expand Down

0 comments on commit e81fe3d

Please sign in to comment.