Browse Source

fixed transaction serialization

cl-refactor
arkpar 10 years ago
parent
commit
b63abaff06
  1. 2
      mix/ClientModel.cpp
  2. 14
      mix/ContractCallDataEncoder.cpp
  3. 33
      mix/MixClient.cpp
  4. 2
      mix/qml/Block.qml
  5. 7
      mix/qml/BlockChain.qml

2
mix/ClientModel.cpp

@ -776,7 +776,7 @@ void ClientModel::onNewTransaction()
case TransactionException::None:
break;
case TransactionException::NotEnoughCash:
emit runFailed("Insufficient balance for contract deployment");
emit runFailed("Insufficient balance");
break;
case TransactionException::OutOfGasIntrinsic:
case TransactionException::OutOfGasBase:

14
mix/ContractCallDataEncoder.cpp

@ -343,8 +343,18 @@ QStringList ContractCallDataEncoder::decode(QList<QVariableDeclaration*> const&
if (type.array)
{
QJsonArray array = decodeArray(type, _v, readPosition);
QJsonDocument jsonDoc = QJsonDocument::fromVariant(array.toVariantList());
r.append(jsonDoc.toJson(QJsonDocument::Compact));
if (type.type == SolidityType::String && array.count() <= 1)
{
if (array.count() == 1)
r.append(array[0].toString());
else
r.append(QString());
}
else
{
QJsonDocument jsonDoc = QJsonDocument::fromVariant(array.toVariantList());
r.append(jsonDoc.toJson(QJsonDocument::Compact));
}
}
else
{

33
mix/MixClient.cpp

@ -130,8 +130,27 @@ ExecutionResult MixClient::debugTransaction(Transaction const& _t, State const&
eth::ExecutionResult er;
Executive execution(execState, _envInfo);
execution.setResultRecipient(er);
execution.initialize(_t);
execution.execute();
ExecutionResult d;
d.address = _t.receiveAddress();
d.sender = _t.sender();
d.value = _t.value();
d.inputParameters = _t.data();
d.executonIndex = m_executions.size();
if (!_call)
d.transactionIndex = m_postMine.pending().size();
try
{
execution.initialize(_t);
execution.execute();
}
catch (Exception const& _e)
{
d.excepted = toTransactionException(_e);
d.transactionData.push_back(_t.data());
return d;
}
std::vector<MachineState> machineStates;
std::vector<unsigned> levels;
@ -199,22 +218,14 @@ ExecutionResult MixClient::debugTransaction(Transaction const& _t, State const&
execution.go(onOp);
execution.finalize();
ExecutionResult d;
d.excepted = er.excepted;
d.inputParameters = _t.data();
d.result = er;
d.machineStates = machineStates;
d.executionCode = std::move(codes);
d.transactionData = std::move(data);
d.address = _t.receiveAddress();
d.sender = _t.sender();
d.value = _t.value();
d.gasUsed = er.gasUsed + er.gasRefunded + c_callStipend;
if (_t.isCreation())
d.contractAddress = right160(sha3(rlpList(_t.sender(), _t.nonce())));
if (!_call)
d.transactionIndex = m_postMine.pending().size();
d.executonIndex = m_executions.size();
return d;
}
@ -228,7 +239,7 @@ void MixClient::executeTransaction(Transaction const& _t, Block& _block, bool _c
ExecutionResult d = debugTransaction(t, _block.state(), envInfo, _call);
// execute on a state
if (!_call)
if (!_call && d.excepted == TransactionException::None)
{
u256 useGas = min(d.gasUsed, _block.gasLimitRemaining());
t = _gasAuto ? replaceGas(_t, useGas, _secret) : _t;

2
mix/qml/Block.qml

@ -12,6 +12,7 @@ ColumnLayout
{
id: root
property variant transactions
property variant transactionModel
property string status
property int number
property int blockWidth: Layout.preferredWidth - statusWidth - horizontalMargin
@ -202,6 +203,7 @@ ColumnLayout
if (index >= 0)
transactions.get(index).saveStatus = saveStatus
transactionModel[index].saveStatus = saveStatus
}
MouseArea {

7
mix/qml/BlockChain.qml

@ -214,6 +214,13 @@ ColumnLayout {
else
return []
}
transactionModel:
{
if (index >= 0)
return scenario.blocks[index].transactions
else
return []
}
status:
{

Loading…
Cancel
Save