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

Merged
merged 9 commits into from
Jan 19, 2025
Merged

Exp timeout #764

merged 9 commits into from
Jan 19, 2025

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 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe in future

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.

@wgr523
Copy link
Collaborator Author

wgr523 commented Jan 6, 2025

  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

yes. pushed the changes, please review

Copy link
Collaborator

@benjamin202410 benjamin202410 left a comment

Choose a reason for hiding this comment

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

I think you need to add config for all envs

@wgr523
Copy link
Collaborator Author

wgr523 commented Jan 12, 2025

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

maybe we will do it in another PR

@wgr523 wgr523 merged commit 537dc5e into dev-upgrade Jan 19, 2025
26 checks passed
JukLee0ira pushed a commit to JukLee0ira/XDPoSChain that referenced this pull request Jan 20, 2025
* feat: write duration calculation in countdown as
interface. add more inputs as function argument

* feat: ExpTimeoutDuration

* fix: three dots usage

* feat: refine exp duration

* feat: add exp timeout config and use it in countdown

* feat: remove const countdown

* feat: remove use of interface in countdown, use error

* fix: countdown reset timer problem

* fix: add default ExpTimeoutConfig for config
JukLee0ira pushed a commit to JukLee0ira/XDPoSChain that referenced this pull request Jan 20, 2025
* feat: write duration calculation in countdown as
interface. add more inputs as function argument

* feat: ExpTimeoutDuration

* fix: three dots usage

* feat: refine exp duration

* feat: add exp timeout config and use it in countdown

* feat: remove const countdown

* feat: remove use of interface in countdown, use error

* fix: countdown reset timer problem

* fix: add default ExpTimeoutConfig for config
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