diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index a6a1b9b1f..8b5ae8302 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -526,9 +526,10 @@ void Main::on_data_textChanged() if (isCreation()) { string code = ui->data->toPlainText().toStdString(); + m_init.clear(); m_data = compileLisp(code, true, m_init); ui->code->setPlainText(QString::fromStdString(disassemble(m_data)) + "\n; Init:" + QString::fromStdString(disassemble(m_init))); - ui->gas->setMinimum((qint64)state().createGas(m_data.size() + m_init.size())); + ui->gas->setMinimum((qint64)state().createGas(m_data.size() + m_init.size(), 0)); ui->gas->setEnabled(true); } else diff --git a/libethereum/Instruction.cpp b/libethereum/Instruction.cpp index 265c284e1..b295eb535 100644 --- a/libethereum/Instruction.cpp +++ b/libethereum/Instruction.cpp @@ -321,7 +321,7 @@ static unsigned pushLiteral(bytes& o_code, u256 _literalValue) for (unsigned i = 0; i < br; ++i) { o_code[o_code.size() - 1 - i] = (byte)(_literalValue & 0xff); - _literalValue <<= 8; + _literalValue >>= 8; } return br + 1; } @@ -883,7 +883,7 @@ string eth::disassemble(bytes const& _mem) { if (numerics) numerics--; - ret << "0x" << hex << n << " "; + ret << "0x" << hex << (int)n << " "; } else { diff --git a/libethereum/State.h b/libethereum/State.h index a1707fb0a..48167b0fc 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -177,7 +177,7 @@ public: u256 playback(bytesConstRef _block, BlockInfo const& _bi, BlockInfo const& _parent, BlockInfo const& _grandParent, bool _fullCommit); /// Get the fee associated for a contract created with the given data. - u256 createGas(uint _nonZeroStorageCount) const { return c_sstoreGas * _nonZeroStorageCount + c_createGas; } + u256 createGas(uint _dataCount, u256 _gas = 0) const { return c_txDataGas * _dataCount + c_createGas + _gas; } /// Get the fee associated for a normal transaction. u256 callGas(uint _dataCount, u256 _gas = 0) const { return c_txDataGas * _dataCount + c_callGas + _gas; }