Skip to content

Commit

Permalink
ci: bump ci builder 0.50.0 (#11334)
Browse files Browse the repository at this point in the history
* ci: bump ci builder `0.50.0`

Bumps the `ci-builder` image with an updated version
of foundry.

Foundry update:
#11325

Docker build:
https://app.circleci.com/pipelines/github/ethereum-optimism/optimism/60263/workflows/154fd94a-4029-4e2f-8bce-4ea4c6d25897

* contracts-bedrock: fix tests after new foundry version

* contracts-bedrock: comment why skip

* test: better comments

* gas-snapshot: regenerate

* snapshots: update

* snapshots: update

* fix(ctb): Align expected ptr in `Bytes.slice` test

An update to `forge-std` causes `bound` to set the free memory pointer
at an unaligned offset. This commit updates the test such that the
expected pointer is correctly aligned, without an assumption on the
starting ptr's alignment.

---------

Co-authored-by: clabby <[email protected]>
  • Loading branch information
tynes and clabby authored Aug 5, 2024
1 parent 0ab3e7a commit 9dc125a
Show file tree
Hide file tree
Showing 9 changed files with 1,502 additions and 1,488 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
parameters:
ci_builder_image:
type: string
default: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.49.0
default: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder:v0.50.0
ci_builder_rust_image:
type: string
default: us-docker.pkg.dev/oplabs-tools-artifacts/images/ci-builder-rust:latest
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369380)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967520)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 561992)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4074035)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369356)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967496)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564483)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076526)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 466947)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512629)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72624)
Expand Down
2,670 changes: 1,335 additions & 1,335 deletions packages/contracts-bedrock/snapshots/state-diff/Kontrol-31337.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/contracts-bedrock/test/L1/ResourceMetering.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ contract ArtifactResourceMetering_Test is Test {

/// @dev Generates a CSV file. No more than the L1 block gas limit should
/// be supplied to the `meter` function to avoid long execution time.
/// This test is skipped because there is no need to run it every time.
/// It generates a CSV file on disk that can be used to analyze the
/// gas usage and cost of the `ResourceMetering` contract. The next time
/// that the gas usage needs to be analyzed, the skip may be removed.
function test_meter_generateArtifact_succeeds() external {
vm.skip({ skipTest: true });

vm.writeLine(
outfile,
"prevBaseFee,prevBoughtGas,prevBlockNumDiff,l1BaseFee,requestedGas,gasConsumed,ethPrice,usdCost,success"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions packages/contracts-bedrock/test/libraries/Bytes.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,23 @@ contract Bytes_slice_Test is Test {

/// @notice Tests that the `slice` function correctly updates the free memory pointer depending
/// on the length of the slice.
/// The calls to `bound` are to reduce the number of times that `assume` is triggered.
function testFuzz_slice_memorySafety_succeeds(bytes memory _input, uint256 _start, uint256 _length) public {
vm.assume(_input.length > 0);

// The start should never be more than the length of the input bytes array - 1
vm.assume(_start < _input.length);
_start = bound(_start, 0, _input.length - 1);

// The length should never be more than the length of the input bytes array - the starting
// slice index.
vm.assume(_length <= _input.length - _start);
_length = bound(_length, 0, _input.length - _start);

// Grab the free memory pointer before the slice operation
uint64 initPtr;
assembly {
initPtr := mload(0x40)
}
uint64 expectedPtr = uint64(initPtr + 0x20 + ((_length + 0x1f) & ~uint256(0x1f)));
uint64 expectedPtr = uint64((initPtr + 0x20 + _length + 0x1f) & ~uint256(0x1f));

// Ensure that all memory outside of the expected range is safe.
vm.expectSafeMemory(initPtr, expectedPtr);
Expand Down Expand Up @@ -107,7 +111,7 @@ contract Bytes_slice_Test is Test {
// Note that we use a slightly less efficient, but equivalent method of rounding
// up `_length` to the next multiple of 32 than is used in the `slice` function.
// This is to diff test the method used in `slice`.
uint64 _expectedPtr = uint64(initPtr + 0x20 + (((_length + 0x1F) >> 5) << 5));
uint64 _expectedPtr = uint64(((initPtr + 0x20 + _length + 0x1F) >> 5) << 5);
assertEq(finalPtr, _expectedPtr);

// Sanity check for equivalence of the rounding methods.
Expand Down Expand Up @@ -144,11 +148,15 @@ contract Bytes_slice_TestFail is Test {

/// @notice Tests that, when given a start index `n` that is greater than
/// `type(uint256).max - n`, the `slice` function reverts.
/// The calls to `bound` are to reduce the number of times that `assume` is triggered.
function testFuzz_slice_rangeOverflows_reverts(bytes memory _input, uint256 _start, uint256 _length) public {
// Ensure that `_length` is a realistic length of a slice. This is to make sure
// we revert on the correct require statement.
_length = bound(_length, 0, _input.length == 0 ? 0 : _input.length - 1);
vm.assume(_length < _input.length);

// Ensure that `_start` will overflow if `_length` is added to it.
_start = bound(_start, type(uint256).max - _length, type(uint256).max);
vm.assume(_start > type(uint256).max - _length);

vm.expectRevert("slice_overflow");
Expand Down

0 comments on commit 9dc125a

Please sign in to comment.