Skip to content

Commit

Permalink
Implemented transient storage in Yul and inline assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
hrkrshnn committed Jul 20, 2022
1 parent 800088e commit b0c0081
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/grammar/SolidityLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ YulEVMBuiltin:
| 'delegatecall' | 'staticcall' | 'return' | 'revert' | 'selfdestruct' | 'invalid'
| 'log0' | 'log1' | 'log2' | 'log3' | 'log4' | 'chainid' | 'origin' | 'gasprice'
| 'blockhash' | 'coinbase' | 'timestamp' | 'number' | 'difficulty' | 'gaslimit'
| 'basefee';
| 'basefee' | 'tload' | 'tstore';
YulLBrace: '{' -> pushMode(YulMode);
YulRBrace: '}' -> popMode;
Expand Down
4 changes: 4 additions & 0 deletions libevmasm/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ std::map<std::string, Instruction> const solidity::evmasm::c_instructions =
{ "LOG2", Instruction::LOG2 },
{ "LOG3", Instruction::LOG3 },
{ "LOG4", Instruction::LOG4 },
{ "TLOAD", Instruction::TLOAD },
{ "TSTORE", Instruction::TSTORE },
{ "CREATE", Instruction::CREATE },
{ "CALL", Instruction::CALL },
{ "CALLCODE", Instruction::CALLCODE },
Expand Down Expand Up @@ -309,6 +311,8 @@ static std::map<Instruction, InstructionInfo> const c_instructionInfo =
{ Instruction::LOG2, { "LOG2", 0, 4, 0, true, Tier::Special } },
{ Instruction::LOG3, { "LOG3", 0, 5, 0, true, Tier::Special } },
{ Instruction::LOG4, { "LOG4", 0, 6, 0, true, Tier::Special } },
{ Instruction::TLOAD, { "TLOAD", 0, 1, 1, false, Tier::Special} },
{ Instruction::TSTORE, { "TSTORE", 0, 2, 0, true, Tier::Special} },
{ Instruction::CREATE, { "CREATE", 0, 3, 1, true, Tier::Special } },
{ Instruction::CALL, { "CALL", 0, 7, 1, true, Tier::Special } },
{ Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, Tier::Special } },
Expand Down
3 changes: 3 additions & 0 deletions libevmasm/Instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ enum class Instruction: uint8_t
LOG3, ///< Makes a log entry; 3 topics.
LOG4, ///< Makes a log entry; 4 topics.

TLOAD = 0xb3, ///< https://eips.ethereum.org/EIPS/eip-1153
TSTORE = 0xb4, ///< https://eips.ethereum.org/EIPS/eip-1153

CREATE = 0xf0, ///< create a new account with associated code
CALL, ///< message-call into an account
CALLCODE, ///< message-call with another account's code only
Expand Down
3 changes: 3 additions & 0 deletions libevmasm/SemanticInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ bool SemanticInformation::invalidInViewFunctions(Instruction _instruction)
case Instruction::LOG2:
case Instruction::LOG3:
case Instruction::LOG4:
// TODO should tload be view?
case Instruction::TLOAD:
case Instruction::TSTORE:
case Instruction::CREATE:
case Instruction::CALL:
case Instruction::CALLCODE:
Expand Down
9 changes: 9 additions & 0 deletions test/tools/yulInterpreter/EVMInstructionInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ u256 EVMInstructionInterpreter::eval(
accessMemory(arg[0], arg[1]);
logTrace(_instruction, arg);
return 0;

case Instruction::TLOAD:
// TODO
yulAssert(false, "");
return 0;
case Instruction::TSTORE:
// TODO
yulAssert(false, "");
return 0;
// --------------- calls ---------------
case Instruction::CREATE:
accessMemory(arg[1], arg[2]);
Expand Down

0 comments on commit b0c0081

Please sign in to comment.