|
13 | 13 | import |
14 | 14 | std/sequtils, |
15 | 15 | ".."/[db/ledger, constants], |
16 | | - "."/[code_stream, memory, message, stack, state], |
| 16 | + "."/[code_stream, memory, stack, state], |
17 | 17 | "."/[types], |
18 | 18 | ./interpreter/[gas_meter, gas_costs, op_codes], |
19 | 19 | ./evm_errors, |
@@ -46,17 +46,6 @@ when defined(evmc_enabled): |
46 | 46 | const |
47 | 47 | evmc_enabled* = defined(evmc_enabled) |
48 | 48 |
|
49 | | -# ------------------------------------------------------------------------------ |
50 | | -# Helpers |
51 | | -# ------------------------------------------------------------------------------ |
52 | | - |
53 | | -proc generateContractAddress(c: Computation, salt: ContractSalt): Address = |
54 | | - if c.msg.kind == EVMC_CREATE: |
55 | | - let creationNonce = c.vmState.readOnlyStateDB().getNonce(c.msg.sender) |
56 | | - result = generateAddress(c.msg.sender, creationNonce) |
57 | | - else: |
58 | | - result = generateSafeAddress(c.msg.sender, salt, c.msg.data) |
59 | | - |
60 | 49 | # ------------------------------------------------------------------------------ |
61 | 50 | # Public functions |
62 | 51 | # ------------------------------------------------------------------------------ |
@@ -259,42 +248,17 @@ template resolveCode*(c: Computation, address: Address): CodeBytesRef = |
259 | 248 | else: |
260 | 249 | c.vmState.readOnlyStateDB.resolveCode(address) |
261 | 250 |
|
262 | | -proc newComputation*(vmState: BaseVMState, sysCall: bool, message: Message, |
263 | | - isPrecompile, keepStack: bool, salt: ContractSalt = ZERO_CONTRACTSALT): Computation = |
264 | | - new result |
265 | | - result.vmState = vmState |
266 | | - result.msg = message |
267 | | - result.gasMeter.init(message.gas) |
268 | | - result.sysCall = sysCall |
269 | | - result.keepStack = keepStack |
270 | | - |
271 | | - if not isPrecompile: |
272 | | - result.memory = EvmMemory.init() |
273 | | - result.stack = EvmStack.init() |
274 | | - |
275 | | - if result.msg.isCreate(): |
276 | | - result.msg.contractAddress = result.generateContractAddress(salt) |
277 | | - result.code = CodeStream.init(message.data) |
278 | | - message.data = @[] |
279 | | - else: |
280 | | - if vmState.fork >= FkPrague: |
281 | | - result.code = CodeStream.init( |
282 | | - vmState.readOnlyStateDB.resolveCode(message.codeAddress)) |
283 | | - else: |
284 | | - result.code = CodeStream.init( |
285 | | - vmState.readOnlyStateDB.getCode(message.codeAddress)) |
286 | | - |
287 | | - |
288 | | -func newComputation*(vmState: BaseVMState, sysCall: bool, |
289 | | - message: Message, code: CodeBytesRef, isPrecompile, keepStack: bool, ): Computation = |
| 251 | +func newComputation*(vmState: BaseVMState, |
| 252 | + keepStack: bool, |
| 253 | + message: Message, |
| 254 | + code = CodeBytesRef(nil)): Computation = |
290 | 255 | new result |
291 | 256 | result.vmState = vmState |
292 | 257 | result.msg = message |
293 | 258 | result.gasMeter.init(message.gas) |
294 | | - result.sysCall = sysCall |
295 | 259 | result.keepStack = keepStack |
296 | 260 |
|
297 | | - if not isPrecompile: |
| 261 | + if not code.isNil: |
298 | 262 | result.code = CodeStream.init(code) |
299 | 263 | result.memory = EvmMemory.init() |
300 | 264 | result.stack = EvmStack.init() |
|
0 commit comments