Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
8762e9a0
Unverified
Commit
8762e9a0
authored
Feb 28, 2023
by
mergify[bot]
Committed by
GitHub
Feb 28, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into willc/atst-final
parents
6d6e407d
904b2c5e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
50 deletions
+111
-50
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+38
-36
ResourceMetering.sol
packages/contracts-bedrock/contracts/L1/ResourceMetering.sol
+14
-14
ResolvedDelegateProxy.t.sol
...tracts-bedrock/contracts/test/ResolvedDelegateProxy.t.sol
+59
-0
No files found.
packages/contracts-bedrock/.gas-snapshot
View file @
8762e9a0
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/contracts/L1/ResourceMetering.sol
View file @
8762e9a0
...
...
@@ -96,11 +96,11 @@ abstract contract ResourceMetering is Initializable {
// Update base fee by adding the base fee delta and clamp the resulting value between
// min and max.
int256 newBaseFee = Arithmetic.clamp(
int256(uint256(params.prevBaseFee)) + baseFeeDelta,
MINIMUM_BASE_FEE,
MAXIMUM_BASE_FEE
);
int256 newBaseFee = Arithmetic.clamp(
{
_value:
int256(uint256(params.prevBaseFee)) + baseFeeDelta,
_min:
MINIMUM_BASE_FEE,
_max:
MAXIMUM_BASE_FEE
}
);
// If we skipped more than one block, we also need to account for every empty block.
// Empty block means there was no demand for deposits in that block, so we should
...
...
@@ -109,15 +109,15 @@ abstract contract ResourceMetering is Initializable {
// Update the base fee by repeatedly applying the exponent 1-(1/change_denominator)
// blockDiff - 1 times. Simulates multiple empty blocks. Clamp the resulting value
// between min and max.
newBaseFee = Arithmetic.clamp(
Arithmetic.cdexp(
newBaseFee,
BASE_FEE_MAX_CHANGE_DENOMINATOR,
int256(blockDiff - 1)
),
MINIMUM_BASE_FEE,
MAXIMUM_BASE_FEE
);
newBaseFee = Arithmetic.clamp(
{
_value: Arithmetic.cdexp({
_coefficient:
newBaseFee,
_denominator:
BASE_FEE_MAX_CHANGE_DENOMINATOR,
_exponent:
int256(blockDiff - 1)
}
),
_min:
MINIMUM_BASE_FEE,
_max:
MAXIMUM_BASE_FEE
}
);
}
// Update new base fee, reset bought gas, and update block number.
...
...
packages/contracts-bedrock/contracts/test/ResolvedDelegateProxy.t.sol
0 → 100644
View file @
8762e9a0
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { AddressManager } from "../legacy/AddressManager.sol";
import { ResolvedDelegateProxy } from "../legacy/ResolvedDelegateProxy.sol";
contract ResolvedDelegateProxy_Test is Test {
AddressManager internal addressManager;
SimpleImplementation internal impl;
SimpleImplementation internal proxy;
function setUp() public {
// Set up the address manager.
addressManager = new AddressManager();
impl = new SimpleImplementation();
addressManager.setAddress("SimpleImplementation", address(impl));
// Set up the proxy.
proxy = SimpleImplementation(
address(new ResolvedDelegateProxy(addressManager, "SimpleImplementation"))
);
}
// Tests that the proxy properly bubbles up returndata when the delegatecall succeeds.
function testFuzz_fallback_delegateCallFoo_succeeds(uint256 x) public {
vm.expectCall(address(impl), abi.encodeWithSelector(impl.foo.selector, x));
assertEq(proxy.foo(x), x);
}
// Tests that the proxy properly bubbles up returndata when the delegatecall reverts.
function test_fallback_delegateCallBar_reverts() public {
vm.expectRevert("SimpleImplementation: revert");
vm.expectCall(address(impl), abi.encodeWithSelector(impl.bar.selector));
proxy.bar();
}
// Tests that the proxy fallback reverts as expected if the implementation within the
// address manager is not set.
function test_fallback_addressManagerNotSet_reverts() public {
AddressManager am = new AddressManager();
SimpleImplementation p = SimpleImplementation(
address(new ResolvedDelegateProxy(am, "SimpleImplementation"))
);
vm.expectRevert("ResolvedDelegateProxy: target address must be initialized");
p.foo(0);
}
}
contract SimpleImplementation {
function foo(uint256 _x) public pure returns (uint256) {
return _x;
}
function bar() public pure {
revert("SimpleImplementation: revert");
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment