@@ -23,6 +23,7 @@ pub struct MemoryStackSubstate<'config> {
2323 logs : Vec < Log > ,
2424 accounts : BTreeMap < H160 , MemoryStackAccount > ,
2525 storages : BTreeMap < ( H160 , H256 ) , H256 > ,
26+ transient_storages : BTreeMap < H256 , H256 > ,
2627 deletes : BTreeSet < H160 > ,
2728}
2829
@@ -34,6 +35,7 @@ impl<'config> MemoryStackSubstate<'config> {
3435 logs : Vec :: new ( ) ,
3536 accounts : BTreeMap :: new ( ) ,
3637 storages : BTreeMap :: new ( ) ,
38+ transient_storages : BTreeMap :: new ( ) ,
3739 deletes : BTreeSet :: new ( ) ,
3840 }
3941 }
@@ -119,6 +121,7 @@ impl<'config> MemoryStackSubstate<'config> {
119121 logs : Vec :: new ( ) ,
120122 accounts : BTreeMap :: new ( ) ,
121123 storages : BTreeMap :: new ( ) ,
124+ transient_storages : BTreeMap :: new ( ) ,
122125 deletes : BTreeSet :: new ( ) ,
123126 } ;
124127 mem:: swap ( & mut entering, self ) ;
@@ -231,6 +234,17 @@ impl<'config> MemoryStackSubstate<'config> {
231234
232235 None
233236 }
237+ pub fn known_transient_storage ( & self , key : H256 ) -> Option < H256 > {
238+ if let Some ( value) = self . transient_storages . get ( & key) {
239+ return Some ( * value) ;
240+ }
241+
242+ if let Some ( parent) = self . parent . as_ref ( ) {
243+ return parent. known_transient_storage ( key) ;
244+ }
245+
246+ None
247+ }
234248
235249 pub fn known_original_storage ( & self , address : H160 ) -> Option < H256 > {
236250 if let Some ( account) = self . accounts . get ( & address) {
@@ -314,6 +328,10 @@ impl<'config> MemoryStackSubstate<'config> {
314328 self . storages . insert ( ( address, key) , value) ;
315329 }
316330
331+ pub fn set_transient_storage ( & mut self , key : H256 , value : H256 ) {
332+ self . transient_storages . insert ( key, value) ;
333+ }
334+
317335 pub fn reset_storage < B : Backend > ( & mut self , address : H160 , backend : & B ) {
318336 let mut removing = Vec :: new ( ) ;
319337
@@ -465,6 +483,12 @@ impl<'backend, 'config, B: Backend> Backend for MemoryStackState<'backend, 'conf
465483 . unwrap_or_else ( || self . backend . storage ( address, key) )
466484 }
467485
486+ fn transient_storage ( & self , key : H256 ) -> H256 {
487+ self . substate
488+ . known_transient_storage ( key)
489+ . unwrap_or_else ( || self . backend . transient_storage ( key) )
490+ }
491+
468492 fn original_storage ( & self , address : H160 , key : H256 ) -> Option < H256 > {
469493 if let Some ( value) = self . substate . known_original_storage ( address) {
470494 return Some ( value) ;
@@ -529,6 +553,10 @@ impl<'backend, 'config, B: Backend> StackState<'config> for MemoryStackState<'ba
529553 self . substate . set_storage ( address, key, value)
530554 }
531555
556+ fn set_transient_storage ( & mut self , key : H256 , value : H256 ) {
557+ self . substate . set_transient_storage ( key, value)
558+ }
559+
532560 fn reset_storage ( & mut self , address : H160 ) {
533561 self . substate . reset_storage ( address, self . backend ) ;
534562 }
0 commit comments