@nomicfoundation/ethereumjs-statemanager
Advanced tools
Comparing version 1.0.0-rc.3 to 1.0.0
@@ -41,3 +41,3 @@ "use strict"; | ||
const it = this._cache.find(keyStr); | ||
if ((0, ethereumjs_util_1.isTruthy)(it.node)) { | ||
if (it.node !== null) { | ||
const rlp = it.value.val; | ||
@@ -56,3 +56,3 @@ const account = ethereumjs_util_1.Account.fromRlpSerializedAccount(rlp); | ||
const it = this._cache.find(keyStr); | ||
if ((0, ethereumjs_util_1.isTruthy)(it.node)) { | ||
if (it.node !== null) { | ||
return it.value.deleted; | ||
@@ -90,24 +90,18 @@ } | ||
while (next) { | ||
if ((0, ethereumjs_util_1.isTruthy)(it.value) && (0, ethereumjs_util_1.isTruthy)(it.value.modified) && (0, ethereumjs_util_1.isFalsy)(it.value.deleted)) { | ||
if (it.value?.modified === true) { | ||
it.value.modified = false; | ||
const accountRlp = it.value.val; | ||
const keyBuf = Buffer.from(it.key, 'hex'); | ||
await this._putCb(keyBuf, accountRlp); | ||
next = it.hasNext; | ||
it.next(); | ||
if (it.value.deleted === false) { | ||
const accountRlp = it.value.val; | ||
await this._putCb(keyBuf, accountRlp); | ||
} | ||
else { | ||
it.value.deleted = true; | ||
it.value.virtual = true; | ||
it.value.val = new ethereumjs_util_1.Account().serialize(); | ||
await this._deleteCb(keyBuf); | ||
} | ||
} | ||
else if ((0, ethereumjs_util_1.isTruthy)(it.value) && (0, ethereumjs_util_1.isTruthy)(it.value.modified) && (0, ethereumjs_util_1.isTruthy)(it.value.deleted)) { | ||
it.value.modified = false; | ||
it.value.deleted = true; | ||
it.value.virtual = true; | ||
it.value.val = new ethereumjs_util_1.Account().serialize(); | ||
const keyBuf = Buffer.from(it.key, 'hex'); | ||
await this._deleteCb(keyBuf); | ||
next = it.hasNext; | ||
it.next(); | ||
} | ||
else { | ||
next = it.hasNext; | ||
it.next(); | ||
} | ||
next = it.hasNext; | ||
it.next(); | ||
} | ||
@@ -160,3 +154,3 @@ } | ||
const val = value.serialize(); | ||
if ((0, ethereumjs_util_1.isTruthy)(it.node)) { | ||
if (it.node !== null) { | ||
this._cache = it.update({ val, modified, deleted, virtual }); | ||
@@ -163,0 +157,0 @@ } |
@@ -127,3 +127,3 @@ "use strict"; | ||
let storageTrie = this._storageTries[addressHex]; | ||
if ((0, ethereumjs_util_1.isFalsy)(storageTrie)) { | ||
if (storageTrie === undefined || storageTrie === null) { | ||
// lookup from state | ||
@@ -190,3 +190,3 @@ storageTrie = await this._lookupStorageTrie(address); | ||
await this._modifyContractStorage(address, async (storageTrie, done) => { | ||
if ((0, ethereumjs_util_1.isTruthy)(value) && value.length) { | ||
if (Buffer.isBuffer(value) && value.length) { | ||
// format input | ||
@@ -401,3 +401,3 @@ const encodedValue = Buffer.from(ethereumjs_rlp_1.RLP.encode(Uint8Array.from(value))); | ||
async hasStateRoot(root) { | ||
return await this._trie.checkRoot(root); | ||
return this._trie.checkRoot(root); | ||
} | ||
@@ -411,3 +411,5 @@ /** | ||
const account = this._cache.lookup(address); | ||
if (account && (0, ethereumjs_util_1.isFalsy)(account.virtual) && !this._cache.keyIsDeleted(address)) { | ||
if (account && | ||
(account.virtual === undefined || account.virtual === false) && | ||
!this._cache.keyIsDeleted(address)) { | ||
return true; | ||
@@ -414,0 +416,0 @@ } |
{ | ||
"name": "@nomicfoundation/ethereumjs-statemanager", | ||
"version": "1.0.0-rc.3", | ||
"version": "1.0.0", | ||
"description": "An Ethereum statemanager implementation", | ||
@@ -43,6 +43,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@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", | ||
"@nomicfoundation/ethereumjs-common": "^3.0.0", | ||
"@nomicfoundation/ethereumjs-rlp": "^4.0.0", | ||
"@nomicfoundation/ethereumjs-trie": "^5.0.0", | ||
"@nomicfoundation/ethereumjs-util": "^8.0.0", | ||
"debug": "^4.3.3", | ||
@@ -49,0 +49,0 @@ "ethereum-cryptography": "0.1.3", |
@@ -1,2 +0,2 @@ | ||
import { Account, isFalsy, isTruthy } from '@nomicfoundation/ethereumjs-util' | ||
import { Account } from '@nomicfoundation/ethereumjs-util' | ||
@@ -63,3 +63,3 @@ import type { Address } from '@nomicfoundation/ethereumjs-util' | ||
const it = this._cache.find(keyStr) | ||
if (isTruthy(it.node)) { | ||
if (it.node !== null) { | ||
const rlp = it.value.val | ||
@@ -79,3 +79,3 @@ const account = Account.fromRlpSerializedAccount(rlp) | ||
const it = this._cache.find(keyStr) | ||
if (isTruthy(it.node)) { | ||
if (it.node !== null) { | ||
return it.value.deleted | ||
@@ -116,22 +116,18 @@ } | ||
while (next) { | ||
if (isTruthy(it.value) && isTruthy(it.value.modified) && isFalsy(it.value.deleted)) { | ||
if (it.value?.modified === true) { | ||
it.value.modified = false | ||
const accountRlp = it.value.val | ||
const keyBuf = Buffer.from(it.key, 'hex') | ||
await this._putCb(keyBuf, accountRlp) | ||
next = it.hasNext | ||
it.next() | ||
} else if (isTruthy(it.value) && isTruthy(it.value.modified) && isTruthy(it.value.deleted)) { | ||
it.value.modified = false | ||
it.value.deleted = true | ||
it.value.virtual = true | ||
it.value.val = new Account().serialize() | ||
const keyBuf = Buffer.from(it.key, 'hex') | ||
await this._deleteCb(keyBuf) | ||
next = it.hasNext | ||
it.next() | ||
} else { | ||
next = it.hasNext | ||
it.next() | ||
if (it.value.deleted === false) { | ||
const accountRlp = it.value.val | ||
await this._putCb(keyBuf, accountRlp) | ||
} else { | ||
it.value.deleted = true | ||
it.value.virtual = true | ||
it.value.val = new Account().serialize() | ||
await this._deleteCb(keyBuf) | ||
} | ||
} | ||
next = it.hasNext | ||
it.next() | ||
} | ||
@@ -196,3 +192,3 @@ } | ||
const val = value.serialize() | ||
if (isTruthy(it.node)) { | ||
if (it.node !== null) { | ||
this._cache = it.update({ val, modified, deleted, virtual }) | ||
@@ -199,0 +195,0 @@ } else { |
@@ -9,4 +9,2 @@ import { RLP } from '@nomicfoundation/ethereumjs-rlp' | ||
bufferToHex, | ||
isFalsy, | ||
isTruthy, | ||
setLengthLeft, | ||
@@ -193,3 +191,3 @@ short, | ||
let storageTrie = this._storageTries[addressHex] | ||
if (isFalsy(storageTrie)) { | ||
if (storageTrie === undefined || storageTrie === null) { | ||
// lookup from state | ||
@@ -269,3 +267,3 @@ storageTrie = await this._lookupStorageTrie(address) | ||
await this._modifyContractStorage(address, async (storageTrie, done) => { | ||
if (isTruthy(value) && value.length) { | ||
if (Buffer.isBuffer(value) && value.length) { | ||
// format input | ||
@@ -508,3 +506,3 @@ const encodedValue = Buffer.from(RLP.encode(Uint8Array.from(value))) | ||
async hasStateRoot(root: Buffer): Promise<boolean> { | ||
return await this._trie.checkRoot(root) | ||
return this._trie.checkRoot(root) | ||
} | ||
@@ -519,3 +517,7 @@ | ||
const account = this._cache.lookup(address) | ||
if (account && isFalsy((account as any).virtual) && !this._cache.keyIsDeleted(address)) { | ||
if ( | ||
account && | ||
((account as any).virtual === undefined || (account as any).virtual === false) && | ||
!this._cache.keyIsDeleted(address) | ||
) { | ||
return true | ||
@@ -522,0 +524,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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
119507
1910
+ Added@nomicfoundation/ethereumjs-common@3.1.2(transitive)
+ Added@nomicfoundation/ethereumjs-rlp@4.0.3(transitive)
+ Added@nomicfoundation/ethereumjs-trie@5.0.5(transitive)
+ Added@nomicfoundation/ethereumjs-util@8.0.6(transitive)
+ Addedelliptic@6.6.1(transitive)
+ Addednode-gyp-build@4.8.3(transitive)
- Removed@nomicfoundation/ethereumjs-common@3.0.0-rc.3(transitive)
- Removed@nomicfoundation/ethereumjs-rlp@4.0.0-rc.3(transitive)
- Removed@nomicfoundation/ethereumjs-trie@5.0.0-rc.3(transitive)
- Removed@nomicfoundation/ethereumjs-util@8.0.0-rc.3(transitive)
- Removedelliptic@6.6.0(transitive)
- Removednode-gyp-build@4.8.2(transitive)