Skip to content

Commit

Permalink
Merge branch 'fix_adjust_excess' into ontake_test
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 committed Aug 9, 2024
2 parents 2d2cfb7 + f1d3ee8 commit 7610e05
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages/bridge-ui": "2.12.0",
"packages/docs-site": "1.11.7",
"packages/docs-site": "1.11.8",
"packages/eventindexer": "0.13.0",
"packages/fork-diff": "0.6.0",
"packages/guardian-prover-health-check": "0.1.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/docs-site/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.11.8](https://github.com/taikoxyz/taiko-mono/compare/docs-site-v1.11.7...docs-site-v1.11.8) (2024-08-08)


### Documentation

* **docs-site:** add more node troubleshooting ([#17872](https://github.com/taikoxyz/taiko-mono/issues/17872)) ([9c31ffc](https://github.com/taikoxyz/taiko-mono/commit/9c31ffc58b36a07286606e8e289504f49301d4df))

## [1.11.7](https://github.com/taikoxyz/taiko-mono/compare/docs-site-v1.11.6...docs-site-v1.11.7) (2024-07-20)


Expand Down
2 changes: 1 addition & 1 deletion packages/docs-site/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docs-site",
"type": "module",
"version": "1.11.7",
"version": "1.11.8",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
Expand Down
9 changes: 8 additions & 1 deletion packages/protocol/contracts/L2/Lib1559Math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ library Lib1559Math {
int256 lnRatio = FixedPointMathLib.lnWad(int256(ratio)); // may be negative

uint256 newGasExcess;

assembly {
newGasExcess := sdiv(add(mul(lnRatio, _newGasTarget), mul(ratio, _gasExcess)), f)
// x = (_newGasTarget * lnRatio + _gasExcess * ratio)
let x := add(mul(_newGasTarget, lnRatio), mul(_gasExcess, ratio))

// If x < 0, set newGasExcess to 0, otherwise calculate newGasExcess = x / f
switch slt(x, 0)
case 1 { newGasExcess := 0 }
default { newGasExcess := div(x, f) }
}

return uint64(newGasExcess.min(type(uint64).max));
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ contract TaikoL2 is EssentialContract {

if (block.number == 0) {
// This is the case in real L2 genesis
} else if (block.number == 1) {
}
else if (block.number == 1) {
// This is the case in tests
uint256 parentHeight = block.number - 1;
l2Hashes[parentHeight] = blockhash(parentHeight);
Expand Down
19 changes: 19 additions & 0 deletions packages/protocol/test/L2/Lib1559Math.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,23 @@ contract TestLib1559Math is TaikoTest {
assertEq(baselineBasefee, basefee);
}
}

function test_change_of_quotient_and_gips2() public {
uint64 excess = 1;
uint64 target = 60_000_000 * 8;
uint256 unit = 10_000_000; // 0.01 gwei

// uint 0.01 gwei
uint256 baselineBasefee = Lib1559Math.basefee(excess, target) / unit;
console2.log("baseline basefee: ", baselineBasefee);

console2.log("maintain basefee when target changes");
uint64 newTarget = 5_000_000 * 8;
uint64 newExcess = Lib1559Math.adjustExcess(excess, target, newTarget);
uint256 basefee = Lib1559Math.basefee(newExcess, newTarget) / unit;
console2.log("old gas excess: ", excess);
console2.log("new gas excess: ", newExcess);
console2.log("basefee: ", basefee);
assertEq(baselineBasefee, basefee);
}
}

0 comments on commit 7610e05

Please sign in to comment.