Skip to content

Commit a1a0a67

Browse files
Amxxernestognw
andauthored
Target Osaka EVM during tests (#6217)
Co-authored-by: ernestognw <ernestognw@gmail.com>
1 parent ad83688 commit a1a0a67

File tree

8 files changed

+69
-106
lines changed

8 files changed

+69
-106
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ runs:
5555
FOUNDRY_DEFAULT_VERSION: "stable"
5656
JAVA_DEFAULT_VERSION: "21"
5757
PYTHON_DEFAULT_VERSION: "3.13"
58-
SOLC_DEFAULT_VERSION: "0.8.27"
58+
SOLC_DEFAULT_VERSION: "0.8.31"
5959
# Node & npm setup
6060
- name: Install Node (${{ steps.versions.outputs.node }})
6161
if: inputs.node != 'off'

contracts/token/ERC20/extensions/ERC20Wrapper.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract contract ERC20Wrapper is ERC20 {
2727
error ERC20InvalidUnderlying(address token);
2828

2929
constructor(IERC20 underlyingToken) {
30-
if (underlyingToken == this) {
30+
if (address(underlyingToken) == address(this)) {
3131
revert ERC20InvalidUnderlying(address(this));
3232
}
3333
_underlying = underlyingToken;

foundry.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[profile.default]
2-
solc_version = '0.8.27'
3-
evm_version = 'prague'
2+
solc_version = '0.8.31'
3+
evm_version = 'osaka'
44
optimizer = true
55
optimizer_runs = 200
66
src = 'contracts'

hardhat.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// ENVVAR
2-
// - COMPILER: compiler version (default: 0.8.27)
2+
// - COMPILER: compiler version (default: 0.8.31)
33
// - SRC: contracts folder to compile (default: contracts)
44
// - RUNS: number of optimization runs (default: 200)
55
// - IR: enable IR compilation (default: false)
@@ -18,7 +18,7 @@ const { argv } = require('yargs/yargs')()
1818
compiler: {
1919
alias: 'compileVersion',
2020
type: 'string',
21-
default: '0.8.27',
21+
default: '0.8.31',
2222
},
2323
src: {
2424
alias: 'source',
@@ -38,7 +38,7 @@ const { argv } = require('yargs/yargs')()
3838
evm: {
3939
alias: 'evmVersion',
4040
type: 'string',
41-
default: 'prague',
41+
default: 'osaka',
4242
},
4343
// Extra modules
4444
coverage: {
@@ -103,7 +103,6 @@ module.exports = {
103103
// we rely on the `code-size` compiler warning, that will cause a compilation error.
104104
allowUnlimitedContractSize: true,
105105
initialBaseFeePerGas: argv.coverage ? 0 : undefined,
106-
enableRip7212: true,
107106
},
108107
},
109108
exposed: {

package-lock.json

Lines changed: 59 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"glob": "^13.0.0",
7373
"globals": "^16.0.0",
7474
"graphlib": "^2.1.8",
75-
"hardhat": "^2.24.3",
75+
"hardhat": "^2.28.0",
7676
"hardhat-exposed": "^0.3.15",
7777
"hardhat-gas-reporter": "^2.1.0",
7878
"hardhat-ignore-warnings": "^0.2.11",

test/utils/cryptography/P256.t.sol

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ contract P256Test is Test {
1616
(bytes32 r, bytes32 s) = vm.signP256(privateKey, digest);
1717
s = _ensureLowerS(s);
1818
assertTrue(P256.verify(digest, r, s, bytes32(x), bytes32(y)));
19+
assertTrue(P256.verifyNative(digest, r, s, bytes32(x), bytes32(y)));
1920
assertTrue(P256.verifySolidity(digest, r, s, bytes32(x), bytes32(y)));
2021
}
2122

@@ -31,22 +32,6 @@ contract P256Test is Test {
3132
assertTrue((qx0 == bytes32(x) && qy0 == bytes32(y)) || (qx1 == bytes32(x) && qy1 == bytes32(y)));
3233
}
3334

34-
function testVerifyNativeUnsupportedRIP7212(bytes32 digest, uint256 seed) public {
35-
// By default, the precompile at address 0x100 is not supported.
36-
37-
uint256 privateKey = _asPrivateKey(seed);
38-
39-
(uint256 x, uint256 y) = vm.publicKeyP256(privateKey);
40-
(bytes32 r, bytes32 s) = vm.signP256(privateKey, digest);
41-
s = _ensureLowerS(s);
42-
43-
(bool success, bytes memory returndata) = address(this).call(
44-
abi.encodeCall(P256Test.verifyNative, (digest, r, s, bytes32(x), bytes32(y)))
45-
);
46-
assertFalse(success);
47-
assertEq(returndata, abi.encodeWithSelector(Errors.MissingPrecompile.selector, address(0x100)));
48-
}
49-
5035
function _asPrivateKey(uint256 seed) private pure returns (uint256) {
5136
return bound(seed, 1, P256.N - 1);
5237
}
@@ -57,9 +42,4 @@ contract P256Test is Test {
5742
return _s > P256.N / 2 ? bytes32(P256.N - _s) : s;
5843
}
5944
}
60-
61-
// See https://github.com/foundry-rs/foundry/issues/10237
62-
function verifyNative(bytes32 digest, bytes32 r, bytes32 s, bytes32 x, bytes32 y) external view {
63-
P256.verifyNative(digest, r, s, x, y);
64-
}
6545
}

test/utils/cryptography/RSA.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('RSA', function () {
3131
it(`signature length ${length} ${test.extra} ${result ? 'works' : 'fails'}`, async function () {
3232
const data = '0x' + test.Msg;
3333
const sig = '0x' + test.S;
34-
const exp = '0x' + test.e;
34+
const exp = ethers.stripZerosLeft('0x' + test.e); // strip zeros to reduce gas cost of the precompile
3535
const mod = '0x' + test.n;
3636

3737
expect(await this.mock.$pkcs1Sha256(bytes32(ethers.sha256(data)), sig, exp, mod)).to.equal(result);

0 commit comments

Comments
 (0)