From 284bfc8a0058d1bebe0a5bd828665ea87f786874 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 14 Feb 2023 14:06:56 +0100 Subject: [PATCH] fix copying the state --- libs/remix-simulator/src/vm-context.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/remix-simulator/src/vm-context.ts b/libs/remix-simulator/src/vm-context.ts index 4dc4190835..c2bf935afa 100644 --- a/libs/remix-simulator/src/vm-context.ts +++ b/libs/remix-simulator/src/vm-context.ts @@ -50,8 +50,14 @@ class CustomEthersStateManager extends EthersStateManager { } copy(): CustomEthersStateManager { - const newState = super.copy() as CustomEthersStateManager - newState.keyHashes = this.keyHashes + const newState = new CustomEthersStateManager({ + provider: (this as any).provider, + blockTag: BigInt((this as any).blockTag), + }) + ;(newState as any).contractCache = new Map((this as any).contractCache) + ;(newState as any).storageCache = new Map((this as any).storageCache) + ;(newState as any)._cache = this._cache + ;(newState as any).keyHashes = this.keyHashes return newState } @@ -85,9 +91,11 @@ class StateManagerCommonStorageDump extends DefaultStateManager { } copy(): StateManagerCommonStorageDump { - const newState = super.copy() as StateManagerCommonStorageDump - newState.keyHashes = this.keyHashes - return newState + const copyState = new StateManagerCommonStorageDump({ + trie: this._trie.copy(false), + }) + copyState.keyHashes = this.keyHashes + return copyState } async dumpStorage (address): Promise {