@@ -66,8 +66,7 @@ namespace hera {
6666
6767 HERA_DEBUG << " ): " << dec;
6868
69- evmc_uint256be result;
70- m_context->fn_table ->get_storage (&result, m_context, &m_msg.destination , &path);
69+ evmc_bytes32 result = m_context->host ->get_storage (m_context, &m_msg.destination , &path);
7170
7271 if (useHex)
7372 {
@@ -150,9 +149,8 @@ namespace hera {
150149 takeInterfaceGas (GasSchedule::balance);
151150
152151 evmc_address address = loadAddress (addressOffset);
153- evmc_uint256be result;
154- m_context->fn_table ->get_balance (&result, m_context, &address);
155- storeUint128 (result, resultOffset);
152+ evmc_uint256be balance = m_context->host ->get_balance (m_context, &address);
153+ storeUint128 (balance, resultOffset);
156154 }
157155
158156 uint32_t EthereumInterface::eeiGetBlockHash (uint64_t number, uint32_t resultOffset)
@@ -161,8 +159,7 @@ namespace hera {
161159
162160 takeInterfaceGas (GasSchedule::blockhash);
163161
164- evmc_uint256be blockhash;
165- m_context->fn_table ->get_block_hash (&blockhash, m_context, static_cast <int64_t >(number));
162+ evmc_bytes32 blockhash = m_context->host ->get_block_hash (m_context, static_cast <int64_t >(number));
166163
167164 if (isZeroUint256 (blockhash))
168165 return 1 ;
@@ -236,7 +233,7 @@ namespace hera {
236233 evmc_address address = loadAddress (addressOffset);
237234 // FIXME: optimise this so no vector needs to be created
238235 vector<uint8_t > codeBuffer (length);
239- size_t numCopied = m_context->fn_table ->copy_code (m_context, &address, codeOffset, codeBuffer.data (), codeBuffer.size ());
236+ size_t numCopied = m_context->host ->copy_code (m_context, &address, codeOffset, codeBuffer.data (), codeBuffer.size ());
240237 ensureCondition (numCopied == length, InvalidMemoryAccess, " Out of bounds (source) memory copy" );
241238
242239 storeMemory (codeBuffer, 0 , resultOffset, length);
@@ -249,7 +246,7 @@ namespace hera {
249246 takeInterfaceGas (GasSchedule::extcode);
250247
251248 evmc_address address = loadAddress (addressOffset);
252- size_t code_size = m_context->fn_table ->get_code_size (m_context, &address);
249+ size_t code_size = m_context->host ->get_code_size (m_context, &address);
253250
254251 return static_cast <uint32_t >(code_size);
255252 }
@@ -317,7 +314,7 @@ namespace hera {
317314 vector<uint8_t > data (length);
318315 loadMemory (dataOffset, data, length);
319316
320- m_context->fn_table ->emit_log (m_context, &m_msg.destination , data.data (), length, topics.data (), numberOfTopics);
317+ m_context->host ->emit_log (m_context, &m_msg.destination , data.data (), length, topics.data (), numberOfTopics);
321318 }
322319
323320 int64_t EthereumInterface::eeiGetBlockNumber ()
@@ -365,19 +362,17 @@ namespace hera {
365362
366363 ensureCondition (!(m_msg.flags & EVMC_STATIC), StaticModeViolation, " storageStore" );
367364
368- evmc_uint256be path = loadBytes32 (pathOffset);
369- evmc_uint256be value = loadBytes32 (valueOffset);
370- evmc_uint256be current;
371-
372- m_context->fn_table ->get_storage (¤t, m_context, &m_msg.destination , &path);
365+ evmc_bytes32 path = loadBytes32 (pathOffset);
366+ evmc_bytes32 value = loadBytes32 (valueOffset);
367+ evmc_bytes32 current = m_context->host ->get_storage (m_context, &m_msg.destination , &path);
373368
374369 // Charge the right amount in case of the create case.
375370 if (isZeroUint256 (current) && !isZeroUint256 (value))
376371 takeInterfaceGas (GasSchedule::storageStoreCreate - GasSchedule::storageStoreChange);
377372
378373 // We do not need to take care about the delete case (gas refund), the client does it.
379374
380- m_context->fn_table ->set_storage (m_context, &m_msg.destination , &path, &value);
375+ m_context->host ->set_storage (m_context, &m_msg.destination , &path, &value);
381376 }
382377
383378 void EthereumInterface::eeiStorageLoad (uint32_t pathOffset, uint32_t resultOffset)
@@ -386,9 +381,8 @@ namespace hera {
386381
387382 takeInterfaceGas (GasSchedule::storageLoad);
388383
389- evmc_uint256be path = loadBytes32 (pathOffset);
390- evmc_uint256be result;
391- m_context->fn_table ->get_storage (&result, m_context, &m_msg.destination , &path);
384+ evmc_bytes32 path = loadBytes32 (pathOffset);
385+ evmc_bytes32 result = m_context->host ->get_storage (m_context, &m_msg.destination , &path);
392386
393387 storeBytes32 (result, resultOffset);
394388 }
@@ -431,7 +425,6 @@ namespace hera {
431425 evmc_message call_message;
432426 call_message.destination = loadAddress (addressOffset);
433427 call_message.flags = m_msg.flags & EVMC_STATIC;
434- call_message.code_hash = {};
435428 call_message.depth = m_msg.depth + 1 ;
436429
437430 switch (kind) {
@@ -489,8 +482,6 @@ namespace hera {
489482 call_message.input_size = 0 ;
490483 }
491484
492- evmc_result call_result;
493-
494485 // Start with base call gas
495486 takeInterfaceGas (GasSchedule::call);
496487
@@ -506,7 +497,7 @@ namespace hera {
506497 return 1 ;
507498
508499 // Only charge callNewAccount gas if the account is new and non-zero value is being transferred per EIP161.
509- if ((kind == EEICallKind::Call) && !m_context->fn_table ->account_exists (m_context, &call_message.destination ))
500+ if ((kind == EEICallKind::Call) && !m_context->host ->account_exists (m_context, &call_message.destination ))
510501 takeInterfaceGas (GasSchedule::callNewAccount);
511502 }
512503
@@ -522,7 +513,7 @@ namespace hera {
522513
523514 call_message.gas = gas;
524515
525- m_context->fn_table ->call (&call_result, m_context, &call_message);
516+ evmc_result call_result = m_context->host ->call (m_context, &call_message);
526517
527518 if (call_result.output_data ) {
528519 m_lastReturnData.assign (call_result.output_data , call_result.output_data + call_result.output_size );
@@ -579,18 +570,15 @@ namespace hera {
579570 create_message.input_size = 0 ;
580571 }
581572
582- create_message.code_hash = {};
583573 create_message.depth = m_msg.depth + 1 ;
584574 create_message.kind = EVMC_CREATE;
585575 create_message.flags = 0 ;
586576
587- evmc_result create_result;
588-
589577 int64_t gas = maxCallGas (m_result.gasLeft );
590578 create_message.gas = gas;
591579 takeInterfaceGas (gas);
592580
593- m_context->fn_table ->call (&create_result, m_context, &create_message);
581+ evmc_result create_result = m_context->host ->call (m_context, &create_message);
594582
595583 /* Return unspent gas */
596584 heraAssert (create_result.gas_left >= 0 , " EVMC returned negative gas left" );
@@ -628,9 +616,10 @@ namespace hera {
628616
629617 evmc_address address = loadAddress (addressOffset);
630618
631- if (!m_context->fn_table ->account_exists (m_context, &address))
619+ if (!m_context->host ->account_exists (m_context, &address))
632620 takeInterfaceGas (GasSchedule::callNewAccount);
633- m_context->fn_table ->selfdestruct (m_context, &m_msg.destination , &address);
621+
622+ m_context->host ->selfdestruct (m_context, &m_msg.destination , &address);
634623
635624 throw EndExecution{};
636625 }
@@ -815,8 +804,7 @@ namespace hera {
815804
816805 bool EthereumInterface::enoughSenderBalanceFor (evmc_uint256be const & value) const
817806 {
818- evmc_uint256be balance;
819- m_context->fn_table ->get_balance (&balance, m_context, &m_msg.destination );
807+ evmc_uint256be balance = m_context->host ->get_balance (m_context, &m_msg.destination );
820808 return safeLoadUint128 (balance) >= safeLoadUint128 (value);
821809 }
822810
0 commit comments