Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tmpnet] Minimize duration of tx acceptance for e2e testing #3685

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

maru-ava
Copy link
Contributor

Why this should be merged

Faster tests mean faster iteration

How this works

  • 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

How this was tested

CI against regression, manually verified decreased runtime

Need to be documented in RELEASES.md?

New node flag should be documented.

@maru-ava maru-ava added the testing This primarily focuses on testing label Jan 30, 2025
@maru-ava maru-ava self-assigned this Jan 30, 2025
@maru-ava maru-ava force-pushed the tmpnet-minimize-tx-acceptance-duration branch from d55ad5a to 021ba8f Compare January 30, 2025 00:14
@maru-ava maru-ava marked this pull request as draft January 30, 2025 00:51
@maru-ava maru-ava force-pushed the tmpnet-minimize-tx-acceptance-duration branch from 021ba8f to 6d51c62 Compare January 30, 2025 02:46
@maru-ava maru-ava marked this pull request as ready for review January 30, 2025 02:47
Copy link
Contributor

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What's the overall time saved?
  2. Reduce the wallet poll interval from 100ms to 10ms - just as a word of warning, getting close to millisecond in tests can be risky on CI running on shared/slow runners, and produce flaky tests, just because the runner is slow and things take milliseconds to execute... think Pentium 4 running CI 😄

@@ -76,3 +78,11 @@ func DefaultChainConfigs() map[string]FlagsMap {
},
}
}

// A set of subnet configuration appropriate for testing.
func DefaultSubnetConfig() FlagsMap {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is only used in this package, can we unexport it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tmpnet is used by other repos - including subnet-evm and hypersdk - and the intention is for reuse.

@maru-ava
Copy link
Contributor Author

maru-ava commented Jan 30, 2025

  1. What's the overall time saved?

I wasn't too concerned with total time saved. The goal was speeding up perceived execution speed when running interactively iterating. It is noticeably faster even without timing.

For a given transaction, a min block delay of 1s ensures that a set of sequentially executed transactions (as is commonly done in a test that uses a single wallet) take a minimum of 1s per transaction. In Stephen's example PR with a polling interval of 1ms, tx acceptance could approach that lower bound. I considered 1ms potentially problematic in the context of CI, though, so bumped the interval to 10ms. Going from a minimum of 1s to a minimum of 10ms is a pretty nice speedup!

  1. Reduce the wallet poll interval from 100ms to 10ms - just as a word of warning, getting close to millisecond in tests can be risky on CI running on shared/slow runners, and produce flaky tests, just because the runner is slow and things take milliseconds to execute... think Pentium 4 running CI 😄

Sure, that's why I didn't go all the way down to 1ms. If its flakey, we'll adjust it.

@maru-ava maru-ava force-pushed the tmpnet-minimize-tx-acceptance-duration branch from 6d51c62 to a392bdb Compare January 30, 2025 18:33
config/config.go Outdated
@@ -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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes some weirdness in the defaults.

  1. The default value of ProposerMinBlockDelay for all subnets is currently proposervm.DefaultMinBlockDelay.
  2. With this change, the default value for subnets that do not specify a custom subnet config is still proposervm.DefaultMinBlockDelay.
  3. With this change, the default value for subnets that do specify a custom subnet config is equal to --proposer-min-block-delay.

I think (2) and (3) should be unified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated loading of subnet config to set the default subnet config if one is not provided. PTAL

config/keys.go Outdated
@@ -208,4 +208,5 @@ const (
TracingExporterTypeKey = "tracing-exporter-type"
TracingHeadersKey = "tracing-headers"
ProcessContextFileKey = "process-context-file"
ProposerMinBlockDelayKey = "proposer-min-block-delay"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include this in RELEASES.md (and maybe in config.md as well?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to config.md. How to add it to RELEASES?

config/keys.go Outdated
@@ -208,4 +208,5 @@ const (
TracingExporterTypeKey = "tracing-exporter-type"
TracingHeadersKey = "tracing-headers"
ProcessContextFileKey = "process-context-file"
ProposerMinBlockDelayKey = "proposer-min-block-delay"
Copy link
Contributor

@StephenButtolph StephenButtolph Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wondering, if this is only supposed to impact the primary network, if we should name it something like --primary-network-min-block-delay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to rename it to --promposevm-min-block-delay or is --proposer-min-block-delay prefereable?

@maru-ava maru-ava force-pushed the tmpnet-minimize-tx-acceptance-duration branch from 5234800 to 579d425 Compare February 4, 2025 05:17
@maru-ava maru-ava force-pushed the tmpnet-minimize-tx-acceptance-duration branch from a2ee6c0 to 0e05126 Compare February 17, 2025 12:57
@@ -1054,8 +1054,9 @@ func getSubnetConfigsFromFlags(v *viper.Viper, subnetIDs []ids.ID) (map[ids.ID]s

res := make(map[ids.ID]subnets.Config)
for _, subnetID := range subnetIDs {
config := getDefaultSubnetConfig(v)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so here we guarantee that for each tracked subnetID we start with the default and override as provided.

@@ -1090,11 +1091,14 @@ func getSubnetConfigsFromDir(v *viper.Viper, subnetIDs []ids.ID) (map[ids.ID]sub

// reads subnet config files from a path and given subnetIDs and returns a map.
for _, subnetID := range subnetIDs {
config := getDefaultSubnetConfig(v)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment added to chains/manager.go implies that we now require a default config is present for each subnetID that we're tracking. Do we need to guarantee that here as well? It seems that if subnetConfigPath is empty, then we'll exit before getting to this point and may not guarantee that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this actually can't cause a problem because there are two behaviors:

  • use the default path where this will be non-empty and therefore not exit early
  • use a non-default path, where it will then check that the directory exists, which will cause an error if the subnetConfigPath is in fact an empty string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible to supply an empty non-default path, so I think it will be necessary to ensure default values in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 477 to 483
"subnet is not tracked": {
givenJSON: `{"Gmt4fuNsGJAd2PX86LBvycGaBpgCYKbuULdCLZs3SEs1Jx1LU":{"validatorOnly":true}}`,
testF: func(require *require.Assertions, given map[ids.ID]subnets.Config) {
require.Empty(given)
},
expectedErr: nil,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep this test as it's still relevant and should produce the same result as the new case default config used when no config provided ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- 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
@maru-ava maru-ava force-pushed the tmpnet-minimize-tx-acceptance-duration branch from 0e05126 to 63c9c73 Compare February 24, 2025 20:35
@maru-ava maru-ava force-pushed the tmpnet-minimize-tx-acceptance-duration branch from 63c9c73 to 10da3ee Compare February 24, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing This primarily focuses on testing
Projects
Status: In Review 👀
Development

Successfully merging this pull request may close these issues.

None yet

5 participants