Skip to content

Commit

Permalink
transient storage tests src
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega committed Mar 15, 2023
1 parent 5c9d067 commit 0be2f63
Show file tree
Hide file tree
Showing 23 changed files with 1,943 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Tload should not load the value stored in the previous block.
#
# Expect storage slot 0 to have value 90 from block 1.
# Expect storage slot 1 to have the original value 1 from block 2.

tloadDoesNotPersistAcrossBlocks:
genesisBlockHeader:
bloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
coinbase: 0xBA5E000000000000000000000000000000000000
difficulty: '131073'
extraData: '0x42'
gasUsed: '0'
mixHash: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
nonce: '0x0102030405060708'
number: '0'
parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000'
receiptTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
stateRoot: '0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a'
timestamp: '0x03b6'
transactionsTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
uncleHash: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
gasLimit: 100000000000000000
gasUsed: 10000000000
baseFeePerGas: 1000
sealEngine: NoProof

pre:
0x000000000000000000000000000000000000000A:
balance: 0x1000000000000000000
code: |
:yul {
switch selector()
case 0x0accf739 { // doStoreAndLoad()
doStoreAndLoad()
}
case 0x43ac1c39 { // doLoad()
doLoad()
}
function doStoreAndLoad() {
verbatim_2i_0o(hex"b4", 0, 90)
let v := verbatim_1i_1o(hex"b3", 0)
sstore(0, v)
}
function doLoad() {
let v := verbatim_1i_1o(hex"b3", 0)
sstore(1, v)
}
function selector() -> s {
let value := calldataload(0)
s := shr(224, value)
}
}
nonce: '0x00'
storage: { 0x01: 0xffff }

0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: 0x1000000000000000000
nonce: 0
code: ''
storage: {}



blocks:
# Block 1
- transactions:
- data: :abi doStoreAndLoad()
accessList: []
gasLimit: 1000000000000
maxPriorityFeePerGas: 1
maxFeePerGas: 1000
nonce: 0
secretKey: 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8
to: 000000000000000000000000000000000000000A
value: 0x0
# Block 2
- transactions:
- data: :abi doLoad()
accessList: []
gasLimit: 1000000000000
maxPriorityFeePerGas: 1
maxFeePerGas: 1000
nonce: 1
secretKey: 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8
to: 000000000000000000000000000000000000000A
value: 0x0



expect:
- network:
- "Merge+1153"
result:
000000000000000000000000000000000000000A:
storage:
0x00: 90
0x01: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Tload should not load the value stored in the previous transaction.
#
# Expect slot 0 to have value 90 from transaction 1.
# Expect slot 1 to have value 0 from transaction 2.

tloadDoesNotPersistCrossTxn:
genesisBlockHeader:
bloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
coinbase: 0xBA5E000000000000000000000000000000000000
difficulty: '131073'
extraData: '0x42'
gasUsed: '0'
mixHash: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
nonce: '0x0102030405060708'
number: '0'
parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000'
receiptTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
stateRoot: '0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a'
timestamp: '0x03b6'
transactionsTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
uncleHash: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
gasLimit: 100000000000000000
gasUsed: 10000000000
baseFeePerGas: 1000
sealEngine: NoProof

pre:
0x000000000000000000000000000000000000000A:
balance: 0x1000000000000000000
code: |
:yul {
switch selector()
case 0x0accf739 { // doStoreAndLoad()
doStoreAndLoad()
}
case 0x43ac1c39 { // doLoad()
doLoad()
}
function doStoreAndLoad() {
verbatim_2i_0o(hex"b4", 0, 90)
let v := verbatim_1i_1o(hex"b3", 0)
sstore(0, v)
}
function doLoad() {
let v := verbatim_1i_1o(hex"b3", 0)
sstore(1, v)
}
function selector() -> s {
let value := calldataload(0)
s := shr(224, value)
}
}
nonce: '0x00'
storage: { 0x01: 0xffff }

0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: 0x1000000000000000000
nonce: 0
code: ''
storage: {}



blocks:
# Block 1
- transactions:
- data: :abi doStoreAndLoad()
accessList: []
gasLimit: 1000000000000
maxPriorityFeePerGas: 1
maxFeePerGas: 1000
nonce: 0
secretKey: 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8
to: 000000000000000000000000000000000000000A
value: 0x0
- data: :abi doLoad()
accessList: []
gasLimit: 1000000000000
maxPriorityFeePerGas: 1
maxFeePerGas: 1000
nonce: 1
secretKey: 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8
to: 000000000000000000000000000000000000000A
value: 0x0



expect:
- network:
- "Merge+1153"
result:
000000000000000000000000000000000000000A:
storage:
0x00: 90
0x01: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 01
# Loading an arbitrary value is 0 at beginning of transaction: TLOAD(x) is 0
#
# Expect storage slot 1 to have value 0.

01_tloadBeginningTxn:
_info:
comment: load arbitrary value is 0 at beginning of transaction

env:
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
currentDifficulty: 0x20000
currentNumber: 1
currentTimestamp: 1000
currentGasLimit: 0x10000000000000
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
currentBaseFee: 10
pre:
000000000000000000000000000000000000000A:
balance: 1000000000000000000
nonce: 0
code: |
:yul {
let val := verbatim_1i_1o(hex"b3", 0)
sstore(1, val)
}
storage: { 0x01: 0xffff }

a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: 1000000000000000000000
code: "0x"
nonce: 0
storage: {}

transaction:
data:
- data: 0x
accessList: []
gasLimit:
- 0x10000000000000
nonce: 0
to: 000000000000000000000000000000000000000A
value:
- 0
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
maxPriorityFeePerGas: 0
maxFeePerGas: 2000

expect:
- network:
- "Merge+1153"
result:
000000000000000000000000000000000000000A:
storage:
0x01: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 02
# Loading after storing returns the stored value: TSTORE(x, y), TLOAD(x) returns y
#
# Expect storage slot 1 to have value 88

02_tloadAfterTstore:
_info:
comment: tload from same slot after tstore returns correct value

env:
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
currentDifficulty: 0x20000
currentNumber: 1
currentTimestamp: 1000
currentGasLimit: 0x10000000000000
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
currentBaseFee: 10

pre:
000000000000000000000000000000000000000A:
balance: 1000000000000000000
nonce: 0
code: |
:yul {
verbatim_2i_0o(hex"b4", 0, 88)
let val := verbatim_1i_1o(hex"b3", 0)
sstore(1, val)
}
storage: {}
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: 1000000000000000000000
code: "0x"
nonce: 0
storage: {}

transaction:
data:
- data: 0x
accessList: []
gasLimit:
- 0x10000000000000
nonce: 0
to: 000000000000000000000000000000000000000A
value:
- 0
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
maxPriorityFeePerGas: 0
maxFeePerGas: 4000

expect:
- network:
- "Merge+1153"
result:
000000000000000000000000000000000000000A:
storage:
0x01: 88
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 03
# Loading from a different slot after storing to a slot returns 0: TSTORE(x, y), TLOAD(z) returns 0
#
# Expect storage slot 0 to have value 0
# Ex 1) stores 30 at slot 0, loads from slot 1, expects storage slot 0 to have 0, expects storage slot 1 to have 0

03_tloadAfterStoreIs0:
_info:
comment: Loading any other slot after storing to a slot returns 0.

env:
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
currentDifficulty: 0x20000
currentNumber: 1
currentTimestamp: 1000
currentGasLimit: 0x10000000000000
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
currentBaseFee: 10

pre:
000000000000000000000000000000000000000A:
balance: 1000000000000000000
nonce: 0
code: |
:yul {
verbatim_2i_0o(hex"b4", 0, 30)
let val := verbatim_1i_1o(hex"b3", 1)
sstore(1, val)
}
storage: { 0x00: 0xffff, 0x01: 0xffff }
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: 1000000000000000000000
code: "0x"
nonce: 0
storage: {}

transaction:
data:
- data: 0x
accessList: []
gasLimit:
- "400000"
nonce: 0
to: 000000000000000000000000000000000000000A
value:
- 0
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
maxPriorityFeePerGas: 0
maxFeePerGas: 2000

expect:
- network:
- "Merge+1153"
result:
000000000000000000000000000000000000000A:
storage:
# The result we expect
0x00: 0xffff # ensure tstore never wrote to storage
0x01: 0 # ensure loading from an unused key is 0
Loading

0 comments on commit 0be2f63

Please sign in to comment.