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

Exp timeout #764

Open
wants to merge 5 commits into
base: dev-upgrade
Choose a base branch
from
Open

Exp timeout #764

wants to merge 5 commits into from

Conversation

wgr523
Copy link
Collaborator

@wgr523 wgr523 commented Dec 17, 2024

Proposed changes

Exp timeout inside consensus timeout countdown

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

@wgr523 wgr523 changed the title [WIP] Exp timeout Exp timeout Dec 23, 2024
@benjamin202410
Copy link
Collaborator

  1. I would recommend remove the constTimeout entirely to make code clean. We can utilize base and MaxExponent=1 to have same feature.
  2. Use interface type to compatible 2 different functions are easy but it strongly lose the strong type restriction. Not recommend to use unless its necessary

case <-t.resetc:
log.Debug("Reset countdown timer")
timer.Reset(t.timeoutDuration)
timer.Reset(t.durationHelper.GetTimeoutDuration(inputs...))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The timer should be stopped before Reset:

	if !timer.Stop() {
		<-timer.C
	}
	timer.Reset(d)

quitc chan chan struct{}
initilised bool
timeoutDuration time.Duration
lock sync.RWMutex // Protects the Initilised field
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use atomic.Bool instead of sync.RWMutex ?

func (d *ExpTimeoutDuration) sanityCheck() {
if d.max_exponent >= max_exponent_upperbound {
log.Error("max_exponent (e)= >= max_exponent_upperbound (e_upper)", "e", d.max_exponent, "e_upper", max_exponent_upperbound)
panic("max_exponent (e)= >= max_exponent_upperbound (e_upper)")
Copy link
Collaborator

@gzliudan gzliudan Dec 28, 2024

Choose a reason for hiding this comment

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

log.Crit can be used here instead of log.Error and panic. But I don't think it's a good idea to call log function in the common package.

@gzliudan
Copy link
Collaborator

I notice that countdown is only used by consensus/XDPoS/engines/engine_v2. Maybe we should move it to other place.

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.

3 participants