Skip to content

Commit a49acd6

Browse files
committed
Remove execution prestate since unused
1 parent 49d3e9d commit a49acd6

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

packages/statemanager/src/statefulVerkleStateManager.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class StatefulVerkleStateManager implements StateManagerInterface {
6363
protected _debug: Debugger
6464
protected _caches?: Caches
6565

66+
preStateRoot: Uint8Array
6667
originalStorageCache: OriginalStorageCache
6768
verkleCrypto: VerkleCrypto
6869

@@ -75,7 +76,6 @@ export class StatefulVerkleStateManager implements StateManagerInterface {
7576
// Post-state provided from the executionWitness.
7677
// Should not update. Used for comparing our computed post-state with the canonical one.
7778
private _postState: VerkleState = {}
78-
private _preState: VerkleState = {}
7979

8080
/**
8181
* StateManager is run in DEBUG mode (default: false)
@@ -88,6 +88,7 @@ export class StatefulVerkleStateManager implements StateManagerInterface {
8888
protected readonly DEBUG: boolean = false
8989

9090
private keccakFunction: Function
91+
9192
constructor(opts: StatefulVerkleStateManagerOpts) {
9293
// Skip DEBUG calls unless 'ethjs' included in environmental DEBUG variables
9394
// Additional window check is to prevent vite browser bundling (and potentially other) to break
@@ -118,6 +119,7 @@ export class StatefulVerkleStateManager implements StateManagerInterface {
118119
this._caches = opts.caches
119120
this.keccakFunction = opts.common.customCrypto.keccak256 ?? keccak256
120121
this.verkleCrypto = opts.common.customCrypto.verkle
122+
this.preStateRoot = new Uint8Array(32) // Initial state root is zeroes
121123
}
122124

123125
/**
@@ -179,23 +181,9 @@ export class StatefulVerkleStateManager implements StateManagerInterface {
179181
throw Error(errorMsg)
180182
}
181183

182-
// Populate the pre-state and post-state from the executionWitness
183-
const preStateRaw = executionWitness.stateDiff.flatMap(({ stem, suffixDiffs }) => {
184-
const suffixDiffPairs = suffixDiffs.map(({ currentValue, suffix }) => {
185-
const key = `${stem}${padToEven(Number(suffix).toString(16))}`
186-
return {
187-
[key]: currentValue,
188-
}
189-
})
190-
191-
return suffixDiffPairs
192-
})
184+
this.preStateRoot = hexToBytes(executionWitness.parentStateRoot) // set prestate root if given
193185

194-
// also maintain a separate preState unaffected by any changes in _state
195-
this._preState = preStateRaw.reduce((prevValue, currentValue) => {
196-
const acc = { ...prevValue, ...currentValue }
197-
return acc
198-
}, {})
186+
// Populate the post-state from the executionWitness
199187

200188
const postStateRaw = executionWitness.stateDiff.flatMap(({ stem, suffixDiffs }) => {
201189
const suffixDiffPairs = suffixDiffs.map(({ newValue, currentValue, suffix }) => {
@@ -219,7 +207,6 @@ export class StatefulVerkleStateManager implements StateManagerInterface {
219207

220208
this._postState = postState
221209

222-
this._debug(`initVerkleExecutionWitness preState=${JSON.stringify(this._preState)}`)
223210
this._debug(`initVerkleExecutionWitness postState=${JSON.stringify(this._postState)}`)
224211
}
225212

0 commit comments

Comments
 (0)