-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21b0bf0
commit e15b8b9
Showing
24 changed files
with
571 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
solidity/ethereum/constructor/transient_state_variable_initialization.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
contract C { | ||
uint128 transient x; | ||
uint128 y; | ||
|
||
constructor() { | ||
x = 100; | ||
y = x; | ||
} | ||
|
||
function f() external view returns (uint128) { | ||
return y; | ||
} | ||
} | ||
|
||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract C { | ||
int8 public transient x; | ||
|
||
function f() public returns(int8) { | ||
x = -1; | ||
return this.x(); | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// x() -> 0 | ||
// f() -> -1 | ||
// x() -> 0 |
22 changes: 22 additions & 0 deletions
22
solidity/ethereum/getters/transient_value_types_multi_frame_call.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
contract C { | ||
int8 public transient x; | ||
|
||
function f() public returns(int8) { | ||
x = -1; | ||
return this.h(); | ||
} | ||
function g() public { | ||
x = x - 1; | ||
} | ||
function h() public returns(int8) { | ||
this.g(); | ||
return this.x(); | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// x() -> 0 | ||
// f() -> -2 | ||
// h() -> -1 | ||
// x() -> 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
solidity/ethereum/inheritance/transient_storage_state_variable.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
contract A { | ||
uint24 transient x; | ||
int24 y; | ||
} | ||
|
||
contract C is A { | ||
uint24 w; | ||
int24 transient z; | ||
|
||
function f() public returns (uint24, int24, uint24, int24) { | ||
x += 1; | ||
y += 2; | ||
w += 3; | ||
z += 4; | ||
|
||
return (x, y, w, z); | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 1, 2, 3, 4 |
26 changes: 26 additions & 0 deletions
26
solidity/ethereum/inheritance/transient_storage_state_variable_abstract_contract.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
abstract contract A { | ||
uint transient x; | ||
int y; | ||
function f() public virtual returns (uint, int, uint, int); | ||
} | ||
|
||
contract C is A { | ||
uint w; | ||
int transient z; | ||
|
||
function g() public { | ||
w += 2; | ||
z += 2; | ||
} | ||
|
||
function f() public override returns (uint, int, uint, int) { | ||
x += 1; | ||
y += 1; | ||
g(); | ||
return (x, y, w, z); | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 1, 1, 2, 2 |
22 changes: 22 additions & 0 deletions
22
...dity/ethereum/inlineAssembly/inline_assembly_transient_storage_access_inside_function.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
contract C { | ||
uint16 transient x; | ||
uint16 public transient y; | ||
uint256 public transient z; | ||
|
||
function f() public returns (uint256) { | ||
uint256 offset; | ||
assembly { | ||
function f() -> o1 { | ||
tstore(z.slot, 7) | ||
o1 := y.offset | ||
} | ||
offset := f() | ||
} | ||
assert(offset == 2); | ||
return z; | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 7 |
18 changes: 18 additions & 0 deletions
18
solidity/ethereum/modifiers/transient_state_variable_value_type.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
contract C { | ||
uint16 transient x; | ||
|
||
modifier m(uint16) { | ||
x += 10; | ||
_; | ||
} | ||
|
||
function f() public m(x) returns (uint16) { | ||
x *= 10; | ||
return x; | ||
} | ||
} | ||
|
||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 100 |
22 changes: 22 additions & 0 deletions
22
solidity/ethereum/operators/compound_assign_transient_storage.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
contract test { | ||
uint value1; | ||
uint transient value2; | ||
function f(uint x, uint y) public returns (uint w) { | ||
uint value3 = y; | ||
value1 += x; | ||
value3 *= x; | ||
value2 += value3 + value1; | ||
return value2 += 7; | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f(uint256,uint256): 0, 6 -> 7 | ||
// f(uint256,uint256): 1, 3 -> 11 | ||
// f(uint256,uint256): 2, 25 -> 0x3c | ||
// f(uint256,uint256): 3, 69 -> 0xdc | ||
// f(uint256,uint256): 4, 84 -> 353 | ||
// f(uint256,uint256): 5, 2 -> 0x20 | ||
// f(uint256,uint256): 6, 51 -> 334 | ||
// f(uint256,uint256): 7, 48 -> 371 |
15 changes: 15 additions & 0 deletions
15
solidity/ethereum/operators/transient_storage_variable_increment_decrement.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
contract C { | ||
int transient x; | ||
function f() public returns (int) { | ||
++x; | ||
++x; | ||
--x; | ||
x++; | ||
x--; | ||
return x; | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 1 |
12 changes: 12 additions & 0 deletions
12
solidity/ethereum/variables/delete_transient_state_variable.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
contract C { | ||
uint transient x; | ||
function f() public returns (uint) { | ||
x = 10; | ||
delete x; | ||
return x; | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 0 |
17 changes: 17 additions & 0 deletions
17
solidity/ethereum/variables/delete_transient_state_variable_non_zero_offset.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
contract C { | ||
bytes14 transient x; | ||
uint32 transient y; | ||
uint112 transient z; | ||
|
||
function f() public returns (bytes14, uint32, uint112) { | ||
x = 0xffffffffffffffffffffffffffff; | ||
y = 0xffffffff; | ||
z = 0xffffffffffffffffffffffffffff; | ||
delete y; | ||
return (x, y, z); | ||
} | ||
} | ||
// ==== | ||
// EVMVersion: >=cancun | ||
// ---- | ||
// f() -> 0xffffffffffffffffffffffffffff000000000000000000000000000000000000, 0, 0xffffffffffffffffffffffffffff |
Oops, something went wrong.