diff --git a/evm-e2e/contracts/EventsEmitter.sol b/evm-e2e/contracts/EventsEmitter.sol deleted file mode 100644 index e9bd2920b..000000000 --- a/evm-e2e/contracts/EventsEmitter.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -contract EventsEmitter { - event TestEvent(address indexed sender, uint256 value); - - function emitEvent(uint256 value) public { - emit TestEvent(msg.sender, value); - } -} \ No newline at end of file diff --git a/evm-e2e/contracts/InfiniteLoopGas.sol b/evm-e2e/contracts/InfiniteLoopGas.sol deleted file mode 100644 index beae47115..000000000 --- a/evm-e2e/contracts/InfiniteLoopGas.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -contract InifiniteLoopGas { - uint256 public counter = 0; - - // Using up all of the gas that you send causes your transaction to fail. - // State changes are undone. - // Gas spent are not refunded. - function forever() public { - // Here we run a loop until all of the gas are spent - // and the transaction fails - while (true) { - counter += 1; - } - } -} diff --git a/evm-e2e/contracts/SendReceiveNibi.sol b/evm-e2e/contracts/SendReceiveNibi.sol deleted file mode 100644 index 1be8479f0..000000000 --- a/evm-e2e/contracts/SendReceiveNibi.sol +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -contract ReceiveNibi { - /* - Which function is called, fallback() or receive()? - - send Nibi - | - msg.data is empty? - / \ - yes no - / \ - receive() exists? fallback() - / \ - yes no - / \ - receive() fallback() - */ - - // Function to receive Nibi. msg.data must be empty - receive() external payable {} - - // Fallback function is called when msg.data is not empty - fallback() external payable {} - - function getBalance() public view returns (uint256) { - return address(this).balance; - } -} - -contract SendNibi { - function sendViaTransfer(address payable _to) public payable { - // This function is no longer recommended for sending Nibi. - _to.transfer(msg.value); - } - - function sendViaSend(address payable _to) public payable { - // Send returns a boolean value indicating success or failure. - // This function is not recommended for sending Nibi. - bool sent = _to.send(msg.value); - require(sent, "Failed to send Nibi"); - } - - function sendViaCall(address payable _to) public payable { - // Call returns a boolean value indicating success or failure. - // This is the current recommended method to use. - (bool sent, bytes memory data) = _to.call{value : msg.value}(""); - require(sent, "Failed to send Nibi"); - } -} diff --git a/evm-e2e/contracts/TestERC20.sol b/evm-e2e/contracts/TestERC20.sol deleted file mode 100644 index bea532843..000000000 --- a/evm-e2e/contracts/TestERC20.sol +++ /dev/null @@ -1,16 +0,0 @@ -// contracts/TestERC20.sol -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; - -contract TestERC20 is ERC20 { - - // Define the supply of TestERC20: 1,000,000 - uint256 constant initialSupply = 1000000 * (10**18); - - // Constructor will be called on contract creation - constructor() ERC20("TestERC20", "FOO") { - _mint(msg.sender, initialSupply); - } -} diff --git a/evm-e2e/contracts/TransactionReverter.sol b/evm-e2e/contracts/TransactionReverter.sol deleted file mode 100644 index 81d7c0949..000000000 --- a/evm-e2e/contracts/TransactionReverter.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -contract TransactionReverter { - uint256 public value; - - error CustomRevertReason(uint256 providedValue); - - // Will try to set state and revert unconditionally - function setAndRevert(uint256 newValue) public { - value = newValue; - revert("Transaction reverted after state change"); - } - - // Will revert with custom error - function revertWithCustomError(uint256 newValue) public { - value = newValue; - revert CustomRevertReason(newValue); - } - - // Will emit event and then revert - event ValueUpdateAttempted(address sender, uint256 value); - function emitAndRevert(uint256 newValue) public { - emit ValueUpdateAttempted(msg.sender, newValue); - value = newValue; - revert("Reverted after event emission"); - } -} \ No newline at end of file diff --git a/evm-e2e/package.json b/evm-e2e/package.json deleted file mode 100644 index 149b78524..000000000 --- a/evm-e2e/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "nibiru-evm-test", - "version": "0.0.1", - "description": "Nibiru EVM tests", - "keywords": [], - "author": "Nibiru Team", - "license": "ISC", - "engines": { - "node": ">=0.18.0" - }, - "devDependencies": { - "@jest/globals": "^29.7.0", - "@typechain/ethers-v6": "^0.5.1", - "@typechain/hardhat": "^9.1.0", - "@types/jest": "^29.5.12", - "dotenv": "^16.4.5", - "eslint": "^8.0.0", - "eslint-config-airbnb": "^19.0.4", - "eslint-config-airbnb-base": "^15.0.0", - "eslint-config-prettier": "^9.1.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-prettier": "^5.1.3", - "ethers": "^6.12.1", - "jest": "^29.7.0", - "prettier": "^3.3.3", - "ts-jest": "^29.2.4", - "typechain": "^8.3.2", - "@nomicfoundation/hardhat-toolbox": "^5.0.0", - "@openzeppelin/contracts": "^5.1.0", - "hardhat": "^2.22.15" - }, - "scripts": { - "test": "jest", - "format": "prettier --write \"test/**/*.ts\"", - "format:check": "prettier --check \"test/**/*.ts\"" - } -} diff --git a/x/evm/precompile/precompile.go b/x/evm/precompile/precompile.go index 8e5a863e7..cf3056a5c 100644 --- a/x/evm/precompile/precompile.go +++ b/x/evm/precompile/precompile.go @@ -202,11 +202,10 @@ func OnRunStart( return res, fmt.Errorf("error committing dirty journal entries: %w", err) } - // Temporarily switching to a local gas meter to enforce gas limit check for a precompile - // returning parent gas meter after execution or failure + // Switching to a local gas meter to enforce gas limit check for a precompile cacheCtx = cacheCtx.WithGasMeter(sdk.NewGasMeter(gasLimit)). - WithKVGasConfig(sdk.GasConfig{}). - WithTransientKVGasConfig(sdk.GasConfig{}) + WithKVGasConfig(store.KVGasConfig()). + WithTransientKVGasConfig(store.TransientGasConfig()) return OnRunStartResult{ Args: args,