@nomicfoundation/ethereumjs-statemanager
Advanced tools
Comparing version 1.0.0-rc.2 to 1.0.0-rc.3
@@ -6,2 +6,3 @@ /// <reference types="node" /> | ||
import type { Account, Address } from '@nomicfoundation/ethereumjs-util'; | ||
import type { Debugger } from 'debug'; | ||
/** | ||
@@ -20,2 +21,3 @@ * Abstract BaseStateManager class for the non-storage-backend | ||
export declare abstract class BaseStateManager { | ||
_debug: Debugger; | ||
_cache: Cache; | ||
@@ -22,0 +24,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseStateManager = void 0; | ||
const debug_1 = require("debug"); | ||
/** | ||
@@ -34,2 +35,3 @@ * Abstract BaseStateManager class for the non-storage-backend | ||
} | ||
this._debug = (0, debug_1.debug)('statemanager:statemanager'); | ||
} | ||
@@ -50,2 +52,5 @@ /** | ||
async putAccount(address, account) { | ||
if (this.DEBUG) { | ||
this._debug(`Save account address=${address} nonce=${account.nonce} balance=${account.balance} contract=${account.isContract() ? 'yes' : 'no'} empty=${account.isEmpty() ? 'yes' : 'no'}`); | ||
} | ||
this._cache.put(address, account); | ||
@@ -73,2 +78,5 @@ } | ||
async deleteAccount(address) { | ||
if (this.DEBUG) { | ||
this._debug(`Delete account ${address}`); | ||
} | ||
this._cache.del(address); | ||
@@ -75,0 +83,0 @@ } |
@@ -82,2 +82,5 @@ "use strict"; | ||
await this._trie._db.put(key, value); | ||
if (this.DEBUG) { | ||
this._debug(`Update codeHash (-> ${(0, ethereumjs_util_1.short)(codeHash)}) for account ${address}`); | ||
} | ||
await this.modifyAccountFields(address, { codeHash }); | ||
@@ -190,2 +193,5 @@ } | ||
const encodedValue = Buffer.from(ethereumjs_rlp_1.RLP.encode(Uint8Array.from(value))); | ||
if (this.DEBUG) { | ||
this._debug(`Update contract storage for account ${address} to ${(0, ethereumjs_util_1.short)(value)}`); | ||
} | ||
await storageTrie.put(key, encodedValue); | ||
@@ -195,2 +201,5 @@ } | ||
// deleting a value | ||
if (this.DEBUG) { | ||
this._debug(`Delete contract storage for account`); | ||
} | ||
await storageTrie.del(key); | ||
@@ -197,0 +206,0 @@ } |
{ | ||
"name": "@nomicfoundation/ethereumjs-statemanager", | ||
"version": "1.0.0-rc.2", | ||
"version": "1.0.0-rc.3", | ||
"description": "An Ethereum statemanager implementation", | ||
@@ -43,6 +43,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@nomicfoundation/ethereumjs-common": "3.0.0-rc.2", | ||
"@nomicfoundation/ethereumjs-rlp": "4.0.0-rc.2", | ||
"@nomicfoundation/ethereumjs-trie": "5.0.0-rc.2", | ||
"@nomicfoundation/ethereumjs-util": "8.0.0-rc.2", | ||
"@nomicfoundation/ethereumjs-common": "3.0.0-rc.3", | ||
"@nomicfoundation/ethereumjs-rlp": "4.0.0-rc.3", | ||
"@nomicfoundation/ethereumjs-trie": "5.0.0-rc.3", | ||
"@nomicfoundation/ethereumjs-util": "8.0.0-rc.3", | ||
"debug": "^4.3.3", | ||
@@ -49,0 +49,0 @@ "ethereum-cryptography": "0.1.3", |
@@ -0,1 +1,3 @@ | ||
import { debug as createDebugLogger } from 'debug' | ||
import type { Cache } from './cache' | ||
@@ -5,2 +7,3 @@ import type { AccountFields } from './interface' | ||
import type { Account, Address } from '@nomicfoundation/ethereumjs-util' | ||
import type { Debugger } from 'debug' | ||
@@ -20,2 +23,3 @@ /** | ||
export abstract class BaseStateManager { | ||
_debug: Debugger | ||
_cache!: Cache | ||
@@ -41,2 +45,3 @@ | ||
} | ||
this._debug = createDebugLogger('statemanager:statemanager') | ||
} | ||
@@ -59,2 +64,9 @@ | ||
async putAccount(address: Address, account: Account): Promise<void> { | ||
if (this.DEBUG) { | ||
this._debug( | ||
`Save account address=${address} nonce=${account.nonce} balance=${ | ||
account.balance | ||
} contract=${account.isContract() ? 'yes' : 'no'} empty=${account.isEmpty() ? 'yes' : 'no'}` | ||
) | ||
} | ||
this._cache.put(address, account) | ||
@@ -84,2 +96,5 @@ } | ||
async deleteAccount(address: Address) { | ||
if (this.DEBUG) { | ||
this._debug(`Delete account ${address}`) | ||
} | ||
this._cache.del(address) | ||
@@ -86,0 +101,0 @@ } |
@@ -144,2 +144,5 @@ import { RLP } from '@nomicfoundation/ethereumjs-rlp' | ||
if (this.DEBUG) { | ||
this._debug(`Update codeHash (-> ${short(codeHash)}) for account ${address}`) | ||
} | ||
await this.modifyAccountFields(address, { codeHash }) | ||
@@ -268,5 +271,11 @@ } | ||
const encodedValue = Buffer.from(RLP.encode(Uint8Array.from(value))) | ||
if (this.DEBUG) { | ||
this._debug(`Update contract storage for account ${address} to ${short(value)}`) | ||
} | ||
await storageTrie.put(key, encodedValue) | ||
} else { | ||
// deleting a value | ||
if (this.DEBUG) { | ||
this._debug(`Delete contract storage for account`) | ||
} | ||
await storageTrie.del(key) | ||
@@ -273,0 +282,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120689
1917
1
+ Added@nomicfoundation/ethereumjs-common@3.0.0-rc.3(transitive)
+ Added@nomicfoundation/ethereumjs-rlp@4.0.0-rc.3(transitive)
+ Added@nomicfoundation/ethereumjs-trie@5.0.0-rc.3(transitive)
+ Added@nomicfoundation/ethereumjs-util@8.0.0-rc.3(transitive)
- Removed@nomicfoundation/ethereumjs-common@3.0.0-rc.2(transitive)
- Removed@nomicfoundation/ethereumjs-rlp@4.0.0-rc.2(transitive)
- Removed@nomicfoundation/ethereumjs-trie@5.0.0-rc.2(transitive)
- Removed@nomicfoundation/ethereumjs-util@8.0.0-rc.2(transitive)