Commit c4733987 authored by ben-chain's avatar ben-chain

add fixed nuisance gas for ovmCALL

parent f62b225d
...@@ -49,6 +49,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager { ...@@ -49,6 +49,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
address constant GAS_METADATA_ADDRESS = 0x06a506A506a506A506a506a506A506A506A506A5; address constant GAS_METADATA_ADDRESS = 0x06a506A506a506A506a506a506A506A506A506A5;
uint256 constant NUISANCE_GAS_SLOAD = 20000; uint256 constant NUISANCE_GAS_SLOAD = 20000;
uint256 constant NUISANCE_GAS_SSTORE = 20000; uint256 constant NUISANCE_GAS_SSTORE = 20000;
uint256 constant MIN_NUISANCE_GAS_PER_CONTRACT = 30000;
uint256 constant NUISANCE_GAS_PER_CONTRACT_BYTE = 100; uint256 constant NUISANCE_GAS_PER_CONTRACT_BYTE = 100;
uint256 constant MIN_GAS_FOR_INVALID_STATE_ACCESS = 30000; uint256 constant MIN_GAS_FOR_INVALID_STATE_ACCESS = 30000;
...@@ -1161,7 +1162,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager { ...@@ -1161,7 +1162,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
if (_wasAccountAlreadyLoaded == false) { if (_wasAccountAlreadyLoaded == false) {
console.log("was not already loaded"); console.log("was not already loaded");
_useNuisanceGas( _useNuisanceGas(
Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE (Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE) + MIN_NUISANCE_GAS_PER_CONTRACT
); );
console.log("got code size:"); console.log("got code size:");
console.log(Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address))); console.log(Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)));
...@@ -1190,7 +1191,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager { ...@@ -1190,7 +1191,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
if (_wasAccountAlreadyChanged == false) { if (_wasAccountAlreadyChanged == false) {
ovmStateManager.incrementTotalUncommittedAccounts(); ovmStateManager.incrementTotalUncommittedAccounts();
_useNuisanceGas( _useNuisanceGas(
Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE (Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE) + MIN_NUISANCE_GAS_PER_CONTRACT
); );
} }
} }
......
...@@ -15,7 +15,11 @@ import { ...@@ -15,7 +15,11 @@ import {
'0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420' '0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420'
const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb' const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
const FRESH_CALL_NUISANCE_GAS_COST = Helper_TestRunner_BYTELEN * NUISANCE_GAS_COSTS.NUISANCE_GAS_PER_CONTRACT_BYTE + NUISANCE_GAS_COSTS.MIN_NUISANCE_GAS_PER_CONTRACT
console.log(`first call cost: ${FRESH_CALL_NUISANCE_GAS_COST}`)
const test_nuisanceGas: TestDefinition = { const test_nuisanceGas: TestDefinition = {
name: 'Basic tests for nuisance gas', name: 'Basic tests for nuisance gas',
preState: { preState: {
...@@ -54,7 +58,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb' ...@@ -54,7 +58,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
postState: { postState: {
ExecutionManager: { ExecutionManager: {
messageRecord: { messageRecord: {
nuisanceGasLeft: OVM_TX_GAS_LIMIT - Helper_TestRunner_BYTELEN * NUISANCE_GAS_COSTS.NUISANCE_GAS_PER_CONTRACT_BYTE nuisanceGasLeft: OVM_TX_GAS_LIMIT - FRESH_CALL_NUISANCE_GAS_COST
} }
} }
}, },
...@@ -90,7 +94,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb' ...@@ -90,7 +94,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
postState: { postState: {
ExecutionManager: { ExecutionManager: {
messageRecord: { messageRecord: {
nuisanceGasLeft: OVM_TX_GAS_LIMIT - 2 * ( Helper_TestRunner_BYTELEN * NUISANCE_GAS_COSTS.NUISANCE_GAS_PER_CONTRACT_BYTE ) nuisanceGasLeft: OVM_TX_GAS_LIMIT - 2 * FRESH_CALL_NUISANCE_GAS_COST
} }
} }
}, },
...@@ -140,7 +144,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb' ...@@ -140,7 +144,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
postState: { postState: {
ExecutionManager: { ExecutionManager: {
messageRecord: { messageRecord: {
nuisanceGasLeft: OVM_TX_GAS_LIMIT - ( Helper_TestRunner_BYTELEN * NUISANCE_GAS_COSTS.NUISANCE_GAS_PER_CONTRACT_BYTE ) - OVM_TX_GAS_LIMIT / 2 nuisanceGasLeft: OVM_TX_GAS_LIMIT - FRESH_CALL_NUISANCE_GAS_COST - OVM_TX_GAS_LIMIT / 2
} }
} }
}, },
......
...@@ -27,6 +27,7 @@ export const VERIFIED_EMPTY_CONTRACT_HASH = ...@@ -27,6 +27,7 @@ export const VERIFIED_EMPTY_CONTRACT_HASH =
export const NUISANCE_GAS_COSTS = { export const NUISANCE_GAS_COSTS = {
NUISANCE_GAS_SLOAD: 20000, NUISANCE_GAS_SLOAD: 20000,
NUISANCE_GAS_SSTORE: 20000, NUISANCE_GAS_SSTORE: 20000,
MIN_NUISANCE_GAS_PER_CONTRACT: 30000,
NUISANCE_GAS_PER_CONTRACT_BYTE: 100, NUISANCE_GAS_PER_CONTRACT_BYTE: 100,
MIN_GAS_FOR_INVALID_STATE_ACCESS: 30000, MIN_GAS_FOR_INVALID_STATE_ACCESS: 30000,
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment