Skip to content

3823 enable previously skipped confirmity tests get transaction by block number and index #3875

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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
59 changes: 27 additions & 32 deletions packages/server/tests/acceptance/conformityTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CallerContract from '../contracts/Caller.json';
import LogsContract from '../contracts/Logs.json';

const directoryPath = path.resolve(__dirname, '../../../../node_modules/execution-apis/tests');
const overwritesDirectoryPath = path.resolve(__dirname, 'data/conformity/overwrites');

let currentBlockHash;
let legacyTransactionAndBlockHash;
Expand Down Expand Up @@ -209,10 +210,6 @@ async function checkRequestBody(fileName, request) {
request.params[0] = transactionHash;
}
}
if (request.method === 'eth_getBalance') {
request.params[0] = ETHEREUM_NETWORK_ACCOUNT_HASH;
request.params[1] = currentBlockHash;
}
if (request.method === 'eth_getTransactionByHash' || request.method === 'eth_getTransactionReceipt') {
request = formatTransactionByHashAndReceiptRequests(fileName, request);
}
Expand Down Expand Up @@ -320,6 +317,7 @@ async function processFileContent(directory, file, content) {
? checkResponseFormat(response.response.data, content.response)
: isResponseValid(schema, response);
expect(valid).to.be.true;
if (response.result) expect(response.result).to.be.equal(JSON.parse(content.response).result);
}

const synthesizeTestCases = function (testCases, updateParamIfNeeded) {
Expand Down Expand Up @@ -347,53 +345,50 @@ const synthesizeTestCases = function (testCases, updateParamIfNeeded) {
}
};

const initGenesisData = async function () {
for (const data of require('./data/conformity/genesis.json')) {
const options = { maxPriorityFeePerGas: gasPrice, maxFeePerGas: gasPrice, gasLimit: gasLimit };
options['to'] = data.account ? data.account : null;
if (data.balance) options['value'] = `0x${data.balance.toString(16)}`;
if (data.bytecode) options['data'] = data.bytecode;
await signAndSendRawTransaction({ chainId, from: sendAccountAddress, type: 2, ...options });
}
};

describe('@api-conformity', async function () {
before(async () => {
relayOpenRpcData = await parseOpenRPCDocument(JSON.stringify(openRpcData));
});

describe('@conformity-batch-1 Ethereum execution apis tests', function () {
this.timeout(240 * 1000);
execApisOpenRpcData = require('../../../../openrpc_exec_apis.json');
before(async () => {
legacyTransactionAndBlockHash = await signAndSendRawTransaction(legacyTransaction);
transaction2930AndBlockHash = await signAndSendRawTransaction(transaction2930);
transaction1559AndBlockHash = await signAndSendRawTransaction(transaction1559);
createContractLegacyTransactionAndBlockHash = await signAndSendRawTransaction(createContractLegacyTransaction);
await initGenesisData();
currentBlockHash = await getLatestBlockHash();
});
//Reading the directories within the ethereum execution api repo
let directories = fs.readdirSync(directoryPath);
let directories = [...new Set([...fs.readdirSync(directoryPath), ...fs.readdirSync(overwritesDirectoryPath)])];
const relaySupportedMethodNames = openRpcData.methods.map((method) => method.name);

//Filtering in order to use only the tests for methods we support in our relay
directories = directories.filter((directory) => relaySupportedMethodNames.includes(directory));
for (const directory of directories) {
const filePath = path.join(directoryPath, directory);
if (fs.statSync(filePath).isDirectory()) {
const files = fs.readdirSync(path.resolve(directoryPath, directory));
for (const file of files) {
it(`Executing for ${directory} and ${file}`, async () => {
//We are excluding these directories, since these tests in execution-apis repos
//use set of contracts which are not deployed on our network
if (
directory === 'eth_getLogs' ||
directory === 'eth_call' ||
directory === 'eth_estimateGas' ||
directory === 'eth_getProof' ||
directory === 'eth_createAccessList'
) {
return;
}
execApisOpenRpcData = require('../../../../openrpc_exec_apis.json');
//Currently, we do not support blobs
if (file.includes('blob')) {
return;
}
const data = fs.readFileSync(path.resolve(directoryPath, directory, file));
const content = splitReqAndRes(data.toString('utf-8'));
await processFileContent(directory, file, content);
});
}
const ls = (dir: string) => (fs.existsSync(dir) && fs.statSync(dir).isDirectory() ? fs.readdirSync(dir) : []);
const files = [
...new Set([...ls(path.join(directoryPath, directory)), ...ls(path.join(overwritesDirectoryPath, directory))]),
];
for (const file of files) {
const isCustom = fs.existsSync(path.join(overwritesDirectoryPath, directory, file));
it(`Executing for ${directory} and ${file}${isCustom ? ' (overwritten)' : ''}`, async () => {
const dir = isCustom ? overwritesDirectoryPath : directoryPath;
const data = fs.readFileSync(path.resolve(dir, directory, file));
const content = splitReqAndRes(data.toString('utf-8'));
await processFileContent(directory, file, content);
});
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{"account":"0x7dcd17433742f4c0ca53122ab541d0ba67fc27df","balance":63},
{"account":null,"balance":0,"bytecode":"0x608060405234801561001057600080fd5b50610384806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632a4c08961461005c57806378b9a1f314610078578063c670f86414610094578063c683d6a3146100b0578063d05285d4146100cc575b600080fd5b61007660048036038101906100719190610251565b6100e8565b005b610092600480360381019061008d9190610215565b61011c565b005b6100ae60048036038101906100a991906101ec565b61014e565b005b6100ca60048036038101906100c591906102a0565b61017e565b005b6100e660048036038101906100e191906101ec565b6101be565b005b8082847fa8fb2f9a49afc2ea148319326c7208965555151db2ce137c05174098730aedc360405160405180910390a4505050565b80827f513dad7582fd8b11c8f4d05e6e7ac8caaa5eb690e9173dd2bed96b5ae0e0d02460405160405180910390a35050565b807f46692c0e59ca9cd1ad8f984a9d11715ec83424398b7eed4e05c8ce84662415a860405160405180910390a250565b8183857f75e7d95cd72588af49ce2e4b7f004bce916d422999adf262a640e4239aab00c7846040516101b09190610312565b60405180910390a450505050565b806040516101cc9190610312565b60405180910390a050565b6000813590506101e681610337565b92915050565b6000602082840312156101fe57600080fd5b600061020c848285016101d7565b91505092915050565b6000806040838503121561022857600080fd5b6000610236858286016101d7565b9250506020610247858286016101d7565b9150509250929050565b60008060006060848603121561026657600080fd5b6000610274868287016101d7565b9350506020610285868287016101d7565b9250506040610296868287016101d7565b9150509250925092565b600080600080608085870312156102b657600080fd5b60006102c4878288016101d7565b94505060206102d5878288016101d7565b93505060406102e6878288016101d7565b92505060606102f7878288016101d7565b91505092959194509250565b61030c8161032d565b82525050565b60006020820190506103276000830184610303565b92915050565b6000819050919050565b6103408161032d565b811461034b57600080fd5b5056fea2646970667358221220a395344b5de9693999e0f06fc92d3f51a0cd6f30e383c9eccda35f50c04bac6364736f6c63430008040033"},
{"account":null,"balance":0,"bytecode":"0x6080604052348015600f57600080fd5b50607680601d6000396000f3fe608060405261ff0160003560f01c1415601e5761ffee60005260206000f35b43600052466020524160405248606052446080523260a0523460c05260e06000f3fea2646970667358221220df54ebe42ca12e658508ac87a25033e061bc8839fb14f209f8a89f2f0095e91f64736f6c63430008090033"}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// retrieves the client's current block number
// Reason for override: In our test case scenario, additional blocks are already prepared before the tests start.
// These extra blocks are needed to submit missing smart contracts.
// That's why block number 20 is replaced by 29 in the response.
>> {"jsonrpc":"2.0","id":1,"method":"eth_blockNumber"}
<< {"jsonrpc":"2.0","id":1,"result":"0x1d"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Performs a call to the callenv contract, which echoes the EVM transaction environment.
// This call uses EIP1559 transaction options.
// See https://github.com/ethereum/hive/tree/master/cmd/hivechain/contracts/callenv.eas for the output structure.
//
// Reason for override: This test uses a smart contract that was predeployed by a transaction included in the
// chain.rlp block data: https://github.com/ethereum/execution-apis/blob/main/tests/chain.rlp
//
// Since we do not replay those transactions before starting the tests, we need a separate test that simulates
// the same scenario. This is done by pointing the `to` address to the contract already deployed on our test node.
//
// Note: This is the original test file, modified for our test purposes: https://github.com/ethereum/execution-apis/blob/main/tests/eth_call/call-callenv-options-eip1559.io
// Only the `params[0].to` field value of the request body has been changed to point to the correct deployed contract
// address.
// All other fields must remain unchanged to preserve the integrity of the original test case.
//
// Additionally, the result field in the response was updated to reflect the actual parameters of the default
// local node instance.
//
// The smart contract should be deployed to the address: 0x2f2a392b4d7d2c2d3134e199295818a02535ef0a
// It should return the value in the format of seven 32-byte fields, where each field contains the following value:
//
// 1. block.number — 0x2d expected, 0xac on Hedera; reflects current block height (Ethereum vs Hedera testnet).
// 2. chainid — 0x0c72dd9d5e883e expected, 0x12a on Hedera; default local chain id is 298.
// 3. block.coinbase — 0x00 expected, 0x62 on Hedera; miner address is simulated and node-dependent on Hedera.
// 4. block.basefee — 0x05763d64 expected, 0x07 on Hedera; Hedera uses fixed or simplified basefee for EVM calls.
// 5. difficulty — 0x00 expected, random 32-byte value on Hedera; represents prevrandao (random seed).
// 6. tx.origin — 0x14e4...58cb2 expected and returned; caller’s address passed in transaction 'from' field.
// 7. msg.value — 0x17 (23 in decimal) expected and returned; actual value sent in the eth_call or transaction.
//
>> {"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"from":"0x14e46043e63d0e3cdcf2530519f4cfaf35058cb2","gas":"0xea60","input":"0x333435","maxFeePerGas":"0x44103f3","maxPriorityFeePerGas":"0xb","to":"0x2f2a392b4d7d2c2d3134e199295818a02535ef0a","value":"0x17"},"latest"]}
<< {"jsonrpc":"2.0","id":1,"result":"0x00000000000000000000000000000000000000000000000000000000000000ac000000000000000000000000000000000000000000000000000000000000012a0000000000000000000000000000000000000000000000000000000000000062000000000000000000000000000000000000000000000000000000000000000075def97dfe5beb77b5d1de1b71cd5bddfdf47dd77af36d5fd9e6db7f5f36e1b7000000000000000000000000435d7d41d4f69f958bda7a8d9f549a0dd9b64c860000000000000000000000000000000000000000000000000000000000000001"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Performs a call to the callenv contract, which echoes the EVM transaction environment.
// See https://github.com/ethereum/hive/tree/master/cmd/hivechain/contracts/callenv.eas for the output structure.
//
// Reason for override: This test uses a smart contract that was predeployed by a transaction included in the
// chain.rlp block data: https://github.com/ethereum/execution-apis/blob/main/tests/chain.rlp
//
// Since we do not replay those transactions before starting the tests, we need a separate test that simulates
// the same scenario. This is done by pointing the `to` address to the contract already deployed on our test node.
//
// Note: This is the original test file, modified for our test purposes: https://github.com/ethereum/execution-apis/blob/main/tests/eth_call/call-callenv.io
// Only the `params[0].to` field value has been changed to point to the correct deployed contract address.
//
// All other fields in the request body must remain unchanged to preserve the integrity of the original test case.
//
// The smart contract should be deployed to the address: 0x2f2a392b4d7d2c2d3134e199295818a02535ef0a
// It should return the value in the format of seven 32-byte fields, where each field contains the following:
//
// 1. block.number — 0x14 expected, 0x8c1 on Hedera; block height is higher due to real-time chain state.
// 2. chainid — 0x0c72dd9d5e883e expected, 0x12a on Hedera; test used a placeholder, Hedera testnet uses chain ID 298.
// 3. block.coinbase — 0x00 expected, 0x62 on Hedera; coinbase is simulated and not used for rewards on Hedera.
// 4. block.basefee — 0x00 expected, 0x00 on Hedera; basefee is present but set to zero when not explicitly simulated.
// 5. difficulty — 0x00 expected, Hedera returned prevrandao value (randomness source in PoS networks).
// 6. tx.origin — 0x00 expected and returned; tx sent from 0x0, so origin is also zero.
// 7. msg.value — 0x00 expected and returned; no value was sent with the call, as expected.
//
>> {"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"from":"0x0000000000000000000000000000000000000000","to":"0x2f2a392b4d7d2c2d3134e199295818a02535ef0a"},"latest"]}
<< {"jsonrpc":"2.0","id":1,"result":"0x00000000000000000000000000000000000000000000000000000000000008c1000000000000000000000000000000000000000000000000000000000000012a00000000000000000000000000000000000000000000000000000000000000620000000000000000000000000000000000000000000000000000000000000000ddef36f5bedc6b4f1ef766fd735d7cd1c7da7f675ddb5d5f7ddd3479cdb4f76d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// performs a basic contract call with default settings
//
// Reason for override: This test uses a smart contract that was predeployed by a transaction included in the
// chain.rlp block data: https://github.com/ethereum/execution-apis/blob/main/tests/chain.rlp
//
// Since we do not replay those transactions before starting the tests, we need a separate test that simulates
// the same scenario. This is done by pointing the `to` address to the contract already deployed on our test node.
//
// Note: This is the original test file, modified for our test purposes: https://github.com/ethereum/execution-apis/blob/main/tests/eth_call/call-contract.io
// Only the `params[0].to` field value has been changed to point to the correct deployed contract address.
// All other fields must remain unchanged to preserve the integrity of the original test case.
>> {"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"from":"0x0000000000000000000000000000000000000000","input":"0xff01","to":"0x2f2a392b4d7d2c2d3134e199295818a02535ef0a"},"latest"]}
<< {"jsonrpc":"2.0","id":1,"result":"0xffee"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// calls a contract that reverts with an ABI-encoded Error(string) value
//
// Reason for override: This test uses a smart contract that was predeployed by a transaction included in the
// chain.rlp block data: https://github.com/ethereum/execution-apis/blob/main/tests/chain.rlp
//
// Since we do not replay those transactions before starting the tests, we need a separate test that simulates
// the same scenario. This is done by pointing the `to` address to the contract already deployed on our test node.
//
// Note: This is the original test file, modified for our test purposes: https://github.com/ethereum/execution-apis/blob/main/tests/eth_call/call-revert-abi-error.io
// Only the `params[0].to` field value has been changed to point to the correct deployed contract address.
// All other fields must remain unchanged to preserve the integrity of the original test case.
>> {"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"from":"0x0000000000000000000000000000000000000000","gas":"0x186a0","input":"0x01","to":"0x0ee3ab1371c93e7c0c281cc0c2107cdebc8b1930"},"latest"]}
<< {"result":"0x","jsonrpc":"2.0","id":1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// calls a contract that reverts with an ABI-encoded Panic(uint) value
//
// Reason for override: This test uses a smart contract that was predeployed by a transaction included in the
// chain.rlp block data: https://github.com/ethereum/execution-apis/blob/main/tests/chain.rlp
//
// Since we do not replay those transactions before starting the tests, we need a separate test that simulates
// the same scenario. This is done by pointing the `to` address to the contract already deployed on our test node.
//
// Note: This is the original test file, modified for our test purposes: https://github.com/ethereum/execution-apis/blob/main/tests/eth_call/call-revert-abi-panic.io
// Only the `params[0].to` field value has been changed to point to the correct deployed contract address.
// All other fields must remain unchanged to preserve the integrity of the original test case.
>> {"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"from":"0x0000000000000000000000000000000000000000","gas":"0x186a0","input":"0x00","to":"0x0ee3ab1371c93e7c0c281cc0c2107cdebc8b1930"},"latest"]}
<< {"result":"0x","jsonrpc":"2.0","id":1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// retrieves the client's current chain id
//
// Reason for override: The Exec API tests used the value 0xc72dd9d5e883e for the chain ID,
// but this value exceeds the integer range allowed by Hedera, where the chain ID must fit within a valid integer type.
// Therefore, the file was overwritten with the chain ID value that is actually used by default on our local network.
>> {"jsonrpc":"2.0","id":1,"method":"eth_chainId"}
<< {"jsonrpc":"2.0","id":1,"result":"0x12a"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// estimates a contract call that reverts
//
// Reason for override: This test uses a smart contract that was predeployed by a transaction included in the
// chain.rlp block data: https://github.com/ethereum/execution-apis/blob/main/tests/chain.rlp
//
// Since we do not replay those transactions before starting the tests, we need a separate test that simulates
// the same scenario. This is done by pointing the `to` address to the contract already deployed on our test node.
//
// Note: This is the original test file, modified for our test purposes: https://github.com/ethereum/execution-apis/blob/main/tests/eth_estimateGas/estimage-failed-call.io
// Only the `params[0].to` field value has been changed to point to the correct deployed contract address.
// All other fields must remain unchanged to preserve the integrity of the original test case.
>> {"jsonrpc":"2.0","id":1,"method":"eth_estimateGas","params":[{"from":"0x0102030000000000000000000000000000000000","input":"0xff030405","to":"0x17e7eedce4ac02ef114a7ed9fe6e2f33feba1667"}]}
<< {"result":"0x","jsonrpc":"2.0","id":1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// estimates a successful contract call
//
// speconly: client response is only checked for schema validity.
//
// Reason for override: This test uses a smart contract that was predeployed by a transaction included in the
// chain.rlp block data: https://github.com/ethereum/execution-apis/blob/main/tests/chain.rlp
//
// Since we do not replay those transactions before starting the tests, we need a separate test that simulates
// the same scenario. This is done by pointing the `to` address to the contract already deployed on our test node.
//
// Note: This is the original test file, modified for our test purposes: https://github.com/ethereum/execution-apis/blob/main/tests/eth_estimateGas/estimage-failed-call.io
// Only the `params[0].to` field value has been changed to point to the correct deployed contract address.
// All other fields must remain unchanged to preserve the integrity of the original test case.
>> {"jsonrpc":"2.0","id":1,"method":"eth_estimateGas","params":[{"from":"0x0102030000000000000000000000000000000000","input":"0xff01","to":"0x17e7eedce4ac02ef114a7ed9fe6e2f33feba1667"}]}
<< {"result":"0x61a80","jsonrpc":"2.0","id":1}
Loading