diff --git a/contracts/contracts/tests/CreateFailCustom.sol b/contracts/contracts/tests/CreateFailCustom.sol new file mode 100644 index 00000000..e912c18b --- /dev/null +++ b/contracts/contracts/tests/CreateFailCustom.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 + +pragma solidity ^0.8.0; + +contract CreateFailCustom { + uint256 constant ERROR_NUM = + 0x1023456789abcdef1023456789abcdef1023456789abcdef1023456789abcdef; + + error CustomError(uint256 value); + + constructor () { + revert CustomError(ERROR_NUM); + } +} diff --git a/contracts/contracts/tests/CreateFailRequire.sol b/contracts/contracts/tests/CreateFailRequire.sol new file mode 100644 index 00000000..8bb76744 --- /dev/null +++ b/contracts/contracts/tests/CreateFailRequire.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: Apache-2.0 + +pragma solidity ^0.8.0; + +contract CreateFailRequire { + constructor () { + require(false, "ThisIsAnError"); + } +} diff --git a/contracts/test/semantics.ts b/contracts/test/semantics.ts index 4c8297d7..c51c2015 100644 --- a/contracts/test/semantics.ts +++ b/contracts/test/semantics.ts @@ -10,7 +10,7 @@ const ERROR_NUM = describe('EVM Semantics', () => { let c: SemanticTests; - let chainId: number; + let chainId: bigint; before(async () => { const f = await ethers.getContractFactory('SemanticTests'); @@ -19,18 +19,48 @@ describe('EVM Semantics', () => { chainId = (await ethers.provider.getNetwork()).chainId; }); + it('eth_call constructor with custom error', async () => { + const f = await ethers.getContractFactory('CreateFailCustom'); + const tx = await f.getDeployTransaction(); + const p = ethers.provider; + try { + const r = await p.call({ + data: tx.data + }); + } catch(x: any) { + expect(x.revert.args[0]).to.eq(ERROR_NUM); + expect(x.revert.name).to.eq('CustomError'); + } + }); + + it('eth_call constructor with require errror', async () => { + const f = await ethers.getContractFactory('CreateFailRequire'); + const tx = await f.getDeployTransaction(); + const p = ethers.provider; + try { + const r = await p.call({ + data: tx.data + }); + } catch(x: any) { + expect(x.revert.args[0]).to.eq('ThisIsAnError'); + expect(x.revert.name).to.eq('Error'); + } + }); + it('eth_call maximum return length vs gas limit', async () => { const i = 1211104; const respHex = await c.testViewLength(i); const respBytes = getBytes(respHex); expect(respBytes.length).eq(i); + let caught = false; try { await c.testViewLength(i + 1); - expect(false).eq(true); } catch (e: any) { + caught = true; expect(e.info.error.message).contains('out of gas'); } + expect(caught).eq(true); }); it('Error string in view call', async () => { diff --git a/runtime/Cargo.lock b/runtime/Cargo.lock index c5fc818e..5ee0aa6e 100644 --- a/runtime/Cargo.lock +++ b/runtime/Cargo.lock @@ -2084,7 +2084,7 @@ dependencies = [ [[package]] name = "oasis-core-keymanager" version = "0.0.0" -source = "git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.9#689ebb41d2fc781b5369a882809f62df61028ec4" +source = "git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.10#96bb870bfe54ff41c70dd828b0c518bf54aa6d8a" dependencies = [ "anyhow", "async-trait", @@ -2093,7 +2093,7 @@ dependencies = [ "lazy_static", "lru 0.9.0", "oasis-cbor", - "oasis-core-runtime 0.0.0 (git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.9)", + "oasis-core-runtime 0.0.0 (git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.10)", "rand", "rustc-hex", "sgx-isa", @@ -2167,7 +2167,7 @@ dependencies = [ [[package]] name = "oasis-core-runtime" version = "0.0.0" -source = "git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.9#689ebb41d2fc781b5369a882809f62df61028ec4" +source = "git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.10#96bb870bfe54ff41c70dd828b0c518bf54aa6d8a" dependencies = [ "anyhow", "arbitrary", @@ -2225,8 +2225,8 @@ dependencies = [ [[package]] name = "oasis-runtime-sdk" -version = "0.8.3" -source = "git+https://github.com/oasisprotocol/oasis-sdk?tag=runtime-sdk/v0.8.3#385af35781072dbe3d5e29f93951972f8ed71e92" +version = "0.8.5" +source = "git+https://github.com/oasisprotocol/oasis-sdk?branch=kostko/feature/evm-simulate-create#44eaec501a97f6ab765006717ebd161437b7bf26" dependencies = [ "anyhow", "base64", @@ -2243,8 +2243,8 @@ dependencies = [ "merlin", "num-traits", "oasis-cbor", - "oasis-core-keymanager 0.0.0 (git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.9)", - "oasis-core-runtime 0.0.0 (git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.9)", + "oasis-core-keymanager 0.0.0 (git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.10)", + "oasis-core-runtime 0.0.0 (git+https://github.com/oasisprotocol/oasis-core?tag=v23.0.10)", "oasis-runtime-sdk-macros", "once_cell", "p256", @@ -2265,7 +2265,7 @@ dependencies = [ [[package]] name = "oasis-runtime-sdk-evm" version = "0.5.0" -source = "git+https://github.com/oasisprotocol/oasis-sdk?tag=runtime-sdk/v0.8.3#385af35781072dbe3d5e29f93951972f8ed71e92" +source = "git+https://github.com/oasisprotocol/oasis-sdk?branch=kostko/feature/evm-simulate-create#44eaec501a97f6ab765006717ebd161437b7bf26" dependencies = [ "anyhow", "base64", @@ -2297,7 +2297,7 @@ dependencies = [ [[package]] name = "oasis-runtime-sdk-macros" version = "0.3.0" -source = "git+https://github.com/oasisprotocol/oasis-sdk?tag=runtime-sdk/v0.8.3#385af35781072dbe3d5e29f93951972f8ed71e92" +source = "git+https://github.com/oasisprotocol/oasis-sdk?branch=kostko/feature/evm-simulate-create#44eaec501a97f6ab765006717ebd161437b7bf26" dependencies = [ "darling 0.20.3", "proc-macro2 1.0.76", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 49dc5d13..8ddb3c2f 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -21,8 +21,8 @@ debug = false keymanager = { git = "https://github.com/oasisprotocol/keymanager-paratime", tag = "v0.4.1-testnet" } # SDK. -module-evm = { git = "https://github.com/oasisprotocol/oasis-sdk", tag = "runtime-sdk/v0.8.3", package = "oasis-runtime-sdk-evm" } -oasis-runtime-sdk = { git = "https://github.com/oasisprotocol/oasis-sdk", tag = "runtime-sdk/v0.8.3" } +module-evm = { git = "https://github.com/oasisprotocol/oasis-sdk", branch = "kostko/feature/evm-simulate-create", package = "oasis-runtime-sdk-evm" } +oasis-runtime-sdk = { git = "https://github.com/oasisprotocol/oasis-sdk", branch = "kostko/feature/evm-simulate-create" } # Third party. once_cell = "1.8.0" diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ddd22df5..efc853d4 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -169,6 +169,7 @@ impl sdk::Runtime for Runtime { max_multisig_signers: 8, gas_costs: modules::core::GasCosts { tx_byte: 1, + storage_byte: 1, auth_signature: 1_000, auth_multisig_signer: 1_000, callformat_x25519_deoxysii: 10_000,