-
Notifications
You must be signed in to change notification settings - Fork 112
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
chore(lib/grandpa): make interval configurable #1903
Conversation
chain/gssmr/defaults.go
Outdated
@@ -85,6 +85,9 @@ var ( | |||
// DefaultDiscoveryInterval is the default interval for searching for DHT peers | |||
DefaultDiscoveryInterval = time.Second * 10 | |||
|
|||
// DefaultGrandpaInterval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// DefaultGrandpaInterval ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I'd mention that this is the time for a grandpa sub-round
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this in there. Still working on understanding all of the polkadot pieces...
cmd/gossamer/config_test.go
Outdated
@@ -390,6 +390,7 @@ func TestNetworkConfigFromFlags(t *testing.T) { | |||
NoBootstrap: testCfg.Network.NoBootstrap, | |||
NoMDNS: testCfg.Network.NoMDNS, | |||
DiscoveryInterval: time.Second * 10, | |||
GrandpaInterval: time.Second, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this value be replaced with testCfg.Network.GrandpaInterval
?
If so then do it at other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I have updated this.
chain/gssmr/config.toml
Outdated
@@ -30,6 +30,7 @@ port = 7001 | |||
nobootstrap = false | |||
nomdns = false | |||
discovery-interval = 10 | |||
grandpa-interval = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you put this under core
instead of network
, as it's consensus related?
cmd/gossamer/config.go
Outdated
if tomlCfg.GrandpaInterval > 0 { | ||
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval) | ||
} else { | ||
cfg.GrandpaInterval = 0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, please move to core
config
cmd/gossamer/config.go
Outdated
@@ -631,6 +631,12 @@ func setDotNetworkConfig(ctx *cli.Context, tomlCfg ctoml.NetworkConfig, cfg *dot | |||
cfg.DiscoveryInterval = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be set to the default value if it's not set
@@ -166,6 +167,7 @@ func NewService(cfg *Config) (*Service, error) { | |||
resumed: make(chan struct{}), | |||
network: cfg.Network, | |||
finalisedCh: finalisedCh, | |||
interval: cfg.Interval, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a check in this function that will error if cfg.Interval == 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the contribution! overall looks good, just a few suggestions.
cmd/gossamer/config.go
Outdated
if tomlCfg.GrandpaInterval > 0 { | ||
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval) | ||
} else { | ||
cfg.GrandpaInterval = 0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless tomlCfg.GrandpaInterval
can be negative, I think we can simplify to:
if tomlCfg.GrandpaInterval > 0 { | |
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval) | |
} else { | |
cfg.GrandpaInterval = 0 | |
} | |
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval) |
@@ -83,6 +82,7 @@ type CoreConfig struct { | |||
SlotDuration uint64 `toml:"slot-duration,omitempty"` | |||
EpochLength uint64 `toml:"epoch-length,omitempty"` | |||
WasmInterpreter string `toml:"wasm-interpreter,omitempty"` | |||
GrandpaInterval uint32 `toml:"grandpa-interval,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we have it as uint32
? I guess that's fine given it's 1
, I'm just wondering 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming that it cannot be negative so I can just store it as that instead of an int
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@zjhuber could you fix the merge conflicts when possible? can merge this right after :) |
@noot just resolved conflicts, this should be good to merge. Apologies for the delay. |
Codecov Report
@@ Coverage Diff @@
## development #1903 +/- ##
===============================================
- Coverage 60.28% 60.26% -0.03%
===============================================
Files 180 180
Lines 18198 18203 +5
===============================================
- Hits 10971 10970 -1
- Misses 5415 5419 +4
- Partials 1812 1814 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@zjhuber no problem at all! thank you :D |
@zjhuber it seems that some of the integration tests are failing due to the interval being zero, could you add something that sets the interval to some |
My bad, I didn't run those tests and missed that. I believe I just fixed the issue in the test. I wasn't able to run the polkadotjs because of some errors I was getting, probably local config issues. But I did see the same issue you were seeing and I believe it is taken care of now. |
@zjhuber thanks so much! will merge this in :) |
🎉 This PR is included in version 0.6.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
* chore(lib/grandpa): make interval configurable * Resolved teams concerns * Fixed integration test Co-authored-by: noot <36753753+noot@users.noreply.github.com> Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
Changes
GrandpaInterval
.Tests
go test -short ./lib/grandpa
go test ./cmd/gossamer
Issues
Fixes #1869
Primary Reviewer
@noot