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

chore(lib/grandpa): make interval configurable #1903

Merged
merged 10 commits into from
Nov 4, 2021

Conversation

zhuber6
Copy link
Contributor

@zhuber6 zhuber6 commented Oct 16, 2021

Changes

  • Updated all files related to reading toml config and default config to handle GrandpaInterval.
  • Updated GRANDPA to use configurable interval via config file.

Tests

go test -short ./lib/grandpa
go test ./cmd/gossamer

Issues

Fixes #1869

Primary Reviewer

@noot

@CLAassistant
Copy link

CLAassistant commented Oct 16, 2021

CLA assistant check
All committers have signed the CLA.

@@ -85,6 +85,9 @@ var (
// DefaultDiscoveryInterval is the default interval for searching for DHT peers
DefaultDiscoveryInterval = time.Second * 10

// DefaultGrandpaInterval
Copy link
Contributor

Choose a reason for hiding this comment

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

// DefaultGrandpaInterval ...

Copy link
Contributor

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

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 this in there. Still working on understanding all of the polkadot pieces...

@@ -390,6 +390,7 @@ func TestNetworkConfigFromFlags(t *testing.T) {
NoBootstrap: testCfg.Network.NoBootstrap,
NoMDNS: testCfg.Network.NoMDNS,
DiscoveryInterval: time.Second * 10,
GrandpaInterval: time.Second,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@@ -30,6 +30,7 @@ port = 7001
nobootstrap = false
nomdns = false
discovery-interval = 10
grandpa-interval = 1
Copy link
Contributor

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?

Comment on lines 634 to 638
if tomlCfg.GrandpaInterval > 0 {
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval)
} else {
cfg.GrandpaInterval = 0
}
Copy link
Contributor

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

@@ -631,6 +631,12 @@ func setDotNetworkConfig(ctx *cli.Context, tomlCfg ctoml.NetworkConfig, cfg *dot
cfg.DiscoveryInterval = 0
Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Contributor

@noot noot left a 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.

chain/gssmr/config.toml Outdated Show resolved Hide resolved
Comment on lines 634 to 638
if tomlCfg.GrandpaInterval > 0 {
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval)
} else {
cfg.GrandpaInterval = 0
}
Copy link
Contributor

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:

Suggested change
if tomlCfg.GrandpaInterval > 0 {
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval)
} else {
cfg.GrandpaInterval = 0
}
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval)

lib/grandpa/grandpa.go Show resolved Hide resolved
cmd/gossamer/config.go Show resolved Hide resolved
@@ -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"`
Copy link
Contributor

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 🤔

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 am assuming that it cannot be negative so I can just store it as that instead of an int.

Copy link
Member

@EclesioMeloJunior EclesioMeloJunior left a comment

Choose a reason for hiding this comment

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

lgtm

@noot
Copy link
Contributor

noot commented Oct 25, 2021

@zjhuber could you fix the merge conflicts when possible? can merge this right after :)

@zhuber6
Copy link
Contributor Author

zhuber6 commented Oct 25, 2021

@noot just resolved conflicts, this should be good to merge. Apologies for the delay.

@codecov
Copy link

codecov bot commented Oct 25, 2021

Codecov Report

Merging #1903 (0e72a6f) into development (cd27ae4) will decrease coverage by 0.02%.
The diff coverage is 84.61%.

Impacted file tree graph

@@               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     
Flag Coverage Δ
unit-tests 60.26% <84.61%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/grandpa/grandpa.go 59.64% <71.42%> (+0.19%) ⬆️
cmd/gossamer/config.go 73.97% <100.00%> (-0.06%) ⬇️
cmd/gossamer/export.go 85.07% <100.00%> (+0.22%) ⬆️
dot/config.go 27.36% <100.00%> (+0.38%) ⬆️
dot/services.go 71.54% <100.00%> (+0.11%) ⬆️
dot/telemetry/telemetry.go 67.21% <0.00%> (-6.56%) ⬇️
dot/core/service.go 52.91% <0.00%> (-0.78%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd27ae4...0e72a6f. Read the comment docs.

@noot
Copy link
Contributor

noot commented Oct 25, 2021

@zjhuber no problem at all! thank you :D

@noot
Copy link
Contributor

noot commented Oct 27, 2021

@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 defaultInterval = 1s if it's zero?

@zhuber6
Copy link
Contributor Author

zhuber6 commented Oct 29, 2021

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.

@noot
Copy link
Contributor

noot commented Nov 3, 2021

@zjhuber thanks so much! will merge this in :)

@noot noot merged commit dc89892 into ChainSafe:development Nov 4, 2021
@github-actions
Copy link

github-actions bot commented Dec 3, 2021

🎉 This PR is included in version 0.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

timwu20 pushed a commit to timwu20/gossamer that referenced this pull request Dec 6, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lib/grandpa: make interval configurable
6 participants