Browse Source

Merge remote-tracking branch 'ethereum/develop' into develop

cl-refactor
winsvega 10 years ago
parent
commit
47dcbaf2e2
  1. 4
      .gitignore
  2. 21
      CMakeLists.txt
  3. 20
      CodingStandards.txt
  4. 11
      README.md
  5. 2
      alethzero/CMakeLists.txt
  6. 28
      alethzero/Main.ui
  7. 367
      alethzero/MainWin.cpp
  8. 27
      alethzero/MainWin.h
  9. 103
      alethzero/NatspecHandler.cpp
  10. 58
      alethzero/NatspecHandler.h
  11. 40
      alethzero/OurWebThreeStubServer.cpp
  12. 12
      alethzero/OurWebThreeStubServer.h
  13. 13
      cmake/EthCompilerSettings.cmake
  14. 9
      cmake/EthDependencies.cmake
  15. 43
      eth/main.cpp
  16. 1
      evmjit
  17. 1
      evmjit/.gitignore
  18. 46
      evmjit/CMakeLists.txt
  19. 18
      evmjit/evmcc/CMakeLists.txt
  20. 210
      evmjit/evmcc/evmcc.cpp
  21. 1
      evmjit/evmcc/test/arith/addmod.evm
  22. 12
      evmjit/evmcc/test/arith/addmod.lll
  23. 1
      evmjit/evmcc/test/arith/arith1.evm
  24. 37
      evmjit/evmcc/test/arith/arith1.lll
  25. 1
      evmjit/evmcc/test/arith/arith_bnot.evm
  26. 14
      evmjit/evmcc/test/arith/arith_bnot.lll
  27. 1
      evmjit/evmcc/test/arith/div.evm
  28. 10
      evmjit/evmcc/test/arith/div.lll
  29. 1
      evmjit/evmcc/test/arith/fib1.evm
  30. 57
      evmjit/evmcc/test/arith/fib1.lll
  31. 1
      evmjit/evmcc/test/arith/mul.evm
  32. 13
      evmjit/evmcc/test/arith/mul.lll
  33. 1
      evmjit/evmcc/test/arith/mulmod.evm
  34. 12
      evmjit/evmcc/test/arith/mulmod.lll
  35. 1
      evmjit/evmcc/test/except/badinst1.evm
  36. 1
      evmjit/evmcc/test/ext/calldatacopy1.evm
  37. 13
      evmjit/evmcc/test/ext/calldatacopy1.lll
  38. 1
      evmjit/evmcc/test/ext/calldatacopy2.evm
  39. 13
      evmjit/evmcc/test/ext/calldatacopy2.lll
  40. 1
      evmjit/evmcc/test/ext/codecopy1.evm
  41. 13
      evmjit/evmcc/test/ext/codecopy1.lll
  42. 1
      evmjit/evmcc/test/ext/codecopy2.evm
  43. 13
      evmjit/evmcc/test/ext/codecopy2.lll
  44. 1
      evmjit/evmcc/test/ext/codecopy3.evm
  45. 13
      evmjit/evmcc/test/ext/codecopy3.lll
  46. 1
      evmjit/evmcc/test/ext/ext_test.evm
  47. 55
      evmjit/evmcc/test/ext/ext_test.lll
  48. 1
      evmjit/evmcc/test/ext/extcodecopy1.evm
  49. 11
      evmjit/evmcc/test/ext/extcodecopy1.lll
  50. 1
      evmjit/evmcc/test/ext/store_delete.evm
  51. 9
      evmjit/evmcc/test/ext/store_delete.lll
  52. 1
      evmjit/evmcc/test/ext/store_test.evm
  53. 14
      evmjit/evmcc/test/ext/store_test.lll
  54. 7
      evmjit/evmcc/test/jump/ackermann.ethel
  55. 1
      evmjit/evmcc/test/jump/ackermann.evm
  56. 1
      evmjit/evmcc/test/jump/badindirect1.evm
  57. 9
      evmjit/evmcc/test/jump/badindirect1.lll
  58. 1
      evmjit/evmcc/test/jump/badindirect2.evm
  59. 12
      evmjit/evmcc/test/jump/badindirect2.lll
  60. 1
      evmjit/evmcc/test/jump/badjump1.evm
  61. 6
      evmjit/evmcc/test/jump/badjump1.lll
  62. 1
      evmjit/evmcc/test/jump/badjump2.evm
  63. 9
      evmjit/evmcc/test/jump/badjump2.lll
  64. 5
      evmjit/evmcc/test/jump/call1.ethel
  65. 1
      evmjit/evmcc/test/jump/call1.evm
  66. 5
      evmjit/evmcc/test/jump/call2.ethel
  67. 1
      evmjit/evmcc/test/jump/call2.evm
  68. 5
      evmjit/evmcc/test/jump/fac.ethel
  69. 1
      evmjit/evmcc/test/jump/fac.evm
  70. 5
      evmjit/evmcc/test/jump/fac_tail.ethel
  71. 1
      evmjit/evmcc/test/jump/fac_tail.evm
  72. 6
      evmjit/evmcc/test/jump/fib1.ethel
  73. 1
      evmjit/evmcc/test/jump/fib1.evm
  74. 1
      evmjit/evmcc/test/jump/for1.evm
  75. 3
      evmjit/evmcc/test/jump/for1.lll
  76. 1
      evmjit/evmcc/test/jump/for2.evm
  77. 3
      evmjit/evmcc/test/jump/for2.lll
  78. 1
      evmjit/evmcc/test/jump/if1.ethel
  79. 1
      evmjit/evmcc/test/jump/if1.evm
  80. 1
      evmjit/evmcc/test/jump/if2.ethel
  81. 1
      evmjit/evmcc/test/jump/if2.evm
  82. 1
      evmjit/evmcc/test/jump/indirect1.evm
  83. 13
      evmjit/evmcc/test/jump/indirect1.lll
  84. 1
      evmjit/evmcc/test/jump/indirect2.evm
  85. 19
      evmjit/evmcc/test/jump/indirect2.lll
  86. 1
      evmjit/evmcc/test/jump/indirect3.evm
  87. 14
      evmjit/evmcc/test/jump/indirect3.lll
  88. 1
      evmjit/evmcc/test/jump/indirect4.evm
  89. 15
      evmjit/evmcc/test/jump/indirect4.lll
  90. 1
      evmjit/evmcc/test/jump/jump1.evm
  91. 11
      evmjit/evmcc/test/jump/jump1.lll
  92. 1
      evmjit/evmcc/test/jump/jump2.evm
  93. 10
      evmjit/evmcc/test/jump/jump2.lll
  94. 1
      evmjit/evmcc/test/jump/jump3.evm
  95. 10
      evmjit/evmcc/test/jump/jump3.lll
  96. 1
      evmjit/evmcc/test/jump/jump4.evm
  97. 17
      evmjit/evmcc/test/jump/jump4.lll
  98. 1
      evmjit/evmcc/test/jump/jump5.evm
  99. 16
      evmjit/evmcc/test/jump/jump5.lll
  100. 1
      evmjit/evmcc/test/jump/jump6.evm

4
.gitignore

@ -65,4 +65,6 @@ DerivedData
project.pbxproj
evmjit
doc/html
*.autosave
node_modules/

21
CMakeLists.txt

@ -49,6 +49,7 @@ endfunction()
function(createBuildInfo)
# Set build platform; to be written to BuildInfo.h
set(ETH_BUILD_PLATFORM "${TARGET_PLATFORM}")
if (CMAKE_COMPILER_IS_MINGW)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/mingw")
elseif (CMAKE_COMPILER_IS_MSYS)
@ -63,11 +64,21 @@ function(createBuildInfo)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown")
endif ()
if (EVMJIT)
set(ETH_BUILD_PLATFORM "${TARGET_PLATFORM}/JIT")
else ()
set(ETH_BUILD_PLATFORM "${TARGET_PLATFORM}/int")
endif ()
if (PARANOIA)
set(ETH_BUILD_PLATFORM "${TARGET_PLATFORM}/PARA")
endif ()
#cmake build type may be not specified when using msvc
if (${CMAKE_BUILD_TYPE})
if (CMAKE_BUILD_TYPE)
set(_cmake_build_type ${CMAKE_BUILD_TYPE})
else()
set(_cmake_build_type "undefined")
set(_cmake_build_type "${CMAKE_CFG_INTDIR}")
endif()
# Generate header file containing useful build information
@ -113,9 +124,7 @@ include(EthExecutableHelper)
createBuildInfo()
if (EVMJIT)
# Workaround for Ubuntu broken LLVM package
link_directories(/usr/lib/llvm-3.5/lib)
set(EVMJIT_CPP TRUE) # include CPP-JIT connector
add_subdirectory(evmjit)
endif()
@ -156,7 +165,7 @@ endif ()
if (NOT HEADLESS)
add_subdirectory(libjsqrc)
add_subdirectory(libqethereum)
add_subdirectory(libqwebthree)
add_subdirectory(alethzero)
add_subdirectory(third)
add_subdirectory(mix)

20
CodingStandards.txt

@ -128,6 +128,10 @@ d. Use override, final and const judiciously.
e. No implementations with the class declaration, except:
- template or force-inline method (though prefer implementation at bottom of header file).
- one-line implementation (in which case include it in same line as declaration).
f. For a method 'foo'
- Member: m_foo;
- Getter: foo() [ also: for booleans, isFoo() ];
- Setter: setFoo();
@ -162,3 +166,19 @@ d. In general expressions should be roughly as important/semantically meaningful
a. Comments should be doxygen-compilable, using @notation rather than \notation.
12. Include Headers
a. Includes should go in order of lower level (STL -> boost -> libdevcore -> libdevcrypto -> libethcore -> libethereum) to higher level. Lower levels are basically dependencies to the higher levels. For example:
#include <string>
#include <boost/filesystem.hpp>
#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/Exceptions.h>
#include <libdevcore/Log.h>
#include <libdevcrypto/SHA3.h>
#include <libethereum/Defaults.h>
b. The only exception to the above rule is the top of a .cpp file where its corresponding header should be located.

11
README.md

@ -1,14 +1,11 @@
## Ethereum C++ Client.
[![Build
Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20C%2B%2B%20master%20branch)](http://build.ethdev.com/builders/Linux%20C%2B%2B%20master%20branch/builds/-1) master [![Build
Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20C%2B%2B%20develop%20branch)](http://build.ethdev.com/builders/Linux%20C%2B%2B%20develop%20branch/builds/-1) develop
By Gav Wood, 2014.
[![Build
+Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20C%2B%2B%20master%20branch)](http://build.ethdev.com/builders/Linux%20C%2B%2B%20master%20branch/builds/-1) master [![Build
+Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20C%2B%2B%20develop%20branch)](http://build.ethdev.com/builders/Linux%20C%2B%2B%20develop%20branch/builds/-1) develop
| Linux | OSX | Windows
----------|---------|-----|--------
develop | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20C%2B%2B%20develop%20branch)](http://build.ethdev.com/builders/Linux%20C%2B%2B%20develop%20branch/builds/-1) | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=OSX%20C%2B%2B%20develop%20branch)](http://build.ethdev.com/builders/OSX%20C%2B%2B%20develop%20branch/builds/-1) | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=Windows%20C%2B%2B%20develop%20branch)](http://build.ethdev.com/builders/Windows%20C%2B%2B%20develop%20branch/builds/-1)
master | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=Linux%20C%2B%2B%20master%20branch)](http://build.ethdev.com/builders/Linux%20C%2B%2B%20master%20branch/builds/-1) | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=OSX%20C%2B%2B%20master%20branch)](http://build.ethdev.com/builders/OSX%20C%2B%2B%20master%20branch/builds/-1) | [![Build+Status](http://build.ethdev.com/buildstatusimage?builder=Windows%20C%2B%2B%20master%20branch)](http://build.ethdev.com/builders/Windows%20C%2B%2B%20master%20branch/builds/-1)
[![Stories in Ready](https://badge.waffle.io/ethereum/cpp-ethereum.png?label=ready&title=Ready)](http://waffle.io/ethereum/cpp-ethereum)

2
alethzero/CMakeLists.txt

@ -34,7 +34,7 @@ add_dependencies(${EXECUTABLE} BuildInfo.h)
target_link_libraries(${EXECUTABLE} Qt5::Core)
target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} qethereum)
target_link_libraries(${EXECUTABLE} qwebthree)
target_link_libraries(${EXECUTABLE} ethereum)
target_link_libraries(${EXECUTABLE} evm)
target_link_libraries(${EXECUTABLE} ethcore)

28
alethzero/Main.ui

@ -95,8 +95,8 @@
<widget class="QLineEdit" name="urlEdit"/>
</item>
<item>
<widget class="QWebView" name="webView" native="true">
<property name="url" stdset="0">
<widget class="QWebView" name="webView">
<property name="url">
<url>
<string>about:blank</string>
</url>
@ -165,6 +165,7 @@
<addaction name="debugDumpStatePre"/>
<addaction name="separator"/>
<addaction name="paranoia"/>
<addaction name="clearPending"/>
<addaction name="killBlockchain"/>
<addaction name="inject"/>
<addaction name="forceMining"/>
@ -172,6 +173,7 @@
<addaction name="enableOptimizer"/>
<addaction name="separator"/>
<addaction name="usePrivate"/>
<addaction name="jitvm"/>
</widget>
<widget class="QMenu" name="menu_View">
<property name="title">
@ -1210,8 +1212,8 @@
<number>0</number>
</property>
<item>
<widget class="QWebView" name="jsConsole" native="true">
<property name="url" stdset="0">
<widget class="QWebView" name="jsConsole">
<property name="url">
<url>
<string>about:blank</string>
</url>
@ -2033,7 +2035,7 @@ font-size: 14pt</string>
</action>
<action name="importKeyFile">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string>Claim Ether Presale &amp;Wallet...</string>
@ -2049,6 +2051,22 @@ font-size: 14pt</string>
<string>New Identity</string>
</property>
</action>
<action name="clearPending">
<property name="text">
<string>Clear Pe&amp;nd&amp;ing</string>
</property>
</action>
<action name="jitvm">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>Use &amp;LLVM-EVM</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

367
alethzero/MainWin.cpp

@ -37,9 +37,10 @@
#include <liblll/Compiler.h>
#include <liblll/CodeFragment.h>
#include <libsolidity/Scanner.h>
#include <libsolidity/CompilerStack.h>
#include <libsolidity/AST.h>
#include <libsolidity/SourceReferenceFormatter.h>
#include <libevm/VM.h>
#include <libevm/VMFactory.h>
#include <libethereum/BlockChain.h>
#include <libethereum/ExtVM.h>
#include <libethereum/Client.h>
@ -47,10 +48,10 @@
#include <libethereum/EthereumHost.h>
#include <libethereum/DownloadMan.h>
#include <libweb3jsonrpc/WebThreeStubServer.h>
#include "MainWin.h"
#include "DownloadView.h"
#include "MiningView.h"
#include "BuildInfo.h"
#include "MainWin.h"
#include "OurWebThreeStubServer.h"
#include "ui_Main.h"
using namespace std;
@ -59,17 +60,22 @@ using namespace dev::p2p;
using namespace dev::eth;
namespace js = json_spirit;
#define Small "font-size: small; "
#define Mono "font-family: Ubuntu Mono, Monospace, Lucida Console, Courier New; font-weight: bold; "
#define Div(S) "<div style=\"" S "\">"
#define Span(S) "<span style=\"" S "\">"
static void initUnits(QComboBox* _b)
{
for (auto n = (unsigned)units().size(); n-- != 0; )
_b->addItem(QString::fromStdString(units()[n].second), n);
}
QString Main::fromRaw(dev::h256 _n, unsigned* _inc)
QString Main::fromRaw(h256 _n, unsigned* _inc)
{
if (_n)
{
std::string s((char const*)_n.data(), 32);
string s((char const*)_n.data(), 32);
auto l = s.find_first_of('\0');
if (!l)
return QString();
@ -90,13 +96,13 @@ QString Main::fromRaw(dev::h256 _n, unsigned* _inc)
return QString();
}
static std::vector<dev::KeyPair> keysAsVector(QList<dev::KeyPair> const& keys)
static vector<KeyPair> keysAsVector(QList<KeyPair> const& keys)
{
auto list = keys.toStdList();
return {begin(list), end(list)};
}
static QString contentsOfQResource(std::string const& res)
static QString contentsOfQResource(string const& res)
{
QFile file(QString::fromStdString(res));
if (!file.open(QFile::ReadOnly))
@ -105,9 +111,9 @@ static QString contentsOfQResource(std::string const& res)
return in.readAll();
}
Address c_config = Address("661005d2720d855f1d9976f88bb10c1a3398c77f");
Address c_newConfig = Address("d5f9d8d94886e70b06e474c3fb14fd43e2f23970");
Address c_nameReg = Address("ddd1cea741d548f90d86fb87a3ae6492e18c03a1");
//Address c_config = Address("661005d2720d855f1d9976f88bb10c1a3398c77f");
Address c_newConfig = Address("661005d2720d855f1d9976f88bb10c1a3398c77f");
//Address c_nameReg = Address("ddd1cea741d548f90d86fb87a3ae6492e18c03a1");
Main::Main(QWidget *parent) :
QMainWindow(parent),
@ -115,7 +121,7 @@ Main::Main(QWidget *parent) :
{
setWindowFlags(Qt::Window);
ui->setupUi(this);
g_logPost = [=](std::string const& s, char const* c)
g_logPost = [=](string const& s, char const* c)
{
simpleDebugOut(s, c);
m_logLock.lock();
@ -135,8 +141,8 @@ Main::Main(QWidget *parent) :
cerr << "Block Hash: " << BlockChain::genesis().hash << endl;
cerr << "Block RLP: " << RLP(block) << endl;
cerr << "Block Hex: " << toHex(block) << endl;
cerr << "Network protocol version: " << dev::eth::c_protocolVersion << endl;
cerr << "Client database version: " << dev::eth::c_databaseVersion << endl;
cerr << "Network protocol version: " << c_protocolVersion << endl;
cerr << "Client database version: " << c_databaseVersion << endl;
ui->configDock->close();
on_verbosity_valueChanged();
@ -157,7 +163,7 @@ Main::Main(QWidget *parent) :
m_webThree.reset(new WebThreeDirect(string("AlethZero/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir() + "/AlethZero", false, {"eth", "shh"}));
m_qwebConnector.reset(new QWebThreeConnector());
m_server.reset(new OurWebThreeStubServer(*m_qwebConnector, *web3(), keysAsVector(m_myKeys)));
m_server.reset(new OurWebThreeStubServer(*m_qwebConnector, *web3(), keysAsVector(m_myKeys), this));
connect(&*m_server, SIGNAL(onNewId(QString)), SLOT(addNewId(QString)));
m_server->setIdentities(keysAsVector(owned()));
m_server->StartListening();
@ -233,7 +239,7 @@ void Main::addNewId(QString _ids)
refreshWhisper();
}
dev::p2p::NetworkPreferences Main::netPrefs() const
NetworkPreferences Main::netPrefs() const
{
return NetworkPreferences(ui->port->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), ui->localNetworking->isChecked());
}
@ -243,14 +249,14 @@ void Main::onKeysChanged()
installBalancesWatch();
}
unsigned Main::installWatch(dev::eth::LogFilter const& _tf, std::function<void()> const& _f)
unsigned Main::installWatch(LogFilter const& _tf, WatchHandler const& _f)
{
auto ret = ethereum()->installWatch(_tf);
m_handlers[ret] = _f;
return ret;
}
unsigned Main::installWatch(dev::h256 _tf, std::function<void()> const& _f)
unsigned Main::installWatch(dev::h256 _tf, WatchHandler const& _f)
{
auto ret = ethereum()->installWatch(_tf);
m_handlers[ret] = _f;
@ -265,30 +271,42 @@ void Main::uninstallWatch(unsigned _w)
void Main::installWatches()
{
installWatch(dev::eth::LogFilter().address(c_config), [=]() { installNameRegWatch(); });
installWatch(dev::eth::LogFilter().address(c_config), [=]() { installCurrenciesWatch(); });
installWatch(dev::eth::PendingChangedFilter, [=](){ onNewPending(); });
installWatch(dev::eth::ChainChangedFilter, [=](){ onNewBlock(); });
installWatch(LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installNameRegWatch(); });
installWatch(LogFilter().address(c_newConfig), [=](LocalisedLogEntries const&) { installCurrenciesWatch(); });
installWatch(PendingChangedFilter, [=](LocalisedLogEntries const&){ onNewPending(); });
installWatch(ChainChangedFilter, [=](LocalisedLogEntries const&){ onNewBlock(); });
}
Address Main::getNameReg() const
{
return abiOut<Address>(ethereum()->call(c_newConfig, abiIn("lookup(uint256)", (u256)1)));
}
Address Main::getCurrencies() const
{
return abiOut<Address>(ethereum()->call(c_newConfig, abiIn("lookup(uint256)", (u256)3)));
}
void Main::installNameRegWatch()
{
uninstallWatch(m_nameRegFilter);
m_nameRegFilter = installWatch(dev::eth::LogFilter().address((u160)ethereum()->stateAt(c_config, 0)), [=](){ onNameRegChange(); });
m_nameRegFilter = installWatch(LogFilter().address((u160)getNameReg()), [=](LocalisedLogEntries const&){ onNameRegChange(); });
}
void Main::installCurrenciesWatch()
{
uninstallWatch(m_currenciesFilter);
m_currenciesFilter = installWatch(dev::eth::LogFilter().address((u160)ethereum()->stateAt(c_config, 1)), [=](){ onCurrenciesChange(); });
m_currenciesFilter = installWatch(LogFilter().address((u160)getCurrencies()), [=](LocalisedLogEntries const&){ onCurrenciesChange(); });
}
void Main::installBalancesWatch()
{
dev::eth::LogFilter tf;
LogFilter tf;
vector<Address> altCoins;
Address coinsAddr = right160(ethereum()->stateAt(c_config, 1));
Address coinsAddr = getCurrencies();
// TODO: Update for new currencies reg.
for (unsigned i = 0; i < ethereum()->stateAt(coinsAddr, 0); ++i)
altCoins.push_back(right160(ethereum()->stateAt(coinsAddr, i + 1)));
for (auto i: m_myKeys)
@ -296,7 +314,7 @@ void Main::installBalancesWatch()
tf.address(c).topic(h256(i.address(), h256::AlignRight));
uninstallWatch(m_balancesFilter);
m_balancesFilter = installWatch(tf, [=](){ onBalancesChange(); });
m_balancesFilter = installWatch(tf, [=](LocalisedLogEntries const&){ onBalancesChange(); });
}
void Main::onNameRegChange()
@ -330,6 +348,9 @@ void Main::onNewBlock()
refreshBlockCount();
refreshBlockChain();
refreshAccounts();
// We must update balances since we can't filter updates to basic accounts.
refreshBalances();
}
void Main::onNewPending()
@ -431,7 +452,7 @@ void Main::eval(QString const& _js)
else
s = "<span style=\"color: #888\">unknown type</span>";
m_consoleHistory.push_back(qMakePair(_js, s));
s = "<html><body style=\"font-family: Monospace, Ubuntu Mono, Lucida Console, Courier New; margin: 0; font-size: 12pt\"><div style=\"position: absolute; bottom: 0; border: 0px; margin: 0px; width: 100%\">";
s = "<html><body style=\"margin: 0;\">" Div(Mono "position: absolute; bottom: 0; border: 0px; margin: 0px; width: 100%");
for (auto const& i: m_consoleHistory)
s += "<div style=\"border-bottom: 1 solid #eee; width: 100%\"><span style=\"float: left; width: 1em; color: #888; font-weight: bold\">&gt;</span><span style=\"color: #35d\">" + i.first.toHtmlEscaped() + "</span></div>"
"<div style=\"border-bottom: 1 solid #eee; width: 100%\"><span style=\"float: left; width: 1em\">&nbsp;</span><span>" + i.second + "</span></div>";
@ -450,37 +471,37 @@ static Public stringToPublic(QString const& _a)
return Public();
}
static Address g_newNameReg;
//static Address g_newNameReg;
QString Main::pretty(dev::Address _a) const
{
static std::map<Address, QString> s_memos;
/* static map<Address, QString> s_memos;
if (!s_memos.count(_a))
{
if (!g_newNameReg)
g_newNameReg = abiOut<Address>(ethereum()->call(c_newConfig, abiIn(1, (u256)1)));
{*/
// if (!g_newNameReg)
auto g_newNameReg = getNameReg();
if (g_newNameReg)
{
QString s = QString::fromStdString(toString(abiOut<string32>(ethereum()->call(g_newNameReg, abiIn(2, _a)))));
s_memos[_a] = s;
QString s = QString::fromStdString(toString(abiOut<string32>(ethereum()->call(g_newNameReg, abiIn("nameOf(address)", _a)))));
// s_memos[_a] = s;
if (s.size())
return s;
}
}
/* }
else
if (s_memos[_a].size())
return s_memos[_a];
return s_memos[_a];*/
h256 n;
/*
if (h160 nameReg = (u160)ethereum()->stateAt(c_config, 0))
n = ethereum()->stateAt(nameReg, (u160)(_a));
if (!n)
n = ethereum()->stateAt(m_nameReg, (u160)(_a));
*/
return fromRaw(n);
}
@ -492,7 +513,7 @@ QString Main::render(dev::Address _a) const
return QString::fromStdString(_a.abridged());
}
string32 fromString(std::string const& _s)
string32 fromString(string const& _s)
{
string32 ret;
for (unsigned i = 0; i < 32 && i <= _s.size(); ++i)
@ -505,21 +526,21 @@ Address Main::fromString(QString const& _n) const
if (_n == "(Create Contract)")
return Address();
static std::map<QString, Address> s_memos;
/* static map<QString, Address> s_memos;
if (!s_memos.count(_n))
{
if (!g_newNameReg)
g_newNameReg = abiOut<Address>(ethereum()->call(c_newConfig, abiIn(1, (u256)1)));
{*/
// if (!g_newNameReg)
auto g_newNameReg = getNameReg();
if (g_newNameReg)
{
Address a = abiOut<Address>(ethereum()->call(g_newNameReg, abiIn(0, ::fromString(_n.toStdString()))));
s_memos[_n] = a;
Address a = abiOut<Address>(ethereum()->call(g_newNameReg, abiIn("addressOf(string32)", ::fromString(_n.toStdString()))));
// s_memos[_n] = a;
if (a)
return a;
}
}
/* }
else
if (s_memos[_n])
return s_memos[_n];
@ -532,14 +553,13 @@ Address Main::fromString(QString const& _n) const
memset(n.data() + sn.size(), 0, 32 - sn.size());
if (_n.size())
{
if (h160 nameReg = (u160)ethereum()->stateAt(c_config, 0))
if (h256 a = ethereum()->stateAt(nameReg, n))
return right160(a);
if (h256 a = ethereum()->stateAt(m_nameReg, n))
return right160(a);
}
}*/
if (_n.size() == 40)
return Address(fromHex(_n.toStdString()));
@ -566,8 +586,9 @@ QString Main::lookup(QString const& _a) const
*/
h256 ret;
if (h160 dnsReg = (u160)ethereum()->stateAt(c_config, 4, 0))
ret = ethereum()->stateAt(dnsReg, n);
// TODO: fix with the new DNSreg contract
// if (h160 dnsReg = (u160)ethereum()->stateAt(c_config, 4, 0))
// ret = ethereum()->stateAt(dnsReg, n);
/* if (!ret)
if (h160 nameReg = (u160)ethereum()->stateAt(c_config, 0, 0))
ret = ethereum()->stateAt(nameReg, n2);
@ -632,6 +653,7 @@ void Main::writeSettings()
s.setValue("url", ui->urlEdit->text());
s.setValue("privateChain", m_privateChain);
s.setValue("verbosity", ui->verbosity->value());
s.setValue("jitvm", ui->jitvm->isChecked());
bytes d = m_webThree->saveNodes();
if (d.size())
@ -706,6 +728,7 @@ void Main::readSettings(bool _skipGeometry)
m_privateChain = s.value("privateChain", "").toString();
ui->usePrivate->setChecked(m_privateChain.size());
ui->verbosity->setValue(s.value("verbosity", 1).toInt());
ui->jitvm->setChecked(s.value("jitvm", true).toBool());
ui->urlEdit->setText(s.value("url", "about:blank").toString()); //http://gavwood.com/gavcoin.html
on_urlEdit_returnPressed();
@ -732,7 +755,7 @@ void Main::on_importKey_triggered()
void Main::on_importKeyFile_triggered()
{
QString s = QFileDialog::getOpenFileName(this, "Import Account", QDir::homePath(), "JSON Files (*.json);;All Files (*)");
QString s = QFileDialog::getOpenFileName(this, "Claim Account Contents", QDir::homePath(), "JSON Files (*.json);;All Files (*)");
try
{
js::mValue val;
@ -762,8 +785,12 @@ void Main::on_importKeyFile_triggered()
if (std::find(m_myKeys.begin(), m_myKeys.end(), k) == m_myKeys.end())
{
m_myKeys.append(k);
keysChanged();
if (m_myKeys.empty())
{
m_myKeys.push_back(KeyPair::create());
keysChanged();
}
ethereum()->transact(k.sec(), ethereum()->balanceAt(k.address()) - gasPrice() * c_txGas, m_myKeys.back().address(), {}, c_txGas, gasPrice());
}
else
QMessageBox::warning(this, "Already Have Key", "Could not import the secret key: we already own this account.");
@ -805,6 +832,12 @@ void Main::on_usePrivate_triggered()
on_killBlockchain_triggered();
}
void Main::on_jitvm_triggered()
{
bool jit = ui->jitvm->isChecked();
VMFactory::setKind(jit ? VMKind::JIT : VMKind::Interpreter);
}
void Main::on_urlEdit_returnPressed()
{
QString s = ui->urlEdit->text();
@ -839,18 +872,18 @@ void Main::on_preview_triggered()
void Main::refreshMining()
{
dev::eth::MineProgress p = ethereum()->miningProgress();
MineProgress p = ethereum()->miningProgress();
ui->mineStatus->setText(ethereum()->isMining() ? QString("%1s @ %2kH/s").arg(p.ms / 1000).arg(p.ms ? p.hashes / p.ms : 0) : "Not mining");
if (!ui->miningView->isVisible())
return;
list<dev::eth::MineInfo> l = ethereum()->miningHistory();
list<MineInfo> l = ethereum()->miningHistory();
static unsigned lh = 0;
if (p.hashes < lh)
ui->miningView->resetStats();
lh = p.hashes;
ui->miningView->appendStats(l, p);
/* if (p.ms)
for (dev::eth::MineInfo const& i: l)
for (MineInfo const& i: l)
cnote << i.hashes * 10 << "h/sec, need:" << i.requirement << " best:" << i.best << " best-so-far:" << p.best << " avg-speed:" << (p.hashes * 1000 / p.ms) << "h/sec";
*/
}
@ -861,8 +894,8 @@ void Main::refreshBalances()
// update all the balance-dependent stuff.
ui->ourAccounts->clear();
u256 totalBalance = 0;
map<Address, tuple<QString, u256, u256>> altCoins;
Address coinsAddr = right160(ethereum()->stateAt(c_config, 1));
/* map<Address, tuple<QString, u256, u256>> altCoins;
Address coinsAddr = getCurrencies();
for (unsigned i = 0; i < ethereum()->stateAt(coinsAddr, 0); ++i)
{
auto n = ethereum()->stateAt(coinsAddr, i + 1);
@ -872,7 +905,7 @@ void Main::refreshBalances()
denom = 1;
// cdebug << n << addr << denom << sha3(h256(n).asBytes());
altCoins[addr] = make_tuple(fromRaw(n), 0, denom);
}
}*/
for (auto i: m_myKeys)
{
u256 b = ethereum()->balanceAt(i.address());
@ -880,18 +913,18 @@ void Main::refreshBalances()
->setData(Qt::UserRole, QByteArray((char const*)i.address().data(), Address::size));
totalBalance += b;
for (auto& c: altCoins)
get<1>(c.second) += (u256)ethereum()->stateAt(c.first, (u160)i.address());
// for (auto& c: altCoins)
// get<1>(c.second) += (u256)ethereum()->stateAt(c.first, (u160)i.address());
}
QString b;
for (auto const& c: altCoins)
/* for (auto const& c: altCoins)
if (get<1>(c.second))
{
stringstream s;
s << setw(toString(get<2>(c.second) - 1).size()) << setfill('0') << (get<1>(c.second) % get<2>(c.second));
b += QString::fromStdString(toString(get<1>(c.second) / get<2>(c.second)) + "." + s.str() + " ") + get<0>(c.second).toUpper() + " | ";
}
}*/
ui->balance->setText(b + QString::fromStdString(formatBalance(totalBalance)));
}
@ -1005,10 +1038,10 @@ void Main::refreshBlockCount()
cwatch << "refreshBlockCount()";
auto d = ethereum()->blockChain().details();
auto diff = BlockInfo(ethereum()->blockChain().block()).difficulty;
ui->blockCount->setText(QString("%6 #%1 @%3 T%2 PV%4 D%5").arg(d.number).arg(toLog2(d.totalDifficulty)).arg(toLog2(diff)).arg(dev::eth::c_protocolVersion).arg(dev::eth::c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet"));
ui->blockCount->setText(QString("%6 #%1 @%3 T%2 PV%4 D%5").arg(d.number).arg(toLog2(d.totalDifficulty)).arg(toLog2(diff)).arg(c_protocolVersion).arg(c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet"));
}
static bool blockMatch(string const& _f, dev::eth::BlockDetails const& _b, h256 _h, BlockChain const& _bc)
static bool blockMatch(string const& _f, BlockDetails const& _b, h256 _h, BlockChain const& _bc)
{
try
{
@ -1064,7 +1097,7 @@ void Main::refreshBlockChain()
auto b = bc.block(h);
for (auto const& i: RLP(b)[1])
{
Transaction t(i.data());
Transaction t(i.data(), CheckSignature::Sender);
if (bm || transactionMatch(filter, t))
{
QString s = t.receiveAddress() ?
@ -1150,11 +1183,14 @@ void Main::timerEvent(QTimerEvent*)
m_qweb->poll();
for (auto const& i: m_handlers)
if (ethereum()->checkWatch(i.first))
i.second();
{
auto ls = ethereum()->checkWatch(i.first);
if (ls.size())
i.second(ls);
}
}
string Main::renderDiff(dev::eth::StateDiff const& _d) const
string Main::renderDiff(StateDiff const& _d) const
{
stringstream s;
@ -1163,24 +1199,24 @@ string Main::renderDiff(dev::eth::StateDiff const& _d) const
{
s << "<hr/>";
dev::eth::AccountDiff const& ad = i.second;
AccountDiff const& ad = i.second;
s << "<code style=\"white-space: pre; font-weight: bold\">" << lead(ad.changeType()) << " </code>" << " <b>" << render(i.first).toStdString() << "</b>";
if (!ad.exist.to())
continue;
if (ad.balance)
{
s << "<br/>" << indent << "Balance " << std::dec << formatBalance(ad.balance.to());
s << " <b>" << std::showpos << (((dev::bigint)ad.balance.to()) - ((dev::bigint)ad.balance.from())) << std::noshowpos << "</b>";
s << "<br/>" << indent << "Balance " << dec << formatBalance(ad.balance.to());
s << " <b>" << showpos << (((dev::bigint)ad.balance.to()) - ((dev::bigint)ad.balance.from())) << noshowpos << "</b>";
}
if (ad.nonce)
{
s << "<br/>" << indent << "Count #" << std::dec << ad.nonce.to();
s << " <b>" << std::showpos << (((dev::bigint)ad.nonce.to()) - ((dev::bigint)ad.nonce.from())) << std::noshowpos << "</b>";
s << "<br/>" << indent << "Count #" << dec << ad.nonce.to();
s << " <b>" << showpos << (((dev::bigint)ad.nonce.to()) - ((dev::bigint)ad.nonce.from())) << noshowpos << "</b>";
}
if (ad.code)
{
s << "<br/>" << indent << "Code " << std::hex << ad.code.to().size() << " bytes";
s << "<br/>" << indent << "Code " << hex << ad.code.to().size() << " bytes";
if (ad.code.from().size())
s << " (" << ad.code.from().size() << " bytes)";
}
@ -1202,7 +1238,7 @@ string Main::renderDiff(dev::eth::StateDiff const& _d) const
else if (i.first > u160(1) << 150)
s << (h160)(u160)i.first;
else
s << std::hex << i.first;
s << hex << i.first;
*/
if (!i.second.from())
s << ": " << prettyU256(i.second.to()).toStdString();
@ -1224,6 +1260,7 @@ void Main::on_transactionQueue_currentItemChanged()
if (i >= 0 && i < (int)ethereum()->pending().size())
{
Transaction tx(ethereum()->pending()[i]);
TransactionReceipt receipt(ethereum()->postState().receipt(i));
auto ss = tx.safeSender();
h256 th = sha3(rlpList(ss, tx.nonce()));
s << "<h3>" << th << "</h3>";
@ -1246,12 +1283,15 @@ void Main::on_transactionQueue_currentItemChanged()
if (tx.data().size())
s << dev::memDump(tx.data(), 16, true);
}
s << "<div>Hex: " Span(Mono) << toHex(tx.rlp()) << "</span></div>";
s << "<hr/>";
s << "<div>Log Bloom: " << receipt.bloom() << "</div>";
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>";
s << renderDiff(ethereum()->diff(i, 0));
// s << "Pre: " << fs.rootHash() << "<br/>";
// s << "Post: <b>" << ts.rootHash() << "</b>";
s << renderDiff(ethereum()->diff(i, 0));
}
ui->pendingInfo->setHtml(QString::fromStdString(s.str()));
@ -1339,13 +1379,13 @@ void Main::on_blocks_currentItemChanged()
for (auto const& i: block[1])
s << "<br/>" << sha3(i.data()).abridged();// << ": <b>" << i[1].toHash<h256>() << "</b> [<b>" << i[2].toInt<u256>() << "</b> used]";
s << "<br/>Post: <b>" << info.stateRoot << "</b>";
s << "<br/>Dump: <span style=\"font-family: Monospace,Lucida Console,Courier,Courier New,sans-serif; font-size: small\">" << toHex(block[0].data()) << "</span>";
s << "<div>Receipts-Hex: <span style=\"font-family: Monospace,Lucida Console,Courier,Courier New,sans-serif; font-size: small\">" << toHex(ethereum()->blockChain().receipts(h).rlp()) << "</span></div>";
s << "<br/>Dump: " Span(Mono) << toHex(block[0].data()) << "</span>";
s << "<div>Receipts-Hex: " Span(Mono) << toHex(ethereum()->blockChain().receipts(h).rlp()) << "</span></div>";
}
else
{
unsigned txi = item->data(Qt::UserRole + 1).toInt();
Transaction tx(block[1][txi].data());
Transaction tx(block[1][txi].data(), CheckSignature::Sender);
auto ss = tx.safeSender();
h256 th = sha3(rlpList(ss, tx.nonce()));
TransactionReceipt receipt = ethereum()->blockChain().receipts(h).receipts[txi];
@ -1364,11 +1404,6 @@ void Main::on_blocks_currentItemChanged()
s << "<br/>R: <b>" << hex << nouppercase << tx.signature().r << "</b>";
s << "<br/>S: <b>" << hex << nouppercase << tx.signature().s << "</b>";
s << "<br/>Msg: <b>" << tx.sha3(eth::WithoutSignature) << "</b>";
s << "<div>Log Bloom: " << receipt.bloom() << "</div>";
s << "<div>Hex: <span style=\"font-family: Monospace,Lucida Console,Courier,Courier New,sans-serif; font-size: small\">" << toHex(block[1][txi].data()) << "</span></div>";
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: <span style=\"font-family: Monospace,Lucida Console,Courier,Courier New,sans-serif; font-size: small\">" << toHex(receipt.rlp()) << "</span></div>";
if (tx.isCreation())
{
if (tx.data().size())
@ -1379,6 +1414,12 @@ void Main::on_blocks_currentItemChanged()
if (tx.data().size())
s << dev::memDump(tx.data(), 16, true);
}
s << "<div>Hex: " Span(Mono) << toHex(block[1][txi].data()) << "</span></div>";
s << "<hr/>";
s << "<div>Log Bloom: " << receipt.bloom() << "</div>";
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>";
s << renderDiff(ethereum()->diff(txi, h));
ui->debugCurrent->setEnabled(true);
ui->debugDumpState->setEnabled(true);
@ -1450,10 +1491,10 @@ void Main::populateDebugger(dev::bytesConstRef _r)
bytesConstRef lastData;
h256 lastHash;
h256 lastDataHash;
auto onOp = [&](uint64_t steps, Instruction inst, dev::bigint newMemSize, dev::bigint gasCost, dev::eth::VM* voidVM, dev::eth::ExtVMFace const* voidExt)
auto onOp = [&](uint64_t steps, Instruction inst, dev::bigint newMemSize, dev::bigint gasCost, VM* voidVM, ExtVMFace const* voidExt)
{
dev::eth::VM& vm = *voidVM;
dev::eth::ExtVM const& ext = *static_cast<dev::eth::ExtVM const*>(voidExt);
VM& vm = *voidVM;
ExtVM const& ext = *static_cast<ExtVM const*>(voidExt);
if (ext.code != lastExtCode)
{
lastExtCode = ext.code;
@ -1475,7 +1516,7 @@ void Main::populateDebugger(dev::bytesConstRef _r)
m_history.append(WorldState({steps, ext.myAddress, vm.curPC(), inst, newMemSize, vm.gas(), lastHash, lastDataHash, vm.stack(), vm.memory(), gasCost, ext.state().storage(ext.myAddress), levels}));
};
m_currentExecution->go(onOp);
m_currentExecution->finalize(onOp);
m_currentExecution->finalize();
initDebugger();
updateDebugger();
}
@ -1497,6 +1538,7 @@ void Main::on_contracts_currentItemChanged()
for (auto const& i: storage)
s << "@" << showbase << hex << prettyU256(i.first).toStdString() << "&nbsp;&nbsp;&nbsp;&nbsp;" << showbase << hex << prettyU256(i.second).toStdString() << "<br/>";
s << "<h4>Body Code</h4>" << disassemble(ethereum()->codeAt(address));
s << Div(Mono) << toHex(ethereum()->codeAt(address)) << "</div>";
ui->contractInfo->appendHtml(QString::fromStdString(s.str()));
}
catch (dev::InvalidTrie)
@ -1576,11 +1618,11 @@ static shh::Topic topicFromText(QString _s)
{
u256 v(d.cap(2).toStdString());
if (d.cap(6) == "szabo")
v *= dev::eth::szabo;
v *= szabo;
else if (d.cap(5) == "finney")
v *= dev::eth::finney;
v *= finney;
else if (d.cap(4) == "ether")
v *= dev::eth::ether;
v *= ether;
bytes bs = dev::toCompactBigEndian(v);
if (d.cap(1) != "$")
for (auto i = bs.size(); i < 32; ++i)
@ -1606,6 +1648,34 @@ static shh::Topic topicFromText(QString _s)
return ret;
}
bool Main::sourceIsSolidity(string const& _source)
{
// TODO: Improve this heuristic
return (_source.substr(0, 8) == "contract" || _source.substr(0, 5) == "//sol");
}
static bool sourceIsSerpent(string const& _source)
{
// TODO: Improve this heuristic
return (_source.substr(0, 5) == "//ser");
}
string const Main::getFunctionHashes(dev::solidity::CompilerStack const &_compiler,
string const& _contractName)
{
string ret = "";
auto const& contract = _compiler.getContractDefinition(_contractName);
auto interfaceFunctions = contract.getInterfaceFunctions();
for (auto const& it: interfaceFunctions)
{
ret += it.first.abridged();
ret += " :";
ret += it.second->getName() + "\n";
}
return ret;
}
void Main::on_data_textChanged()
{
m_pcWarp.clear();
@ -1619,12 +1689,17 @@ void Main::on_data_textChanged()
{
m_data = fromHex(src);
}
else if (src.substr(0, 8) == "contract") // improve this heuristic
else if (sourceIsSolidity(src))
{
dev::solidity::CompilerStack compiler;
try
{
// compiler.addSources(dev::solidity::StandardSources);
m_data = compiler.compile(src, m_enableOptimizer);
solidity = "<h4>Solidity</h4>";
solidity += "<pre>" + QString::fromStdString(compiler.getInterface()).replace(QRegExp("\\s"), "").toHtmlEscaped() + "</pre>";
solidity += "<pre>" + QString::fromStdString(compiler.getSolidityInterface()).toHtmlEscaped() + "</pre>";
solidity += "<pre>" + QString::fromStdString(getFunctionHashes(compiler)).toHtmlEscaped() + "</pre>";
}
catch (dev::Exception const& exception)
{
@ -1637,29 +1712,29 @@ void Main::on_data_textChanged()
solidity = "<h4>Solidity</h4><pre>Uncaught exception.</pre>";
}
}
else
else if (sourceIsSerpent(src))
{
m_data = dev::eth::compileLLL(src, m_enableOptimizer, &errors);
if (errors.size())
try
{
try
{
m_data = dev::asBytes(::compile(src));
for (auto& i: errors)
i = "(LLL " + i + ")";
}
catch (string err)
{
errors.push_back("Serpent " + err);
}
m_data = dev::asBytes(::compile(src));
for (auto& i: errors)
i = "(LLL " + i + ")";
}
else
catch (string err)
{
errors.push_back("Serpent " + err);
}
}
else
{
m_data = compileLLL(src, m_enableOptimizer, &errors);
if (errors.empty())
{
auto asmcode = dev::eth::compileLLLToAsm(src, false);
auto asmcode = compileLLLToAsm(src, false);
lll = "<h4>Pre</h4><pre>" + QString::fromStdString(asmcode).toHtmlEscaped() + "</pre>";
if (m_enableOptimizer)
{
asmcode = dev::eth::compileLLLToAsm(src, true);
asmcode = compileLLLToAsm(src, true);
lll = "<h4>Opt</h4><pre>" + QString::fromStdString(asmcode).toHtmlEscaped() + "</pre>" + lll;
}
}
@ -1671,7 +1746,7 @@ void Main::on_data_textChanged()
for (auto const& i: errors)
errs.append("<div style=\"border-left: 6px solid #c00; margin-top: 2px\">" + QString::fromStdString(i).toHtmlEscaped() + "</div>");
}
ui->code->setHtml(errs + lll + solidity + "<h4>Code</h4>" + QString::fromStdString(disassemble(m_data)).toHtmlEscaped());
ui->code->setHtml(errs + lll + solidity + "<h4>Code</h4>" + QString::fromStdString(disassemble(m_data)).toHtmlEscaped() + "<h4>Hex</h4>" Div(Mono) + QString::fromStdString(toHex(m_data)) + "</div>");
ui->gas->setMinimum((qint64)Client::txGas(m_data, 0));
if (!ui->gas->isEnabled())
ui->gas->setValue(m_backupGas);
@ -1699,6 +1774,18 @@ void Main::on_data_textChanged()
updateFee();
}
void Main::on_clearPending_triggered()
{
writeSettings();
ui->mine->setChecked(false);
ui->net->setChecked(false);
web3()->stopNetwork();
ethereum()->clearPending();
readSettings(true);
installWatches();
refreshAll();
}
void Main::on_killBlockchain_triggered()
{
writeSettings();
@ -1770,8 +1857,6 @@ void Main::on_net_triggered()
web3()->setClientVersion(n);
if (ui->net->isChecked())
{
// TODO: alter network stuff?
//ui->port->value(), string(), 0, NodeMode::Full, ui->idealPeers->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), m_privateChain.size() ? sha3(m_privateChain.toStdString()) : 0
web3()->setIdealPeerCount(ui->idealPeers->value());
web3()->setNetworkPreferences(netPrefs());
ethereum()->setNetworkId(m_privateChain.size() ? sha3(m_privateChain.toStdString()) : 0);
@ -1830,7 +1915,28 @@ void Main::on_send_clicked()
debugFinished();
Secret s = i.secret();
if (isCreation())
{
// If execution is a contract creation, add Natspec to
// a local Natspec LEVELDB
ethereum()->transact(s, value(), m_data, ui->gas->value(), gasPrice());
string src = ui->data->toPlainText().toStdString();
if (sourceIsSolidity(src))
try
{
dev::solidity::CompilerStack compiler;
m_data = compiler.compile(src, m_enableOptimizer);
for (string& s: compiler.getContractNames())
{
h256 contractHash = compiler.getContractCodeHash(s);
m_natspecDB.add(contractHash,
compiler.getMetadata(s, dev::solidity::DocumentationType::NATSPEC_USER));
}
}
catch (...)
{
statusBar()->showMessage("Couldn't compile Solidity Contract.");
}
}
else
ethereum()->transact(s, value(), fromString(ui->destination->currentText()), m_data, ui->gas->value(), gasPrice());
return;
@ -1873,9 +1979,24 @@ void Main::on_debug_clicked()
}
}
bool beginsWith(Address _a, bytes const& _b)
{
for (unsigned i = 0; i < min<unsigned>(20, _b.size()); ++i)
if (_a[i] != _b[i])
return false;
return true;
}
void Main::on_create_triggered()
{
m_myKeys.append(KeyPair::create());
bool ok = true;
QString s = QInputDialog::getText(this, "Special Beginning?", "If you want a special key, enter some hex digits that it should begin with.\nNOTE: The more you enter, the longer generation will take.", QLineEdit::Normal, QString(), &ok);
if (!ok)
return;
KeyPair p;
while (!beginsWith(p.address(), asBytes(s.toStdString())))
p = KeyPair::create();
m_myKeys.append(p);
keysChanged();
}
@ -1966,7 +2087,7 @@ void Main::on_dumpTracePretty_triggered()
f << " STORAGE" << endl;
for (auto const& i: ws.storage)
f << showbase << hex << i.first << ": " << i.second << endl;
f << dec << ws.levels.size() << " | " << ws.cur << " | #" << ws.steps << " | " << hex << setw(4) << setfill('0') << ws.curPC << " : " << dev::eth::instructionInfo(ws.inst).name << " | " << dec << ws.gas << " | -" << dec << ws.gasCost << " | " << ws.newMemSize << "x32";
f << dec << ws.levels.size() << " | " << ws.cur << " | #" << ws.steps << " | " << hex << setw(4) << setfill('0') << ws.curPC << " : " << instructionInfo(ws.inst).name << " | " << dec << ws.gas << " | -" << dec << ws.gasCost << " | " << ws.newMemSize << "x32";
}
}
@ -2053,7 +2174,9 @@ QString Main::prettyU256(dev::u256 _n) const
unsigned inc = 0;
QString raw;
ostringstream s;
if (!(_n >> 64))
if (_n > szabo && _n < 1000000 * ether)
s << "<span style=\"color: #215\">" << formatBalance(_n) << "</span> <span style=\"color: #448\">(0x" << hex << (uint64_t)_n << ")</span>";
else if (!(_n >> 64))
s << "<span style=\"color: #008\">" << (uint64_t)_n << "</span> <span style=\"color: #448\">(0x" << hex << (uint64_t)_n << ")</span>";
else if (!~(_n >> 64))
s << "<span style=\"color: #008\">" << (int64_t)_n << "</span> <span style=\"color: #448\">(0x" << hex << (int64_t)_n << ")</span>";
@ -2193,7 +2316,7 @@ void Main::updateDebugger()
cwarn << "PC (" << (unsigned)ws.curPC << ") is after code range (" << m_codes[ws.code].size() << ")";
ostringstream ss;
ss << dec << "STEP: " << ws.steps << " | PC: 0x" << hex << ws.curPC << " : " << dev::eth::instructionInfo(ws.inst).name << " | ADDMEM: " << dec << ws.newMemSize << " words | COST: " << dec << ws.gasCost << " | GAS: " << dec << ws.gas;
ss << dec << "STEP: " << ws.steps << " | PC: 0x" << hex << ws.curPC << " : " << instructionInfo(ws.inst).name << " | ADDMEM: " << dec << ws.newMemSize << " words | COST: " << dec << ws.gasCost << " | GAS: " << dec << ws.gas;
ui->debugStateInfo->setText(QString::fromStdString(ss.str()));
stringstream s;
for (auto const& i: ws.storage)
@ -2215,6 +2338,16 @@ void Main::on_post_clicked()
whisper()->inject(m.seal(from, topicFromText(ui->shhTopic->toPlainText()), ui->shhTtl->value(), ui->shhWork->value()));
}
string Main::lookupNatSpec(dev::h256 const& _contractHash) const
{
return m_natspecDB.retrieve(_contractHash);
}
string Main::lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData)
{
return m_natspecDB.getUserNotice(_contractHash, _transactionData);
}
void Main::refreshWhispers()
{
ui->whispers->clear();

27
alethzero/MainWin.h

@ -34,8 +34,11 @@
#include <libethcore/CommonEth.h>
#include <libethereum/State.h>
#include <libethereum/Executive.h>
#include <libqethereum/QEthereum.h>
#include <libqwebthree/QWebThree.h>
#include <libwebthree/WebThree.h>
#include <libsolidity/CompilerStack.h>
#include "NatspecHandler.h"
namespace Ui {
class Main;
@ -66,6 +69,8 @@ struct WorldState
std::vector<WorldState const*> levels;
};
using WatchHandler = std::function<void(dev::eth::LocalisedLogEntries const&)>;
class Main : public QMainWindow
{
Q_OBJECT
@ -78,6 +83,9 @@ public:
dev::eth::Client* ethereum() const { return m_webThree->ethereum(); }
std::shared_ptr<dev::shh::WhisperHost> whisper() const { return m_webThree->whisper(); }
std::string lookupNatSpec(dev::h256 const& _contractHash) const;
std::string lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData);
QList<dev::KeyPair> owned() const { return m_myIdentities + m_myKeys; }
public slots:
@ -126,6 +134,7 @@ private slots:
void on_debugTimeline_valueChanged();
void on_jsInput_returnPressed();
void on_killBlockchain_triggered();
void on_clearPending_triggered();
void on_importKey_triggered();
void on_exportKey_triggered();
void on_inject_triggered();
@ -153,6 +162,7 @@ private slots:
void on_importKeyFile_triggered();
void on_post_clicked();
void on_newIdentity_triggered();
void on_jitvm_triggered();
void refreshWhisper();
void refreshBlockChain();
@ -168,6 +178,8 @@ private:
QString prettyU256(dev::u256 _n) const;
QString lookup(QString const& _n) const;
dev::Address getNameReg() const;
dev::Address getCurrencies() const;
void populateDebugger(dev::bytesConstRef r);
void initDebugger();
@ -189,8 +201,8 @@ private:
dev::u256 value() const;
dev::u256 gasPrice() const;
unsigned installWatch(dev::eth::LogFilter const& _tf, std::function<void()> const& _f);
unsigned installWatch(dev::h256 _tf, std::function<void()> const& _f);
unsigned installWatch(dev::eth::LogFilter const& _tf, WatchHandler const& _f);
unsigned installWatch(dev::h256 _tf, WatchHandler const& _f);
void uninstallWatch(unsigned _w);
void keysChanged();
@ -219,11 +231,17 @@ private:
void refreshBlockCount();
void refreshBalances();
/// Attempts to infer that @c _source contains Solidity code
bool sourceIsSolidity(std::string const& _source);
/// @eturns all method hashes of a Solidity contract in a string
std::string const getFunctionHashes(dev::solidity::CompilerStack const &_compiler,
std::string const& _contractName = "");
std::unique_ptr<Ui::Main> ui;
std::unique_ptr<dev::WebThreeDirect> m_webThree;
std::map<unsigned, std::function<void()>> m_handlers;
std::map<unsigned, WatchHandler> m_handlers;
unsigned m_nameRegFilter = (unsigned)-1;
unsigned m_currenciesFilter = (unsigned)-1;
unsigned m_balancesFilter = (unsigned)-1;
@ -261,4 +279,5 @@ private:
QWebThree* m_qweb = nullptr;
static QString fromRaw(dev::h256 _n, unsigned* _inc = nullptr);
NatspecHandler m_natspecDB;
};

103
alethzero/NatspecHandler.cpp

@ -0,0 +1,103 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file NatspecHandler.cpp
* @author Lefteris Karapetsas <lefteris@ethdev.com>
* @date 2015
*/
#include "NatspecHandler.h"
#include <string>
#include <boost/filesystem.hpp>
#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/Exceptions.h>
#include <libdevcore/Log.h>
#include <libdevcrypto/SHA3.h>
#include <libethereum/Defaults.h>
using namespace dev;
using namespace dev::eth;
using namespace std;
NatspecHandler::NatspecHandler()
{
string path = Defaults::dbPath();
boost::filesystem::create_directories(path);
ldb::Options o;
o.create_if_missing = true;
ldb::DB::Open(o, path + "/natspec", &m_db);
}
NatspecHandler::~NatspecHandler()
{
delete m_db;
}
void NatspecHandler::add(dev::h256 const& _contractHash, string const& _doc)
{
bytes k = _contractHash.asBytes();
string v = _doc;
m_db->Put(m_writeOptions, ldb::Slice((char const*)k.data(), k.size()), ldb::Slice((char const*)v.data(), v.size()));
}
string NatspecHandler::retrieve(dev::h256 const& _contractHash) const
{
bytes k = _contractHash.asBytes();
string ret;
m_db->Get(m_readOptions, ldb::Slice((char const*)k.data(), k.size()), &ret);
return ret;
}
string NatspecHandler::getUserNotice(string const& json, dev::bytes const& _transactionData)
{
Json::Value natspec;
Json::Value userNotice;
string retStr;
m_reader.parse(json, natspec);
bytes transactionFunctionPart(_transactionData.begin(), _transactionData.begin() + 4);
FixedHash<4> transactionFunctionHash(transactionFunctionPart);
Json::Value methods = natspec["methods"];
for (Json::ValueIterator it = methods.begin(); it != methods.end(); ++it)
{
Json::Value keyValue = it.key();
if (!keyValue.isString())
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Illegal Natspec JSON detected"));
string functionSig = keyValue.asString();
FixedHash<4> functionHash(dev::sha3(functionSig));
if (functionHash == transactionFunctionHash)
{
Json::Value val = (*it)["notice"];
if (!val.isString())
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Illegal Natspec JSON detected"));
return val.asString();
}
}
// not found
return string();
}
string NatspecHandler::getUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData)
{
return getUserNotice(retrieve(_contractHash), _transactionData);
}

58
alethzero/NatspecHandler.h

@ -0,0 +1,58 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file NatspecHandler.h
* @author Lefteris Karapetsas <lefteris@ethdev.com>
* @date 2015
*/
#pragma once
#pragma warning(push)
#pragma warning(disable: 4100 4267)
#include <leveldb/db.h>
#pragma warning(pop)
#include <jsoncpp/json/json.h>
#include <libdevcore/FixedHash.h>
namespace ldb = leveldb;
class NatspecHandler
{
public:
NatspecHandler();
~NatspecHandler();
/// Stores locally in a levelDB a key value pair of contract code hash to natspec documentation
void add(dev::h256 const& _contractHash, std::string const& _doc);
/// Retrieves the natspec documentation as a string given a contract code hash
std::string retrieve(dev::h256 const& _contractHash) const;
/// Given a json natspec string and the transaction data return the user notice
std::string getUserNotice(std::string const& json, const dev::bytes& _transactionData);
/// Given a contract code hash and the transaction's data retrieve the natspec documention's
/// user notice for that transaction.
/// @returns The user notice or an empty string if no natspec for the contract exists
/// or if the existing natspec does not document the @c _methodName
std::string getUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionDacta);
private:
ldb::ReadOptions m_readOptions;
ldb::WriteOptions m_writeOptions;
ldb::DB* m_db;
Json::Reader m_reader;
};

40
alethzero/OurWebThreeStubServer.cpp

@ -20,12 +20,19 @@
*/
#include "OurWebThreeStubServer.h"
#include <QMessageBox>
#include <QAbstractButton>
#include <libwebthree/WebThree.h>
#include "MainWin.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
OurWebThreeStubServer::OurWebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, dev::WebThreeDirect& _web3, std::vector<dev::KeyPair> const& _accounts):
WebThreeStubServer(_conn, _web3, _accounts)
OurWebThreeStubServer::OurWebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, dev::WebThreeDirect& _web3,
std::vector<dev::KeyPair> const& _accounts, Main* main):
WebThreeStubServer(_conn, _web3, _accounts), m_web3(&_web3), m_main(main)
{}
std::string OurWebThreeStubServer::shh_newIdentity()
@ -34,3 +41,32 @@ std::string OurWebThreeStubServer::shh_newIdentity()
emit onNewId(QString::fromStdString(toJS(kp.sec())));
return toJS(kp.pub());
}
bool OurWebThreeStubServer::showAuthenticationPopup(std::string const& _title, std::string const& _text) const
{
QMessageBox userInput;
userInput.setText(QString::fromStdString(_title));
userInput.setInformativeText(QString::fromStdString(_text + "\n Do you wish to allow this?"));
userInput.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
userInput.button(QMessageBox::Ok)->setText("Allow");
userInput.button(QMessageBox::Cancel)->setText("Reject");
userInput.setDefaultButton(QMessageBox::Cancel);
return userInput.exec() == QMessageBox::Ok;
}
bool OurWebThreeStubServer::authenticate(dev::TransactionSkeleton const& _t) const
{
h256 contractCodeHash = m_web3->ethereum()->postState().codeHash(_t.to);
if (contractCodeHash == EmptySHA3)
// recipient has no code - nothing special about this transaction.
// TODO: show basic message for value transfer.
return true;
std::string userNotice = m_main->lookupNatSpecUserNotice(contractCodeHash, _t.data);
if (userNotice.empty())
return showAuthenticationPopup("Unverified Pending Transaction",
"An undocumented transaction is about to be executed.");
// otherwise it's a transaction to a contract for which we have the natspec
return showAuthenticationPopup("Pending Transaction", userNotice);
}

12
alethzero/OurWebThreeStubServer.h

@ -24,15 +24,25 @@
#include <libdevcrypto/Common.h>
#include <libweb3jsonrpc/WebThreeStubServer.h>
class Main;
class OurWebThreeStubServer: public QObject, public WebThreeStubServer
{
Q_OBJECT
public:
OurWebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, dev::WebThreeDirect& _web3, std::vector<dev::KeyPair> const& _accounts);
OurWebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, dev::WebThreeDirect& _web3,
std::vector<dev::KeyPair> const& _accounts, Main* main);
virtual std::string shh_newIdentity() override;
virtual bool authenticate(dev::TransactionSkeleton const& _t) const;
signals:
void onNewId(QString _s);
private:
bool showAuthenticationPopup(std::string const& _title, std::string const& _text) const;
dev::WebThreeDirect* m_web3;
Main* m_main;
};

13
cmake/EthCompilerSettings.cmake

@ -28,8 +28,17 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# specify Exception Handling Model in msvc
set(CMAKE_C_FLAGS "/EHsc")
set(CMAKE_CXX_FLAGS "/EHsc")
# disable unknown pragma warning (4068)
# disable unsafe function warning (4996)
# disable decorated name length exceeded, name was truncated (4503)
# disable warning C4535: calling _set_se_translator() requires /EHa (for boost tests)
# declare Windows XP requirement
add_compile_options(/EHsc /wd4068 /wd4996 /wd4503 -D_WIN32_WINNT=0x0501)
# disable empty object file warning
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
# warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
# warning LNK4099: pdb was not found with lib
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099,4075")
# windows likes static
set(ETH_STATIC 1)

9
cmake/EthDependencies.cmake

@ -113,6 +113,15 @@ if (NOT HEADLESS)
message(" - macdeployqt path: ${MACDEPLOYQT_APP}")
endif()
# TODO check node && npm version
find_program(ETH_NODE node)
string(REGEX REPLACE "node" "" ETH_NODE_DIRECTORY ${ETH_NODE})
message(" - nodejs location : ${ETH_NODE}")
find_program(ETH_NPM npm)
string(REGEX REPLACE "npm" "" ETH_NPM_DIRECTORY ${ETH_NPM})
message(" - npm location : ${ETH_NPM}")
endif() #HEADLESS
# use multithreaded boost libraries, with -mt suffix

43
eth/main.cpp

@ -30,6 +30,7 @@
#include <libdevcrypto/FileSystem.h>
#include <libevmcore/Instruction.h>
#include <libevm/VM.h>
#include <libevm/VMFactory.h>
#include <libethereum/All.h>
#include <libwebthree/WebThree.h>
#if ETH_READLINE
@ -121,7 +122,11 @@ void help()
<< " -u,--public-ip <ip> Force public ip to given (default; auto)." << endl
<< " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl
<< " -x,--peers <number> Attempt to connect to given number of peers (Default: 5)." << endl
<< " -V,--version Show the version and exit." << endl;
<< " -V,--version Show the version and exit." << endl
#if ETH_EVMJIT
<< " --jit Use EVM JIT (default: off)." << endl
#endif
;
exit(0);
}
@ -145,6 +150,8 @@ string credits(bool _interactive = false)
void version()
{
cout << "eth version " << dev::Version << endl;
cout << "Network protocol version: " << dev::eth::c_protocolVersion << endl;
cout << "Client database version: " << dev::eth::c_databaseVersion << endl;
cout << "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
exit(0);
}
@ -173,6 +180,12 @@ void sighandler(int)
g_exit = true;
}
enum class NodeMode
{
PeerServer,
Full
};
int main(int argc, char** argv)
{
unsigned short listenPort = 30303;
@ -191,6 +204,7 @@ int main(int argc, char** argv)
bool upnp = true;
bool useLocal = false;
bool forceMining = false;
bool jit = false;
string clientName;
// Init defaults
@ -256,13 +270,14 @@ int main(int argc, char** argv)
mining = ~(unsigned)0;
else if (isFalse(m))
mining = 0;
else if (int i = stoi(m))
mining = i;
else
{
cerr << "Unknown -m/--mining option: " << m << endl;
return -1;
}
try {
mining = stoi(m);
}
catch (...) {
cerr << "Unknown -m/--mining option: " << m << endl;
return -1;
}
}
else if (arg == "-b" || arg == "--bootstrap")
bootstrap = true;
@ -293,6 +308,15 @@ int main(int argc, char** argv)
return -1;
}
}
else if (arg == "--jit")
{
#if ETH_EVMJIT
jit = true;
#else
cerr << "EVM JIT not enabled" << endl;
return -1;
#endif
}
else if (arg == "-h" || arg == "--help")
help();
else if (arg == "-V" || arg == "--version")
@ -306,9 +330,10 @@ int main(int argc, char** argv)
cout << credits();
VMFactory::setKind(jit ? VMKind::JIT : VMKind::Interpreter);
NetworkPreferences netPrefs(listenPort, publicIP, upnp, useLocal);
dev::WebThreeDirect web3(
"Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM),
"Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM) + (jit ? "/JIT" : ""),
dbPath,
false,
mode == NodeMode::Full ? set<string>{"eth", "shh"} : set<string>(),
@ -672,7 +697,7 @@ int main(int argc, char** argv)
f << ext->myAddress << " " << hex << toHex(dev::toCompactBigEndian(vm->curPC(), 1)) << " " << hex << toHex(dev::toCompactBigEndian((int)(byte)instr, 1)) << " " << hex << toHex(dev::toCompactBigEndian((uint64_t)vm->gas(), 1)) << endl;
};
e.go(oof);
e.finalize(oof);
e.finalize();
}
catch(Exception const& _e)
{

1
evmjit

@ -1 +0,0 @@
Subproject commit 66d5a2b5cdf1361dcf0205b191dd12be090ed224

1
evmjit/.gitignore

@ -0,0 +1 @@
/build/

46
evmjit/CMakeLists.txt

@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 2.8.12)
project(evmjit)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
else()
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -fPIC")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Do not allow unresovled symbols in shared library (default on linux)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
endif()
# LLVM
if(LLVM_DIR OR APPLE) # local LLVM build
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
add_definitions(${LLVM_DEFINITIONS})
# TODO: bitwriter is needed only for evmcc
llvm_map_components_to_libnames(LLVM_LIBS core support mcjit x86asmparser x86codegen bitwriter)
else()
# Workaround for Ubuntu broken LLVM package
message(STATUS "Using llvm-3.5-dev package from Ubuntu. If does not work, build LLVM and set -DLLVM_DIR=llvm-build/share/llvm/cmake")
execute_process(COMMAND llvm-config-3.5 --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS)
message(STATUS "LLVM include dirs: ${LLVM_INCLUDE_DIRS}")
set(LLVM_LIBS "-lLLVMBitWriter -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMX86AsmParser -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMTarget -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMExecutionEngine -lLLVMMC -lLLVMCore -lLLVMSupport -lz -lpthread -lffi -ltinfo -ldl -lm")
add_definitions(-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS)
link_directories(/usr/lib/llvm-3.5/lib)
endif()
# Boost
find_package(Boost REQUIRED)
add_subdirectory(libevmjit)
if(EVMJIT_CPP)
add_subdirectory(libevmjit-cpp)
endif()
if(EVMJIT_TOOLS)
add_subdirectory(evmcc)
endif()

18
evmjit/evmcc/CMakeLists.txt

@ -0,0 +1,18 @@
set(TARGET_NAME evmcc)
set(SOURCES
evmcc.cpp
)
source_group("" FILES ${SOURCES})
add_executable(${TARGET_NAME} ${SOURCES})
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER "tools")
include_directories(../..)
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ethereum)
target_link_libraries(${TARGET_NAME} ${Boost_PROGRAM_OPTIONS_LIBRARIES})
install(TARGETS ${TARGET_NAME} DESTINATION bin )

210
evmjit/evmcc/evmcc.cpp

@ -0,0 +1,210 @@
#include <chrono>
#include <iostream>
#include <fstream>
#include <ostream>
#include <string>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
#include <llvm/Bitcode/ReaderWriter.h>
#include <llvm/Support/raw_os_ostream.h>
#include <llvm/Support/Signals.h>
#include <llvm/Support/PrettyStackTrace.h>
#include <libdevcore/Common.h>
#include <libdevcore/CommonIO.h>
#include <libevmcore/Instruction.h>
#include <libevm/ExtVMFace.h>
#include <evmjit/libevmjit/Compiler.h>
#include <evmjit/libevmjit/ExecutionEngine.h>
void parseProgramOptions(int _argc, char** _argv, boost::program_options::variables_map& _varMap)
{
namespace opt = boost::program_options;
opt::options_description explicitOpts("Allowed options");
explicitOpts.add_options()
("help,h", "show usage information")
("compile,c", "compile the code to LLVM IR")
("interpret,i", "compile the code to LLVM IR and execute")
("gas,g", opt::value<size_t>(), "set initial gas for execution")
("disassemble,d", "dissassemble the code")
("dump-cfg", "dump control flow graph to graphviz file")
("dont-optimize", "turn off optimizations")
("optimize-stack", "optimize stack use between basic blocks (default: on)")
("rewrite-switch", "rewrite LLVM switch to branches (default: on)")
("output-ll", opt::value<std::string>(), "dump generated LLVM IR to file")
("output-bc", opt::value<std::string>(), "dump generated LLVM bitcode to file")
("show-logs", "output LOG statements to stderr")
("verbose,V", "enable verbose output");
opt::options_description implicitOpts("Input files");
implicitOpts.add_options()
("input-file", opt::value<std::string>(), "input file");
opt::options_description allOpts("");
allOpts.add(explicitOpts).add(implicitOpts);
opt::positional_options_description inputOpts;
inputOpts.add("input-file", 1);
const char* errorMsg = nullptr;
try
{
auto parser = opt::command_line_parser(_argc, _argv).options(allOpts).positional(inputOpts);
opt::store(parser.run(), _varMap);
opt::notify(_varMap);
}
catch (boost::program_options::error& err)
{
errorMsg = err.what();
}
if (!errorMsg && _varMap.count("input-file") == 0)
errorMsg = "missing input file name";
if (_varMap.count("disassemble") == 0
&& _varMap.count("compile") == 0
&& _varMap.count("interpret") == 0)
{
errorMsg = "at least one of -c, -i, -d is required";
}
if (errorMsg || _varMap.count("help"))
{
if (errorMsg)
std::cerr << "Error: " << errorMsg << std::endl;
std::cout << "Usage: " << _argv[0] << " <options> input-file " << std::endl
<< explicitOpts << std::endl;
std::exit(errorMsg ? 1 : 0);
}
}
int main(int argc, char** argv)
{
llvm::sys::PrintStackTraceOnErrorSignal();
llvm::PrettyStackTraceProgram X(argc, argv);
boost::program_options::variables_map options;
parseProgramOptions(argc, argv, options);
auto inputFile = options["input-file"].as<std::string>();
std::ifstream ifs(inputFile);
if (!ifs.is_open())
{
std::cerr << "cannot open input file " << inputFile << std::endl;
exit(1);
}
std::string src((std::istreambuf_iterator<char>(ifs)),
(std::istreambuf_iterator<char>()));
boost::algorithm::trim(src);
using namespace dev;
bytes bytecode = fromHex(src);
if (options.count("disassemble"))
{
std::string assembly = eth::disassemble(bytecode);
std::cout << assembly << std::endl;
}
if (options.count("compile") || options.count("interpret"))
{
size_t initialGas = 10000;
if (options.count("gas"))
initialGas = options["gas"].as<size_t>();
auto compilationStartTime = std::chrono::high_resolution_clock::now();
eth::jit::Compiler::Options compilerOptions;
compilerOptions.dumpCFG = options.count("dump-cfg") > 0;
bool optimize = options.count("dont-optimize") == 0;
compilerOptions.optimizeStack = optimize || options.count("optimize-stack") > 0;
compilerOptions.rewriteSwitchToBranches = optimize || options.count("rewrite-switch") > 0;
auto compiler = eth::jit::Compiler(compilerOptions);
auto module = compiler.compile(bytecode, "main");
auto compilationEndTime = std::chrono::high_resolution_clock::now();
module->dump();
if (options.count("output-ll"))
{
auto outputFile = options["output-ll"].as<std::string>();
std::ofstream ofs(outputFile);
if (!ofs.is_open())
{
std::cerr << "cannot open output file " << outputFile << std::endl;
exit(1);
}
llvm::raw_os_ostream ros(ofs);
module->print(ros, nullptr);
ofs.close();
}
if (options.count("output-bc"))
{
auto outputFile = options["output-bc"].as<std::string>();
std::ofstream ofs(outputFile);
if (!ofs.is_open())
{
std::cerr << "cannot open output file " << outputFile << std::endl;
exit(1);
}
llvm::raw_os_ostream ros(ofs);
llvm::WriteBitcodeToFile(module.get(), ros);
ros.flush();
ofs.close();
}
if (options.count("verbose"))
{
std::cerr << "*** Compilation time: "
<< std::chrono::duration_cast<std::chrono::microseconds>(compilationEndTime - compilationStartTime).count()
<< std::endl;
}
if (options.count("interpret"))
{
using namespace eth::jit;
ExecutionEngine engine;
eth::jit::u256 gas = initialGas;
// Create random runtime data
RuntimeData data;
data.set(RuntimeData::Gas, gas);
data.set(RuntimeData::Address, (u160)Address(1122334455667788));
data.set(RuntimeData::Caller, (u160)Address(0xfacefacefaceface));
data.set(RuntimeData::Origin, (u160)Address(101010101010101010));
data.set(RuntimeData::CallValue, 0xabcd);
data.set(RuntimeData::CallDataSize, 3);
data.set(RuntimeData::GasPrice, 1003);
data.set(RuntimeData::CoinBase, (u160)Address(101010101010101015));
data.set(RuntimeData::TimeStamp, 1005);
data.set(RuntimeData::Number, 1006);
data.set(RuntimeData::Difficulty, 16);
data.set(RuntimeData::GasLimit, 1008);
data.set(RuntimeData::CodeSize, bytecode.size());
data.callData = (uint8_t*)"abc";
data.code = bytecode.data();
// BROKEN: env_* functions must be implemented & RuntimeData struct created
// TODO: Do not compile module again
auto result = engine.run(bytecode, &data, nullptr);
return static_cast<int>(result);
}
}
return 0;
}

1
evmjit/evmcc/test/arith/addmod.evm

@ -0,0 +1 @@
60646107b760271460005560006001f2

12
evmjit/evmcc/test/arith/addmod.lll

@ -0,0 +1,12 @@
;; Should return (1975 + 39) `mod` 100 = 14 = 0x0e
(asm
100
1975
39
ADDMOD
0
MSTORE8
0
1
RETURN
)

1
evmjit/evmcc/test/arith/arith1.evm

@ -0,0 +1 @@
60016001900160070260050160029004600490066021900560150160030260059007600303600960110860005460086000f2

37
evmjit/evmcc/test/arith/arith1.lll

@ -0,0 +1,37 @@
(asm
1
1
SWAP1
ADD ;; 2
7
MUL ;; 14
5
ADD ;; 19
2
SWAP1
DIV ;; 9
4
SWAP1
MOD ;; 1
33
SWAP1
SDIV;; 0
21
ADD ;; 21
3
MUL ;; 63
5
SWAP1
SMOD;; 3
3
SUB ;; 0
9
17
EXP ;; 17^9
0
MSTORE
8
0
RETURN
)

1
evmjit/evmcc/test/arith/arith_bnot.evm

@ -0,0 +1 @@
6201e2406000546000530960005460206000f2

14
evmjit/evmcc/test/arith/arith_bnot.lll

@ -0,0 +1,14 @@
(asm
123456
0
MSTORE
0
MLOAD
BNOT
0
MSTORE
32
0
RETURN
)

1
evmjit/evmcc/test/arith/div.evm

@ -0,0 +1 @@
60027ffedcba9876543210fedcba9876543210fedcba9876543210fedcba98765432100460005460206000f2

10
evmjit/evmcc/test/arith/div.lll

@ -0,0 +1,10 @@
(asm
0x2
0xfedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210
DIV
0
MSTORE
32
0
RETURN
)

1
evmjit/evmcc/test/arith/fib1.evm

@ -0,0 +1 @@
60016001818101818101818101818101818101818101818101818101818101818101818101818101818101818101818101818101818101

57
evmjit/evmcc/test/arith/fib1.lll

@ -0,0 +1,57 @@
;; Fibbonacci unrolled
(asm
1
1
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
DUP2
DUP2
ADD
)

1
evmjit/evmcc/test/arith/mul.evm

@ -0,0 +1 @@
7001234567890abcdef0fedcba09876543217001234567890abcdef0fedcba09876543217001234567890abcdef0fedcba0987654321020260005460206000f2

13
evmjit/evmcc/test/arith/mul.lll

@ -0,0 +1,13 @@
(asm
0x1234567890abcdef0fedcba0987654321
0x1234567890abcdef0fedcba0987654321
0x1234567890abcdef0fedcba0987654321
MUL
MUL
0
MSTORE
32
0
RETURN
;; 47d0817e4167b1eb4f9fc722b133ef9d7d9a6fb4c2c1c442d000107a5e419561
)

1
evmjit/evmcc/test/arith/mulmod.evm

@ -0,0 +1 @@
6064601b60251560005560006001f2

12
evmjit/evmcc/test/arith/mulmod.lll

@ -0,0 +1,12 @@
;; Should return (27 * 37) `mod` 100 = 99 = 0x63
(asm
100
27
37
MULMOD
0
MSTORE8
0
1
RETURN
)

1
evmjit/evmcc/test/except/badinst1.evm

@ -0,0 +1 @@
4a

1
evmjit/evmcc/test/ext/calldatacopy1.evm

@ -0,0 +1 @@
60326000600a37600053600a6014f2

13
evmjit/evmcc/test/ext/calldatacopy1.lll

@ -0,0 +1,13 @@
(asm
50 ;; byte count
0 ;; source index in calldata array
10 ;; dest index in memory
CALLDATACOPY
0
MLOAD ;; to dump memory
10
20
RETURN
)

1
evmjit/evmcc/test/ext/calldatacopy2.evm

@ -0,0 +1 @@
606464e8d4a510006000376000536000600af2

13
evmjit/evmcc/test/ext/calldatacopy2.lll

@ -0,0 +1,13 @@
(asm
100 ;; byte count
1000000000000 ;; source index in calldata array
0 ;; dest index in memory
CALLDATACOPY
0
MLOAD ;; to dump memory
0
10
RETURN
)

1
evmjit/evmcc/test/ext/codecopy1.evm

@ -0,0 +1 @@
60146000600a39600053600a6014f2

13
evmjit/evmcc/test/ext/codecopy1.lll

@ -0,0 +1,13 @@
(asm
20 ;; byte count
0 ;; source index in code array
10 ;; dest index in memory
CODECOPY
0
MLOAD ;; to dump memory
10
20
RETURN
)

1
evmjit/evmcc/test/ext/codecopy2.evm

@ -0,0 +1 @@
606464e8d4a510006000396000536000600af2

13
evmjit/evmcc/test/ext/codecopy2.lll

@ -0,0 +1,13 @@
(asm
100 ;; byte count
1000000000000 ;; source index in code array
0 ;; dest index in memory
CODECOPY
0
MLOAD ;; to dump memory
0
10
RETURN
)

1
evmjit/evmcc/test/ext/codecopy3.evm

@ -0,0 +1 @@
3860006000396000536000600af2

13
evmjit/evmcc/test/ext/codecopy3.lll

@ -0,0 +1,13 @@
(asm
CODESIZE ;; byte count
0 ;; source index in code array
0 ;; dest index in memory
CODECOPY
0
MLOAD ;; to dump memory
0
10
RETURN
)

1
evmjit/evmcc/test/ext/ext_test.evm

@ -0,0 +1 @@
5a3031333234363a4041424344455a36600035602635601335387f1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff600054602060006000f06020600060206000600030610bb8f1600053611000545b60200260002030ff60016002f2

55
evmjit/evmcc/test/ext/ext_test.lll

@ -0,0 +1,55 @@
(asm
PC
ADDRESS
BALANCE
CALLER
ORIGIN
CALLVALUE
CALLDATASIZE
GASPRICE
PREVHASH
COINBASE
TIMESTAMP
NUMBER
DIFFICULTY
GASLIMIT
PC
CALLDATASIZE
0
CALLDATALOAD
38
CALLDATALOAD
19
CALLDATALOAD
CODESIZE
0x1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff
0
MSTORE
32
0
0
CREATE
32
0
32
0
0
ADDRESS
3000
CALL
0
MLOAD
4096
MSTORE
MSIZE
32
MUL
0
SHA3
ADDRESS
SUICIDE
1
2
RETURN
)

1
evmjit/evmcc/test/ext/extcodecopy1.evm

@ -0,0 +1 @@
60c86000600a303c60005360006020f2

11
evmjit/evmcc/test/ext/extcodecopy1.lll

@ -0,0 +1,11 @@
(asm
200 ;; byte count
0 ;; source index in code array
10 ;; dest index in memory
ADDRESS
EXTCODECOPY
0 MLOAD ;; to dump memory
0 32 RETURN
)

1
evmjit/evmcc/test/ext/store_delete.evm

@ -0,0 +1 @@
6104d26063576000606357

9
evmjit/evmcc/test/ext/store_delete.lll

@ -0,0 +1,9 @@
(asm
1234
99
SSTORE
0
99
SSTORE
)

1
evmjit/evmcc/test/ext/store_test.evm

@ -0,0 +1 @@
607b607c60015760005760015660005603

14
evmjit/evmcc/test/ext/store_test.lll

@ -0,0 +1,14 @@
(asm
123
124
1
SSTORE
0
SSTORE
1
SLOAD
0
SLOAD
SUB
)

7
evmjit/evmcc/test/jump/ackermann.ethel

@ -0,0 +1,7 @@
let A m n =
if m == 0 then n+1
else if n == 0 then A (m-1) 1
else A (m-1) (A (m) (n-1))
return A 3 8

1
evmjit/evmcc/test/jump/ackermann.evm

@ -0,0 +1 @@
6009600360086012585d60005460206000f26000820e6047596000810e603859603460018303603084600185036012585d6012585d60445860436001830360016012585d604b5860018101905090509058

1
evmjit/evmcc/test/jump/badindirect1.evm

@ -0,0 +1 @@
601b602502585d

9
evmjit/evmcc/test/jump/badindirect1.lll

@ -0,0 +1,9 @@
;; Indirect jump out of code
(asm
27
37
MUL
JUMP
JUMPDEST
)

1
evmjit/evmcc/test/jump/badindirect2.evm

@ -0,0 +1 @@
60016003600302596000600058

12
evmjit/evmcc/test/jump/badindirect2.lll

@ -0,0 +1,12 @@
;; Indirect jump into data
(asm
1 ;; 0
3
3
MUL ;; 6
JUMPI ;; 7
0 ;; 8
0
JUMP
)

1
evmjit/evmcc/test/jump/badjump1.evm

@ -0,0 +1 @@
6103e758

6
evmjit/evmcc/test/jump/badjump1.lll

@ -0,0 +1,6 @@
;; Direct jump out of code.
(asm
999
JUMP
)

1
evmjit/evmcc/test/jump/badjump2.evm

@ -0,0 +1 @@
6004586000600058

9
evmjit/evmcc/test/jump/badjump2.lll

@ -0,0 +1,9 @@
;; Direct jump into data
(asm
4 ;; 0 0-3
JUMP ;; 2
0 ;; 3 3-4
0 ;; 5 4-7
JUMP ;; 6
)

5
evmjit/evmcc/test/jump/call1.ethel

@ -0,0 +1,5 @@
let f n = n + 1
return f 2

1
evmjit/evmcc/test/jump/call1.evm

@ -0,0 +1 @@
600760026010585d60005460206000f28060010190509058

5
evmjit/evmcc/test/jump/call2.ethel

@ -0,0 +1,5 @@
let f a b = a + b
return f 2 3

1
evmjit/evmcc/test/jump/call2.evm

@ -0,0 +1 @@
6009600260036012585d60005460206000f2818101905090509058

5
evmjit/evmcc/test/jump/fac.ethel

@ -0,0 +1,5 @@
let fac n =
if n == 0 then 1
else n * fac (n-1)
return fac 60

1
evmjit/evmcc/test/jump/fac.evm

@ -0,0 +1 @@
6007603c6010585d60005460206000f26000810e6026596020600182036010585d8102602858600190509058

5
evmjit/evmcc/test/jump/fac_tail.ethel

@ -0,0 +1,5 @@
let fac a n =
if n == 0 then a
else fac (a*n) (n-1)
return fac 1 60

1
evmjit/evmcc/test/jump/fac_tail.evm

@ -0,0 +1 @@
60096001603c6012585d60005460206000f26000810e6029596025818302600183036012585d602a5881905090509058

6
evmjit/evmcc/test/jump/fib1.ethel

@ -0,0 +1,6 @@
let fib n =
if n < 3 then 1
else fib (n-1) + fib (n-2)
return fib 10

1
evmjit/evmcc/test/jump/fib1.evm

@ -0,0 +1 @@
6007600a6010585d60005460206000f26003810a602f596020600282036010585d602a600183036010585d01603158600190509058

1
evmjit/evmcc/test/jump/for1.evm

@ -0,0 +1 @@
600a60805460006080530b0f60255960a0536080530160a054600160805303608054600558

3
evmjit/evmcc/test/jump/for1.lll

@ -0,0 +1,3 @@
(for [i]:10 (> @i 0) [i](- @i 1)
[j](+ @i @j)
)

1
evmjit/evmcc/test/jump/for2.evm

@ -0,0 +1 @@
6000608054600a6080530a0f60255960a0536080530160a054600160805301608054600558

3
evmjit/evmcc/test/jump/for2.lll

@ -0,0 +1,3 @@
(for [i]:0 (< @i 10) [i](+ @i 1)
[j](+ @i @j)
)

1
evmjit/evmcc/test/jump/if1.ethel

@ -0,0 +1 @@
return if 0 then 1 else 2

1
evmjit/evmcc/test/jump/if1.evm

@ -0,0 +1 @@
60006300000010596002630000001258600160005460206000f2

1
evmjit/evmcc/test/jump/if2.ethel

@ -0,0 +1 @@
return if 1 then 1 else 2

1
evmjit/evmcc/test/jump/if2.evm

@ -0,0 +1 @@
60016300000010596002630000001258600160005460206000f2

1
evmjit/evmcc/test/jump/indirect1.evm

@ -0,0 +1 @@
600460030158005d6001600054

13
evmjit/evmcc/test/jump/indirect1.lll

@ -0,0 +1,13 @@
;; Indirect JUMP
(asm
4 ;; 0
3 ;; 2
ADD ;; 4
JUMP ;; 5
STOP ;; 6
JUMPDEST ;; 7
1
0
MSTORE
)

1
evmjit/evmcc/test/jump/indirect2.evm

@ -0,0 +1 @@
600860060158005d6001600054005d600260005400

19
evmjit/evmcc/test/jump/indirect2.lll

@ -0,0 +1,19 @@
;; Indirect JUMP
(asm
8 ;; 0
6 ;; 2
ADD ;; 4
JUMP ;; 5 --> 14
STOP ;; 6
JUMPDEST ;; 7
1 ;; 8
0 ;; 10
MSTORE ;; 12
STOP ;; 13
JUMPDEST ;; 14
2
0
MSTORE
STOP
)

1
evmjit/evmcc/test/jump/indirect3.evm

@ -0,0 +1 @@
6001600460050159005d6001600054

14
evmjit/evmcc/test/jump/indirect3.lll

@ -0,0 +1,14 @@
;; Indirect JUMP
(asm
1 ;; 0
4 ;; 2
5 ;; 4
ADD ;; 6
JUMPI ;; 7
STOP ;; 8
JUMPDEST ;; 9
1
0
MSTORE
)

1
evmjit/evmcc/test/jump/indirect4.evm

@ -0,0 +1 @@
60006007600501596001600054005d00

15
evmjit/evmcc/test/jump/indirect4.lll

@ -0,0 +1,15 @@
;; Indirect JUMP
(asm
0 ;; 0
7 ;; 2
5 ;; 4
ADD ;; 6
JUMPI ;; 7
1 ;; 8
0 ;; 9
MSTORE ;; 10
STOP ;; 11
JUMPDEST ;; 12
STOP
)

1
evmjit/evmcc/test/jump/jump1.evm

@ -0,0 +1 @@
600458006001600154

11
evmjit/evmcc/test/jump/jump1.lll

@ -0,0 +1,11 @@
;; Direct JUMP.
;; output: memory[1] == 1
(asm
4 ;; 0
JUMP ;; 2
STOP ;; 3
1 ;; 4
1 ;; 6
MSTORE ;; 8
)

1
evmjit/evmcc/test/jump/jump2.evm

@ -0,0 +1 @@
6008586001600154

10
evmjit/evmcc/test/jump/jump2.lll

@ -0,0 +1,10 @@
;; Direct JUMP to the end of code.
;; output: memory should have size 0.
(asm
8 ;; 0
JUMP ;; 2
1 ;; 3
1 ;; 5
MSTORE ;; 7
)

1
evmjit/evmcc/test/jump/jump3.evm

@ -0,0 +1 @@
602a586001600154

10
evmjit/evmcc/test/jump/jump3.lll

@ -0,0 +1,10 @@
;; Direct JUMP past the end of code.
;; output: memory should have size 0.
(asm
42
JUMP
1
1
MSTORE
)

1
evmjit/evmcc/test/jump/jump4.evm

@ -0,0 +1 @@
600b6009580000600558005d6001600154

17
evmjit/evmcc/test/jump/jump4.lll

@ -0,0 +1,17 @@
;; Direct JUMP.
;; output: memory[1] = 1
(asm
11 ;; 0
9 ;; 2
JUMP ;; 4 --> 9
STOP ;; 5
STOP ;; 6
5 ;; 7
JUMP ;; 9 --> 11
STOP ;; 10
JUMPDEST
1 ;; 11
1
MSTORE
)

1
evmjit/evmcc/test/jump/jump5.evm

@ -0,0 +1 @@
6005600e585d600160015400600f5800

16
evmjit/evmcc/test/jump/jump5.lll

@ -0,0 +1,16 @@
;; Direct JUMP.
;; output: memory[1] = 1
(asm
5 ;; 0
14 ;; 2
JUMP ;; 4 --> 14
JUMPDEST ;; 5
1 ;; 6
1 ;; 8
MSTORE ;; 10
STOP ;; 11
15 ;; 12
JUMP ;; 14 --> 5
STOP ;; 15
)

1
evmjit/evmcc/test/jump/jump6.evm

@ -0,0 +1 @@
600358600f600d58006014600758005d6001600154005d600260025400

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save