Skip to content

Commit

Permalink
#1748 fixing compatibiliti with geth prestate
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Dec 26, 2023
1 parent 91d58b3 commit 8d60ef1
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions test/historicstate/hardhat/scripts/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,6 @@ async function verifyFourByteTraceAgainstGethTrace(_fileName: string) {
differences.forEach((difference, index) => {
// do not print differences related to total gas in the account

if (difference.kind == "E" && difference.path!.length == 2) {
if (difference.path![0] == "difference.path![0]" || key == "gas" || key == "gasUsed")
return;
}

foundDiffs = true;

console.log(`Found difference (lhs is expected value) ${index + 1} at path:`, difference.path);
Expand Down Expand Up @@ -400,7 +395,7 @@ async function verifyPrestateTraceAgainstGethTrace(_fileName: string) {
// do not print differences related to total gas in the account

if (difference.kind == "E" && difference.path!.length == 2) {
if (difference.path![0] == "OWNER.address" || difference.path![1] == "nonce")
if (difference.path![0] == "OWNER.address" && difference.path![1] == "nonce")
return;
}

Expand Down Expand Up @@ -442,6 +437,43 @@ async function verifyPrestateTraceAgainstGethTrace(_fileName: string) {
await expect(foundDiffs).to.be.eq(false)
}

async function verifyPrestateDiffTraceAgainstGethTrace(_fileName: string) {

const _expectedResultFileName = GETH_TRACES_DIR + _fileName;
const _actualResultFileName = SKALE_TRACES_DIR + _fileName;

let expectedResult = await readJSONFile(_expectedResultFileName)
let actualResult = await readJSONFile(_actualResultFileName)

const differences = deepDiff(expectedResult, actualResult)!;

let foundDiffs = false;


if (differences) {
differences.forEach((difference, index) => {
// do not print differences related to total gas in the account

if (difference.path!.length == 3) {
if (difference.path![1] == "CALL.address") {
return;
}
}

foundDiffs = true;

console.log(`Found difference (lhs is expected value) ${index + 1} at path:`, difference.path);
console.log(`Difference ${index + 1}:`, difference);
});
}


await expect(foundDiffs).to.be.eq(false)
}





async function verifyGasCalculations(_actualResult: any): Promise<void> {
let structLogs: object[] = _actualResult.structLogs;
Expand Down Expand Up @@ -488,7 +520,7 @@ async function main(): Promise<void> {
await verifyPrestateTraceAgainstGethTrace(TEST_CONTRACT_CALL_PRESTATETRACER_FILE_NAME)

await callDebugTraceCall(deployedContract, PRESTATEDIFF_TRACER, TEST_CONTRACT_CALL_PRESTATEDIFFTRACER_FILE_NAME);
await verifyPrestateTraceAgainstGethTrace(TEST_CONTRACT_CALL_PRESTATEDIFFTRACER_FILE_NAME)
await verifyPrestateDiffTraceAgainstGethTrace(TEST_CONTRACT_CALL_PRESTATEDIFFTRACER_FILE_NAME)

}

Expand Down

0 comments on commit 8d60ef1

Please sign in to comment.