From 44163acc33467bf061f46d7f7f26fdff2706a5db Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Tue, 13 Jun 2023 10:53:54 -0700 Subject: [PATCH] wip refactor --- boa/environment.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/boa/environment.py b/boa/environment.py index 484ab7a1..140c12ac 100644 --- a/boa/environment.py +++ b/boa/environment.py @@ -33,6 +33,17 @@ def enable_pyevm_verbose_logging(): setup_DEBUG2_logging() logger.setLevel("DEBUG2") +import copy +import copyreg +import pickle + +import lru + +def pickle_lru(lru_obj): + return ( lru.LRU, (lru_obj.get_size(),), None, None, iter(lru_obj.items()),) + +copyreg.pickle(lru.LRU, pickle_lru) + class VMPatcher: _exc_patchables = { @@ -362,22 +373,6 @@ def apply_message(cls, state, message, tx_ctx): computation = cls.apply_computation(state, message, tx_ctx) db = state._account_db - import copy - import copyreg - import pickle - - import lru - - def pickle_lru(lru_obj): - return ( - lru.LRU, - (lru_obj.get_size(),), - None, - None, - iter(lru_obj.items()), - ) - - copyreg.pickle(lru.LRU, pickle_lru) computation._restore_state = copy.deepcopy( (