Skip to content

Commit

Permalink
Merge branch 'master' into update-versions-v1.11.6
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed May 22, 2024
2 parents aaf831a + dd7a18f commit 684040c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 39 deletions.
29 changes: 9 additions & 20 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ import (
"github.com/ava-labs/avalanchego/vms/avm"
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
"github.com/ava-labs/avalanchego/vms/platformvm/upgrade"
"github.com/ava-labs/avalanchego/vms/registry"
"github.com/ava-labs/avalanchego/vms/rpcchainvm/runtime"
Expand Down Expand Up @@ -1134,25 +1133,15 @@ func (n *Node) initVMs() error {
SybilProtectionEnabled: n.Config.SybilProtectionEnabled,
PartialSyncPrimaryNetwork: n.Config.PartialSyncPrimaryNetwork,
TrackedSubnets: n.Config.TrackedSubnets,
StaticFeeConfig: fee.StaticConfig{
TxFee: n.Config.TxFee,
CreateAssetTxFee: n.Config.CreateAssetTxFee,
CreateSubnetTxFee: n.Config.CreateSubnetTxFee,
TransformSubnetTxFee: n.Config.TransformSubnetTxFee,
CreateBlockchainTxFee: n.Config.CreateBlockchainTxFee,
AddPrimaryNetworkValidatorFee: n.Config.AddPrimaryNetworkValidatorFee,
AddPrimaryNetworkDelegatorFee: n.Config.AddPrimaryNetworkDelegatorFee,
AddSubnetValidatorFee: n.Config.AddSubnetValidatorFee,
AddSubnetDelegatorFee: n.Config.AddSubnetDelegatorFee,
},
UptimePercentage: n.Config.UptimeRequirement,
MinValidatorStake: n.Config.MinValidatorStake,
MaxValidatorStake: n.Config.MaxValidatorStake,
MinDelegatorStake: n.Config.MinDelegatorStake,
MinDelegationFee: n.Config.MinDelegationFee,
MinStakeDuration: n.Config.MinStakeDuration,
MaxStakeDuration: n.Config.MaxStakeDuration,
RewardConfig: n.Config.RewardConfig,
StaticFeeConfig: n.Config.StaticConfig,
UptimePercentage: n.Config.UptimeRequirement,
MinValidatorStake: n.Config.MinValidatorStake,
MaxValidatorStake: n.Config.MaxValidatorStake,
MinDelegatorStake: n.Config.MinDelegatorStake,
MinDelegationFee: n.Config.MinDelegationFee,
MinStakeDuration: n.Config.MinStakeDuration,
MaxStakeDuration: n.Config.MaxStakeDuration,
RewardConfig: n.Config.RewardConfig,
UpgradeConfig: upgrade.Config{
ApricotPhase3Time: version.GetApricotPhase3Time(n.Config.NetworkID),
ApricotPhase5Time: version.GetApricotPhase5Time(n.Config.NetworkID),
Expand Down
12 changes: 8 additions & 4 deletions scripts/build_antithesis_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ function build_images {
docker_cmd="${docker_cmd} --build-arg AVALANCHEGO_NODE_IMAGE=antithesis-avalanchego-node:${TAG}"
fi

# Build node image first to allow the workload image to use it.
${docker_cmd} -t "${node_image_name}" -f "${node_dockerfile}" "${AVALANCHE_PATH}"
if [[ -n "${image_prefix}" ]]; then
# Push images with an image prefix since the prefix defines a registry location
if [[ -n "${image_prefix}" && -z "${node_only}" ]]; then
# Push images with an image prefix since the prefix defines a
# registry location, and only if building all images. When
# building just the node image the image is only intended to be
# used locally.
docker_cmd="${docker_cmd} --push"
fi

# Build node image first to allow the workload image to use it.
${docker_cmd} -t "${node_image_name}" -f "${node_dockerfile}" "${AVALANCHE_PATH}"

if [[ -n "${node_only}" ]]; then
# Skip building the config and workload images. Supports building the avalanchego
# node image as the base image for the xsvm node image.
Expand Down
2 changes: 1 addition & 1 deletion snow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Currently, Avalanchego implements its own message serialization to communicate.

### [Network](https://github.com/ava-labs/avalanchego/blob/master/network/network.go)

The networking interface is shared across all chains. It implements functions from the `ExternalSender` interface. The two functions it implements are `Send` and `Gossip`. `Send` sends a message of type `OutboundMessage` to a specific set of nodes (specified by an array of `NodeIDs`). `Gossip` sends a message of type `OutboundMessage` to a random group of nodes in a subnet (can be a validator or a non-validator). gossiping is used to push transactions across the network. The networking protocol uses TLS to pass messages between peers.
The networking interface is shared across all chains. It implements functions from the `ExternalSender` interface. The two functions it implements are `Send` and `Gossip`. `Send` sends a message of type `OutboundMessage` to a specific set of nodes (specified by an array of `NodeIDs`). `Gossip` sends a message of type `OutboundMessage` to a random group of nodes in a subnet (can be a validator or a non-validator). Gossiping is used to push transactions across the network. The networking protocol uses TLS to pass messages between peers.

Along with sending and gossiping, the networking library is also responsible for making connections and maintaining connections. Any node whether they are a validator or non-validator will attempt to connect to the primary network.

Expand Down
10 changes: 10 additions & 0 deletions snow/engine/snowman/bootstrap/interval/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ func GetBlockIterator(db database.Iteratee) database.Iterator {
return db.NewIteratorWithPrefix(blockPrefix)
}

// GetBlockIterator returns a block iterator that will produce values
// corresponding to persisted blocks in order of increasing height starting at
// [height].
func GetBlockIteratorWithStart(db database.Iteratee, height uint64) database.Iterator {
return db.NewIteratorWithStartAndPrefix(
makeBlockKey(height),
blockPrefix,
)
}

func GetBlock(db database.KeyValueReader, height uint64) ([]byte, error) {
return db.Get(makeBlockKey(height))
}
Expand Down
41 changes: 27 additions & 14 deletions snow/engine/snowman/bootstrap/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ func execute(
log("compacting database before executing blocks...")
if err := db.Compact(nil, nil); err != nil {
// Not a fatal error, log and move on.
log("failed to compact bootstrap database before executing blocks", zap.Error(err))
log("failed to compact bootstrap database before executing blocks",
zap.Error(err),
)
}
}

Expand Down Expand Up @@ -167,6 +169,25 @@ func execute(
)
defer func() {
iterator.Release()

halted := haltable.Halted()
if !halted {
log("compacting database after executing blocks...")
if err := db.Compact(nil, nil); err != nil {
// Not a fatal error, log and move on.
log("failed to compact bootstrap database after executing blocks",
zap.Error(err),
)
}
}

numProcessed := totalNumberToProcess - tree.Len()
log("executed blocks",
zap.Uint64("numExecuted", numProcessed),
zap.Uint64("numToExecute", totalNumberToProcess),
zap.Bool("halted", halted),
zap.Duration("duration", time.Since(startTime)),
)
}()

log("executing blocks",
Expand Down Expand Up @@ -208,7 +229,10 @@ func execute(

processedSinceIteratorRelease = 0
iterator.Release()
iterator = interval.GetBlockIterator(db)
// We specify the starting key of the iterator so that the
// underlying database doesn't need to scan over the, potentially
// not yet compacted, blocks we just deleted.
iterator = interval.GetBlockIteratorWithStart(db, height+1)
}

if now := time.Now(); now.After(timeOfNextLog) {
Expand Down Expand Up @@ -248,16 +272,5 @@ func execute(
if err := writeBatch(); err != nil {
return err
}
if err := iterator.Error(); err != nil {
return err
}

numProcessed := totalNumberToProcess - tree.Len()
log("executed blocks",
zap.Uint64("numExecuted", numProcessed),
zap.Uint64("numToExecute", totalNumberToProcess),
zap.Bool("halted", haltable.Halted()),
zap.Duration("duration", time.Since(startTime)),
)
return nil
return iterator.Error()
}

0 comments on commit 684040c

Please sign in to comment.