mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Using gas provided by test engine and fix for creating fake ExtVMFace.
This commit is contained in:
parent
dfac5a0033
commit
f31f3bcfc5
4 changed files with 8 additions and 8 deletions
|
|
@ -112,7 +112,8 @@ int main(int argc, char** argv)
|
|||
auto engine = eth::jit::ExecutionEngine();
|
||||
auto module = eth::jit::Compiler().compile({bytecode.data(), bytecode.size()});
|
||||
module->dump();
|
||||
auto result = engine.run(std::move(module));
|
||||
u256 gas = 10000;
|
||||
auto result = engine.run(std::move(module), gas);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ ExecutionEngine::ExecutionEngine()
|
|||
extern "C" { EXPORT std::jmp_buf* rt_jmpBuf; }
|
||||
|
||||
|
||||
int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, ExtVMFace* _ext)
|
||||
int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, u256& _gas, ExtVMFace* _ext)
|
||||
{
|
||||
auto module = _module.get(); // Keep ownership of the module in _module
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, ExtVMFace* _ext)
|
|||
// Create fake ExtVM interface
|
||||
if (!_ext)
|
||||
{
|
||||
auto _ext = new ExtVMFace;
|
||||
_ext = new ExtVMFace;
|
||||
_ext->myAddress = Address(1122334455667788);
|
||||
_ext->caller = Address(0xfacefacefaceface);
|
||||
_ext->origin = Address(101010101010101010);
|
||||
|
|
@ -102,8 +102,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, ExtVMFace* _ext)
|
|||
}
|
||||
|
||||
// Init runtime
|
||||
uint64_t gas = 100;
|
||||
Runtime runtime(gas, *_ext);
|
||||
Runtime runtime(_gas, *_ext);
|
||||
|
||||
auto entryFunc = module->getFunction("main");
|
||||
if (!entryFunc)
|
||||
|
|
@ -124,7 +123,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module, ExtVMFace* _ext)
|
|||
else
|
||||
returnCode = static_cast<ReturnCode>(r);
|
||||
|
||||
gas = static_cast<decltype(gas)>(Runtime::getGas());
|
||||
_gas = Runtime::getGas();
|
||||
|
||||
if (returnCode == ReturnCode::Return)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class ExecutionEngine
|
|||
public:
|
||||
ExecutionEngine();
|
||||
|
||||
int run(std::unique_ptr<llvm::Module> module, ExtVMFace* _ext = nullptr);
|
||||
int run(std::unique_ptr<llvm::Module> module, u256& _gas, ExtVMFace* _ext = nullptr);
|
||||
|
||||
bytes returnData;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ bytes VM::go(ExtVMFace& _ext)
|
|||
module->dump();
|
||||
|
||||
ExecutionEngine engine;
|
||||
auto exitCode = engine.run(std::move(module), &_ext);
|
||||
auto exitCode = engine.run(std::move(module), m_gas, &_ext);
|
||||
|
||||
switch (exitCode)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue