diff --git a/node/node.go b/node/node.go index fff8e13572cb..3138f00c1c38 100644 --- a/node/node.go +++ b/node/node.go @@ -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" @@ -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), diff --git a/scripts/build_antithesis_images.sh b/scripts/build_antithesis_images.sh index 8e3c534bbcbe..8e49d1bcb700 100755 --- a/scripts/build_antithesis_images.sh +++ b/scripts/build_antithesis_images.sh @@ -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. diff --git a/snow/README.md b/snow/README.md index 86a90919b2ac..99cfc5351356 100644 --- a/snow/README.md +++ b/snow/README.md @@ -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. diff --git a/snow/engine/snowman/bootstrap/interval/state.go b/snow/engine/snowman/bootstrap/interval/state.go index cf2e2bf3a2ef..8ba06824eea2 100644 --- a/snow/engine/snowman/bootstrap/interval/state.go +++ b/snow/engine/snowman/bootstrap/interval/state.go @@ -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)) } diff --git a/snow/engine/snowman/bootstrap/storage.go b/snow/engine/snowman/bootstrap/storage.go index b70330218439..53c2e735a572 100644 --- a/snow/engine/snowman/bootstrap/storage.go +++ b/snow/engine/snowman/bootstrap/storage.go @@ -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), + ) } } @@ -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", @@ -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) { @@ -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() }