Skip to content

Commit

Permalink
[tmpnet] Minimize duration of tx acceptance for e2e testing
Browse files Browse the repository at this point in the history
- Enable configuration of min block delay for primary subnet with
  the addition of node flag `--proposer-min-block-delay`
- Configure tmpnet to default the block delay to zero for all subnets
- Reduce the wallet poll interval from 100ms to 10ms
- Remove unnecessary sleep in virtuous test
  • Loading branch information
maru-ava committed Jan 30, 2025
1 parent e1430e6 commit b2c02b0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ func getDefaultSubnetConfig(v *viper.Viper) subnets.Config {
return subnets.Config{
ConsensusParameters: getConsensusConfig(v),
ValidatorOnly: false,
ProposerMinBlockDelay: proposervm.DefaultMinBlockDelay,
ProposerMinBlockDelay: v.GetDuration(ProposerMinBlockDelayKey),
ProposerNumHistoricalBlocks: proposervm.DefaultNumHistoricalBlocks,
}
}
Expand Down
4 changes: 4 additions & 0 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/ava-labs/avalanchego/utils/ulimit"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/proposervm"
)

const (
Expand Down Expand Up @@ -384,6 +385,9 @@ func addNodeFlags(fs *pflag.FlagSet) {
fs.StringToString(TracingHeadersKey, map[string]string{}, "The headers to provide the trace indexer")

fs.String(ProcessContextFileKey, defaultProcessContextPath, "The path to write process context to (including PID, API URI, and staking address).")

// Primary Subnet Config
fs.Duration(ProposerMinBlockDelayKey, proposervm.DefaultMinBlockDelay, "Minimum delay to enforce when building a snowman++ block for the primary subnet")
}

// BuildFlagSet returns a complete set of flags for avalanchego
Expand Down
1 change: 1 addition & 0 deletions config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,5 @@ const (
TracingExporterTypeKey = "tracing-exporter-type"
TracingHeadersKey = "tracing-headers"
ProcessContextFileKey = "process-context-file"
ProposerMinBlockDelayKey = "proposer-min-block-delay"
)
1 change: 0 additions & 1 deletion tests/e2e/x/transfer/virtuous.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() {

for i := 0; i < totalRounds; i++ {
runFunc(i)
time.Sleep(time.Second)
}

_ = e2e.CheckBootstrapIsPossible(tc, env.GetNetwork())
Expand Down
2 changes: 2 additions & 0 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmp
)
},
),
// Reducing the default from 100ms speeds up detection of tx acceptance
common.WithPollFrequency(10*time.Millisecond),
)
OutputWalletBalances(tc, wallet)
return wallet
Expand Down
11 changes: 11 additions & 0 deletions tests/fixture/tmpnet/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const (
// A short minimum stake duration enables testing of staking logic.
DefaultMinStakeDuration = time.Second

// Reducing this from the 1s default speeds up tx acceptance
DefaultProposerMinBlockDelay = 0 * time.Second

defaultConfigFilename = "config.json"
)

Expand Down Expand Up @@ -59,6 +62,7 @@ func DefaultTmpnetFlags() FlagsMap {
// Specific to e2e testing
config.MinStakeDurationKey: DefaultMinStakeDuration.String(),
config.ProposerVMUseCurrentHeightKey: true,
config.ProposerMinBlockDelayKey: DefaultProposerMinBlockDelay,
}
flags.SetDefaults(DefaultTestFlags())
return flags
Expand All @@ -76,3 +80,10 @@ func DefaultChainConfigs() map[string]FlagsMap {
},
}
}

// A set of subnet configuration appropriate for testing.
func DefaultSubnetConfig() FlagsMap {
return FlagsMap{
"proposerMinBlockDelay": DefaultProposerMinBlockDelay,
}
}
6 changes: 6 additions & 0 deletions tests/fixture/tmpnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,12 @@ func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiURI
zap.String("name", subnet.Name),
)

// Apply tmpnet defaults
if subnet.Config == nil {
subnet.Config = FlagsMap{}
}
subnet.Config.SetDefaults(DefaultSubnetConfig())

if subnet.OwningKey == nil {
// Allocate a pre-funded key and remove it from the network so it won't be used for
// other purposes
Expand Down

0 comments on commit b2c02b0

Please sign in to comment.