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

Acp 176 config #1462

Draft
wants to merge 1 commit into
base: acp-176
Choose a base branch
from
Draft
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
16 changes: 8 additions & 8 deletions plugin/evm/upgrade/acp176/acp176.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@
)

type Config struct {
MinGasPrice gas.Price // M
MinTargetPerSecond uint64 // P
MinGasPrice gas.Price // M
TargetToMax uint64 // multiplier to convert from target per second to max per second
TimeToFillCapacity uint64 // in seconds
TargetToPriceUpdateConversion uint64
}

const (
MinTargetPerSecond = 1_000_000 // P
MaxTargetExcessDiff = 1 << 15 // Q
TargetConversion = MaxTargetChangeRate * MaxTargetExcessDiff // D
MaxTargetExcessDiff = 2 ^ 15 // Q

TimeToFillCapacity = 10 // in seconds
TargetToMax = 2 // multiplier to convert from target per second to max per second
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does 2 here control doubling the price? I.e does 3 here means triple it?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the ratio between R and T, in variables from the ACP. In other words, we add twice as much gas to the bucket as is our target. This also defines our "sustained maximum capacity", so that with sustained 2 * T sized blocks, we increase x by T * dt every block, so the fee will double every 60s. You can think of this as our excess gas over target. So I think that if you change this ratio to something else (say 3), then we get sustained higher excess (like 2 * T * dt), so then this change will actually half the time to double. However, It's important to note that this is because this the time for the fee to double is linear in this "sustained excess gas", not the "sustained gas".

TargetToPriceUpdateConversion = 87 // 87s ~= 60s * ln(2) which makes the price double at most every ~60 seconds
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder if the calculation here made by using TargetToMax if so we need to factor out 60s as a separate parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know Stephen thought about it, but the more intuitive parameter is this ratio between K and T, that produces the 60s doubling time. Note that the comment is actually backwards (since that equation is clearly not true).

Copy link
Contributor

Choose a reason for hiding this comment

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

Relating to my comment above, this equation (as a function of this ratio and TargetToMax, would look like this:
DoublingTime = TargetToPriceUpdateConversion * ln(2) / (TargetToMax - 1)

MaxTargetChangeRate = 1024 // Controls the rate that the target can change per block.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is something we cannot parameterize because EVM also imposes the same limit.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is something we can parameterize

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

MaxTargetChangeRate = 1024 // Controls the rate that the target can change per block.

TargetToMaxCapacity = TargetToMax * TimeToFillCapacity

Check failure on line 34 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-latest)

undefined: TargetToMax

Check failure on line 34 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-latest)

undefined: TimeToFillCapacity

Check failure on line 34 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-latest)

undefined: TargetToMax

Check failure on line 34 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-latest)

undefined: TimeToFillCapacity

Check failure on line 34 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (windows-latest)

undefined: TargetToMax

Check failure on line 34 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (windows-latest)

undefined: TimeToFillCapacity
MinMaxPerSecond = MinTargetPerSecond * TargetToMax

Check failure on line 35 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-latest)

undefined: MinTargetPerSecond

Check failure on line 35 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-latest)

undefined: TargetToMax

Check failure on line 35 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-latest)

undefined: MinTargetPerSecond

Check failure on line 35 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-latest)

undefined: TargetToMax

Check failure on line 35 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (windows-latest)

undefined: MinTargetPerSecond

Check failure on line 35 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (windows-latest)

undefined: TargetToMax
MinMaxCapacity = MinMaxPerSecond * TimeToFillCapacity

Check failure on line 36 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (macos-latest)

undefined: TimeToFillCapacity

Check failure on line 36 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (ubuntu-latest)

undefined: TimeToFillCapacity

Check failure on line 36 in plugin/evm/upgrade/acp176/acp176.go

View workflow job for this annotation

GitHub Actions / Golang Unit Tests (windows-latest)

undefined: TimeToFillCapacity

maxTargetExcess = 1_024_950_627 // TargetConversion * ln(MaxUint64 / MinTargetPerSecond) + 1
// maxTargetExcess = 1_024_950_627 // TargetConversion * ln(MaxUint64 / MinTargetPerSecond) + 1
)

// State represents the current state of the gas pricing and constraints.
Expand Down
Loading