From 9dd9b025d1cd86be8dfb085fc9b59ae13b246f41 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 5 Jan 2015 11:35:56 +0000 Subject: [PATCH] BLOCKHASH --- libethcore/CommonEth.cpp | 2 +- libevm/VM.h | 12 ++++-------- libevmcore/Instruction.cpp | 4 ++-- libevmcore/Instruction.h | 2 +- libserpent/opcodes.cpp | 2 +- libsolidity/ExpressionCompiler.cpp | 6 +++--- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 9801bc89f..c70bc353b 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 49; +const unsigned c_protocolVersion = 51; const unsigned c_databaseVersion = 5; static const vector> g_units = diff --git a/libevm/VM.h b/libevm/VM.h index 47efbfcba..6cdb53400 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -219,9 +219,8 @@ inline bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _st break; } - case Instruction::PREVHASH: - if (c_protocolVersion > 49) - require(1); + case Instruction::BLOCKHASH: + require(1); break; case Instruction::PC: @@ -563,11 +562,8 @@ inline bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _st case Instruction::GASPRICE: m_stack.push_back(_ext.gasPrice); break; - case Instruction::PREVHASH: - if (c_protocolVersion > 49) - m_stack.back() = (u256)_ext.prevhash(m_stack.back()); - else - m_stack.push_back(_ext.previousBlock.hash); + case Instruction::BLOCKHASH: + m_stack.back() = (u256)_ext.prevhash(m_stack.back()); break; case Instruction::COINBASE: m_stack.push_back((u160)_ext.currentBlock.coinbaseAddress); diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index b4a4d9f3b..bba3d7745 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -67,7 +67,7 @@ const std::map dev::eth::c_instructions = { "GASPRICE", Instruction::GASPRICE }, { "EXTCODESIZE", Instruction::EXTCODESIZE }, { "EXTCODECOPY", Instruction::EXTCODECOPY }, - { "PREVHASH", Instruction::PREVHASH }, + { "BLOCKHASH", Instruction::BLOCKHASH }, { "COINBASE", Instruction::COINBASE }, { "TIMESTAMP", Instruction::TIMESTAMP }, { "NUMBER", Instruction::NUMBER }, @@ -200,7 +200,7 @@ static const std::map c_instructionInfo = { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false } }, { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false } }, { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true } }, - { Instruction::PREVHASH, { "PREVHASH", 0, 0, 1, false } }, + { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false } }, { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false } }, { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false } }, { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false } }, diff --git a/libevmcore/Instruction.h b/libevmcore/Instruction.h index 555dbf0ea..a28e8f8da 100644 --- a/libevmcore/Instruction.h +++ b/libevmcore/Instruction.h @@ -73,7 +73,7 @@ enum class Instruction: uint8_t EXTCODESIZE, ///< get external code size (from another contract) EXTCODECOPY, ///< copy external code (from another contract) - PREVHASH = 0x40, ///< get hash of most recent complete block + BLOCKHASH = 0x40, ///< get hash of most recent complete block COINBASE, ///< get the block's coinbase address TIMESTAMP, ///< get the block's timestamp NUMBER, ///< get the block's number diff --git a/libserpent/opcodes.cpp b/libserpent/opcodes.cpp index b24144e46..2fc7d7530 100644 --- a/libserpent/opcodes.cpp +++ b/libserpent/opcodes.cpp @@ -44,7 +44,7 @@ Mapping mapping[] = { Mapping("GASPRICE", 0x3a, 0, 1), Mapping("EXTCODESIZE", 0x3b, 1, 1), Mapping("EXTCODECOPY", 0x3c, 4, 0), - Mapping("PREVHASH", 0x40, 0, 1), + Mapping("BLOCKHASH", 0x40, 1, 1), Mapping("COINBASE", 0x41, 0, 1), Mapping("TIMESTAMP", 0x42, 0, 1), Mapping("NUMBER", 0x43, 0, 1), diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index cf641935a..6bf14f559 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -344,9 +344,9 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) m_context << eth::Instruction::COINBASE; else if (member == "timestamp") m_context << eth::Instruction::TIMESTAMP; - else if (member == "prevhash") - m_context << eth::Instruction::PREVHASH; - else if (member == "difficulty") +/* else if (member == "blockhash") + m_context << eth::Instruction::BLOCKHASH; +*/ else if (member == "difficulty") m_context << eth::Instruction::DIFFICULTY; else if (member == "number") m_context << eth::Instruction::NUMBER;