Browse Source

State fix.

cl-refactor
Gav Wood 11 years ago
parent
commit
1769356fdf
  1. 3
      alethzero/MainWin.cpp
  2. 2
      libethereum/Executive.cpp
  3. 15
      libethereum/State.cpp
  4. 4
      libethereum/VM.h

3
alethzero/MainWin.cpp

@ -975,12 +975,9 @@ void Main::initDebugger()
dc->clear();
if (m_currentExecution)
{
for (unsigned i = 0; i < m_currentExecution->ext().code.size(); ++i)
cnote << i << std::hex << (int)m_currentExecution->ext().code[i];
for (unsigned i = 0; i <= m_currentExecution->ext().code.size(); ++i)
{
byte b = i < m_currentExecution->ext().code.size() ? m_currentExecution->ext().code[i] : 0;
cnote << i << std::hex << (int)b;
QString s = c_instructionInfo.at((Instruction)b).name;
m_pcWarp[i] = dc->count();
ostringstream out;

2
libethereum/Executive.cpp

@ -117,7 +117,7 @@ void Executive::create(Address _sender, u256 _endowment, u256 _gasPrice, u256 _g
// Execute _init.
m_vm = new VM(_gas);
m_ext = new ExtVM(m_s, m_newAddress, _sender, _origin, _endowment, _gasPrice, _init, _init);
m_ext = new ExtVM(m_s, m_newAddress, _sender, _origin, _endowment, _gasPrice, bytesConstRef(), _init);
}
bool Executive::go(uint64_t _steps)

15
libethereum/State.cpp

@ -358,9 +358,17 @@ u256 State::playbackRaw(bytesConstRef _block, BlockInfo const& _grandParent, boo
unsigned i = 0;
for (auto const& tr: RLP(_block)[1])
{
// cnote << m_state.root() << m_state;
// cnote << *this;
execute(tr[0].data());
if (tr[1].toInt<u256>() != m_state.root())
{
// Invalid state root
cnote << m_state.root() << m_state;
cnote << *this;
cnote << "INVALID: " << tr[1].toInt<u256>();
throw InvalidTransactionStateRoot();
}
if (tr[2].toInt<u256>() != gasUsed())
throw InvalidTransactionGasUsed();
if (_fullCommit)
@ -657,6 +665,9 @@ bytes const& State::code(Address _contract) const
u256 State::execute(bytesConstRef _rlp)
{
cnote << m_state.root() << m_state;
cnote << *this;
Executive e(*this);
e.setup(_rlp);
@ -669,6 +680,10 @@ u256 State::execute(bytesConstRef _rlp)
commit();
cnote << "Done TX";
cnote << m_state.root() << m_state;
cnote << *this;
// Add to the user-originated transactions that we've executed.
m_transactions.push_back(TransactionReceipt(e.t(), m_state.root(), startGasUSed + e.gasUsed()));
m_transactionSet.insert(e.t().sha3());

4
libethereum/VM.h

@ -332,7 +332,7 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, uint64_t _steps)
m_stack.pop_back();
unsigned l = (unsigned)m_stack.back();
m_stack.pop_back();
unsigned el = cf + l > _ext.data.size() ? _ext.data.size() - cf : l;
unsigned el = cf + l > _ext.data.size() ? _ext.data.size() < cf ? 0 : _ext.data.size() - cf : l;
memcpy(m_temp.data() + mf, _ext.data.data() + cf, el);
memset(m_temp.data() + mf + el, 0, l - el);
break;
@ -349,7 +349,7 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, uint64_t _steps)
m_stack.pop_back();
unsigned l = (unsigned)m_stack.back();
m_stack.pop_back();
unsigned el = cf + l > _ext.code.size() ? _ext.code.size() - cf : l;
unsigned el = cf + l > _ext.code.size() ? _ext.code.size() < cf ? 0 : _ext.code.size() - cf : l;
memcpy(m_temp.data() + mf, _ext.code.data() + cf, el);
memset(m_temp.data() + mf + el, 0, l - el);
break;

Loading…
Cancel
Save