From a202d2a633cf70d0dd8c5f9ae0ea0fed62893cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 12 May 2015 12:13:42 +0200 Subject: [PATCH] Update SmartVM to new VM interface (without gas counter) --- libevm/SmartVM.cpp | 10 ++++------ libevm/SmartVM.h | 4 +--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/libevm/SmartVM.cpp b/libevm/SmartVM.cpp index 4f759a745..7343bd7a2 100644 --- a/libevm/SmartVM.cpp +++ b/libevm/SmartVM.cpp @@ -41,7 +41,7 @@ namespace } } -bytesConstRef SmartVM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) +bytesConstRef SmartVM::go(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { auto codeHash = sha3(_ext.code); auto vmKind = VMKind::Interpreter; // default VM @@ -66,11 +66,9 @@ bytesConstRef SmartVM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _step } // TODO: Selected VM must be kept only because it returns reference to its internal memory. - // VM implementations should be stateless, without gas counter and escaping memory reference. - m_selectedVM = VMFactory::create(vmKind, gas()); - auto out = m_selectedVM->go(_ext, _onOp, _steps); - m_gas = m_selectedVM->gas(); - return out; + // VM implementations should be stateless, without escaping memory reference. + m_selectedVM = VMFactory::create(vmKind); + return m_selectedVM->go(io_gas, _ext, _onOp, _steps); } } diff --git a/libevm/SmartVM.h b/libevm/SmartVM.h index 29f464ecd..cc198c0c2 100644 --- a/libevm/SmartVM.h +++ b/libevm/SmartVM.h @@ -31,9 +31,7 @@ namespace eth class SmartVM: public VMFace { public: - SmartVM(u256 _gas): VMFace(_gas) {} - - virtual bytesConstRef go(ExtVMFace& _ext, OnOpFunc const& _onOp = {}, uint64_t _steps = (uint64_t)-1) override final; + virtual bytesConstRef go(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _onOp = {}, uint64_t _steps = (uint64_t)-1) override final; private: std::unique_ptr m_selectedVM;