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

feat(protocol): make TaikoL2Deprecated ABI go-ethereum compatible #18659

Merged
merged 6 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
32 changes: 16 additions & 16 deletions packages/protocol/contracts/layer2/based/TaikoL2Deprecated.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,45 @@ abstract contract TaikoL2Deprecated {
}

function anchor(
bytes32, /*_l1BlockHash*/
bytes32, /*_l1StateRoot*/
uint64, /*_l1BlockId*/
uint32 /*_parentGasUsed */
bytes32 _l1BlockHash,
bytes32 _l1StateRoot,
uint64 _l1BlockId,
uint32 _parentGasUsed
)
external
deprecated
{ }

function getBasefee(
uint64, /*_anchorBlockId*/
uint32 /*_parentGasUsed*/
uint64 _anchorBlockId,
uint32 _parentGasUsed
)
public
pure
deprecated
returns (uint256, /*basefee_*/ uint64 /*parentGasExcess_*/ )
returns (uint256 basefee_, uint64 parentGasExcess_)
{ }

function adjustExcess(
uint64, /*_currGasExcess*/
uint64, /*_currGasTarget*/
uint64 /*_newGasTarget*/
uint64 _currGasExcess,
uint64 _currGasTarget,
uint64 _newGasTarget
)
public
pure
deprecated
returns (uint64 /*newGasExcess_*/ )
returns (uint64 newGasExcess_)
{ }

function calculateBaseFee(
LibSharedData.BaseFeeConfig calldata, /*_baseFeeConfig*/
uint64, /*_blocktime*/
uint64, /*_parentGasExcess*/
uint32 /*_parentGasUsed*/
LibSharedData.BaseFeeConfig calldata _baseFeeConfig,
uint64 _blocktime,
uint64 _parentGasExcess,
uint32 _parentGasUsed
)
public
pure
deprecated
returns (uint256, /*basefee_*/ uint64 /*parentGasExcess_*/ )
returns (uint256 basefee_, uint64 parentGasExcess_)
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ contract AttestationBase is Test, DcapTestUtils, V3QuoteParseUtils {
bool expected
)
internal
view
returns (V3Struct.ParsedV3QuoteStruct memory v3quote)
{
v3quote = ParseV3QuoteBytes(address(pemCertChainLib), v3QuoteBytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../fixtures/BeaconProofs.sol";

/// @dev The beacon chain data used here is from slot 9000000 on Ethereum mainnet.
contract BeaconProofsVerification is BaseTest {
function test_beaconProofsVerification_validatorInclusionInValidatorList() public {
function test_beaconProofsVerification_validatorInclusionInValidatorList() public pure {
bytes32[8] memory validatorChunks = BeaconProofs.validatorChunks();

bytes32 validatorHashTreeRoot = LibMerkleUtils.merkleize(validatorChunks);
Expand All @@ -24,7 +24,7 @@ contract BeaconProofsVerification is BaseTest {
);
}

function test_beaconProofsVerification_validatorListInclusionInBeaconState() public {
function test_beaconProofsVerification_validatorListInclusionInBeaconState() public pure {
bytes32[] memory beaconStateProofForValidatorList =
BeaconProofs.beaconStateProofForValidatorList();

Expand All @@ -38,7 +38,7 @@ contract BeaconProofsVerification is BaseTest {
);
}

function test_beaconProofsVerification_beaconStateInclusionInBeaconBlock() public {
function test_beaconProofsVerification_beaconStateInclusionInBeaconBlock() public pure {
bytes32[] memory beaconBlockProofForBeaconState =
BeaconProofs.beaconBlockProofForBeaconState();

Expand All @@ -52,7 +52,7 @@ contract BeaconProofsVerification is BaseTest {
);
}

function test_beaconProofsVerification_proposerInclusionInBeaconBlock() public {
function test_beaconProofsVerification_proposerInclusionInBeaconBlock() public pure {
bytes32[] memory beaconBlockProofForProposer = BeaconProofs.beaconBlockProofForProposer();

uint256 validatorIndex = BeaconProofs.validatorIndex();
Expand Down
20 changes: 10 additions & 10 deletions packages/protocol/test/layer1/preconf/bls/BLSExpandMsgXmd.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ import "src/layer1/preconf/libs/LibBLS12381.sol";
contract BLSExpendMsgXmd is BaseTest {
bytes internal expand_msg_dst = "QUUX-V01-CS02-with-expander-SHA256-128";

function test_expandMsgXmd_empty_msg_0x20() public {
function test_expandMsgXmd_empty_msg_0x20() public view {
uint256[] memory result = LibBLS12381._expandMsgXmd("", expand_msg_dst, 0x20);
uint256 expected = 0x68a985b87eb6b46952128911f2a4412bbc302a9d759667f87f7a21d803f07235;

assertEq(result[0], expected);
}

function testExpandMsgXmd_abc_0x20() public {
function testExpandMsgXmd_abc_0x20() public view {
uint256[] memory result = LibBLS12381._expandMsgXmd("abc", expand_msg_dst, 0x20);
uint256 expected = 0xd8ccab23b5985ccea865c6c97b6e5b8350e794e603b4b97902f53a8a0d605615;

assertEq(result[0], expected);
}

function testExpandMsgXmd_abcdef0123456789_0x20() public {
function testExpandMsgXmd_abcdef0123456789_0x20() public view {
uint256[] memory result =
LibBLS12381._expandMsgXmd("abcdef0123456789", expand_msg_dst, 0x20);
uint256 expected = 0xeff31487c770a893cfb36f912fbfcbff40d5661771ca4b2cb4eafe524333f5c1;

assertEq(result[0], expected);
}

function testExpandMsgXmd_q128_0x20() public {
function testExpandMsgXmd_q128_0x20() public view {
uint256[] memory result = LibBLS12381._expandMsgXmd(
"q128_qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq",
expand_msg_dst,
Expand All @@ -42,7 +42,7 @@ contract BLSExpendMsgXmd is BaseTest {
assertEq(result[0], expected);
}

function testExpandMsgXmd_a512_0x20() public {
function testExpandMsgXmd_a512_0x20() public view {
uint256[] memory result = LibBLS12381._expandMsgXmd(
"a512_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
expand_msg_dst,
Expand All @@ -53,7 +53,7 @@ contract BLSExpendMsgXmd is BaseTest {
assertEq(result[0], expected);
}

function testExpandMsgXmd_empty_msg_0x80() public {
function testExpandMsgXmd_empty_msg_0x80() public view {
uint256[] memory result = LibBLS12381._expandMsgXmd("", expand_msg_dst, 0x80);
bytes memory expected =
hex"af84c27ccfd45d41914fdff5df25293e221afc53d8ad2ac06d5e3e29485dadbee0d121587713a3e0dd4d5e69e93eb7cd4f5df4cd103e188cf60cb02edc3edf18eda8576c412b18ffb658e3dd6ec849469b979d444cf7b26911a08e63cf31f9dcc541708d3491184472c2c29bb749d4286b004ceb5ee6b9a7fa5b646c993f0ced";
Expand All @@ -66,7 +66,7 @@ contract BLSExpendMsgXmd is BaseTest {
);
}

function testExpandMsgXmd_abc_0x80() public {
function testExpandMsgXmd_abc_0x80() public view {
uint256[] memory result = LibBLS12381._expandMsgXmd("abc", expand_msg_dst, 0x80);
bytes memory expected =
hex"abba86a6129e366fc877aab32fc4ffc70120d8996c88aee2fe4b32d6c7b6437a647e6c3163d40b76a73cf6a5674ef1d890f95b664ee0afa5359a5c4e07985635bbecbac65d747d3d2da7ec2b8221b17b0ca9dc8a1ac1c07ea6a1e60583e2cb00058e77b7b72a298425cd1b941ad4ec65e8afc50303a22c0f99b0509b4c895f40";
Expand All @@ -79,7 +79,7 @@ contract BLSExpendMsgXmd is BaseTest {
);
}

function testExpandMsgXmd_abcdef0123456789_0x80() public {
function testExpandMsgXmd_abcdef0123456789_0x80() public view {
uint256[] memory result =
LibBLS12381._expandMsgXmd("abcdef0123456789", expand_msg_dst, 0x80);
bytes memory expected =
Expand All @@ -93,7 +93,7 @@ contract BLSExpendMsgXmd is BaseTest {
);
}

function testExpandMsgXmd_q128_0x80() public {
function testExpandMsgXmd_q128_0x80() public view {
uint256[] memory result = LibBLS12381._expandMsgXmd(
"q128_qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq",
expand_msg_dst,
Expand All @@ -110,7 +110,7 @@ contract BLSExpendMsgXmd is BaseTest {
);
}

function testExpandMsgXmd_a512_0x80() public {
function testExpandMsgXmd_a512_0x80() public view {
uint256[] memory result = LibBLS12381._expandMsgXmd(
"a512_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
expand_msg_dst,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "src/layer1/preconf/libs/LibBLS12381.sol";
contract BLSHashToFieldFp2 is BaseTest {
bytes internal hash_to_dst = "QUUX-V01-CS02-with-BLS12381G2_XMD:SHA-256_SSWU_RO_";

function test_hashToFieldFp2_empty_msg() public {
function test_hashToFieldFp2_empty_msg() public view {
LibBLS12381.FieldPoint2[2] memory result = LibBLS12381.hashToFieldFp2("", hash_to_dst);
bytes memory expected_u0 =
hex"0000000000000000000000000000000003dbc2cce174e91ba93cbb08f26b917f98194a2ea08d1cce75b2b9cc9f21689d80bd79b594a613d0a68eb807dfdc1cf8";
Expand All @@ -26,7 +26,7 @@ contract BLSHashToFieldFp2 is BaseTest {
assertEq(bytes.concat(bytes32(result[1].u_I[0]), bytes32(result[1].u_I[1])), expected_u1_I);
}

function test_hashToFieldFp2_msg_abc() public {
function test_hashToFieldFp2_msg_abc() public view {
LibBLS12381.FieldPoint2[2] memory result = LibBLS12381.hashToFieldFp2("abc", hash_to_dst);
bytes memory expected_u0 =
hex"0000000000000000000000000000000015f7c0aa8f6b296ab5ff9c2c7581ade64f4ee6f1bf18f55179ff44a2cf355fa53dd2a2158c5ecb17d7c52f63e7195771";
Expand All @@ -43,7 +43,7 @@ contract BLSHashToFieldFp2 is BaseTest {
assertEq(bytes.concat(bytes32(result[1].u_I[0]), bytes32(result[1].u_I[1])), expected_u1_I);
}

function test_hash_to_field_msg_fp2_abcdef0123456789() public {
function test_hash_to_field_msg_fp2_abcdef0123456789() public view {
LibBLS12381.FieldPoint2[2] memory result =
LibBLS12381.hashToFieldFp2("abcdef0123456789", hash_to_dst);
bytes memory expected_u0 =
Expand All @@ -61,7 +61,7 @@ contract BLSHashToFieldFp2 is BaseTest {
assertEq(bytes.concat(bytes32(result[1].u_I[0]), bytes32(result[1].u_I[1])), expected_u1_I);
}

function test_hashToFieldFp2_msg_q128() public {
function test_hashToFieldFp2_msg_q128() public view {
LibBLS12381.FieldPoint2[2] memory result = LibBLS12381.hashToFieldFp2(
"q128_qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq",
hash_to_dst
Expand All @@ -81,7 +81,7 @@ contract BLSHashToFieldFp2 is BaseTest {
assertEq(bytes.concat(bytes32(result[1].u_I[0]), bytes32(result[1].u_I[1])), expected_u1_I);
}

function test_hashToFieldFp2_msg_a512() public {
function test_hashToFieldFp2_msg_a512() public view {
LibBLS12381.FieldPoint2[2] memory result = LibBLS12381.hashToFieldFp2(
"a512_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
hash_to_dst
Expand Down
11 changes: 6 additions & 5 deletions packages/protocol/test/layer2/LibEIP1559.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "./TaikoL2Test.sol";
contract TestLibEIP1559 is TaikoL2Test {
using LibMath for uint256;

function test_ethQty() external {
function test_ethQty() external pure {
assertEq(LibEIP1559.ethQty(60_000_000 * 8, 0), 1);
assertEq(LibEIP1559.ethQty(60_000_000 * 8, 60_000_000), 1);
assertEq(LibEIP1559.ethQty(60_000_000 * 8, 60_000_000 * 100), 268_337);
Expand Down Expand Up @@ -36,7 +36,7 @@ contract TestLibEIP1559 is TaikoL2Test {
console2.log("Mainnet minimal basefee: ", LibEIP1559.basefee(5_000_000 * 8, 1_340_000_000));
}

function test_change_of_quotient_and_gasIssuancePerSecond() public {
function test_change_of_quotient_and_gasIssuancePerSecond() public pure {
uint64 excess = 150 * 2_000_000;
uint64 target = 4 * 2_000_000;
uint256 unit = 10_000_000; // 0.01 gwei
Expand Down Expand Up @@ -78,7 +78,7 @@ contract TestLibEIP1559 is TaikoL2Test {
}
}

function test_change_of_quotient_and_gasIssuancePerSecond2() public {
function test_change_of_quotient_and_gasIssuancePerSecond2() public pure {
uint64 excess = 1;
uint64 target = 60_000_000 * 8;
uint256 unit = 10_000_000; // 0.01 gwei
Expand All @@ -100,15 +100,15 @@ contract TestLibEIP1559 is TaikoL2Test {

/// forge-config: layer2.fuzz.runs = 1000
/// forge-config: layer2.fuzz.show-logs = true
function test_fuzz_ethQty(uint64 _gasTarget, uint64 _gasExcess) external {
function test_fuzz_ethQty(uint64 _gasTarget, uint64 _gasExcess) external pure {
if (_gasTarget == 0) _gasTarget = 1;
uint256 result = LibEIP1559.ethQty(_gasTarget, _gasExcess);
assertTrue(result > 0);
}

/// forge-config: layer2.fuzz.runs = 2000
/// forge-config: layer2.fuzz.show-logs = true
function test_fuzz_basefee(uint64 _gasTarget, uint64 _gasExcess) external {
function test_fuzz_basefee(uint64 _gasTarget, uint64 _gasExcess) external pure {
uint256 result = LibEIP1559.basefee(_gasTarget, _gasExcess);
assertTrue(result >= 1);
}
Expand All @@ -121,6 +121,7 @@ contract TestLibEIP1559 is TaikoL2Test {
uint64 _oldGasExcess
)
external
pure
{
(uint64 newGasTarget_, uint64 newGasExcess_) =
LibEIP1559.adjustExcess(_oldGasTarget, _newGasTarget, _oldGasExcess);
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol/test/layer2/TaikoL2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ contract TaikoL2Tests is TaikoL2Test {
L2.withdraw(address(0), Alice);
}

function test_L2_getBlockHash() external {
function test_L2_getBlockHash() external view {
assertEq(L2.getBlockHash(uint64(1000)), 0);
}

Expand All @@ -114,6 +114,7 @@ contract TaikoL2Tests is TaikoL2Test {
uint8 _sharingPctg
)
external
view
{
LibSharedData.BaseFeeConfig memory baseFeeConfig = LibSharedData.BaseFeeConfig({
adjustmentQuotient: _adjustmentQuotient,
Expand Down
Loading