diff --git a/src/Base.sol b/src/Base.sol index d948010f..076f18a6 100644 --- a/src/Base.sol +++ b/src/Base.sol @@ -34,6 +34,11 @@ abstract contract CommonBase { uint256 internal constant SECP256K1_ORDER = 115792089237316195423570985008687907852837564279074904382605163141518161494337; + /// @dev Protocol system address: caller of system calls (EIP-4788, EIP-2935, EIP-7002, EIP-7251) + /// and emitter of EIP-7708 ETH transfer logs. + /// Taken from https://eips.ethereum.org/EIPS/eip-4788. + address internal constant SYSTEM_ADDRESS = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE; + uint256 internal constant UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935; diff --git a/src/StdConstants.sol b/src/StdConstants.sol index 9f069ef8..b5cabf20 100644 --- a/src/StdConstants.sol +++ b/src/StdConstants.sol @@ -27,4 +27,8 @@ library StdConstants { /// @dev The order of the secp256k1 curve. uint256 internal constant SECP256K1_ORDER = 115792089237316195423570985008687907852837564279074904382605163141518161494337; + /// @dev Protocol system address: caller of system calls (EIP-4788, EIP-2935, EIP-7002, EIP-7251) + /// and emitter of EIP-7708 ETH transfer logs. + /// Taken from https://eips.ethereum.org/EIPS/eip-4788. + address internal constant SYSTEM_ADDRESS = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE; } diff --git a/test/CommonBase.t.sol b/test/CommonBase.t.sol index 28c91a91..53256dba 100644 --- a/test/CommonBase.t.sol +++ b/test/CommonBase.t.sol @@ -34,6 +34,10 @@ contract CommonBaseTest is Test { assertEq(SECP256K1_ORDER, StdConstants.SECP256K1_ORDER); } + function testSystemAddressValue() public pure { + assertEq(SYSTEM_ADDRESS, StdConstants.SYSTEM_ADDRESS); + } + function testUint256MaxValue() public pure { assertEq(UINT256_MAX, type(uint256).max); } diff --git a/test/StdConstants.t.sol b/test/StdConstants.t.sol index 8ed524ec..effaf0bf 100644 --- a/test/StdConstants.t.sol +++ b/test/StdConstants.t.sol @@ -33,6 +33,11 @@ contract StdConstantsTest is Test { assertEq(address(this), StdConstants.VM.computeCreateAddress(StdConstants.DEFAULT_SENDER, 1)); assertEq(StdConstants.DEFAULT_TEST_CONTRACT, StdConstants.VM.computeCreateAddress(address(this), 1)); } + + function testSystemAddress() public pure { + assertEq(StdConstants.SYSTEM_ADDRESS, 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE); + assertEq(StdConstants.SYSTEM_ADDRESS, address(uint160(uint256(type(uint160).max - 1)))); + } } contract Dummy {}