Skip to content

Commit a526c48

Browse files
snissnrvagg
andauthored
feat: tstore fevm test (#12849)
* check in fevm tstorage test. note that the network upgrade is a todo. Because the network upgrade does not happen the tests currently fail so they are commented with what needs to change once the network upgrade can be wired in. * remove TODOs from tstore test and update asserts to assert that the expected correct result happens. * typo bugfix * Update itests/contracts/TransientStorageTest.sol Co-authored-by: Rod Vagg <[email protected]> * Update itests/contracts/TransientStorageTest.sol Co-authored-by: Rod Vagg <[email protected]> * upgrade go-state-types version for tstore migration code * ran `make bundle-gen` and `bash pack.sh v16 v16.0.0-dev1` --------- Co-authored-by: Rod Vagg <[email protected]>
1 parent cb1ff81 commit a526c48

File tree

7 files changed

+361
-140
lines changed

7 files changed

+361
-140
lines changed

build/actors/v16.tar.zst

-90.9 KB
Binary file not shown.

build/builtin_actors_gen.go

Lines changed: 126 additions & 126 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ require (
5151
github.com/filecoin-project/go-jsonrpc v0.7.0
5252
github.com/filecoin-project/go-padreader v0.0.1
5353
github.com/filecoin-project/go-paramfetch v0.0.4
54-
github.com/filecoin-project/go-state-types v0.16.0-rc2 // dependency-check-ignore: unknown
54+
github.com/filecoin-project/go-state-types v0.16.0-rc3 // dependency-check-ignore: unknown
5555
github.com/filecoin-project/go-statemachine v1.0.3
5656
github.com/filecoin-project/go-statestore v0.2.0
5757
github.com/filecoin-project/go-storedcounter v0.1.0
@@ -87,7 +87,7 @@ require (
8787
github.com/ipfs/bbloom v0.0.4
8888
github.com/ipfs/boxo v0.20.0
8989
github.com/ipfs/go-block-format v0.2.0
90-
github.com/ipfs/go-cid v0.4.1
90+
github.com/ipfs/go-cid v0.5.0
9191
github.com/ipfs/go-datastore v0.6.0
9292
github.com/ipfs/go-ds-badger2 v0.1.3
9393
github.com/ipfs/go-ds-leveldb v0.5.0
@@ -155,12 +155,12 @@ require (
155155
go.uber.org/fx v1.23.0
156156
go.uber.org/multierr v1.11.0
157157
go.uber.org/zap v1.27.0
158-
golang.org/x/crypto v0.31.0
158+
golang.org/x/crypto v0.32.0
159159
golang.org/x/mod v0.21.0
160160
golang.org/x/net v0.33.0
161161
golang.org/x/sync v0.10.0
162-
golang.org/x/sys v0.28.0
163-
golang.org/x/term v0.27.0
162+
golang.org/x/sys v0.29.0
163+
golang.org/x/term v0.28.0
164164
golang.org/x/time v0.5.0
165165
golang.org/x/tools v0.26.0
166166
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da

go.sum

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab/go
304304
github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
305305
github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
306306
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
307-
github.com/filecoin-project/go-state-types v0.16.0-rc2 h1:+R4NzNBaIYZq6GZYHSB7aTuoHPL7gFnB0MmPEq6mYvc=
308-
github.com/filecoin-project/go-state-types v0.16.0-rc2/go.mod h1:TwnMxZiLa6wUT4u4KWJ+02VMwIQS/EoDJrAowy3Z6G0=
307+
github.com/filecoin-project/go-state-types v0.16.0-rc3 h1:V56ahdMNmAbr/9MdIqxT8w3p2SCsn94u02Zc1sMsDCk=
308+
github.com/filecoin-project/go-state-types v0.16.0-rc3/go.mod h1:W/l8gYD5JNIwEjp4dOiHuJh9dYjwpckjSlaZvSESkbQ=
309309
github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk=
310310
github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
311311
github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI=
@@ -599,8 +599,9 @@ github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67Fexh
599599
github.com/ipfs/go-cid v0.0.6-0.20200501230655-7c82f3b81c00/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog=
600600
github.com/ipfs/go-cid v0.0.6/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I=
601601
github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I=
602-
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
603602
github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
603+
github.com/ipfs/go-cid v0.5.0 h1:goEKKhaGm0ul11IHA7I6p1GmKz8kEYniqFopaB5Otwg=
604+
github.com/ipfs/go-cid v0.5.0/go.mod h1:0L7vmeNXpQpUS9vt+yEARkJ8rOg43DF3iPgn4GIN0mk=
604605
github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
605606
github.com/ipfs/go-datastore v0.0.5/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
606607
github.com/ipfs/go-datastore v0.1.1/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw=
@@ -1467,8 +1468,8 @@ golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE
14671468
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
14681469
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
14691470
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
1470-
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
1471-
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
1471+
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
1472+
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
14721473
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
14731474
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
14741475
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1680,8 +1681,8 @@ golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
16801681
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
16811682
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
16821683
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1683-
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
1684-
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
1684+
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
1685+
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
16851686
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
16861687
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
16871688
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -1693,8 +1694,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
16931694
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
16941695
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
16951696
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
1696-
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
1697-
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
1697+
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
1698+
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
16981699
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
16991700
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
17001701
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6080604052348015600e575f5ffd5b50610d0c8061001c5f395ff3fe608060405234801561000f575f5ffd5b506004361061009c575f3560e01c8063ad5963ca11610064578063ad5963ca14610158578063b279888b14610188578063cf83c71c146101a4578063dec9f688146101ae578063e90bf998146101b85761009c565b806302a5e064146100a057806306c0f8b9146100d057806318e1813f1461010057806323d746281461013057806354e84d1b1461014e575b5f5ffd5b6100ba60048036038101906100b59190610639565b6101c2565b6040516100c79190610673565b60405180910390f35b6100ea60048036038101906100e591906106e6565b6101d1565b6040516100f7919061072b565b60405180910390f35b61011a60048036038101906101159190610639565b610361565b604051610127919061072b565b60405180910390f35b610138610372565b604051610145919061072b565b60405180910390f35b61015661037e565b005b610172600480360381019061016d91906106e6565b6103d3565b60405161017f919061072b565b60405180910390f35b6101a2600480360381019061019d9190610744565b61048f565b005b6101ac610496565b005b6101b661053d565b005b6101c0610597565b005b5f5f825c905080915050919050565b5f5f600490505f605890505f84905081835d8073ffffffffffffffffffffffffffffffffffffffff1663b279888b6004607b6040518363ffffffff1660e01b81526004016102209291906107fd565b5f604051808303815f87803b158015610237575f5ffd5b505af1158015610249573d5f5f3e3d5ffd5b505050505f835c9050828114610294576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028b906108a4565b60405180910390fd5b5f8273ffffffffffffffffffffffffffffffffffffffff166302a5e06460046040518263ffffffff1660e01b81526004016102cf91906108c2565b602060405180830381865afa1580156102ea573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061030e91906108ef565b9050607b8114610353576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034a90610964565b60405180910390fd5b600195505050505050919050565b5f5f825c90505f8114915050919050565b5f61037b6105f0565b90565b5f600390505f61038d82610361565b9050806103cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103c6906109f2565b60405180910390fd5b5050565b5f5f600590505f607b905080825d8373ffffffffffffffffffffffffffffffffffffffff1663dec9f6886040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610426575f5ffd5b505af1158015610438573d5f5f3e3d5ffd5b505050505f825c9050818114610483576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047a90610a80565b60405180910390fd5b60019350505050919050565b80825d5050565b5f600190505f602a905080825d5f825c90508181146104ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104e190610b0e565b60405180910390fd5b5f600290505f815c90505f8114610536576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161052d90610b9c565b60405180910390fd5b5050505050565b5f600690505f6101c8905080825d5f825c9050818114610592576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058990610c2a565b60405180910390fd5b505050565b5f600390505f6063905080825d5f825c90508181146105eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e290610cb8565b60405180910390fd5b505050565b6105f8610496565b610600610597565b565b5f5ffd5b5f819050919050565b61061881610606565b8114610622575f5ffd5b50565b5f813590506106338161060f565b92915050565b5f6020828403121561064e5761064d610602565b5b5f61065b84828501610625565b91505092915050565b61066d81610606565b82525050565b5f6020820190506106865f830184610664565b92915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6106b58261068c565b9050919050565b6106c5816106ab565b81146106cf575f5ffd5b50565b5f813590506106e0816106bc565b92915050565b5f602082840312156106fb576106fa610602565b5b5f610708848285016106d2565b91505092915050565b5f8115159050919050565b61072581610711565b82525050565b5f60208201905061073e5f83018461071c565b92915050565b5f5f6040838503121561075a57610759610602565b5b5f61076785828601610625565b925050602061077885828601610625565b9150509250929050565b5f819050919050565b5f819050919050565b5f6107ae6107a96107a484610782565b61078b565b610606565b9050919050565b6107be81610794565b82525050565b5f819050919050565b5f6107e76107e26107dd846107c4565b61078b565b610606565b9050919050565b6107f7816107cd565b82525050565b5f6040820190506108105f8301856107b5565b61081d60208301846107ee565b9392505050565b5f82825260208201905092915050565b7f4e657374656420636f6e747261637420696e74657266657265642077697468205f8201527f7468697320636f6e747261637427732073746f72616765000000000000000000602082015250565b5f61088e603783610824565b915061089982610834565b604082019050919050565b5f6020820190508181035f8301526108bb81610882565b9050919050565b5f6020820190506108d55f8301846107b5565b92915050565b5f815190506108e98161060f565b92915050565b5f6020828403121561090457610903610602565b5b5f610911848285016108db565b91505092915050565b7f4e657374656420636f6e7472616374206461746120696e636f727265637400005f82015250565b5f61094e601e83610824565b91506109598261091a565b602082019050919050565b5f6020820190508181035f83015261097b81610942565b9050919050565b7f5472616e7369656e742073746f7261676520776173206e6f7420636c656172655f8201527f64206166746572207472616e73616374696f6e00000000000000000000000000602082015250565b5f6109dc603383610824565b91506109e782610982565b604082019050919050565b5f6020820190508181035f830152610a09816109d0565b9050919050565b7f5265656e74727920616c7465726564207472616e7369656e742073746f7261675f8201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b5f610a6a602183610824565b9150610a7582610a10565b604082019050919050565b5f6020820190508181035f830152610a9781610a5e565b9050919050565b7f544c4f414420646964206e6f742072657472696576652074686520636f7272655f8201527f63742076616c7565000000000000000000000000000000000000000000000000602082015250565b5f610af8602883610824565b9150610b0382610a9e565b604082019050919050565b5f6020820190508181035f830152610b2581610aec565b9050919050565b7f556e696e697469616c697a656420544c4f414420646964206e6f7420726574755f8201527f726e207a65726f00000000000000000000000000000000000000000000000000602082015250565b5f610b86602783610824565b9150610b9182610b2c565b604082019050919050565b5f6020820190508181035f830152610bb381610b7a565b9050919050565b7f5265656e7472792063616c6c6261636b206661696c656420746f2073746f72655f8201527f20636f72726563742076616c7565000000000000000000000000000000000000602082015250565b5f610c14602e83610824565b9150610c1f82610bba565b604082019050919050565b5f6020820190508181035f830152610c4181610c08565b9050919050565b7f544c4f414420646964206e6f742072657472696576652073746f7265642076615f8201527f6c75652077697468696e207472616e73616374696f6e00000000000000000000602082015250565b5f610ca2603683610824565b9150610cad82610c48565b604082019050919050565b5f6020820190508181035f830152610ccf81610c96565b905091905056fea26469706673582212201a4d9f2694a40645ce896b3becdae2e653fa67b8642d2b7567a7c34ae759829564736f6c634300081c0033
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.24;
3+
4+
contract TransientStorageTest {
5+
constructor() {
6+
}
7+
8+
// Test 0: Initial Constructor Test
9+
function runTests() public returns (bool) {
10+
_runTests();
11+
}
12+
13+
function _runTests() internal {
14+
testBasicFunctionality();
15+
testLifecycleValidation();
16+
}
17+
18+
// Test 1: Basic Functionality
19+
function testBasicFunctionality() public {
20+
uint256 slot = 1;
21+
uint256 value = 42;
22+
23+
// Store value using TSTORE
24+
assembly {
25+
tstore(slot, value)
26+
}
27+
28+
// Retrieve value using TLOAD
29+
uint256 retrievedValue;
30+
assembly {
31+
retrievedValue := tload(slot)
32+
}
33+
34+
require(retrievedValue == value, "TLOAD did not retrieve the correct value");
35+
36+
// Verify TLOAD from uninitialized location
37+
uint256 uninitializedSlot = 2;
38+
uint256 uninitializedValue;
39+
assembly {
40+
uninitializedValue := tload(uninitializedSlot)
41+
}
42+
43+
require(uninitializedValue == 0, "Uninitialized TLOAD did not return zero");
44+
}
45+
46+
// Test 2.1: Verify transient storage clears after transaction
47+
function testLifecycleValidation() public {
48+
uint256 slot = 3;
49+
uint256 value = 99;
50+
51+
// Store value using TSTORE
52+
assembly {
53+
tstore(slot, value)
54+
}
55+
56+
// Verify it exists within the same transaction
57+
uint256 retrievedValue;
58+
assembly {
59+
retrievedValue := tload(slot)
60+
}
61+
require(retrievedValue == value, "TLOAD did not retrieve stored value within transaction");
62+
}
63+
64+
// Test 2.2: Verify transient storage clears in subsequent transactions
65+
function testLifecycleValidationSubsequentTransaction() public {
66+
uint256 slot = 3;
67+
bool cleared = isStorageCleared(slot);
68+
require(cleared, "Transient storage was not cleared after transaction");
69+
}
70+
71+
// Utility Function: Check if transient storage is cleared
72+
function isStorageCleared(uint256 slot) public view returns (bool) {
73+
uint256 retrievedValue;
74+
assembly {
75+
retrievedValue := tload(slot)
76+
}
77+
return retrievedValue == 0; // True if cleared
78+
}
79+
80+
// Test 3: Verify nested contract independence
81+
function testNestedContracts(address other) public returns (bool) {
82+
uint256 slot = 4;
83+
uint256 value = 88;
84+
85+
TransientStorageTest nested = TransientStorageTest(other);
86+
87+
// Store in this contract's transient storage
88+
assembly {
89+
tstore(slot, value)
90+
}
91+
92+
// Call nested contract to write its own transient storage
93+
nested.writeTransientData(slot, 123);
94+
95+
// Verify this contract's data is unchanged
96+
uint256 retrievedValue;
97+
assembly {
98+
retrievedValue := tload(slot)
99+
}
100+
require(retrievedValue == value, "Nested contract interfered with this contract's storage");
101+
102+
// Verify nested contract's data independently
103+
uint256 nestedValue = nested.readTransientData(slot);
104+
require(nestedValue == 123, "Nested contract data incorrect");
105+
return true;
106+
}
107+
108+
// Test 4: Reentry scenario
109+
function testReentry(address otherContract) public returns (bool) {
110+
uint256 slot = 5;
111+
uint256 value = 123;
112+
113+
// Store a value in transient storage
114+
assembly {
115+
tstore(slot, value)
116+
}
117+
118+
// Call the other contract to trigger a callback to this contract
119+
TransientStorageTest(otherContract).reentryCallback();
120+
121+
// After reentry, check that the transient storage still has the correct value
122+
uint256 retrievedValue;
123+
assembly {
124+
retrievedValue := tload(slot)
125+
}
126+
127+
require(retrievedValue == value, "Reentry altered transient storage");
128+
return true;
129+
}
130+
131+
// Utility Function for Test 4: Reentry callback
132+
function reentryCallback() public {
133+
uint256 slot = 6;
134+
uint256 value = 456;
135+
136+
// Store a different value in a different slot
137+
assembly {
138+
tstore(slot, value)
139+
}
140+
141+
// Verify the value was stored correctly
142+
uint256 retrievedValue;
143+
assembly {
144+
retrievedValue := tload(slot)
145+
}
146+
147+
require(retrievedValue == value, "Reentry callback failed to store correct value");
148+
}
149+
150+
// Utility Function for Test 3: Write to transient storage
151+
function writeTransientData(uint256 slot, uint256 value) external {
152+
assembly {
153+
tstore(slot, value)
154+
}
155+
}
156+
157+
// Utility Function for Test 3: Read from transient storage
158+
function readTransientData(uint256 slot) external view returns (uint256) {
159+
uint256 value;
160+
assembly {
161+
value := tload(slot)
162+
}
163+
return value;
164+
}
165+
}

0 commit comments

Comments
 (0)