Browse Source

BLOCKHASH

cl-refactor
Gav Wood 10 years ago
parent
commit
9dd9b025d1
  1. 2
      libethcore/CommonEth.cpp
  2. 8
      libevm/VM.h
  3. 4
      libevmcore/Instruction.cpp
  4. 2
      libevmcore/Instruction.h
  5. 2
      libserpent/opcodes.cpp
  6. 6
      libsolidity/ExpressionCompiler.cpp

2
libethcore/CommonEth.cpp

@ -32,7 +32,7 @@ namespace dev
namespace eth namespace eth
{ {
const unsigned c_protocolVersion = 49; const unsigned c_protocolVersion = 51;
const unsigned c_databaseVersion = 5; const unsigned c_databaseVersion = 5;
static const vector<pair<u256, string>> g_units = static const vector<pair<u256, string>> g_units =

8
libevm/VM.h

@ -219,8 +219,7 @@ inline bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _st
break; break;
} }
case Instruction::PREVHASH: case Instruction::BLOCKHASH:
if (c_protocolVersion > 49)
require(1); require(1);
break; break;
@ -563,11 +562,8 @@ inline bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _st
case Instruction::GASPRICE: case Instruction::GASPRICE:
m_stack.push_back(_ext.gasPrice); m_stack.push_back(_ext.gasPrice);
break; break;
case Instruction::PREVHASH: case Instruction::BLOCKHASH:
if (c_protocolVersion > 49)
m_stack.back() = (u256)_ext.prevhash(m_stack.back()); m_stack.back() = (u256)_ext.prevhash(m_stack.back());
else
m_stack.push_back(_ext.previousBlock.hash);
break; break;
case Instruction::COINBASE: case Instruction::COINBASE:
m_stack.push_back((u160)_ext.currentBlock.coinbaseAddress); m_stack.push_back((u160)_ext.currentBlock.coinbaseAddress);

4
libevmcore/Instruction.cpp

@ -67,7 +67,7 @@ const std::map<std::string, Instruction> dev::eth::c_instructions =
{ "GASPRICE", Instruction::GASPRICE }, { "GASPRICE", Instruction::GASPRICE },
{ "EXTCODESIZE", Instruction::EXTCODESIZE }, { "EXTCODESIZE", Instruction::EXTCODESIZE },
{ "EXTCODECOPY", Instruction::EXTCODECOPY }, { "EXTCODECOPY", Instruction::EXTCODECOPY },
{ "PREVHASH", Instruction::PREVHASH }, { "BLOCKHASH", Instruction::BLOCKHASH },
{ "COINBASE", Instruction::COINBASE }, { "COINBASE", Instruction::COINBASE },
{ "TIMESTAMP", Instruction::TIMESTAMP }, { "TIMESTAMP", Instruction::TIMESTAMP },
{ "NUMBER", Instruction::NUMBER }, { "NUMBER", Instruction::NUMBER },
@ -200,7 +200,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo =
{ Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false } }, { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false } },
{ Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false } }, { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false } },
{ Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true } }, { 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::COINBASE, { "COINBASE", 0, 0, 1, false } },
{ Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false } }, { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false } },
{ Instruction::NUMBER, { "NUMBER", 0, 0, 1, false } }, { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false } },

2
libevmcore/Instruction.h

@ -73,7 +73,7 @@ enum class Instruction: uint8_t
EXTCODESIZE, ///< get external code size (from another contract) EXTCODESIZE, ///< get external code size (from another contract)
EXTCODECOPY, ///< copy external code (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 COINBASE, ///< get the block's coinbase address
TIMESTAMP, ///< get the block's timestamp TIMESTAMP, ///< get the block's timestamp
NUMBER, ///< get the block's number NUMBER, ///< get the block's number

2
libserpent/opcodes.cpp

@ -44,7 +44,7 @@ Mapping mapping[] = {
Mapping("GASPRICE", 0x3a, 0, 1), Mapping("GASPRICE", 0x3a, 0, 1),
Mapping("EXTCODESIZE", 0x3b, 1, 1), Mapping("EXTCODESIZE", 0x3b, 1, 1),
Mapping("EXTCODECOPY", 0x3c, 4, 0), Mapping("EXTCODECOPY", 0x3c, 4, 0),
Mapping("PREVHASH", 0x40, 0, 1), Mapping("BLOCKHASH", 0x40, 1, 1),
Mapping("COINBASE", 0x41, 0, 1), Mapping("COINBASE", 0x41, 0, 1),
Mapping("TIMESTAMP", 0x42, 0, 1), Mapping("TIMESTAMP", 0x42, 0, 1),
Mapping("NUMBER", 0x43, 0, 1), Mapping("NUMBER", 0x43, 0, 1),

6
libsolidity/ExpressionCompiler.cpp

@ -344,9 +344,9 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess)
m_context << eth::Instruction::COINBASE; m_context << eth::Instruction::COINBASE;
else if (member == "timestamp") else if (member == "timestamp")
m_context << eth::Instruction::TIMESTAMP; m_context << eth::Instruction::TIMESTAMP;
else if (member == "prevhash") /* else if (member == "blockhash")
m_context << eth::Instruction::PREVHASH; m_context << eth::Instruction::BLOCKHASH;
else if (member == "difficulty") */ else if (member == "difficulty")
m_context << eth::Instruction::DIFFICULTY; m_context << eth::Instruction::DIFFICULTY;
else if (member == "number") else if (member == "number")
m_context << eth::Instruction::NUMBER; m_context << eth::Instruction::NUMBER;

Loading…
Cancel
Save