diff --git a/alethzero/Main.ui b/alethzero/Main.ui index c786a29f5..e948a9ca2 100644 --- a/alethzero/Main.ui +++ b/alethzero/Main.ui @@ -6,8 +6,8 @@ 0 0 - 1504 - 798 + 1711 + 1138 @@ -91,7 +91,7 @@ 0 0 - 1504 + 1711 20 @@ -123,9 +123,18 @@ + + + &Debug + + + + + + @@ -395,7 +404,7 @@ - 442 + 510 360 @@ -429,29 +438,26 @@ - - - - &Amount - - - value + + + + Qt::Vertical + + + + Qt::NoFocus + + - - - - - - - - - - 430000000 + + + + &Gas - - 0 + + gas @@ -471,32 +477,6 @@ - - - - Qt::Vertical - - - - - Qt::NoFocus - - - - - - - - @ - - - 1 - - - 430000000 - - - @@ -513,21 +493,11 @@ - - - - - - - &Gas - - - gas - - + + - - + + 0 @@ -537,28 +507,34 @@ - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - &Send + + + + + + + @ + + + 1 + + + 430000000 - - + + - - 0 + + 1 0 - - + + (Create Contract) @@ -575,16 +551,49 @@ - - + + + + &Execute + + + + + + + + + + 430000000 + + + 0 + + + + + + + &Amount + + + value + + + + + - - 1 + + 0 0 - - (Create Contract) + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -812,6 +821,53 @@ + + + QDockWidget::DockWidgetFeatureMask + + + Debugger + + + 8 + + + + + + + Qt::Horizontal + + + + + + Qt::Vertical + + + + + + + + + + + 0 + 0 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + &Quit @@ -867,6 +923,30 @@ &Preview + + + true + + + &Debug EVM Execution + + + + + &Single Step + + + F10 + + + + + &Continue + + + F5 + + diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index df8ff090f..0c6e0a1d4 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -939,9 +939,17 @@ void Main::on_send_clicked() m_client->unlock(); Secret s = i.secret(); if (isCreation()) - m_client->transact(s, value(), m_data, m_init, ui->gas->value(), gasPrice()); + if (ui->enableDebug->checked()) + { + } + else + m_client->transact(s, value(), m_data, m_init, ui->gas->value(), gasPrice()); else - m_client->transact(s, value(), fromString(ui->destination->text()), m_data, ui->gas->value(), gasPrice()); + if (ui->enableDebug->checked()) + { + } + else + m_client->transact(s, value(), fromString(ui->destination->text()), m_data, ui->gas->value(), gasPrice()); refresh(); return; } @@ -955,6 +963,49 @@ void Main::on_create_triggered() m_keysChanged = true; } +class ExecutionContext +{ +public: + bool go(unsigned _steps = (unsigned)-1); +}; + +bool ExecutionContext::go(unsigned _steps) +{ + +} + +void Main::on_enableDebug_triggered() +{ + ui->debugPanel->setEnabled(ui->enableDebug->checked()); + ui->debugStep->setEnabled(ui->enableDebug->checked()); + ui->debugContinue->setEnabled(ui->enableDebug->checked()); + ui->send->setText(ui->enableDebug->checked() ? "D&ebug" : "&Execute"); +} + +void Main::on_step_triggered() +{ + if (!m_currentExecution) + return; + if (m_currentExecution->go(1)) + finished(); + else + updateExecution(); +} + +void Main::on_continue_triggered() +{ + if (!m_currentExecution) + return; + if (m_currentExecution->go()) + finished(); + else + updateExecution(); +} + +void Main::updateExecution() +{ +} + // extra bits needed to link on VS #ifdef _MSC_VER diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index b40427b66..f9348ade2 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -191,6 +191,8 @@ private: Q_PROPERTY(QEthereum* ethereum READ ethereum WRITE setEthereum NOTIFY ethChanged) }; +class ExecutionContext; + class QEthereum: public QObject { Q_OBJECT @@ -287,6 +289,9 @@ private slots: void on_preview_triggered() { refresh(true); } void on_quit_triggered() { close(); } void on_urlEdit_editingFinished(); + void on_debugStep_triggered(); + void on_debugContinue_triggered(); + void on_enableDebug_triggered(); void refresh(bool _override = false); void refreshNetwork(); @@ -297,6 +302,7 @@ signals: private: QString pretty(eth::Address _a) const; + void updateExecution(); QString render(eth::Address _a) const; eth::Address fromString(QString const& _a) const; @@ -329,6 +335,8 @@ private: unsigned m_backupGas; + std::shared_ptr m_currentExecution; + QNetworkAccessManager m_webCtrl; QEthereum* m_ethereum; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 23ad0cbd1..279ad99f9 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -601,6 +601,10 @@ bytes const& State::contractCode(Address _contract) const return m_cache[_contract].code(); } +void State::prepExecution(bytesConstRef _rlp) +{ +} + void State::execute(bytesConstRef _rlp) { // Entry point for a user-executed transaction. @@ -616,7 +620,7 @@ void State::execute(bytesConstRef _rlp) throw InvalidNonce(nonceReq, t.nonce); } - // Don't like transactions whose gas price is too low. NOTE: this won't stay here forever - it's just until we get a proper gas proce discovery protocol going. + // Don't like transactions whose gas price is too low. NOTE: this won't stay here forever - it's just until we get a proper gas price discovery protocol going. if (t.gasPrice < 10 * szabo) { clog(StateChat) << "Offered gas-price is too low."; diff --git a/libethereum/State.h b/libethereum/State.h index 6a5485df2..921b1b196 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -52,6 +52,15 @@ struct StateChat: public LogChannel { static const char* name() { return "=S="; class ExtVM; +class ExecutionState +{ +public: + ExecutionState(State& _s): m_s(_s) {} + +private: + State& m_s; +}; + /** * @brief Model of the current state of the ledger. * Maintains current ledger (m_current) as a fast hash-map. This is hashed only when required (i.e. to create or verify a block). @@ -125,6 +134,8 @@ public: void execute(bytes const& _rlp) { return execute(&_rlp); } void execute(bytesConstRef _rlp); + void prepExecution(bytesConstRef _rlp); + /// Check if the address is a valid normal (non-contract) account address. bool isNormalAddress(Address _address) const;