From a7a5ed4cceea26ccc5f9153600aadea9e31c55ff Mon Sep 17 00:00:00 2001 From: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> Date: Mon, 30 Oct 2023 20:21:28 -0300 Subject: [PATCH] `modexp` big integers arithmetics (#124) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial new implementation * Fix compilation error * Implementation of add operation for big integers (#136) * Implement Big UInt Left Shift (#139) * Add `bigUIntShl` implementation * Add constants * Fix compilation * Implement Big UInt Right Shift (#137) * Add `bigUIntShr` implementation * Add constants * Implement Big UInt Bitwise Or for modexp (#135) * Implement bigUIntBitOr * Fix bigUIntBitOr * Fix bigUIntBitOr Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Fix missing closing brackets --------- Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Implement big uint conditional select for modexp (#148) * Implement bigUIntCondSelect * Fix missing curly braces Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Implement Big UInt Right Shift (#137) * Add `bigUIntShr` implementation * Add constants * Implement Big UInt Bitwise Or for modexp (#135) * Implement bigUIntBitOr * Fix bigUIntBitOr * Fix bigUIntBitOr Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Fix missing closing brackets --------- Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> --------- Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Implement mul operation for big UInts (#151) * First implementation of mul operation for bigints * Fix multiplication for big integers * Fix some merge issues * Improve comments and function docs * Delete whitespaces * Substraction with borrow (#149) * First substraction draft * Fix compile problems * Working implementation * Updated code * Updated code * Update subtract implementation * Remove console_log * Add docs for function * Update function docs * Remove tests from from ModExp.yul * Fix typo * Restore horrible whitespaces to avoid an ugly merge conflict * Update precompiles/Modexp.yul Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Revert "Update precompiles/Modexp.yul" This reverts commit 582bc41a0bb7fb02a1a68717fdf83c6fe432d422. --------- Co-authored-by: Joaquín P. Centeno Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Refactor `modexp` reimplementation (#156) * Make Big UInt API functions naming consistent * Refactor `bigUIntAdd` variable names * Refactor `bigUIntMul` variable names * Refactor `subLimbsWithBorrow` * Refactor `bigUintSubtractionWithBorrow` * Refactor `bigUIntAdd` * Fix `bigUIntSubWithBorrow` * Format `storeLimbValueAtOffset` * Refactor `bigUIntBitOr` Made it consistent with the rest of the code convention and naming * Refactor `bigUIntCondSelect` Made it consistent with the rest of the code convention and naming * Reorder `overflowingSubWithBorrow` * Move comment to modexp API Docs section * Biguint division (#159) * Division draft * Non working draft * Fix compile errors * Use proper pointers for quotient and remainder * Add fix note, some more changes * Add comment * Implement `big_uint_bit_size` * Increase pointer to prevent it from steping over console_log * WIP divrem * Fix loop and zero initializer * Push test cases * Add other test case * Add docs and tests for `big_uint_inplace_or_1` * Fix bug related to bit shifting * Fix borrow return in big uint sub function * Delete playground file used for debugging * Fix sub with borrow function * Add playground again to check more big integer division tests * Remove playground used for testing * Write documentation for new shift functions * Improve naming and documentation for new helper functions * Rename bigUIntOrWith1 to bigUintInPlaceOrWith1 * Add tmp buffer parameters to bigUIntDivRem. Improve docs. * Simplify subLimbsWithBorrow Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Remove `mul` call from `bigUIntInPlaceOrWith1` Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Remove multiplications from copyBigUint Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Optimize bigUIntBitSize loop Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Simplify zeroWithLimbSizeAt --------- Co-authored-by: Francisco Krause Arnim Co-authored-by: IAvecilla Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Implement mul mod operation for big UInts (#161) * Division draft * Non working draft * Fix compile errors * Use proper pointers for quotient and remainder * Add fix note, some more changes * Add comment * Implement `big_uint_bit_size` * Increase pointer to prevent it from steping over console_log * WIP divrem * Fix loop and zero initializer * Push test cases * Add other test case * Add docs and tests for `big_uint_inplace_or_1` * Fix bug related to bit shifting * Fix borrow return in big uint sub function * Delete playground file used for debugging * Fix sub with borrow function * Add playground again to check more big integer division tests * Remove playground used for testing * Write documentation for new shift functions * Improve naming and documentation for new helper functions * Rename bigUIntOrWith1 to bigUintInPlaceOrWith1 * Add tmp buffer parameters to bigUIntDivRem. Improve docs. * Add big uint mul mod skeleton * Remove wrong comment * Update algorithm comment * Add limb size doubling and divide by two for mul mod operation * Functions to duplicate and halve limb size work in place * Use camelCase * Remove console_log * Add docs * Update doc --------- Co-authored-by: Francisco Krause Arnim Co-authored-by: Joaquín P. Centeno * Add parseCallData function * Add function to left-pad big uints * Remove console log function * Change left padding functions for big uints to not work in place * Add `parseCalldata` function (#168) * Remove redundant parse call data declaration * Free memory pointer (#169) * Add free memory pointer function * Update precompiles/Modexp.yul Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Update precompiles/Modexp.yul Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> --------- Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> * Start parsing the input calldata * Correctly parse call data * Add left pad steps for modexp inputs * Add pad if needed function * Modexp for big UInts skeleton (#164) * WIP: modexp skeleton * Use of mul mod function for big integers * imlement aux function to check if big uint is larger than 1 * minor fix * Restore modexp from target branch * Fix mul mod * Finish modexp implementation * Remove playground used for debugging * Update modexp with final state of modular exponentiation function * Fix merge issue * Change all names to camel case * fix typo Co-authored-by: Francisco Krause Arnim <56402156+fkrause98@users.noreply.github.com> --------- Co-authored-by: IAvecilla Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> Co-authored-by: Francisco Krause Arnim <56402156+fkrause98@users.noreply.github.com> * Add simple integration * Fix calldata buffer in zero check * Uncomment checks for base cases * Fix result length to match with mod length * Fix condition in parse call data * Update test assertions with new test node updates * Add comment for tests with a temp patch * Fix modexp result length * Fix limb amount for modexp operands * Clean sratch buffers in each iteration * Clean sratch buffers for every operation * Remove unused functions * Delete free memory pointer usage and calculate pointers manually * Replace all mul operations for shifts to improve gas usage * Include basic optimizations * Add optimizations for reminder calculations * Add small improvement for main loop in modular exp * Add temporary fix for modexp test * Add modex reference script * Remove unnecesary memory stores * Reduce iterations in rem function * Compilation fix * Print gas used on tests * Add build script to create gas reports * Save gas used for each test of the precompiles * Add aux functions to write lines in each report * Merge main * Fix tests lint * Fix lint in test utils * Change L1 url --------- Co-authored-by: Nacho Avecilla Co-authored-by: Joaquín Centeno Co-authored-by: Francisco Krause Arnim <56402156+fkrause98@users.noreply.github.com> Co-authored-by: Francisco Krause Arnim Co-authored-by: IAvecilla Co-authored-by: Javier Chatruc --- docs/src/SUMMARY.md | 1 + docs/src/modexp/api.md | 27 + precompiles/Modexp.yul | 883 ++++++++++++++++++++++----- scripts/modexp_reference.py | 22 + tests/build.rs | 33 + tests/tests/ecadd_tests.rs | 90 ++- tests/tests/ecmul_tests.rs | 360 +++++++---- tests/tests/ecpairing_tests.rs | 53 +- tests/tests/modexp_tests.rs | 509 +++++++++------ tests/tests/p256verify_tests.rs | 17 +- tests/tests/secp256k1verify_tests.rs | 17 +- tests/tests/test_utils.rs | 44 +- 12 files changed, 1512 insertions(+), 544 deletions(-) create mode 100644 docs/src/modexp/api.md create mode 100644 scripts/modexp_reference.py create mode 100644 tests/build.rs diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 6df7d600..05aa6dbf 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -13,4 +13,5 @@ - [Optimizations](ecpairing/optimizations.md) - [ModExp]() - [Specification](modexp/spec.md) + - [API Docs](modexp/api.md) - [Optimizations](modexp/optimizations.md) diff --git a/docs/src/modexp/api.md b/docs/src/modexp/api.md new file mode 100644 index 00000000..432d05ec --- /dev/null +++ b/docs/src/modexp/api.md @@ -0,0 +1,27 @@ +# API Docs + +## Big Unsigned Integers Arithmetic + +### `bigUIntAdd` + +### `bigUIntSubWithBorrow` + +### `bigUIntMul` + +### `bigUIntBitOr` + +``` ++------------+-----------------------+-------------------------------+-------------------------------+-------------------------------+-----------------+-----------------+--------------------------------------+ +| Iteration | currentOffset | lhsCurrentPtr | rhsCurrentPtr | resCurrentPtr | lhsCurrentValue | rhsCurrentValue | resCurrentValue | ++------------+-----------------------+-------------------------------+-------------------------------+-------------------------------+-----------------+-----------------+--------------------------------------+ +| 0 | +0x00 | lhsPtr + 0x00 | rhsPtr + 0x00 | resPtr + 0x00 | lhs[0] | rhs[0] | or(lhs[0], rhs[0]) | +| 1 | +0x20 | lhsPtr + 0x20 | rhsPtr + 0x20 | resPtr + 0x20 | lhs[1] | rhs[1] | or(lhs[1], rhs[1]) | +| 2 | +0x40 | lhsPtr + 0x40 | rhsPtr + 0x40 | resPtr + 0x40 | lhs[2] | rhs[2] | or(lhs[2], rhs[2]) | +| | | | | | | | | +| ... | ... | ... | ... | ... | ... | ... | ... | +| | | | | | | | | +| nLimbs - 1 | +(0x20 * (nLimbs - 1) | lhsPtr + (0x20 * (nLimbs - 1) | rhsPtr + (0x20 * (nLimbs - 1) | resPtr + (0x20 * (nLimbs - 1) | lhs[nLimbs - 1] | rhs[nLimbs - 1] | or(lhs[nLimbs - 1], rhs[nLimbs - 1]) | ++------------+-----------------------+-------------------------------+-------------------------------+-------------------------------+-----------------+-----------------+--------------------------------------+ +``` + +### `bigUIntCondSelect` \ No newline at end of file diff --git a/precompiles/Modexp.yul b/precompiles/Modexp.yul index a18d8521..cb74e679 100644 --- a/precompiles/Modexp.yul +++ b/precompiles/Modexp.yul @@ -2,194 +2,765 @@ object "ModExp" { code { } object "ModExp_deployed" { code { - //////////////////////////////////////////////////////////////// - // CONSTANTS - //////////////////////////////////////////////////////////////// - function WORD_SIZE() -> word { - word := 0x20 + // CONSTANTS + function LIMB_SIZE_IN_BYTES() -> limbSize { + limbSize := 0x20 } - ////////////////////////////////////////////////////////////////// - // HELPER FUNCTIONS - ////////////////////////////////////////////////////////////////// + function LIMB_SIZE_IN_BITS() -> limbSize { + limbSize := 0x100 + } + + // HELPER FUNCTIONS + function bigIntLimbsWithoutZeros(ptr, totalLimbs) -> limbs { + limbs := 0 + for { let i := 0 } lt(i, totalLimbs) { i := add(i, 1) } { + let limb := mload(add(ptr, shl(5, i))) + if limb { + limbs := add(limbs, 1) + } + } + } - function exponentIsZero(exponent_limbs, exponent_pointer) -> isZero { - isZero := 0 - let next_limb_pointer := exponent_pointer - for { let limb_number := 0 } lt(limb_number, exponent_limbs) { limb_number := add(limb_number, 1) } { - let limb := mload(next_limb_pointer) - isZero := or(isZero, limb) - if isZero { + function bigIntLimbs(length) -> limbs, misalignment { + limbs := div(length, LIMB_SIZE_IN_BYTES()) + misalignment := mod(length, LIMB_SIZE_IN_BYTES()) + if misalignment { + limbs := add(limbs, 1) + } + } + + /// @notice Stores a zero in big unsigned integer form in memory. + /// @param nLimbs The number of limbs needed to represent the operand. + /// @param toAddress The pointer to the MSB of the destination. + function zeroWithLimbSizeAt(nLimbs, toAddress) { + let overflow := add(toAddress, shl(5, nLimbs)) + for { } lt(toAddress, overflow) { toAddress := add(toAddress, LIMB_SIZE_IN_BYTES()) } { + mstore(toAddress, 0) + } + } + + /// @notice Copy a big unsigned integer from one memory location to another. + /// @param nLimbs The number of limbs needed to represent the operand. + /// @param fromAddress The pointer to the MSB of the number to copy. + /// @param toAddress The pointer to the MSB of the destination. + function copyBigUint(nLimbs, fromAddress, toAddress) { + let total_bytes := shl(5, nLimbs) + for { let i } lt(i, total_bytes) { i := add(i, LIMB_SIZE_IN_BYTES()) } { + mstore(add(i, toAddress), mload(add(i, fromAddress))) + } + } + + /// @notice Computes an addition and checks for overflow. + /// @param augend The value to add to. + /// @param addend The value to add. + /// @return sum The sum of the two values. + /// @return overflowed True if the addition overflowed, false otherwise. + function overflowingAdd(augend, addend) -> sum, overflowed { + sum := add(augend, addend) + overflowed := lt(sum, augend) + } + + /// @notice Computes the difference between two 256 bit number and keeps + /// account of the borrow bit. + /// @param minuend The left side of the difference (i.e. the a in a - b). + /// @param subtrahend The right side of the difference (i.e. the b in a - b). + /// @return difference i.e. the c in c = a - b. + /// @return overflowed If there was any borrow on the subtraction, is returned as 1. + function overflowingSubWithBorrow(minuend, subtrahend, borrow) -> difference, overflowed { + difference := sub(minuend, add(subtrahend, borrow)) + overflowed := gt(difference, minuend) + } + + /// @notice Retrieves the highest half of the multiplication result. + /// @param multiplicand The value to multiply. + /// @param multiplier The multiplier. + /// @return ret The highest half of the multiplication result. + function getHighestHalfOfMultiplication(multiplicand, multiplier) -> ret { + ret := verbatim_2i_1o("mul_high", multiplicand, multiplier) + } + + /// @notice Checks whether calldata[start, start + len) is zero. + /// @param start The pointer to the calldata where the big number starts. + /// @param len The number of bytes that the big number occupies. + /// @return res A boolean indicating whether the big number is zero (true) or not (false). + function callDataBufferIsZero(start, len) -> res { + // Initialize result as true, assuming the number is zero until proven otherwise. + res := true + + // Calculate the ending pointer of the big number in memory. + let end := add(start, len) + // Calculate the number of bytes in the last (potentially partial) word of the big number. + let lastWordBytes := mod(len, 32) + // Calculate the ending pointer of the last full 32-byte word. + let endOfLastFullWord := sub(end, lastWordBytes) + + // Loop through each full 32-byte word to check for non-zero bytes. + for { let ptr := start } lt(ptr, endOfLastFullWord) { ptr := add(ptr, 32) } { + let word := calldataload(ptr) + if word { + res := false break } - next_limb_pointer := add(next_limb_pointer, WORD_SIZE()) } - isZero := iszero(isZero) + + // Check if the last partial word has any non-zero bytes. + if lastWordBytes { + // Create a mask that isolates the valid bytes in the last word. + // The mask has its first `lastWordBytes` bytes set to `0xff`. + let mask := sub(shl(shl(3, lastWordBytes), 1), 1) + let word := shr(sub(LIMB_SIZE_IN_BITS(), shl(3, lastWordBytes)), calldataload(endOfLastFullWord)) + // Use the mask to isolate the valid bytes and check if any are non-zero. + if and(word, mask) { + res := false + } + } } - //////////////////////////////////////////////////////////////// - // FALLBACK - //////////////////////////////////////////////////////////////// + /// @notice Checks whether a big number is zero. + /// @param start The pointer to the calldata where the big number starts. + /// @param len The number of bytes that the big number occupies. + /// @return res A boolean indicating whether the big number is zero (true) or not (false). + function bigUIntIsZero(start, len) -> res { + // Initialize result as true, assuming the number is zero until proven otherwise. + res := true - let base_length := calldataload(0) - let exponent_length := calldataload(32) - let modulus_length := calldataload(64) + // Calculate the ending pointer of the big number in memory. + let end := add(start, len) + // Calculate the number of bytes in the last (potentially partial) word of the big number. + let lastWordBytes := mod(len, 32) + // Calculate the ending pointer of the last full 32-byte word. + let endOfLastFullWord := sub(end, lastWordBytes) - if lt(calldatasize(), 96) { - return(0, 0) + // Loop through each full 32-byte word to check for non-zero bytes. + for { let ptr := start } lt(ptr, endOfLastFullWord) { ptr := add(ptr, 32) } { + let word := calldataload(ptr) + if word { + res := false + break + } + } + + // Check if the last partial word has any non-zero bytes. + if lastWordBytes { + // Create a mask that isolates the valid bytes in the last word. + // The mask has its first `lastWordBytes` bytes set to `0xff`. + let mask := sub(shl(shl(3, lastWordBytes), 1), 1) + let word := calldataload(endOfLastFullWord) + // Use the mask to isolate the valid bytes and check if any are non-zero. + if and(word, mask) { + res := false + } + } } - // Workaround to handle the case when all inputs are 0 - if eq(calldatasize(), 96) { - return(0, modulus_length) + /// @notice Checks whether a big number is one. + /// @param start The pointer to the calldata where the big number starts. + /// @param len The number of bytes that the big number occupies. + /// @return res A boolean indicating whether the big number is one (true) or not (false). + function callDataBufferIsOne(start, len) -> res { + if len { + let lastBytePtr := sub(add(start, len), 1) + let lastByte := byte(0, calldataload(lastBytePtr)) + + // Check if the last byte is one. + let lastByteIsOne := eq(lastByte, 1) + // Check if all other bytes are zero using the callDataBufferIsZero function + // The length for this check is (len - 1) because we exclude the last byte. + let otherBytesAreZeroes := callDataBufferIsZero(start, sub(len, 1)) + + // The number is one if the last byte is one and all other bytes are zero. + res := and(lastByteIsOne, otherBytesAreZeroes) + } } - // Handle a special case when both the base and mod length is zero - if and(iszero(base_length), iszero(modulus_length)) { - return(0, 0) + /// @notice Performs the big unsigned integer left shift (<<). + /// @dev The result is stored from `shiftedPtr` to `shiftedPtr + (LIMB_SIZE_IN_BYTES * nLimbs)`. + /// @param numberPtr The pointer to the MSB of the number to shift. + /// @param nLimbs The number of limbs needed to represent the operands. + /// @param shiftedPtr The pointer to the MSB of the shifted number. + function bigUIntShl(times, numberPtr, nLimbs, shiftedPtr) { + switch times + case 0 { + // If the pointers are different and the amount of bits to shift is zero, + // then we copy the number, otherwise, we do nothing. + if iszero(eq(numberPtr, shiftedPtr)) { + let currentLimbPtr := numberPtr + let currentShiftedLimbPtr := shiftedPtr + for { let i } lt(i, nLimbs) { i := add(i, 1) } { + mstore(currentShiftedLimbPtr, mload(currentLimbPtr)) + currentShiftedLimbPtr := add(currentShiftedLimbPtr, LIMB_SIZE_IN_BYTES()) + currentLimbPtr := add(currentLimbPtr, LIMB_SIZE_IN_BYTES()) + } + } + } + default { + let effectiveShifts := mod(times, LIMB_SIZE_IN_BITS()) + let b_inv := sub(LIMB_SIZE_IN_BITS(), effectiveShifts) + let limbsToShiftOut := div(times, LIMB_SIZE_IN_BITS()) + let shiftDivInv := sub(LIMB_SIZE_IN_BITS(), limbsToShiftOut) + + switch iszero(effectiveShifts) + case 1 { + // When numberPtr could be equal to shiftedPtr that means that the result + // will be stored in the same pointer as the value to shift. To avoid + // overlaping, as this is a left shift we read and store from left to + // right. + + let currentLimbPtrOffset := shl(5, limbsToShiftOut) + let currentLimbPtr := add(numberPtr, currentLimbPtrOffset) + let currentShiftedLimbPtr := shiftedPtr + for { let i := limbsToShiftOut } lt(i, nLimbs) { i := add(i, 1) } { + mstore(currentShiftedLimbPtr, mload(currentLimbPtr)) + currentLimbPtr := add(currentLimbPtr, LIMB_SIZE_IN_BYTES()) + currentShiftedLimbPtr := add(currentShiftedLimbPtr, LIMB_SIZE_IN_BYTES()) + } + // Fill with zeros the limbs that will shifted out limbs. + // We need to fill the zeros after in the edge case that numberPtr == shiftedPtr. + for { let i } lt(i, limbsToShiftOut) { i := add(i, 1) } { + mstore(currentShiftedLimbPtr, 0) + currentShiftedLimbPtr := add(currentShiftedLimbPtr, LIMB_SIZE_IN_BYTES()) + } + } + default { + // When there are effectiveShifts we need to do a bit more of work. + // We go from right to left, shifting the current limb and adding the + // previous one shifted to the left by b_inv bits. + let currentLimbPtrOffset := shl(5, limbsToShiftOut) + let currentLimbPtr := add(numberPtr, currentLimbPtrOffset) + let nextLimbPtr := add(currentLimbPtr, LIMB_SIZE_IN_BYTES()) + let currentShiftedLimbPtr := shiftedPtr + for { let i := limbsToShiftOut } lt(i, nLimbs) { i := add(i, 1) } { + let shiftedLimb := or(shr(b_inv, mload(nextLimbPtr)), shl(effectiveShifts, mload(currentLimbPtr))) + mstore(currentShiftedLimbPtr, shiftedLimb) + nextLimbPtr := add(nextLimbPtr, LIMB_SIZE_IN_BYTES()) + currentLimbPtr := add(currentLimbPtr, LIMB_SIZE_IN_BYTES()) + currentShiftedLimbPtr := add(currentShiftedLimbPtr, LIMB_SIZE_IN_BYTES()) + } + // Finally the non-zero LSB limb. + mstore(currentShiftedLimbPtr, shl(effectiveShifts, mload(currentShiftedLimbPtr))) + currentShiftedLimbPtr := add(currentShiftedLimbPtr, LIMB_SIZE_IN_BYTES()) + // Fill with zeros the shifted in limbs. + for { let i } lt(i, limbsToShiftOut) { i := add(i, 1) } { + mstore(currentShiftedLimbPtr, 0) + currentShiftedLimbPtr := add(currentShiftedLimbPtr, LIMB_SIZE_IN_BYTES()) + } + } + } + } + + /// @notice Add two big numbers. + /// @param augendPtr The pointer where the big number on the left operand starts. + /// @param addendPtr The pointer where the big number on right operand starts. + /// @param nLimbs The number of 32-byte words that the big numbers occupy. + /// @param sumPtr The pointer where the result of the addition will be stored. + /// @return overflowed A boolean indicating whether the addition overflowed (true) or not (false). + function bigUIntAdd(augendPtr, addendPtr, nLimbs, sumPtr) -> overflowed { + let totalLength := shl(5, nLimbs) + let carry + + let augendCurrentLimbPtr := add(augendPtr, totalLength) + let addendCurrentLimbPtr := add(addendPtr, totalLength) + + // Loop through each full 32-byte word to add the two big numbers. + for { let i := 1 } or(eq(i,nLimbs), lt(i, nLimbs)) { i := add(i, 1) } { + // Check limb from the right (least significant limb) + let currentLimbOffset := shl(5, i) + augendCurrentLimbPtr := sub(augendCurrentLimbPtr, currentLimbOffset) + addendCurrentLimbPtr := sub(addendCurrentLimbPtr, currentLimbOffset) + + let addendLimb := mload(addendCurrentLimbPtr) + let augendLimb := mload(augendCurrentLimbPtr) + let sum, overflow := overflowingAdd(augendLimb, addendLimb) + let sumWithPreviousCarry, carrySumOverflow := overflowingAdd(sum, carry) + sum := sumWithPreviousCarry + carry := or(overflow, carrySumOverflow) + let limbResultPtr := sub(add(sumPtr,totalLength), currentLimbOffset) + mstore(limbResultPtr, sum) + } + overflowed := carry + + } + + function getLimbValueAtOffset(limbPointer, anOffset) -> limbValue { + limbValue := mload(add(anOffset, limbPointer)) + } + + function storeLimbValueAtOffset(limbPointer, anOffset, aValue) { + mstore(add(limbPointer, anOffset), aValue) } - if and(iszero(base_length), iszero(exponent_length)) { - return(0, modulus_length) + /// @notice Computes the difference between two 256 bit number and keeps + /// account of the borrow bit + /// in lshPointer and rhsPointer. + /// @dev Reference: https://github.com/lambdaclass/lambdaworks/blob/main/math/src/unsigned_integer/element.rs#L785 + /// @param leftLimb The left side of the difference (i.e. the a in a - b). + /// @param rightLimb The right side of the difference (i.e. the b in a - b). + /// @return subtractionResult i.e. the c in c = a - b. + /// @return returnBorrow If there was any borrow on the subtraction, is returned as 1. + function subLimbsWithBorrow(leftLimb, rightLimb, limbBorrow) -> subtractionResult, returnBorrow { + let rightPlusBorrow := add(rightLimb, limbBorrow) + subtractionResult := sub(leftLimb, rightPlusBorrow) + returnBorrow := gt(subtractionResult, leftLimb) } + /// @notice Computes the BigUint subtraction between the number stored + /// in minuendPtr and subtrahendPtr. + /// @dev Reference: https://github.com/lambdaclass/lambdaworks/blob/main/math/src/unsigned_integer/element.rs#L795 + /// @param minuendPtr The start of the left hand side subtraction Big Number. + /// @param subtrahendPtr The start of the right hand side subtraction Big Number. + /// @return nLimbs The number of limbs of both numbers. + /// @return differencePtr Where the result will be stored. + function bigUIntSubWithBorrow(minuendPtr, subtrahendPtr, nLimbs, differencePtr) -> borrow { + let minuendCurrentLimb + let subtrahendCurrentLimb + let differenceCurrentLimb + borrow := 0 + let limbOffset + for { let i := nLimbs } gt(i, 0) { i := sub(i, 1) } { + limbOffset := shl(5, sub(i,1)) + let minuendCurrentLimb := getLimbValueAtOffset(minuendPtr, limbOffset) + let subtrahendCurrentLimb := getLimbValueAtOffset(subtrahendPtr, limbOffset) + differenceCurrentLimb, borrow := overflowingSubWithBorrow(minuendCurrentLimb, subtrahendCurrentLimb, borrow) + storeLimbValueAtOffset(differencePtr, limbOffset, differenceCurrentLimb) + } + } + + /// @notice Performs the multiplication between two bigUInts + /// @dev The result is stored from `productPtr` to `productPtr + (LIMB_SIZE * nLimbs)`. + /// @param multiplicandPtr The start index in memory of the first number. + /// @param multiplierPtr The start index in memory of the second number. + /// @param nLimbs The number of limbs needed to represent the operands. + function bigUIntMul(multiplicandPtr, multiplierPtr, nLimbs, productPtr) { + zeroWithLimbSizeAt(shl(1, nLimbs), productPtr) // product = 0 + + let retIndex, retWordAfter, retWordBefore + // Iterating over each limb in the first number. + for { let i := nLimbs } gt(i, 0) { i := sub(i, 1) } { + let carry + + // Iterating over each limb in the second number. + for { let j := nLimbs } gt(j, 0) { j := sub(j, 1) } { + // Loading the i-th and j-th limbs of the first and second numbers. + let word1 := mload(add(multiplicandPtr, shl(5, sub(i, 1)))) + let word2 := mload(add(multiplierPtr, shl(5, sub(j, 1)))) + + let product, carryFlag := overflowingAdd(mul(word1, word2), carry) + carry := add(getHighestHalfOfMultiplication(word1, word2), carryFlag) + + // Calculate the index to store the product. + retIndex := add(productPtr, shl(5, sub(add(i, j), 1))) + retWordBefore := mload(retIndex) // Load the previous value at the result index. + retWordAfter, carryFlag := overflowingAdd(retWordBefore, product) + + mstore(retIndex, retWordAfter) + carry := add(carry, carryFlag) + } + + // Store the last word which comes from the final carry. + retIndex := add(productPtr, shl(5, sub(i, 1))) + mstore(retIndex, carry) + } + } + + // @notice Computes the bit size of an unsigned integer. + // @dev Return value boundary: `0 <= bitSize <= 256` + // @param number An unsigned integer value. + // @return bitSize Number of bits required to represent `number`. + function UIntBitSize(number) -> bitSize { + // Increment bitSize until there are no significant bits left. + bitSize := 0 + for { let shift_me := number } lt(0, shift_me) { shift_me := shr(1, shift_me) } { + bitSize := add(bitSize, 1) + } + } + + /// @notice Computes the bit size of a big unsigned integer. + /// @param basePtr Base pointer for a big unsigned integer. + /// @param nLimbs The number of limbs needed to represent the operand. + /// @return bitSize Number of bits of the big unsigned integer. + function bigUIntBitSize(basePtr, nLimbs) -> bitSize { + bitSize := shl(8, nLimbs) + + // Iterate until finding the most significant limb or reach the end of the limbs. + let limb + let offset + for { let i } and(lt(i, nLimbs), iszero(limb)) { i := add(i, 1) } { + bitSize := sub(bitSize, 256) // Decrement one limb worth of bits. + let ptr_i := add(basePtr, offset) // = basePtr + i * 32 bytes + limb := mload(ptr_i) + offset := add(offset, LIMB_SIZE_IN_BYTES()) + } + + // At this point, `limb == limbs[i - 1]`. Where `i` equals the + // last value it took. + + // At this point, `bitSize` equals the amount of bits in the + // limbs following the most significant limb. - let base_pointer := 96 - let base_padding := sub(WORD_SIZE(), base_length) - let padded_base_pointer := add(96, base_padding) - calldatacopy(padded_base_pointer, base_pointer, base_length) - let base := mload(base_pointer) + bitSize := add(bitSize, UIntBitSize(limb)) + } + + /// @notice Performs in-place `x | 1` operation. + /// @dev This function will mutate the memory space `mem[basePtr...(basePtr + nLimbs * 32)]` + /// @dev It consumes constant time, aka `O(1)`. + /// @param basePtr Base pointer for a big unsigned integer. + /// @param nLimbs Number of 32 Byte limbs composing the big unsigned integer. + function bigUIntInPlaceOrWith1(basePtr, nLimbs) { + let offset := shl(5, sub(nLimbs, 1)) + let limbPtr := add(basePtr, offset) + let limb := mload(limbPtr) + mstore(limbPtr, or(limb, 0x1)) + } + + /// @notice Performs one shift to the left for a big unsigned integer (<<). + /// @dev The shift is performed in-place, mutating the memory space of the number. + /// @param numberPtr The pointer to the MSB of the number to shift. + /// @param nLimbs The number of limbs needed to represent the operand. + function bigUIntOneShiftLeft(numberPtr, nLimbs) { + let p := add(numberPtr, shl(5, nLimbs)) // numberPtr + 32 * nLimbs + let carryBit + for { } lt(numberPtr, p) { } { + p := sub(p, 32) + let limb := mload(p) + let msb := shr(255, limb) + limb := or(shl(1, limb), carryBit) + mstore(p, limb) + carryBit := msb + } + } + + /// @notice Performs one shift to the right for a big unsigned integer (>>). + /// @dev The shift is performed in-place, mutating the memory space of the number. + /// @param numberPtr The pointer to the MSB of the number to shift. + /// @param nLimbs The number of limbs needed to represent the operand. + function bigUIntOneShiftRight(numberPtr, nLimbs) { + let overflowPtr := add(numberPtr, shl(5, nLimbs)) + let carryBit + for { let p := numberPtr } lt(p, overflowPtr) { p := add(p, 32) } { + let limb := mload(p) + let lsb := and(limb, 1) + limb := or(shr(1, limb), carryBit) + carryBit := shl(255, lsb) + mstore(p, limb) + } + } + + /// @notice Computes the quotiend and reminder of dividing two big unsigned integers. + /// @dev + /// @dev Temporary buffers: + /// @dev ------------------ + /// @dev + /// @dev This function requires two temporary buffers for internal storage: + /// @dev - Both buffers must provide `nLimbs * 32` bytes of writable memory space. + /// @dev - Neither buffer should overlap with each other. + /// @dev - Neither needs to be initialized to any particular value. + /// @dev - Consider the written values as undefined after the function returns. + /// @dev + /// @dev Return values: + /// @dev -------------- + /// @dev + /// @dev - resulting `quotient` will be written `mem[basePtr, basePtr + 32 * nLimbs)` + /// @dev - resulting `reminder` will be written `mem[basePtr, basePtr + 32 * nLimbs)` + /// @dev + /// @param dividend_ptr Base pointer for a big unsigned integer representing the dividend. + /// @param divisor_ptr Base pointer for a big unsigned integer representing the divisor. + /// @param tmp_ptr_1 Base pointer for a contiguous memory space of `nLimbs` for internal usage. Will be overwritten. + /// @param tmp_ptr_2 Base pointer for a contiguous memory space of `nLimbs` for internal usage. Will be overwritten. + /// @param nLimbs Amount of limbs for each big unsigned integer. + /// @param quotient_ptr Base pointer for a big unsigned integer to write the division quotient. + /// @param rem_ptr Base pointer for a big unsigned integer to write the division remainder. + function bigUIntRem(dividend_ptr, divisor_ptr, tmp_ptr_1, tmp_ptr_2, nLimbs, realLimbs, modulusBitSize, rem_ptr) { + // Assign meaningful internal names to the temporary buffers passed as parameters. We use abstract names for + // parameters to prevent the leakage of implementation details. + zeroWithLimbSizeAt(nLimbs, tmp_ptr_1) // tmp_ptr_1 = 0 + zeroWithLimbSizeAt(nLimbs, tmp_ptr_2) // tmp_ptr_2 = 0 + + copyBigUint(nLimbs, dividend_ptr, rem_ptr) // rem = dividend + + let bd := sub(shl(8, realLimbs), modulusBitSize) + bigUIntShl(bd, divisor_ptr, nLimbs, tmp_ptr_1) // c == divisor << bd + + for { } iszero(0) { } { + let borrow := bigUIntSubWithBorrow(rem_ptr, tmp_ptr_1, nLimbs, tmp_ptr_2) + + if iszero(borrow) { + copyBigUint(nLimbs, tmp_ptr_2, rem_ptr) + } + + if iszero(bd) { + break + } + + bd := sub(bd, 1) + bigUIntOneShiftRight(tmp_ptr_1, nLimbs) // c = c >> 1 + } + } + + function bigUIntIsGreaterThanOne(nLimbs, basePtr) -> ret { + // Pointer to the least significant limb. + let p := add(basePtr, shl(5, sub(nLimbs, 1))) + + // Least significant limb. + let limb := mload(p) + + // If the least significant limb is greater than 1, we know for + // sure that the big unsigned integer will be greater than 1. + ret := gt(limb, 1) + + // If we don't know yet whether the big unsigned integer is + // greater than one, we will have to look if there exists a more + // significative limb thats greater than 0. + // + // We are iterating backwards, because the big unsigned integers + // we are working with may be left padded with zeros to match + // the size of other big unsigned integers. This way we have a + // better chance to consume less iterations. In the worst case + // scenario, where the answer is false, we will have to read the + // whole number from memory, making this algorithm `O(nLimbs)`. + for { } and(lt(basePtr, p), eq(ret, false)) { } { + p := sub(p, LIMB_SIZE_IN_BYTES()) + ret := lt(0, mload(p)) + } + } + + function bigUIntModTwo(nLimbs, basePtr) -> ret { + let p := add(basePtr, shl(5, sub(nLimbs, 1))) // Least significant limb addr. + ret := and(mload(p), 0x1) + } + + function flip(lhs, rhs) -> ret_lhs, ret_rhs { + ret_lhs := rhs + ret_rhs := lhs + } + + function bigUIntLowerHalfPtr(nLimbs, basePtr) -> p { + let upperHalfSizeInBytes := shl(4, nLimbs) // nLimbs * 32 / 2 + p := add(basePtr, upperHalfSizeInBytes) + } + + // @notice Computes the big uint modular exponentiation `result[] := base[] ** exponent[] % modulus[]`. + // @param nLimbs Amount of limbs that compose each of the big unsigned integer parameters. + // @param basePtr Base pointer to a big unsigned integer representing the `base[]`. It's most significant half must be zeros. + // @param exponentPtr Base pointer to a big unsigned integer representing the `exponent[]`. It's most significant half must be zeros. + // @param modulusPtr Base pointer to a big unsigned integer representing the `modulus[]`. Must be greater than 0. It's most significant half must be zeros. + // @param resultPtr Base pointer to a big unsigned integer to store the result[]. Must be initialized to zeros. + function bigUIntModularExponentiation(nLimbs, basePtr, exponentPtr, modulusPtr, resultPtr, scratchBuf1Ptr, scratchBuf2Ptr, scratchBuf3Ptr) { + // Algorithm pseudocode: + // See: https://en.wikipedia.org/wiki/Modular_exponentiation#Pseudocode + // function modular_pow(base, exponent, modulus) is + // if modulus = 1 then + // return 0 + // Assert :: (modulus - 1) * (modulus - 1) does not overflow base + // result := 1 + // base := base mod modulus + // while exponent > 0 do + // if (exponent mod 2 == 1) then + // result := (result * base) mod modulus + // exponent := exponent >> 1 + // base := (base * base) mod modulus + // return result + + // PSEUDOCODE: `if modulus = 1 then return 0`. + // We are using the precondition that `result == 0` and `0 < modulus`. + // FIXME: Does the algorithm work without this check? We may be paying the cost of running this function just for a rare test case. + if bigUIntIsGreaterThanOne(nLimbs, modulusPtr) { + + // Assert :: (modulus - 1) * (modulus - 1) does not overflow base + // We are certain that this is true because our precondition requires the most significant half of exponent to be zeros. + + // PSEUDOCODE: `result := 1` + // Again, we are using the precondition that `result[] == 0` + bigUIntInPlaceOrWith1(resultPtr, nLimbs) + let modulusBitSize := bigUIntBitSize(modulusPtr, nLimbs) + let exponentBitSize := bigUIntBitSize(exponentPtr, nLimbs) + + // PSEUDOCODE: `base := base mod modulus` + // FIXME: Is ok to mutate the base[] we were given? Shall we use a temporal buffer? + let limbsToRem := bigIntLimbsWithoutZeros(basePtr, nLimbs) + bigUIntRem(basePtr, modulusPtr, scratchBuf1Ptr, scratchBuf2Ptr, nLimbs, limbsToRem, modulusBitSize, scratchBuf3Ptr) + basePtr, scratchBuf3Ptr := flip(basePtr, scratchBuf3Ptr) + + // PSEUDOCODE: `while exponent > 0 do` + // FIXME: Is ok to mutate the exponent[] we were given? Shall we use a temporal buffer? + for { let i } lt(i, exponentBitSize) { i := add(i, 1) } { + let base_low_ptr := bigUIntLowerHalfPtr(nLimbs, basePtr) + // PSEUDOCODE: `if (exponent mod 2 == 1) then` + if bigUIntModTwo(nLimbs, exponentPtr) { + + // PSEUDOCODE: `result := (result * base) mod modulus` + // Since result[] is our return value, we are allowed to mutate it. + let result_low_ptr := bigUIntLowerHalfPtr(nLimbs, resultPtr) + + // scratch_buf_1 <- result * base. NOTICE that the higher half of `scratch_buf_1` may be non-0. + bigUIntMul(result_low_ptr, base_low_ptr, shr(1, nLimbs), scratchBuf1Ptr) + // result <- scratch_buf_1 % modulus. The upper half of return is guaranteed to be 0. + let limbsToRem := bigIntLimbsWithoutZeros(scratchBuf1Ptr, nLimbs) + bigUIntRem(scratchBuf1Ptr, modulusPtr, scratchBuf3Ptr, scratchBuf2Ptr, nLimbs, limbsToRem, modulusBitSize, resultPtr) + } + + // PSEUDOCODE: `exponent := exponent >> 1` + // FIXME: Is ok to mutate the exponent[] we were given? Shall we use a temporal buffer? + bigUIntOneShiftRight(exponentPtr, nLimbs) + + // PSEUDOCODE: `base := (base * base) mod modulus` + // scratch_buf_2 <- base * base + bigUIntMul(base_low_ptr, base_low_ptr, shr(1, nLimbs), scratchBuf2Ptr) + + let limbsToRem := bigIntLimbsWithoutZeros(scratchBuf2Ptr, nLimbs) + // base <- temp % modulus + bigUIntRem(scratchBuf2Ptr, modulusPtr, scratchBuf1Ptr, scratchBuf3Ptr, nLimbs, limbsToRem, modulusBitSize, basePtr) + } + } + } - // As the exponent length could be more than 32 bytes we - // decided to represent the exponent with limbs. Because - // of that, we keep track of a calldata pointer and a memory - // pointer. - // - // The calldata pointer keeps track of the real exponent length - // (which could not be divisible by the word size). - // The memory pointer keeps track of the adjusted exponent length - // (which is always divisible by the word size). - // - // There is a special case to handle when the leftmost limb of - // the exponent has less than 32 bytes in the calldata (e.g. if - // the calldata has 33 bytes in the calldata, in our limbs - // representation it should have 64 bytes). Here is where it - // it could be a difference between the real exponent length and - // the adjusted exponent length. - // - // For the amount of limbs, if the exponent length is divisible - // by the word size, then we just divide it by the word size. - // If not, we divide and then add the remainder limb (this is - // the case when the leftmost limb has less than 32 bytes). - // - // In the special case, the memory exponent pointer and the - // calldata exponent pointer are outphased. That's why after - // loading the exponent from the calldata, we still need to - // compute two pointers for the modulus. - let calldata_exponent_pointer := add(base_pointer, base_length) - let memory_exponent_pointer := add(base_pointer, WORD_SIZE()) - let exponent_limbs := 0 - switch iszero(mod(exponent_length, WORD_SIZE())) - case 0 { - exponent_limbs := add(div(exponent_length, WORD_SIZE()), 1) - } - case 1 { - exponent_limbs := div(exponent_length, WORD_SIZE()) - } - // The exponent expected length given the amount of limbs. - let adjusted_exponent_length := mul(WORD_SIZE(), exponent_limbs) - let calldata_next_limb_pointer := calldata_exponent_pointer - let memory_next_limb_pointer := memory_exponent_pointer - for { let limb_number := 0 } lt(limb_number, exponent_limbs) { limb_number := add(limb_number, 1) } { - // The msb of the leftmost limb could be one. - // This left-pads with zeros the leftmost limbs to achieve 32 bytes. - if iszero(limb_number) { - // The amount of zeros to left-pad. - let padding := sub(adjusted_exponent_length, exponent_length) - // This is either 0 or > 0 if there are any zeros to pad. - let padded_exponent_pointer := add(memory_exponent_pointer, padding) - let amount_of_bytes_for_first_limb := sub(WORD_SIZE(), padding) - calldatacopy(padded_exponent_pointer, calldata_exponent_pointer, amount_of_bytes_for_first_limb) - calldata_next_limb_pointer := add(calldata_exponent_pointer, amount_of_bytes_for_first_limb) - memory_next_limb_pointer := add(memory_exponent_pointer, WORD_SIZE()) - continue - } - calldatacopy(memory_next_limb_pointer, calldata_next_limb_pointer, WORD_SIZE()) - calldata_next_limb_pointer := add(calldata_next_limb_pointer, WORD_SIZE()) - memory_next_limb_pointer := add(memory_next_limb_pointer, WORD_SIZE()) - } - - let calldata_modulus_pointer := add(calldata_exponent_pointer, exponent_length) - let memory_modulus_pointer := add(memory_exponent_pointer, adjusted_exponent_length) - calldatacopy(add(memory_modulus_pointer, sub(WORD_SIZE(), modulus_length)), calldata_modulus_pointer, modulus_length) - - let modulus := mload(memory_modulus_pointer) + /// @notice Pad a big uint with zeros to the left until newLimbNumber is reached. + /// @dev The result is stored from `resultPtr` to `resultPtr + (LIMB_SIZE_IN_BYTES * newLimbNumber)`. + /// @dev If currentLimbNumber is equal to newLimbNumber, then the result is the same as the input. + /// @param ptr The pointer to the MSB of the number to pad. + /// @param currentLimbNumber The number of limbs needed to represent the operand. + /// @param newLimbNumber The number of limbs wanted to represent the operand. + /// @param resultPtr The pointer to the MSB of the padded number. + function bigUIntPadWithZeros(ptr, currentLimbNumber, newLimbNumber, resultPtr) { + for { let i } lt(i, currentLimbNumber) { i := add(i, 1) } { + // Move the limb to the right position + mstore(add(resultPtr, shl(5, sub(sub(newLimbNumber, 1), i))), mload(add(ptr, shl(5, sub(sub(currentLimbNumber,1), i))))) + } + } - // 1^exponent % modulus = 1 - if eq(base, 1) { - mstore(0, 1) - let unpadding := sub(WORD_SIZE(), modulus_length) - return(unpadding, modulus_length) + // Last limbs refers to the most significant limb in big-endian representation. + function parseCalldata(calldataValuePtr, calldataValueLen, resPtr) -> memoryValueLen { + // The in-memory value length in bytes of the calldata value. + memoryValueLen := calldataValueLen + let numberOfLimbs := div(calldataValueLen, LIMB_SIZE_IN_BYTES()) + let lastLimbMisalignmentInBytes := mod(calldataValueLen, LIMB_SIZE_IN_BYTES()) + let firstLimbExtraBytes := sub(LIMB_SIZE_IN_BYTES(), lastLimbMisalignmentInBytes) + let lastLimbBytes := sub(LIMB_SIZE_IN_BYTES(), firstLimbExtraBytes) + let misalignedWordPtr := sub(calldataValuePtr, firstLimbExtraBytes) + if lastLimbMisalignmentInBytes { + // If there is a misalignment, then we need to add one more limb to the result length. + numberOfLimbs := add(numberOfLimbs, 1) + memoryValueLen := shl(5, numberOfLimbs) + let misalignedLimb := calldataload(misalignedWordPtr) + let firstWordExtraBits := shl(3, firstLimbExtraBytes) + misalignedLimb := shl(firstWordExtraBits, misalignedLimb) + misalignedLimb := shr(firstWordExtraBits, misalignedLimb) + mstore(resPtr, misalignedLimb) + } + + let currentLimbCalldataPtr := calldataValuePtr + let currentLimbMemoryPtr := resPtr + for { let currentLimbNumber } lt(currentLimbNumber, numberOfLimbs) { currentLimbNumber := add(currentLimbNumber, 1) } { + if and(iszero(currentLimbNumber), gt(lastLimbMisalignmentInBytes, 0)) { + // If the MSL is misaligned, then at this point it has been handled and we should + // skip the first iteration (which handles the MSL if it is not misaligned). + currentLimbCalldataPtr := add(currentLimbCalldataPtr, lastLimbBytes) + currentLimbMemoryPtr := add(currentLimbMemoryPtr, LIMB_SIZE_IN_BYTES()) + continue + } + let currentLimb := calldataload(currentLimbCalldataPtr) + mstore(currentLimbMemoryPtr, currentLimb) + currentLimbCalldataPtr := add(currentLimbCalldataPtr, LIMB_SIZE_IN_BYTES()) + currentLimbMemoryPtr := add(currentLimbMemoryPtr, LIMB_SIZE_IN_BYTES()) + } + } + + //////////////////////////////////////////////////////////////// + // FALLBACK + //////////////////////////////////////////////////////////////// + let baseLen := calldataload(0) + let expLen := calldataload(32) + let modLen := calldataload(64) + + // Handle a special case when both the base and mod length are zeroes. + if and(iszero(baseLen), iszero(modLen)) { + return(0, 0) } + let basePtr := 96 + let expPtr := add(basePtr, baseLen) + let modPtr := add(expPtr, expLen) + + // Note: This check covers the case where length of the modulo is zero. // base^exponent % 0 = 0 - if iszero(modulus) { - mstore(0, 0) - return(0, modulus_length) + if callDataBufferIsZero(modPtr, modLen) { + // Fulfill memory with all zeroes. + for { let ptr } lt(ptr, modLen) { ptr := add(ptr, 32) } { + mstore(ptr, 0) + } + return(0, modLen) + } + + // 1^exponent % modulus = 1 + if callDataBufferIsOne(basePtr, baseLen) { + // Fulfill memory with all zeroes. + for { let ptr } lt(ptr, modLen) { ptr := add(ptr, 32) } { + mstore(ptr, 0) + } + mstore8(sub(modLen, 1), 1) + return(0, modLen) } // base^0 % modulus = 1 - if exponentIsZero(exponent_length, memory_exponent_pointer) { - mstore(0, 1) - let unpadding := sub(WORD_SIZE(), modulus_length) - return(unpadding, modulus_length) + if callDataBufferIsZero(expPtr, expLen) { + // Fulfill memory with all zeroes. + for { let ptr } lt(ptr, modLen) { ptr := add(ptr, 32) } { + mstore(ptr, 0) + } + mstore8(sub(modLen, 1), 1) + return(0, modLen) } // 0^exponent % modulus = 0 - if iszero(base) { - mstore(0, 0) - return(0, modulus_length) - } - - switch eq(exponent_limbs, 1) - // Special case of one limb, we load the hole word. - case 1 { - let pow := 1 - // If we have one limb, then the exponent has 32 bytes and it is - // located in 0x - let exponent := mload(memory_exponent_pointer) - base := mod(base, modulus) - for { let i := 0 } gt(exponent, 0) { i := add(i, 1) } { - if eq(mod(exponent, 2), 1) { - pow := mulmod(pow, base, modulus) - } - exponent := shr(1, exponent) - base := mulmod(base, base, modulus) - } - - mstore(0, pow) - let unpadding := sub(WORD_SIZE(), modulus_length) - return(unpadding, modulus_length) - } - case 0 { - let pow := 1 - base := mod(base, modulus) - let next_limb_pointer := memory_exponent_pointer - for { let limb_number := 0 } lt(limb_number, exponent_limbs) { limb_number := add(limb_number, 1) } { - let current_limb := mload(next_limb_pointer) - for { let i := 0 } gt(current_limb, 0) { i := add(i, 1) } { - if eq(mod(current_limb, 2), 1) { - pow := mulmod(pow, base, modulus) - } - current_limb := shr(1, current_limb) - base := mulmod(base, base, modulus) - } - next_limb_pointer := add(next_limb_pointer, WORD_SIZE()) + if callDataBufferIsZero(basePtr, baseLen) { + // Fulfill memory with all zeroes. + for { let ptr } lt(ptr, modLen) { ptr := add(ptr, 32) } { + mstore(ptr, 0) } - mstore(0, pow) - let unpadding := sub(WORD_SIZE(), modulus_length) - return(unpadding, modulus_length) + return(0, modLen) + } + + let limbsBaseLen, misalignment := bigIntLimbs(baseLen) + let limbsExpLen, misalignment := bigIntLimbs(expLen) + let limbsModLen, misalignment := bigIntLimbs(modLen) + + let ptrBaseLimbs + parseCalldata(basePtr, baseLen, ptrBaseLimbs) + + let ptrExpLimbs := shl(5, limbsBaseLen) + parseCalldata(expPtr, expLen, ptrExpLimbs) + + let ptrModLimbs := add(ptrExpLimbs, shl(5, limbsExpLen)) + parseCalldata(modPtr, modLen, ptrModLimbs) + + let maxLimbNumber := limbsBaseLen + if lt(maxLimbNumber, limbsExpLen) { + maxLimbNumber := limbsExpLen + } + if lt(maxLimbNumber, limbsModLen) { + maxLimbNumber := limbsModLen } + + maxLimbNumber := add(maxLimbNumber, maxLimbNumber) + let memForMaxLimbNumber := shl(5, maxLimbNumber) + let baseStartPtr := add(ptrModLimbs, shl(5, limbsModLen)) + let exponentStartPtr := add(baseStartPtr, memForMaxLimbNumber) + let moduloStartPtr := add(exponentStartPtr, memForMaxLimbNumber) + + bigUIntPadWithZeros(ptrBaseLimbs, limbsBaseLen, maxLimbNumber, baseStartPtr) + bigUIntPadWithZeros(ptrExpLimbs, limbsExpLen, maxLimbNumber, exponentStartPtr) + bigUIntPadWithZeros(ptrModLimbs, limbsModLen, maxLimbNumber, moduloStartPtr) + + let scratchBufferPtr1 := add(moduloStartPtr, memForMaxLimbNumber) + let scratchBufferPtr2 := add(scratchBufferPtr1, memForMaxLimbNumber) + let scratchBufferPtr3 := add(scratchBufferPtr2, memForMaxLimbNumber) + let resultPtr := add(scratchBufferPtr3, memForMaxLimbNumber) + + bigUIntModularExponentiation(maxLimbNumber, baseStartPtr, exponentStartPtr, moduloStartPtr, resultPtr, scratchBufferPtr1, scratchBufferPtr2, scratchBufferPtr3) + + let finalResultEnd := add(resultPtr, memForMaxLimbNumber) + let finalResultStart := sub(finalResultEnd, modLen) + return(finalResultStart, modLen) } } } diff --git a/scripts/modexp_reference.py b/scripts/modexp_reference.py new file mode 100644 index 00000000..d4c5d992 --- /dev/null +++ b/scripts/modexp_reference.py @@ -0,0 +1,22 @@ +#! /usr/bin/python3 +def modular_pow(base, exponent, modulus): + if modulus == 1: + return 0 + + result = 1 + base %= modulus + + while exponent > 0: + print(f"Exponent: {hex(exponent)}, result: {hex(result)}, base: {hex(base)}") + if exponent % 2 == 1: + result = (result * base) % modulus + exponent >>= 1 + base = (base * base) % modulus + + return result + +# Example usage: +base = 390298093899999943928098409885853890809480289080848908498808490890809858888590 +exponent = 328010176336108753607932954472681594880 +modulus = 328083392909999939299399093209090192209 +result = modular_pow(base, exponent, modulus) diff --git a/tests/build.rs b/tests/build.rs new file mode 100644 index 00000000..2db7f9db --- /dev/null +++ b/tests/build.rs @@ -0,0 +1,33 @@ +use std::fs::OpenOptions; +use std::io::Write; + +fn main() { + let directory = "gas_reports"; + if !std::path::Path::new(directory).exists() { + std::fs::create_dir(directory).unwrap(); + } + + let precompiles_report_list: Vec = vec![ + "modexp".to_string(), + "ecadd".to_string(), + "ecmul".to_string(), + "ecpairing".to_string(), + "p256verify".to_string(), + "secp256k1verify".to_string(), + ]; + precompiles_report_list + .into_iter() + .for_each(|mut precompile_name| { + let file_path = format!("{}/{}_report.md", directory, precompile_name); + precompile_name.push_str("_report.md"); + let mut file = OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .open(file_path) + .unwrap(); + + writeln!(file, "| Test case | Gas used |").unwrap(); + writeln!(file, "| --------- | -------- |").unwrap(); + }); +} diff --git a/tests/tests/ecadd_tests.rs b/tests/tests/ecadd_tests.rs index ad59361b..92ef7567 100644 --- a/tests/tests/ecadd_tests.rs +++ b/tests/tests/ecadd_tests.rs @@ -1,9 +1,7 @@ use zksync_web3_rs::{types::Bytes, zks_utils::ECADD_PRECOMPILE_ADDRESS}; mod test_utils; -use test_utils::{era_call, eth_call}; - -use crate::test_utils::parse_call_result; +use test_utils::{era_call, eth_call, parse_call_result, write_ecadd_gas_result}; // Puts the points (6, 9) and (19274124, 124124) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 25000 bytes #[tokio::test] @@ -29,8 +27,8 @@ async fn ecadd_0_0_0_0_21000_0() { ) .await .unwrap(); - - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 0 bytes. Gives the execution 21000 bytes"); } @@ -39,7 +37,8 @@ async fn ecadd_0_0_0_0_21000_0() { async fn ecadd_1_2_0_0_21000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -48,7 +47,8 @@ async fn ecadd_1_2_0_0_21000_128() { async fn ecadd_0_0_0_0_25000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 25000 bytes"); } @@ -71,7 +71,8 @@ async fn ecadd_0_0_1_3_25000_128() { async fn ecadd_0_0_1_2_25000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (1, 2) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 25000 bytes"); } @@ -80,7 +81,8 @@ async fn ecadd_0_0_1_2_25000_128() { async fn ecadd_0_0_0_0_25000_64() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 64 bytes. Gives the execution 25000 bytes"); } @@ -89,7 +91,8 @@ async fn ecadd_0_0_0_0_25000_64() { async fn ecadd_1_2_1_2_21000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (1, 2) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -105,7 +108,8 @@ async fn ecadd_1_3_0_0_25000_80() { async fn ecadd_1_2_0_0_25000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 25000 bytes"); } @@ -114,7 +118,8 @@ async fn ecadd_1_2_0_0_25000_192() { async fn ecadd_0_0_0_0_21000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 21000 bytes"); } @@ -123,7 +128,8 @@ async fn ecadd_0_0_0_0_21000_192() { async fn ecadd_0_0_0_0_25000_80() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 80 bytes. Gives the execution 25000 bytes"); } @@ -132,7 +138,8 @@ async fn ecadd_0_0_0_0_25000_80() { async fn ecadd_1145_3932_1145_4651_21000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa92e83f8d734803fc370eba25ed1f6b8768bd6d83887b87165fc2434fe11a830cb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa92e83f8d734803fc370eba25ed1f6b8768bd6d83887b87165fc2434fe11a830cb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (10744596414106452074759370245733544594153395043370666422502510773307029471145, 848677436511517736191562425154572367705380862894644942948681172815252343932) and (10744596414106452074759370245733544594153395043370666422502510773307029471145, 21039565435327757486054843320102702720990930294403178719740356721829973864651) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 21000 bytes"); } @@ -141,7 +148,8 @@ async fn ecadd_1145_3932_1145_4651_21000_192() { async fn ecadd_0_0_1_2_21000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (1, 2) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 21000 bytes"); } @@ -150,7 +158,8 @@ async fn ecadd_0_0_1_2_21000_192() { async fn ecadd_1_2_1_2_25000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (1, 2) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 25000 bytes"); } @@ -159,7 +168,8 @@ async fn ecadd_1_2_1_2_25000_192() { async fn ecadd_1_2_0_0_25000_64() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 64 bytes. Gives the execution 25000 bytes"); } @@ -168,7 +178,8 @@ async fn ecadd_1_2_0_0_25000_64() { async fn ecadd_1145_3932_2969_1336_21000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d98").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d98").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (10744596414106452074759370245733544594153395043370666422502510773307029471145, 848677436511517736191562425154572367705380862894644942948681172815252343932) and (1624070059937464756887933993293429854168590106605707304006200119738501412969, 3269329550605213075043232856820720631601935657990457502777101397807070461336) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -184,7 +195,8 @@ async fn ecadd_6_9_19274124_124124_21000_128() { async fn ecadd_0_0_0_0_21000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -207,7 +219,8 @@ async fn ecadd_0_0_1_3_21000_128() { async fn ecadd_1_2_0_0_25000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 25000 bytes"); } @@ -223,7 +236,8 @@ async fn ecadd_1_3_0_0_21000_80() { async fn ecadd_1_2_1_2_25000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (1, 2) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 25000 bytes"); } @@ -244,8 +258,8 @@ async fn ecadd_0_0_0_0_25000_0() { ) .await .unwrap(); - - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 0 bytes. Gives the execution 25000 bytes"); } @@ -254,7 +268,8 @@ async fn ecadd_0_0_0_0_25000_0() { async fn ecadd_0_0_1_2_21000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (1, 2) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -263,7 +278,8 @@ async fn ecadd_0_0_1_2_21000_128() { async fn ecadd_0_0_0_0_21000_64() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 64 bytes. Gives the execution 21000 bytes"); } @@ -272,7 +288,8 @@ async fn ecadd_0_0_0_0_21000_64() { async fn ecadd_0_0_0_0_21000_80() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 80 bytes. Gives the execution 21000 bytes"); } @@ -281,7 +298,8 @@ async fn ecadd_0_0_0_0_21000_80() { async fn ecadd_0_0_0_0_25000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 25000 bytes"); } @@ -290,7 +308,8 @@ async fn ecadd_0_0_0_0_25000_192() { async fn ecadd_1_2_0_0_21000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 21000 bytes"); } @@ -299,7 +318,8 @@ async fn ecadd_1_2_0_0_21000_192() { async fn ecadd_1_2_1_2_21000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (1, 2) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 21000 bytes"); } @@ -308,7 +328,8 @@ async fn ecadd_1_2_1_2_21000_192() { async fn ecadd_0_0_1_2_25000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (0, 0) and (1, 2) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 25000 bytes"); } @@ -317,7 +338,8 @@ async fn ecadd_0_0_1_2_25000_192() { async fn ecadd_1145_3932_1145_4651_25000_192() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa92e83f8d734803fc370eba25ed1f6b8768bd6d83887b87165fc2434fe11a830cb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa92e83f8d734803fc370eba25ed1f6b8768bd6d83887b87165fc2434fe11a830cb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (10744596414106452074759370245733544594153395043370666422502510773307029471145, 848677436511517736191562425154572367705380862894644942948681172815252343932) and (10744596414106452074759370245733544594153395043370666422502510773307029471145, 21039565435327757486054843320102702720990930294403178719740356721829973864651) into the ECADD precompile, truncating or expanding the input data to 192 bytes. Gives the execution 25000 bytes"); } @@ -326,7 +348,8 @@ async fn ecadd_1145_3932_1145_4651_25000_192() { async fn ecadd_1145_3932_2969_1336_25000_128() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d98").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d98").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (10744596414106452074759370245733544594153395043370666422502510773307029471145, 848677436511517736191562425154572367705380862894644942948681172815252343932) and (1624070059937464756887933993293429854168590106605707304006200119738501412969, 3269329550605213075043232856820720631601935657990457502777101397807070461336) into the ECADD precompile, truncating or expanding the input data to 128 bytes. Gives the execution 25000 bytes"); } @@ -335,6 +358,7 @@ async fn ecadd_1145_3932_2969_1336_25000_128() { async fn ecadd_1_2_0_0_21000_64() { let eth_response = eth_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECADD_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecadd_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the points (1, 2) and (0, 0) into the ECADD precompile, truncating or expanding the input data to 64 bytes. Gives the execution 21000 bytes"); } diff --git a/tests/tests/ecmul_tests.rs b/tests/tests/ecmul_tests.rs index 6379e577..9c2431e3 100644 --- a/tests/tests/ecmul_tests.rs +++ b/tests/tests/ecmul_tests.rs @@ -1,9 +1,7 @@ use zksync_web3_rs::{types::Bytes, zks_utils::ECMUL_PRECOMPILE_ADDRESS}; mod test_utils; -use test_utils::{era_call, eth_call}; - -use crate::test_utils::parse_call_result; +use test_utils::{era_call, eth_call, parse_call_result, write_ecmul_gas_result}; // Puts the point (1, 3) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes #[tokio::test] @@ -17,7 +15,8 @@ async fn ecmul_1_3_0_21000_128() { async fn ecmul_1_2_5616_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -47,7 +46,8 @@ async fn ecmul_1_3_5617_28000_96() { async fn ecmul_1_2_5616_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -77,7 +77,8 @@ async fn ecmul_1_3_5616_28000_128() { async fn ecmul_7827_6598_5616_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -100,7 +101,8 @@ async fn ecmul_1_3_5617_28000_128() { async fn ecmul_1_2_340282366920938463463374607431768211456_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -123,7 +125,8 @@ async fn ecmul_1_3_1_28000_128() { async fn ecmul_1_2_9935_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -132,7 +135,8 @@ async fn ecmul_1_2_9935_21000_96() { async fn ecmul_1_2_5617_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -141,7 +145,8 @@ async fn ecmul_1_2_5617_28000_128() { async fn ecmul_1_2_340282366920938463463374607431768211456_21000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 21000 bytes"); } @@ -150,7 +155,8 @@ async fn ecmul_1_2_340282366920938463463374607431768211456_21000_80() { async fn ecmul_1_2_2_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -166,7 +172,8 @@ async fn ecmul_1_3_9_21000_128() { async fn ecmul_7827_6598_1456_21000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 21000 bytes"); } @@ -175,7 +182,8 @@ async fn ecmul_7827_6598_1456_21000_80() { async fn ecmul_7827_6598_0_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -184,7 +192,8 @@ async fn ecmul_7827_6598_0_28000_96() { async fn ecmul_7827_6598_1456_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -193,7 +202,8 @@ async fn ecmul_7827_6598_1456_21000_96() { async fn ecmul_7827_6598_0_28000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 28000 bytes"); } @@ -216,7 +226,8 @@ async fn ecmul_1_3_9_28000_96() { async fn ecmul_7827_6598_9935_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -225,7 +236,8 @@ async fn ecmul_7827_6598_9935_21000_96() { async fn ecmul_1_2_5617_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -255,7 +267,8 @@ async fn ecmul_1_3_9935_28000_96() { async fn ecmul_7827_6598_0_28000_64() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 64 bytes. Gives the execution 28000 bytes"); } @@ -264,7 +277,8 @@ async fn ecmul_7827_6598_0_28000_64() { async fn ecmul_1_2_9935_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -280,7 +294,8 @@ async fn ecmul_1_3_9935_28000_128() { async fn ecmul_1_2_9935_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -289,7 +304,8 @@ async fn ecmul_1_2_9935_28000_128() { async fn ecmul_7827_6598_1_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -298,7 +314,8 @@ async fn ecmul_7827_6598_1_21000_96() { async fn ecmul_1_2_9_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -307,7 +324,8 @@ async fn ecmul_1_2_9_28000_96() { async fn ecmul_1_2_5617_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -344,7 +362,8 @@ async fn ecmul_1_3_5616_21000_96() { async fn ecmul_7827_6598_2_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -353,7 +372,8 @@ async fn ecmul_7827_6598_2_21000_96() { async fn ecmul_1_2_9_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -376,7 +396,8 @@ async fn ecmul_1_3_2_21000_128() { async fn ecmul_7827_6598_5617_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -392,7 +413,8 @@ async fn ecmul_1_3_0_28000_80() { async fn ecmul_7827_6598_9_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -401,7 +423,8 @@ async fn ecmul_7827_6598_9_28000_96() { async fn ecmul_1_2_9_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -417,7 +440,8 @@ async fn ecmul_1_3_5617_21000_96() { async fn ecmul_1_2_5616_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -433,7 +457,8 @@ async fn ecmul_1_3_0_21000_64() { async fn ecmul_7827_6598_5616_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -449,7 +474,8 @@ async fn ecmul_1_3_1_28000_96() { async fn ecmul_7827_6598_2_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -458,7 +484,8 @@ async fn ecmul_7827_6598_2_21000_128() { async fn ecmul_1_2_340282366920938463463374607431768211456_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -467,7 +494,8 @@ async fn ecmul_1_2_340282366920938463463374607431768211456_21000_128() { async fn ecmul_7827_6598_9935_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -476,7 +504,8 @@ async fn ecmul_7827_6598_9935_28000_128() { async fn ecmul_1_2_340282366920938463463374607431768211456_28000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 28000 bytes"); } @@ -485,7 +514,8 @@ async fn ecmul_1_2_340282366920938463463374607431768211456_28000_80() { async fn ecmul_1_2_9935_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -501,7 +531,8 @@ async fn ecmul_1_3_2_28000_96() { async fn ecmul_1_2_340282366920938463463374607431768211456_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -510,7 +541,8 @@ async fn ecmul_1_2_340282366920938463463374607431768211456_28000_96() { async fn ecmul_1_2_340282366920938463463374607431768211456_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -519,7 +551,8 @@ async fn ecmul_1_2_340282366920938463463374607431768211456_28000_128() { async fn ecmul_7827_6598_2_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -528,7 +561,8 @@ async fn ecmul_7827_6598_2_28000_128() { async fn ecmul_7827_6598_0_21000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 21000 bytes"); } @@ -537,7 +571,8 @@ async fn ecmul_7827_6598_0_21000_80() { async fn ecmul_7827_6598_1456_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -546,7 +581,8 @@ async fn ecmul_7827_6598_1456_28000_96() { async fn ecmul_7827_6598_0_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -555,7 +591,8 @@ async fn ecmul_7827_6598_0_21000_96() { async fn ecmul_7827_6598_9935_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -564,7 +601,8 @@ async fn ecmul_7827_6598_9935_21000_128() { async fn ecmul_7827_6598_1456_28000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 28000 bytes"); } @@ -573,7 +611,8 @@ async fn ecmul_7827_6598_1456_28000_80() { async fn ecmul_7827_6598_9935_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -589,7 +628,8 @@ async fn ecmul_1_3_9_21000_96() { async fn ecmul_7827_6598_5617_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -605,7 +645,8 @@ async fn ecmul_1_3_9935_21000_96() { async fn ecmul_7827_6598_1456_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -614,7 +655,8 @@ async fn ecmul_7827_6598_1456_21000_128() { async fn ecmul_7827_6598_0_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -623,7 +665,8 @@ async fn ecmul_7827_6598_0_28000_128() { async fn ecmul_1_2_2_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -632,7 +675,8 @@ async fn ecmul_1_2_2_28000_96() { async fn ecmul_7827_6598_0_21000_64() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f6").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 64 bytes. Gives the execution 21000 bytes"); } @@ -641,7 +685,8 @@ async fn ecmul_7827_6598_0_21000_64() { async fn ecmul_7827_6598_5617_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -650,7 +695,8 @@ async fn ecmul_7827_6598_5617_28000_128() { async fn ecmul_7827_6598_0_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -659,7 +705,8 @@ async fn ecmul_7827_6598_0_21000_128() { async fn ecmul_7827_6598_1456_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -668,7 +715,8 @@ async fn ecmul_7827_6598_1456_28000_128() { async fn ecmul_1_2_9_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -677,7 +725,8 @@ async fn ecmul_1_2_9_21000_96() { async fn ecmul_7827_6598_1_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -700,7 +749,8 @@ async fn ecmul_1_3_340282366920938463463374607431768211456_21000_96() { async fn ecmul_7827_6598_9_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -723,7 +773,8 @@ async fn ecmul_1_3_340282366920938463463374607431768211456_21000_128() { async fn ecmul_1_2_5617_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -732,7 +783,8 @@ async fn ecmul_1_2_5617_28000_96() { async fn ecmul_7827_6598_5616_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -741,7 +793,8 @@ async fn ecmul_7827_6598_5616_28000_128() { async fn ecmul_7827_6598_2_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -750,7 +803,8 @@ async fn ecmul_7827_6598_2_28000_96() { async fn ecmul_7827_6598_1_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -766,7 +820,8 @@ async fn ecmul_1_3_0_21000_80() { async fn ecmul_7827_6598_5617_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -775,7 +830,8 @@ async fn ecmul_7827_6598_5617_28000_96() { async fn ecmul_7827_6598_9_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -798,7 +854,8 @@ async fn ecmul_1_3_0_21000_96() { async fn ecmul_7827_6598_5616_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -807,7 +864,8 @@ async fn ecmul_7827_6598_5616_21000_128() { async fn ecmul_1_2_616_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000230644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -816,7 +874,8 @@ async fn ecmul_1_2_616_28000_96() { async fn ecmul_7827_6598_9_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f60000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -825,7 +884,8 @@ async fn ecmul_7827_6598_9_21000_96() { async fn ecmul_7827_6598_1_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (11999875504842010600789954262886096740416429265635183817701593963271973497827, 11843594000332171325303933275547366297934113019079887694534126289021216356598) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -834,7 +894,8 @@ async fn ecmul_7827_6598_1_28000_128() { async fn ecmul_0_0_340282366920938463463374607431768211456_28000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 28000 bytes"); } @@ -843,7 +904,8 @@ async fn ecmul_0_0_340282366920938463463374607431768211456_28000_80() { async fn ecmul_0_0_0_21000_64() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 64 bytes. Gives the execution 21000 bytes"); } @@ -852,7 +914,8 @@ async fn ecmul_0_0_0_21000_64() { async fn ecmul_0_0_1_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -861,7 +924,8 @@ async fn ecmul_0_0_1_21000_128() { async fn ecmul_0_0_340282366920938463463374607431768211456_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -870,7 +934,8 @@ async fn ecmul_0_0_340282366920938463463374607431768211456_28000_96() { async fn ecmul_0_0_0_28000_40() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 40 bytes. Gives the execution 28000 bytes"); } @@ -879,7 +944,8 @@ async fn ecmul_0_0_0_28000_40() { async fn ecmul_0_0_5616_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -888,7 +954,8 @@ async fn ecmul_0_0_5616_21000_96() { async fn ecmul_0_0_9_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -904,7 +971,8 @@ async fn ecmul_0_3_2_21000_96() { async fn ecmul_0_0_1_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -913,7 +981,8 @@ async fn ecmul_0_0_1_28000_96() { async fn ecmul_1_2_0_28000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 28000 bytes"); } @@ -929,7 +998,8 @@ async fn ecmul_0_3_9935_28000_96() { async fn ecmul_1_2_0_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -938,7 +1008,8 @@ async fn ecmul_1_2_0_28000_96() { async fn ecmul_0_0_1_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -947,7 +1018,8 @@ async fn ecmul_0_0_1_28000_128() { async fn ecmul_0_0_9_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -963,7 +1035,8 @@ async fn ecmul_0_3_9_28000_96() { async fn ecmul_0_0_2_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -979,7 +1052,8 @@ async fn ecmul_0_3_0_28000_64() { async fn ecmul_0_0_0_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -988,7 +1062,8 @@ async fn ecmul_0_0_0_28000_128() { async fn ecmul_0_0_9935_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -1004,7 +1079,8 @@ async fn ecmul_0_3_5616_21000_96() { async fn ecmul_0_0_9_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1025,8 +1101,8 @@ async fn ecmul_0_0_0_21000_0() { ) .await .unwrap(); - - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 0 bytes. Gives the execution 21000 bytes"); } @@ -1042,7 +1118,8 @@ async fn ecmul_0_3_1_21000_96() { async fn ecmul_1_2_2_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1051,7 +1128,8 @@ async fn ecmul_1_2_2_21000_128() { async fn ecmul_0_0_0_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1060,7 +1138,8 @@ async fn ecmul_0_0_0_21000_128() { async fn ecmul_0_0_2_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1069,7 +1148,8 @@ async fn ecmul_0_0_2_21000_128() { async fn ecmul_0_0_340282366920938463463374607431768211456_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1078,7 +1158,8 @@ async fn ecmul_0_0_340282366920938463463374607431768211456_21000_128() { async fn ecmul_1_2_0_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1087,7 +1168,8 @@ async fn ecmul_1_2_0_21000_128() { async fn ecmul_1_2_2_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1110,7 +1192,8 @@ async fn ecmul_0_3_0_28000_80() { async fn ecmul_1_2_0_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -1126,7 +1209,8 @@ async fn ecmul_0_3_5617_28000_96() { async fn ecmul_0_0_340282366920938463463374607431768211456_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -1135,7 +1219,8 @@ async fn ecmul_0_0_340282366920938463463374607431768211456_28000_128() { async fn ecmul_0_0_2_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -1144,7 +1229,8 @@ async fn ecmul_0_0_2_28000_128() { async fn ecmul_1_2_1_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -1153,7 +1239,8 @@ async fn ecmul_1_2_1_28000_128() { async fn ecmul_0_0_5617_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -1176,7 +1263,8 @@ async fn ecmul_0_3_340282366920938463463374607431768211456_21000_80() { async fn ecmul_1_2_0_28000_64() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 64 bytes. Gives the execution 28000 bytes"); } @@ -1185,7 +1273,8 @@ async fn ecmul_1_2_0_28000_64() { async fn ecmul_1_2_1_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1194,7 +1283,8 @@ async fn ecmul_1_2_1_21000_128() { async fn ecmul_0_0_0_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1203,7 +1293,8 @@ async fn ecmul_0_0_0_21000_96() { async fn ecmul_1_2_1_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1212,7 +1303,8 @@ async fn ecmul_1_2_1_21000_96() { async fn ecmul_0_0_0_21000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 21000 bytes"); } @@ -1221,7 +1313,8 @@ async fn ecmul_0_0_0_21000_80() { async fn ecmul_0_0_340282366920938463463374607431768211456_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1230,7 +1323,8 @@ async fn ecmul_0_0_340282366920938463463374607431768211456_21000_96() { async fn ecmul_0_0_0_21000_40() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 40 bytes. Gives the execution 21000 bytes"); } @@ -1239,7 +1333,8 @@ async fn ecmul_0_0_0_21000_40() { async fn ecmul_0_0_5616_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1248,7 +1343,8 @@ async fn ecmul_0_0_5616_21000_128() { async fn ecmul_0_0_0_28000_64() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 64 bytes. Gives the execution 28000 bytes"); } @@ -1276,8 +1372,8 @@ async fn ecmul_0_0_0_28000_0() { ) .await .unwrap(); - - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 0 bytes. Gives the execution 28000 bytes"); } @@ -1286,7 +1382,8 @@ async fn ecmul_0_0_0_28000_0() { async fn ecmul_0_0_340282366920938463463374607431768211456_21000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 340282366920938463463374607431768211456 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 21000 bytes"); } @@ -1316,7 +1413,8 @@ async fn ecmul_0_3_2_28000_96() { async fn ecmul_0_0_5616_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -1325,7 +1423,8 @@ async fn ecmul_0_0_5616_28000_96() { async fn ecmul_1_2_0_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1341,7 +1440,8 @@ async fn ecmul_0_3_9935_21000_96() { async fn ecmul_1_2_0_21000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 21000 bytes"); } @@ -1357,7 +1457,8 @@ async fn ecmul_0_3_340282366920938463463374607431768211456_28000_128() { async fn ecmul_0_0_1_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1366,7 +1467,8 @@ async fn ecmul_0_0_1_21000_96() { async fn ecmul_0_0_5616_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495616 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -1403,7 +1505,8 @@ async fn ecmul_0_3_5617_21000_128() { async fn ecmul_0_0_2_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 2 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1412,7 +1515,8 @@ async fn ecmul_0_0_2_21000_96() { async fn ecmul_0_0_9935_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1421,7 +1525,8 @@ async fn ecmul_0_0_9935_21000_96() { async fn ecmul_0_0_5617_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -1444,7 +1549,8 @@ async fn ecmul_0_3_5617_28000_128() { async fn ecmul_0_0_9_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 9 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -1460,7 +1566,8 @@ async fn ecmul_0_3_5616_28000_96() { async fn ecmul_0_0_5617_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1490,7 +1597,8 @@ async fn ecmul_0_3_9935_28000_128() { async fn ecmul_0_0_9935_21000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 21000 bytes"); } @@ -1541,7 +1649,8 @@ async fn ecmul_0_3_9_21000_128() { async fn ecmul_0_0_9935_28000_128() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 115792089237316195423570985008687907853269984665640564039457584007913129639935 into the ECMUL precompile, truncating or expanding the input data to 128 bytes. Gives the execution 28000 bytes"); } @@ -1557,7 +1666,8 @@ async fn ecmul_0_3_5617_21000_96() { async fn ecmul_0_0_5617_21000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 21888242871839275222246405745257275088548364400416034343698204186575808495617 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 21000 bytes"); } @@ -1566,7 +1676,8 @@ async fn ecmul_0_0_5617_21000_96() { async fn ecmul_1_2_0_21000_64() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 64 bytes. Gives the execution 21000 bytes"); } @@ -1596,7 +1707,8 @@ async fn ecmul_0_3_340282366920938463463374607431768211456_28000_96() { async fn ecmul_0_0_0_28000_80() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 80 bytes. Gives the execution 28000 bytes"); } @@ -1605,7 +1717,8 @@ async fn ecmul_0_0_0_28000_80() { async fn ecmul_1_2_1_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (1, 2) and the factor 1 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } @@ -1614,7 +1727,8 @@ async fn ecmul_1_2_1_28000_96() { async fn ecmul_0_0_0_28000_96() { let eth_response = eth_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECMUL_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecmul_gas_result(gas_used); assert_eq!(eth_response, era_output, "Puts the point (0, 0) and the factor 0 into the ECMUL precompile, truncating or expanding the input data to 96 bytes. Gives the execution 28000 bytes"); } diff --git a/tests/tests/ecpairing_tests.rs b/tests/tests/ecpairing_tests.rs index a51ebbf1..6565bcb2 100644 --- a/tests/tests/ecpairing_tests.rs +++ b/tests/tests/ecpairing_tests.rs @@ -1,7 +1,7 @@ use zksync_web3_rs::{types::Bytes, zks_utils::ECPAIRING_PRECOMPILE_ADDRESS}; mod test_utils; -use test_utils::{era_call, eth_call, parse_call_result}; +use test_utils::{era_call, eth_call, parse_call_result, write_ecpairing_gas_result}; // Puts the given data into the ECPAIRING precompile #[tokio::test] @@ -20,7 +20,8 @@ async fn ecpairing_empty_data_insufficient_gas() { ) .await .unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -53,7 +54,8 @@ async fn ecpairing_perturb_zeropoint_by_one() { async fn ecpairing_one_point_with_g1_zero() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -79,7 +81,8 @@ async fn ecpairing_one_point_with_g2_zero_and_g1_invalid() { async fn ecpairing_two_point_match_1() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa000000000000000000000000000000000000000000000000000000000000000130644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd45198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa000000000000000000000000000000000000000000000000000000000000000130644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd45198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -91,7 +94,8 @@ async fn ecpairing_two_point_match_1() { async fn ecpairing_two_point_fail_1() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -103,7 +107,8 @@ async fn ecpairing_two_point_fail_1() { async fn ecpairing_two_point_oog() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa000000000000000000000000000000000000000000000000000000000000000130644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd45198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa000000000000000000000000000000000000000000000000000000000000000130644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd45198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -115,7 +120,8 @@ async fn ecpairing_two_point_oog() { async fn ecpairing_three_point_fail_1() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c51bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e256d1dfa2b657ba5cd030427000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000021a2c3013d2ea92e13c800cde68ef56a294b883f6ac35d25f587c09b1b3c635f7290158a80cd3d66530f74dc94c94adb88f5cdb481acca997b6e60071f08a115f00cacf3523caf879d7d05e30549f1e6fdce364cbb8724b0329c6c2a39d4f018e0692e55db067300e6e3fe56218fa2f940054e57e7ef92bf7d475a9d8a8502fd200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c51bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e256d1dfa2b657ba5cd030427000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000021a2c3013d2ea92e13c800cde68ef56a294b883f6ac35d25f587c09b1b3c635f7290158a80cd3d66530f74dc94c94adb88f5cdb481acca997b6e60071f08a115f00cacf3523caf879d7d05e30549f1e6fdce364cbb8724b0329c6c2a39d4f018e0692e55db067300e6e3fe56218fa2f940054e57e7ef92bf7d475a9d8a8502fd200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -127,7 +133,8 @@ async fn ecpairing_three_point_fail_1() { async fn ecpairing_one_point_insufficient_gas() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -151,7 +158,8 @@ async fn ecpairing_empty_data() { ) .await .unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -163,7 +171,8 @@ async fn ecpairing_empty_data() { async fn ecpairing_two_point_match_4() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c51bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e256d1dfa2b657ba5cd030427000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000021a2c3013d2ea92e13c800cde68ef56a294b883f6ac35d25f587c09b1b3c635f7290158a80cd3d66530f74dc94c94adb88f5cdb481acca997b6e60071f08a115f2f997f3dbd66a7afe07fe7862ce239edba9e05c5afff7f8a1259c9733b2dfbb929d1691530ca701b4a106054688728c9972c8512e9789e9567aae23e302ccd75").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c51bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e256d1dfa2b657ba5cd030427000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000021a2c3013d2ea92e13c800cde68ef56a294b883f6ac35d25f587c09b1b3c635f7290158a80cd3d66530f74dc94c94adb88f5cdb481acca997b6e60071f08a115f2f997f3dbd66a7afe07fe7862ce239edba9e05c5afff7f8a1259c9733b2dfbb929d1691530ca701b4a106054688728c9972c8512e9789e9567aae23e302ccd75").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -182,7 +191,8 @@ async fn ecpairing_perturb_g2_by_one() { async fn ecpairing_three_point_match_1() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c51bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e256d1dfa2b657ba5cd030427000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000021a2c3013d2ea92e13c800cde68ef56a294b883f6ac35d25f587c09b1b3c635f7290158a80cd3d66530f74dc94c94adb88f5cdb481acca997b6e60071f08a115f2f997f3dbd66a7afe07fe7862ce239edba9e05c5afff7f8a1259c9733b2dfbb929d1691530ca701b4a106054688728c9972c8512e9789e9567aae23e302ccd75000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c51bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e256d1dfa2b657ba5cd030427000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000021a2c3013d2ea92e13c800cde68ef56a294b883f6ac35d25f587c09b1b3c635f7290158a80cd3d66530f74dc94c94adb88f5cdb481acca997b6e60071f08a115f2f997f3dbd66a7afe07fe7862ce239edba9e05c5afff7f8a1259c9733b2dfbb929d1691530ca701b4a106054688728c9972c8512e9789e9567aae23e302ccd75000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -194,7 +204,8 @@ async fn ecpairing_three_point_match_1() { async fn ecpairing_two_point_match_5() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -206,7 +217,8 @@ async fn ecpairing_two_point_match_5() { async fn ecpairing_two_point_match_2() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -218,7 +230,8 @@ async fn ecpairing_two_point_match_2() { async fn ecpairing_two_point_fail_2() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c51bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e256d1dfa2b657ba5cd03042700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002105384b6dd6c48634b9fe89cb3e19667c1fe6736c69df070d674c95a42b3b8242c0d8e67f0f2c14c43734b430d8be4265af8c4f7a67deb0b029fd2dff99cc6b9015eaec465d922580c7de5d4a5c26de75eaf2af6841b7412ef2eebd1e051076f1b4c21849e48de12d1bae2bad3299717aa8664ade430e19dec72a6e10a39b0ab").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("105456a333e6d636854f987ea7bb713dfd0ae8371a72aea313ae0c32c0bf10160cf031d41b41557f3e7e3ba0c51bebe5da8e6ecd855ec50fc87efcdeac168bcc0476be093a6d2b4bbf907172049874af11e1b6267606e00804d3ff0037ec57fd3010c68cb50161b7d1d96bb71edfec9880171954e56871abf3d93cc94d745fa114c059d74e5b6c4ec14ae5864ebe23a71781d86c29fb8fb6cce94f70d3de7a2101b33461f39d9e887dbb100f170a2345dde3c07e256d1dfa2b657ba5cd03042700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002105384b6dd6c48634b9fe89cb3e19667c1fe6736c69df070d674c95a42b3b8242c0d8e67f0f2c14c43734b430d8be4265af8c4f7a67deb0b029fd2dff99cc6b9015eaec465d922580c7de5d4a5c26de75eaf2af6841b7412ef2eebd1e051076f1b4c21849e48de12d1bae2bad3299717aa8664ade430e19dec72a6e10a39b0ab").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -230,7 +243,8 @@ async fn ecpairing_two_point_fail_2() { async fn ecpairing_two_points_with_one_g2_zero() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -263,7 +277,8 @@ async fn ecpairing_perturb_zeropoint_by_curve_order() { async fn ecpairing_one_point_with_g2_zero() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -289,7 +304,8 @@ async fn ecpairing_bad_length_193() { async fn ecpairing_two_point_match_3() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002203e205db4f19b37b60121b83a7333706db86431c6d835849957ed8c3928ad7927dc7234fd11d3e8c36c59277c3e6f149d5cd3cfa9a62aee49f8130962b4b3b9195e8aa5b7827463722b8c153931579d3505566b4edf48d498e185f0509de15204bb53b8977e5f92a0bc372742c4830944a59b4fe6b1c0466e2a6dad122b5d2e030644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd31a76dae6d3272396d0cbe61fced2bc532edac647851e3ac53ce1cc9c7e645a83198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002203e205db4f19b37b60121b83a7333706db86431c6d835849957ed8c3928ad7927dc7234fd11d3e8c36c59277c3e6f149d5cd3cfa9a62aee49f8130962b4b3b9195e8aa5b7827463722b8c153931579d3505566b4edf48d498e185f0509de15204bb53b8977e5f92a0bc372742c4830944a59b4fe6b1c0466e2a6dad122b5d2e030644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd31a76dae6d3272396d0cbe61fced2bc532edac647851e3ac53ce1cc9c7e645a83198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" @@ -301,7 +317,8 @@ async fn ecpairing_two_point_match_3() { async fn ecpairing_one_point_fail() { let eth_response = eth_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); let era_response = era_call(ECPAIRING_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_ecpairing_gas_result(gas_used); assert_eq!( eth_response, era_output, "Puts the given data into the ECPAIRING precompile" diff --git a/tests/tests/modexp_tests.rs b/tests/tests/modexp_tests.rs index b8ae9ed7..6f848762 100644 --- a/tests/tests/modexp_tests.rs +++ b/tests/tests/modexp_tests.rs @@ -1,15 +1,17 @@ use zksync_web3_rs::{types::Bytes, zks_utils::MODEXP_PRECOMPILE_ADDRESS}; +#[cfg(test)] mod test_utils; use test_utils::{era_call, eth_call}; -use crate::test_utils::parse_call_result; +use crate::test_utils::{parse_call_result, write_modexp_gas_result}; #[tokio::test] async fn modexp_0() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -17,11 +19,11 @@ async fn modexp_0() { async fn modexp_1() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_2() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd").unwrap()))).await.is_err()); @@ -32,7 +34,8 @@ async fn modexp_2() { async fn modexp_3() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003ffff800000000000000000000000000000000000000000000000000000000000000007").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003ffff800000000000000000000000000000000000000000000000000000000000000007").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -40,7 +43,8 @@ async fn modexp_3() { async fn modexp_4() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003ffff80").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003ffff80").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -48,7 +52,8 @@ async fn modexp_4() { async fn modexp_5() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002003").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -56,7 +61,8 @@ async fn modexp_5() { async fn modexp_6() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020038000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020038000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -64,7 +70,8 @@ async fn modexp_6() { async fn modexp_7() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000080").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000080").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -72,7 +79,8 @@ async fn modexp_7() { async fn modexp_8() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -80,7 +88,8 @@ async fn modexp_8() { async fn modexp_9() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000101").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000101").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -88,7 +97,8 @@ async fn modexp_9() { async fn modexp_10() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000304").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000304").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -96,7 +106,8 @@ async fn modexp_10() { async fn modexp_11() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020004").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020004").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -104,7 +115,8 @@ async fn modexp_11() { async fn modexp_12() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020300").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020300").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -112,7 +124,8 @@ async fn modexp_12() { async fn modexp_13() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010304").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010304").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -120,7 +133,8 @@ async fn modexp_13() { async fn modexp_14() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010204").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010204").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -128,7 +142,8 @@ async fn modexp_14() { async fn modexp_15() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000203").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000203").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -136,7 +151,8 @@ async fn modexp_15() { async fn modexp_16() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000202030006").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000202030006").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -144,7 +160,8 @@ async fn modexp_16() { async fn modexp_17() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020306").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001020306").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -152,7 +169,8 @@ async fn modexp_17() { async fn modexp_18() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002020300").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002020300").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -160,7 +178,8 @@ async fn modexp_18() { async fn modexp_19() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000202030000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000202030000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -168,7 +187,8 @@ async fn modexp_19() { async fn modexp_20() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020203").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020203").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -176,7 +196,8 @@ async fn modexp_20() { async fn modexp_21() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002023003").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002023003").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -184,7 +205,8 @@ async fn modexp_21() { async fn modexp_22() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020230").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020230").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -192,7 +214,8 @@ async fn modexp_22() { async fn modexp_23() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000202").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000202").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -200,7 +223,8 @@ async fn modexp_23() { async fn modexp_24() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -208,7 +232,8 @@ async fn modexp_24() { async fn modexp_25() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001001001010010").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001001001010010").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -216,7 +241,8 @@ async fn modexp_25() { async fn modexp_26() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000064").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000064").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -224,15 +250,18 @@ async fn modexp_26() { async fn modexp_27() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030006").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030006").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x` because of mod length being 0. #[tokio::test] async fn modexp_28() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(&[])); } @@ -240,7 +269,8 @@ async fn modexp_28() { async fn modexp_29() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -248,7 +278,8 @@ async fn modexp_29() { async fn modexp_30() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -256,7 +287,8 @@ async fn modexp_30() { async fn modexp_31() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010035ee4e488f45e64d2f07becd54646357381d32f30b74c299a8c25d5202c04938ef6c4764a04f10fc908b78c4486886000f6d290251a79681a83b950c7e5c37351").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010035ee4e488f45e64d2f07becd54646357381d32f30b74c299a8c25d5202c04938ef6c4764a04f10fc908b78c4486886000f6d290251a79681a83b950c7e5c37351").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -264,7 +296,8 @@ async fn modexp_31() { async fn modexp_32() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000cd935b43e42204fcbfb734a6e27735e8e90204fcc1fd2727bb040f9eecb").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000cd935b43e42204fcbfb734a6e27735e8e90204fcc1fd2727bb040f9eecb").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -272,7 +305,8 @@ async fn modexp_32() { async fn modexp_33() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060846813a8d2d451387340fa0597c6545ae63").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060846813a8d2d451387340fa0597c6545ae63").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -280,7 +314,8 @@ async fn modexp_33() { async fn modexp_34() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000d02534f82b1013f20d9c7d18d62cd95674d2e013f20d9c7d18d62cd95674d2f").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000d02534f82b1013f20d9c7d18d62cd95674d2e013f20d9c7d18d62cd95674d2f").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -288,16 +323,18 @@ async fn modexp_34() { async fn modexp_35() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000120785e45de3d6be050ba3c4d33ff0bb2d010ace3b1dfe9c49f4c7a8075102fa19a86c010ace3b1dfe9c49f4c7a8075102fa19a86d").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000120785e45de3d6be050ba3c4d33ff0bb2d010ace3b1dfe9c49f4c7a8075102fa19a86c010ace3b1dfe9c49f4c7a8075102fa19a86d").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x` because of mod length being 0. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x` because of mod length being 0. #[tokio::test] async fn modexp_36() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000ff2a1e5300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000ff2a1e5300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(&[])); } @@ -311,7 +348,8 @@ async fn modexp_37() { async fn modexp_tests_0() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -319,7 +357,8 @@ async fn modexp_tests_0() { async fn modexp_tests_1() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -327,7 +366,8 @@ async fn modexp_tests_1() { async fn modexp_tests_2() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -335,7 +375,8 @@ async fn modexp_tests_2() { async fn modexp_tests_3() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -343,7 +384,8 @@ async fn modexp_tests_3() { async fn modexp_tests_4() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -351,7 +393,8 @@ async fn modexp_tests_4() { async fn modexp_tests_5() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -359,7 +402,8 @@ async fn modexp_tests_5() { async fn modexp_tests_6() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -367,7 +411,8 @@ async fn modexp_tests_6() { async fn modexp_tests_7() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -375,7 +420,8 @@ async fn modexp_tests_7() { async fn modexp_tests_8() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -383,7 +429,8 @@ async fn modexp_tests_8() { async fn modexp_tests_9() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -391,48 +438,45 @@ async fn modexp_tests_9() { async fn modexp_tests_10() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1_048_578. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1_048_578. #[tokio::test] async fn modexp_tests_11() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 1_048_578])); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_12() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_13() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_14() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_15() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_16() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff").unwrap()))).await.is_err()); @@ -443,7 +487,8 @@ async fn modexp_tests_16() { async fn modexp_tests_17() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -451,7 +496,8 @@ async fn modexp_tests_17() { async fn modexp_tests_18() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -459,7 +505,8 @@ async fn modexp_tests_18() { async fn modexp_tests_19() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -467,7 +514,8 @@ async fn modexp_tests_19() { async fn modexp_tests_20() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -475,7 +523,8 @@ async fn modexp_tests_20() { async fn modexp_tests_21() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -483,7 +532,8 @@ async fn modexp_tests_21() { async fn modexp_tests_22() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -491,7 +541,8 @@ async fn modexp_tests_22() { async fn modexp_tests_23() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -499,7 +550,8 @@ async fn modexp_tests_23() { async fn modexp_tests_24() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -507,7 +559,8 @@ async fn modexp_tests_24() { async fn modexp_tests_25() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -515,7 +568,8 @@ async fn modexp_tests_25() { async fn modexp_tests_26() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -523,48 +577,45 @@ async fn modexp_tests_26() { async fn modexp_tests_27() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578. #[tokio::test] async fn modexp_tests_28() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 1_048_578])); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_29() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_30() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_31() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_32() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_33() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000ffffffffffffffff").unwrap()))).await.is_err()); @@ -575,7 +626,8 @@ async fn modexp_tests_33() { async fn modexp_tests_34() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -583,7 +635,8 @@ async fn modexp_tests_34() { async fn modexp_tests_35() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -591,7 +644,8 @@ async fn modexp_tests_35() { async fn modexp_tests_36() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -599,7 +653,8 @@ async fn modexp_tests_36() { async fn modexp_tests_37() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -607,7 +662,8 @@ async fn modexp_tests_37() { async fn modexp_tests_38() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -615,7 +671,8 @@ async fn modexp_tests_38() { async fn modexp_tests_39() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -623,7 +680,8 @@ async fn modexp_tests_39() { async fn modexp_tests_40() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -631,7 +689,8 @@ async fn modexp_tests_40() { async fn modexp_tests_41() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -639,7 +698,8 @@ async fn modexp_tests_41() { async fn modexp_tests_42() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -647,7 +707,8 @@ async fn modexp_tests_42() { async fn modexp_tests_43() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -655,7 +716,8 @@ async fn modexp_tests_43() { async fn modexp_tests_44() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -663,48 +725,45 @@ async fn modexp_tests_44() { async fn modexp_tests_45() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578. #[tokio::test] async fn modexp_tests_46() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 1_048_578])); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_47() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_48() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_49() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_50() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_51() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000ffffffffffffffff").unwrap()))).await.is_err()); @@ -715,7 +774,8 @@ async fn modexp_tests_51() { async fn modexp_tests_52() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -723,7 +783,8 @@ async fn modexp_tests_52() { async fn modexp_tests_53() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -731,102 +792,105 @@ async fn modexp_tests_53() { async fn modexp_tests_54() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 16. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 16. #[tokio::test] async fn modexp_tests_55() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 16])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 32. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 32. #[tokio::test] async fn modexp_tests_56() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 32])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 64. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 64. #[tokio::test] async fn modexp_tests_57() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 64])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 100. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 100. #[tokio::test] async fn modexp_tests_58() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 100])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 128. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 128. #[tokio::test] async fn modexp_tests_59() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 128])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 4.097. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 4.097. #[tokio::test] async fn modexp_tests_60() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 4_097])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578 +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578 #[tokio::test] async fn modexp_tests_61() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 1_048_578])); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_62() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_63() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_64() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff0000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_65() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff00000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff00000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_66() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffff000000000000000000000000000000000000000000000000ffffffffffffffff").unwrap()))).await.is_err()); @@ -837,7 +901,8 @@ async fn modexp_tests_66() { async fn modexp_tests_67() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -845,7 +910,8 @@ async fn modexp_tests_67() { async fn modexp_tests_68() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -853,7 +919,8 @@ async fn modexp_tests_68() { async fn modexp_tests_69() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -861,7 +928,8 @@ async fn modexp_tests_69() { async fn modexp_tests_70() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -869,7 +937,8 @@ async fn modexp_tests_70() { async fn modexp_tests_71() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -877,7 +946,8 @@ async fn modexp_tests_71() { async fn modexp_tests_72() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -885,7 +955,8 @@ async fn modexp_tests_72() { async fn modexp_tests_73() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -893,7 +964,8 @@ async fn modexp_tests_73() { async fn modexp_tests_74() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -901,7 +973,8 @@ async fn modexp_tests_74() { async fn modexp_tests_75() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -909,7 +982,8 @@ async fn modexp_tests_75() { async fn modexp_tests_76() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -917,48 +991,45 @@ async fn modexp_tests_76() { async fn modexp_tests_77() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578. #[tokio::test] async fn modexp_tests_78() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 1_048_578])); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_79() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_80() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_81() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_82() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_83() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff").unwrap()))).await.is_err()); @@ -969,7 +1040,8 @@ async fn modexp_tests_83() { async fn modexp_tests_84() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -977,7 +1049,8 @@ async fn modexp_tests_84() { async fn modexp_tests_85() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -985,7 +1058,8 @@ async fn modexp_tests_85() { async fn modexp_tests_86() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -993,7 +1067,8 @@ async fn modexp_tests_86() { async fn modexp_tests_87() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1001,7 +1076,8 @@ async fn modexp_tests_87() { async fn modexp_tests_88() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1009,7 +1085,8 @@ async fn modexp_tests_88() { async fn modexp_tests_89() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000010").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1017,7 +1094,8 @@ async fn modexp_tests_89() { async fn modexp_tests_90() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1025,7 +1103,8 @@ async fn modexp_tests_90() { async fn modexp_tests_91() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1033,7 +1112,8 @@ async fn modexp_tests_91() { async fn modexp_tests_92() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1041,7 +1121,8 @@ async fn modexp_tests_92() { async fn modexp_tests_93() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000080").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1049,48 +1130,45 @@ async fn modexp_tests_93() { async fn modexp_tests_94() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000001001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578 +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 1.048.578 #[tokio::test] async fn modexp_tests_95() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000100002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 1_048_578])); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_96() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000010000004").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_97() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000001000000008").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_98() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000ffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_99() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); assert!(era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000ffffffffffffff").unwrap()))).await.is_err()); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_tests_100() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000ffffffffffffffff").unwrap()))).await.is_err()); @@ -1101,7 +1179,8 @@ async fn modexp_tests_100() { async fn modexp_tests_101() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1109,7 +1188,8 @@ async fn modexp_tests_101() { async fn modexp_tests_102() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1117,7 +1197,8 @@ async fn modexp_tests_102() { async fn modexp_tests_103() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1125,7 +1206,8 @@ async fn modexp_tests_103() { async fn modexp_tests_104() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1133,7 +1215,8 @@ async fn modexp_tests_104() { async fn modexp_tests_105() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1141,7 +1224,8 @@ async fn modexp_tests_105() { async fn modexp_tests_106() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1149,7 +1233,8 @@ async fn modexp_tests_106() { async fn modexp_tests_107() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1157,7 +1242,8 @@ async fn modexp_tests_107() { async fn modexp_tests_108() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1165,7 +1251,8 @@ async fn modexp_tests_108() { async fn modexp_tests_109() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1173,7 +1260,8 @@ async fn modexp_tests_109() { async fn modexp_tests_110() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1181,7 +1269,8 @@ async fn modexp_tests_110() { async fn modexp_tests_111() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1189,7 +1278,8 @@ async fn modexp_tests_111() { async fn modexp_tests_112() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1197,106 +1287,118 @@ async fn modexp_tests_112() { async fn modexp_tests_113() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000064").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 39.936. +// FIXME:This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 39.936. #[tokio::test] async fn modexp_tests_114() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000027000000000000000000000000000000000000000000000000000000000000009c00").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000027000000000000000000000000000000000000000000000000000000000000009c00").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 39_936])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 11.579. +// FIXME:This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 11.579. #[tokio::test] async fn modexp_tests_115() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000071140000000000000000000000000000000000000000000000000000000000002d3b").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000071140000000000000000000000000000000000000000000000000000000000002d3b").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 11_579])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 37.111. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 37.111. #[tokio::test] async fn modexp_tests_116() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000090f700000000000000000000000000000000000000000000000000000000000090f7").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000090f700000000000000000000000000000000000000000000000000000000000090f7").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 37_111])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 37.111. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 37.111. #[tokio::test] async fn modexp_tests_117() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000e7f00000000000000000000000000000000000000000000000000000000000090f7").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000e7f00000000000000000000000000000000000000000000000000000000000090f7").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 37_111])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 2.401. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 2.401. #[tokio::test] async fn modexp_tests_118() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000003100000000000000000000000000000000000000000000000000000000000009610000000000000000000000000000000000000000000000000000000000000961").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000003100000000000000000000000000000000000000000000000000000000000009610000000000000000000000000000000000000000000000000000000000000961").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 2_401])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 22000. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 22000. #[tokio::test] async fn modexp_tests_119() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000009100000000000000000000000000000000000000000000000000000000000000578b00000000000000000000000000000000000000000000000000000000000055f0").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000009100000000000000000000000000000000000000000000000000000000000000578b00000000000000000000000000000000000000000000000000000000000055f0").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 22000])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x` because of mod length being 0. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x` because of mod length being 0. #[tokio::test] async fn modexp_tests_120() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000910000000000000000000000000000000000000000000000000000000000000090f70000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000910000000000000000000000000000000000000000000000000000000000000090f70000000000000000000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(&[])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00` because of mod length being 1. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00` because of mod length being 1. #[tokio::test] async fn modexp_tests_121() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000910000000000000000000000000000000000000000000000000000000000000090f70000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000910000000000000000000000000000000000000000000000000000000000000090f70000000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(&[0])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 37.111. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 37.111. #[tokio::test] async fn modexp_tests_122() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000910000000000000000000000000000000000000000000000000000000000000090f700000000000000000000000000000000000000000000000000000000000090f7").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000910000000000000000000000000000000000000000000000000000000000000090f700000000000000000000000000000000000000000000000000000000000090f7").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 37_111])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 97. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 97. #[tokio::test] async fn modexp_tests_123() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000001bd000000000000000000000000000000000000000000000000000000000000090f70000000000000000000000000000000000000000000000000000000000000061").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000001bd000000000000000000000000000000000000000000000000000000000000090f70000000000000000000000000000000000000000000000000000000000000061").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 97])); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 97. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 97. #[tokio::test] async fn modexp_tests_124() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000910000000000000000000000000000000000000000000000000000000000000090f70000000000000000000000000000000000000000000000000000000000000061").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000910000000000000000000000000000000000000000000000000000000000000090f70000000000000000000000000000000000000000000000000000000000000061").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 97])); } @@ -1304,16 +1406,18 @@ async fn modexp_tests_124() { async fn modexp_tests_125() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000d7a1").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000009c000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000d7a1").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 42.965 +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x00...000` because of mod length being 42.965 #[tokio::test] async fn modexp_tests_126() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000d796000000000000000000000000000000000000000000000000000000000000d796000000000000000000000000000000000000000000000000000000000000a7d5").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000d796000000000000000000000000000000000000000000000000000000000000d796000000000000000000000000000000000000000000000000000000000000a7d5").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(vec![0; 42_965])); } @@ -1321,20 +1425,21 @@ async fn modexp_tests_126() { async fn modexp_random_input_0() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000e300000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000e300000000000000000000000000000000000000000000000000").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } -// This test fails on L1 with "out of gas" error and success on L2 returning `0x` because of mod length being 0. +// FIXME: This test fails on L1 with "out of gas" error and success on L2 returning `0x` because of mod length being 0. #[tokio::test] async fn modexp_random_input_1() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000008000000000000000000000000000000000000000000000000000000000000400000000000000000000000a").unwrap()))).await.is_err()); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000008000000000000000000000000000000000000000000000000000000000000400000000000000000000000a").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(era_output, Bytes::from(&[])); } -// This test fails on L1 with "out of gas" error and is reverted on L2 returning `0x00`. #[tokio::test] async fn modexp_random_input_2() { assert!(eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001147000000000000000000000000000000000000000000000000000000000061660350000000000000000000000000000000000000000000000000000000000000008").unwrap()))).await.is_err()); @@ -1357,8 +1462,8 @@ async fn modexp_edge_cases_1() { ) .await .unwrap(); - - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1366,7 +1471,8 @@ async fn modexp_edge_cases_1() { async fn modexp_edge_cases_2() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1374,7 +1480,8 @@ async fn modexp_edge_cases_2() { async fn modexp_edge_cases_3() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000100").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000100").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1382,7 +1489,8 @@ async fn modexp_edge_cases_3() { async fn modexp_edge_cases_4() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001010200").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001010200").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } @@ -1390,6 +1498,7 @@ async fn modexp_edge_cases_4() { async fn modexp_edge_cases_5() { let eth_response = eth_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02f1").unwrap()))).await.unwrap(); let era_response = era_call(MODEXP_PRECOMPILE_ADDRESS, None, Some(Bytes::from(hex::decode("00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02f1").unwrap()))).await.unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_modexp_gas_result(gas_used); assert_eq!(eth_response, era_output); } diff --git a/tests/tests/p256verify_tests.rs b/tests/tests/p256verify_tests.rs index 6a2c103c..d6e093a4 100644 --- a/tests/tests/p256verify_tests.rs +++ b/tests/tests/p256verify_tests.rs @@ -1,7 +1,6 @@ use zksync_web3_rs::types::{Address, Bytes, H160}; - mod test_utils; -use test_utils::{era_call, parse_call_result}; +use test_utils::{era_call, parse_call_result, write_p256verify_gas_result}; pub const P256VERIFTY_PRECOMPILE_ADDRESS: Address = H160([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -27,7 +26,8 @@ async fn p256verify_valid_signature_one() { ) .await .unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_p256verify_gas_result(gas_used); assert_eq!(era_output, Bytes::from(RESPONSE_VALID)) } @@ -40,7 +40,8 @@ async fn p256verify_valid_signature_two() { ) .await .unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_p256verify_gas_result(gas_used); assert_eq!(era_output, Bytes::from(RESPONSE_VALID)) } @@ -53,7 +54,8 @@ async fn p256verify_invalid_signature() { ) .await .unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_p256verify_gas_result(gas_used); assert_eq!(era_output, Bytes::from(RESPONSE_INVALID)) } @@ -82,6 +84,7 @@ async fn p256verify_invalid_s() { .err() .unwrap() .to_string(); + assert_eq!(era_response, EXECUTION_REVERTED) } @@ -96,6 +99,7 @@ async fn p256verify_public_key_inf() { .err() .unwrap() .to_string(); + assert_eq!(era_response, EXECUTION_REVERTED) } @@ -110,6 +114,7 @@ async fn p256verify_public_key_x_not_in_field() { .err() .unwrap() .to_string(); + assert_eq!(era_response, EXECUTION_REVERTED) } @@ -124,6 +129,7 @@ async fn p256verify_public_key_y_not_in_field() { .err() .unwrap() .to_string(); + assert_eq!(era_response, EXECUTION_REVERTED) } @@ -138,5 +144,6 @@ async fn p256verify_public_key_not_in_curve() { .err() .unwrap() .to_string(); + assert_eq!(era_response, EXECUTION_REVERTED) } diff --git a/tests/tests/secp256k1verify_tests.rs b/tests/tests/secp256k1verify_tests.rs index 18af52d9..c2eb02a5 100644 --- a/tests/tests/secp256k1verify_tests.rs +++ b/tests/tests/secp256k1verify_tests.rs @@ -1,15 +1,13 @@ use zksync_web3_rs::types::{Address, Bytes, H160}; +mod test_utils; +use test_utils::{era_call, parse_call_result, write_secp256k1verify_gas_result}; + pub const SECP256K1VERIFTY_PRECOMPILE_ADDRESS: Address = H160([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, ]); -mod test_utils; -use test_utils::era_call; - -use crate::test_utils::parse_call_result; - const RESPONSE_VALID: [u8; 32] = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, ]; @@ -29,7 +27,8 @@ async fn secp256k1verify_valid_signature_one() { ) .await .unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_secp256k1verify_gas_result(gas_used); assert_eq!(era_output, Bytes::from(RESPONSE_VALID)) } @@ -42,7 +41,8 @@ async fn secp256k1verify_valid_signature_two() { ) .await .unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_secp256k1verify_gas_result(gas_used); assert_eq!(era_output, Bytes::from(RESPONSE_VALID)) } @@ -55,7 +55,8 @@ async fn secp256k1verify_invalid_signature() { ) .await .unwrap(); - let (era_output, _) = parse_call_result(&era_response); + let (era_output, gas_used) = parse_call_result(&era_response); + write_secp256k1verify_gas_result(gas_used); assert_eq!(era_output, Bytes::from(RESPONSE_INVALID)) } diff --git a/tests/tests/test_utils.rs b/tests/tests/test_utils.rs index 5c16df0d..c5bdc463 100644 --- a/tests/tests/test_utils.rs +++ b/tests/tests/test_utils.rs @@ -1,4 +1,4 @@ -use std::env; +use std::{env, fs::OpenOptions, io::Write}; use zksync_web3_rs::{ providers::{Http, Middleware, Provider, ProviderError}, types::{transaction::eip2718::TypedTransaction, Address, Bytes, Eip1559TransactionRequest}, @@ -21,6 +21,48 @@ pub fn parse_call_result(bytes: &[u8]) -> (Bytes, u32) { (output.into(), gas_used) } +fn write_line_to_report(used_gas: u32, report_to_write: &str) { + let mut file = OpenOptions::new() + .append(true) + .open(report_to_write) + .unwrap(); + + let curr_thread = std::thread::current(); + let test_name = curr_thread.name().unwrap(); + + writeln!(file, "| {test_name} | {used_gas} |").unwrap(); +} + +#[allow(dead_code)] +pub fn write_modexp_gas_result(used_gas: u32) { + write_line_to_report(used_gas, "gas_reports/modexp_report.md"); +} + +#[allow(dead_code)] +pub fn write_ecadd_gas_result(used_gas: u32) { + write_line_to_report(used_gas, "gas_reports/ecadd_report.md"); +} + +#[allow(dead_code)] +pub fn write_ecmul_gas_result(used_gas: u32) { + write_line_to_report(used_gas, "gas_reports/ecmul_report.md"); +} + +#[allow(dead_code)] +pub fn write_ecpairing_gas_result(used_gas: u32) { + write_line_to_report(used_gas, "gas_reports/ecpairing_report.md"); +} + +#[allow(dead_code)] +pub fn write_p256verify_gas_result(used_gas: u32) { + write_line_to_report(used_gas, "gas_reports/p256verify_report.md"); +} + +#[allow(dead_code)] +pub fn write_secp256k1verify_gas_result(used_gas: u32) { + write_line_to_report(used_gas, "gas_reports/secp256k1verify_report.md"); +} + pub fn eth_provider() -> Provider { let url: String = env::var("ZKSYNC_WEB3_RS_L1_PROVIDER_URL").unwrap_or(DEFAULT_L1_PROVIDER_URL.to_owned());