diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-18 11:38:05 +0800 |
---|---|---|
committer | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-13 20:54:32 +0800 |
commit | 500ab821044759594eb3db08876b2925b9b3709b (patch) | |
tree | 72da52de9a7e22509b210a70e92430beb143bcae /libevmasm | |
parent | 0957231a8ed1990baacd67f48c3d3550b5250733 (diff) | |
download | dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.tar.gz dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.tar.zst dexon-solidity-500ab821044759594eb3db08876b2925b9b3709b.zip |
Add opcode RAND support
DEXON has a built-in on chain random oracle that allow one to retrieve a
random variable. Add `rand` solidity variable is introduced to load the
random variable onto the stack.
Diffstat (limited to 'libevmasm')
-rw-r--r-- | libevmasm/Instruction.cpp | 2 | ||||
-rw-r--r-- | libevmasm/Instruction.h | 1 | ||||
-rw-r--r-- | libevmasm/SemanticInformation.cpp | 1 |
3 files changed, 4 insertions, 0 deletions
diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index cf98c938..2bd00821 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -58,6 +58,7 @@ const std::map<std::string, Instruction> dev::solidity::c_instructions = { "MULMOD", Instruction::MULMOD }, { "SIGNEXTEND", Instruction::SIGNEXTEND }, { "KECCAK256", Instruction::KECCAK256 }, + { "RAND", Instruction::RAND }, { "ADDRESS", Instruction::ADDRESS }, { "BALANCE", Instruction::BALANCE }, { "ORIGIN", Instruction::ORIGIN }, @@ -202,6 +203,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo = { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false, Tier::Mid } }, { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false, Tier::Low } }, { Instruction::KECCAK256, { "KECCAK256", 0, 2, 1, true, Tier::Special } }, + { Instruction::RAND, { "RAND", 0, 0, 1, false, Tier::High } }, { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, Tier::Base } }, { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, Tier::Balance } }, { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, Tier::Base } }, diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 539a83b0..1540cbbe 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -66,6 +66,7 @@ enum class Instruction: uint8_t SAR, ///< bitwise SAR operation KECCAK256 = 0x20, ///< compute KECCAK-256 hash + RAND = 0x2f, ///< load a random value ADDRESS = 0x30, ///< get address of currently executing account BALANCE, ///< get balance of the given account diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index 2a24a27e..b068f6dc 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -239,6 +239,7 @@ bool SemanticInformation::invalidInPureFunctions(Instruction _instruction) case Instruction::BLOCKHASH: case Instruction::COINBASE: case Instruction::TIMESTAMP: + case Instruction::RAND: case Instruction::NUMBER: case Instruction::DIFFICULTY: case Instruction::GASLIMIT: |