Skip to content

Commit 39d7044

Browse files
authored
Fix memory usage regression caused by stateroot mismatch fix (#3540)
* Clean up unused imports. * Alternative state root mismatch fix which should not increase memory usage.
1 parent c50982d commit 39d7044

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

execution_chain/db/aristo/aristo_tx_frame.nim

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ proc buildSnapshot(txFrame: AristoTxRef, minLevel: int) =
3737
# `frame` has a snapshot only in the first iteration of the for loop
3838
txFrame.snapshot = move(frame.snapshot)
3939

40-
# Copy cached values that are not present in the newer txFrame.
41-
# These are needed to update the main caches in the AristoDbRef instance.
42-
for k, v in frame.accLeaves:
43-
discard txFrame.accLeaves.hasKeyOrPut(k, v)
44-
for k, v in frame.stoLeaves:
45-
discard txFrame.stoLeaves.hasKeyOrPut(k, v)
46-
4740
# Verify that https://github.com/nim-lang/Nim/issues/23759 is not present
4841
assert frame.snapshot.vtx.len == 0 and frame.snapshot.level.isNone()
4942

@@ -217,7 +210,22 @@ with --debug-eager-state-root."""
217210
# really run after things have been written (to maintain sync betweeen
218211
# in-memory and on-disk state)
219212

220-
# Copy back updated payloads
213+
# Copy back updated payloads into the shared database LRU caches.
214+
215+
# Copy cached values from the snapshot
216+
for accPath, v in txFrame.snapshot.acc:
217+
if v[0] == nil:
218+
db.accLeaves.del(accPath)
219+
else:
220+
discard db.accLeaves.update(accPath, v[0])
221+
222+
for mixPath, v in txFrame.snapshot.sto:
223+
if v[0] == nil:
224+
db.stoLeaves.del(mixPath)
225+
else:
226+
discard db.stoLeaves.update(mixPath, v[0])
227+
228+
# Copy cached values from the txFrame
221229
for accPath, vtx in txFrame.accLeaves:
222230
if vtx == nil:
223231
db.accLeaves.del(accPath)

execution_chain/nimbus_execution_client.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import
1111
../execution_chain/compile_info
1212

1313
import
14-
std/[os, osproc, strutils, net, options],
14+
std/[os, osproc, net, options],
1515
chronicles,
1616
eth/net/nat,
1717
metrics,

execution_chain/rpc/debug.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{.push raises: [].}
1111

1212
import
13-
std/json,
13+
# std/json,
1414
json_rpc/rpcserver,
1515
# ./rpc_utils,
1616
./rpc_types,

tests/test_stateless_witness_generation.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import
1414
stew/byteutils,
15-
chronicles,
1615
unittest2,
1716
../execution_chain/common/common,
1817
../execution_chain/stateless/witness_generation

0 commit comments

Comments
 (0)