Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vms/evm/acp226/acp226.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const (
// MaxDelayExcessDiff (Q) is the maximum change in excess per update
MaxDelayExcessDiff = 200

// InitialDelayExcess represents the initial (≈2000ms) delay excess.
// Formula: ConversionRate (2^20) * ln(2000) + 1
InitialDelayExcess = 7_970_124
Copy link
Contributor

@joshua-kim joshua-kim Sep 19, 2025

Choose a reason for hiding this comment

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

These feel like magic numbers even though we use a godoc to document them... could we define these through calculation in code? i.e

const conversionRate = 1 << 20 // 2^20 fixed-point scale

var InitialDelayExcess = int(float64(conversionRate)*math.Log(2000)) + 1

Copy link
Contributor

Choose a reason for hiding this comment

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

These values are consensus critical, so I don't think it is reasonable to perform floating point operations to generate them. (The actual number is more important than the mechanism used to derive them)

Copy link
Contributor Author

@ceyonur ceyonur Sep 19, 2025

Choose a reason for hiding this comment

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

(same reason as what Stephen posted above while I writing this)
I think that would actually end up what we try to avoid with binary search. I think math.Log precision can differ from machine to machine and end-up having different initial values.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we need to make this configurable by minimum delay setting in the future, an approach @StephenButtolph recommended to me for ACP-224 is to use some rational approximation for ln(x), but that would basically be a magic number itself here anyways.


maxDelayExcess = 46_516_320 // ConversionRate * ln(MaxUint64 / MinDelayMilliseconds) + 1
)

Expand Down
4 changes: 2 additions & 2 deletions vms/evm/acp226/acp226_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ var (
delay: 1000,
},
{
name: "2000ms_delay",
excess: 7_970_124, // ConversionRate (2^20) * ln(2000) + 1
name: "2000ms_delay_initial",
excess: InitialDelayExcess, // ConversionRate (2^20) * ln(2000) + 1
delay: 2000,
},
{
Expand Down