Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monorepo: remove isTruthy and isFalsy usage #2233

Closed
wants to merge 67 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
81ae11d
vm: remove isTruthy and isFalsy
gabrocheleau Aug 25, 2022
69fa699
Merge branch 'master' into vm/remove-isTruthy-isFalsy
gabrocheleau Aug 25, 2022
4d32e32
vm: remove additional isTruthy/isFalsy from vm
gabrocheleau Aug 25, 2022
fbe9e10
statemanager: remove isFalsy and isTruthy
gabrocheleau Aug 25, 2022
0f900ed
tx: remove isTruthy and isFalsy from tx
gabrocheleau Aug 25, 2022
109cf04
block: remove isTruthy and isFalsy from tx
gabrocheleau Aug 25, 2022
ce5af34
blockchain: remove isTruthy and isFalsy
gabrocheleau Aug 25, 2022
95a686e
vm: remove isTruthy and isFalsy
gabrocheleau Aug 25, 2022
ce9ead1
vm: remove additional isTruthy/isFalsy from vm
gabrocheleau Aug 25, 2022
9514ce7
statemanager: remove isFalsy and isTruthy
gabrocheleau Aug 25, 2022
c26d6d6
tx: remove isTruthy and isFalsy from tx
gabrocheleau Aug 25, 2022
484ba8c
block: remove isTruthy and isFalsy from tx
gabrocheleau Aug 25, 2022
f4b4e1f
blockchain: remove isTruthy and isFalsy
gabrocheleau Aug 25, 2022
bb15cff
trie: remove isTruthy and isFalsy
gabrocheleau Aug 25, 2022
a3825e5
block: fix londonHfBlock check
gabrocheleau Aug 25, 2022
38245ba
chore: replace -n with BigInt(0) for consistency
gabrocheleau Aug 25, 2022
1598b30
utils: remove isTruthy and isFalsy usage
gabrocheleau Aug 25, 2022
4effbde
block: remaining isTruthys
gabrocheleau Aug 25, 2022
6c9023e
ethash: remove isTruthy and isFalsy usage
gabrocheleau Aug 25, 2022
2cf4a98
devp2p: remove isTruthy and isFalsy usage
gabrocheleau Aug 25, 2022
f13abd4
Merge branch 'master' into monorepo/remove-isTruthy-isFalsy
gabrocheleau Aug 25, 2022
ed43589
Merge branch 'master' into monorepo/remove-isTruthy-isFalsy
gabrocheleau Aug 25, 2022
0309148
chore: merge
gabrocheleau Aug 25, 2022
e77c157
Merge branch 'temp/isTruthy-isFalsy' into monorepo/remove-isTruthy-is…
gabrocheleau Aug 25, 2022
46f345f
block: null coalescing instead of ternary
gabrocheleau Aug 25, 2022
1f4b9ec
block: check for BigInt(0)
gabrocheleau Aug 25, 2022
0225807
trie: to fixup
gabrocheleau Aug 25, 2022
d9baab3
block: to fixup
gabrocheleau Aug 25, 2022
c157bd4
evm: remove isTruthy/isFalsy
gabrocheleau Aug 25, 2022
ca413d5
evm: remove isTruthy/isFalsy in tests
gabrocheleau Aug 25, 2022
99078c1
common: remove isTruthy/isFalsy in tests
gabrocheleau Aug 25, 2022
4e24a01
client: remove isTruthy/isFalsy from eth.ts
gabrocheleau Aug 25, 2022
c82852c
client: remove isTruthy/isFalsy from cli
gabrocheleau Aug 25, 2022
8656296
vm: remove isTruthy/isFalsy from execution lib
gabrocheleau Aug 25, 2022
75f7940
vm: remove isTruthy/isFalsy from miner lib
gabrocheleau Aug 25, 2022
7fbbe71
Merge branch 'master' into monorepo/remove-isTruthy-isFalsy
gabrocheleau Aug 26, 2022
b3cba9e
client: more removal of isTruthy/isFalsy
gabrocheleau Aug 26, 2022
b20b325
Merge branch 'monorepo/remove-isTruthy-isFalsy' of https://github.com…
gabrocheleau Aug 26, 2022
d0bde60
chore: merge
gabrocheleau Aug 26, 2022
49dabca
Merge branch 'master' into monorepo/remove-isTruthy-isFalsy
gabrocheleau Aug 26, 2022
99a458f
client: attempt fixing tests
gabrocheleau Aug 26, 2022
0493427
trie: remove remaining isTruthy
gabrocheleau Aug 26, 2022
b801884
client: fix broken test
gabrocheleau Aug 26, 2022
234effe
client: improve printf info types
gabrocheleau Aug 26, 2022
d472b6e
client: remove more isTruthy/isFalsy instances
gabrocheleau Aug 26, 2022
2fdde0d
client: remove more isTruthy/isFalsy instances
gabrocheleau Aug 26, 2022
cdd3478
client: fix optional validation if
gabrocheleau Aug 26, 2022
2b29c04
client: remove more isTruthy/isFalsy instances
gabrocheleau Aug 26, 2022
e2cd9aa
client: remove more isTruthy/isFalsy instances
gabrocheleau Aug 26, 2022
a3b59fb
client: remove remaining instances of isTruthy/isFalsy
gabrocheleau Aug 26, 2022
6946b61
util: remove isTruthy/isFalsy from utils
gabrocheleau Aug 26, 2022
16ac33c
block: refactor JsonRpcBlock to block and remove unnecessary transact…
gabrocheleau Aug 28, 2022
73775e6
block: fix from-rpc test types
gabrocheleau Aug 29, 2022
5931e3f
block: fix type issue in blockFromRpc test
gabrocheleau Aug 29, 2022
1babc1f
StateManager: simplify flush method logic
gabrocheleau Aug 29, 2022
69235f8
blockchain: remove unnecessary undefined check
gabrocheleau Aug 29, 2022
af6cc19
client: fix cli startBlock undefined check
gabrocheleau Aug 29, 2022
1eb89c2
evm: remove unnecessary precompiles undefined check
gabrocheleau Aug 29, 2022
ad0567c
util: remove isFalsy and isTruthy utils
gabrocheleau Aug 29, 2022
e53fb70
vm: remove unnecessary undefined check from runTx
gabrocheleau Aug 29, 2022
3a0a1d6
common: remove ttd !== BigInt(0) check
gabrocheleau Aug 29, 2022
3594938
Merge branch 'master' into monorepo/remove-isTruthy-isFalsy
gabrocheleau Aug 29, 2022
28a81d1
client: remove unnecessary true equality
gabrocheleau Aug 30, 2022
a173bb5
client: simplify get logic and add comment
gabrocheleau Aug 30, 2022
1c8538e
devp2p: address review, simplify some types
gabrocheleau Aug 30, 2022
70bdc5a
common: check for bigint instead of undefined
gabrocheleau Aug 30, 2022
f721b7b
Merge branch 'master' into monorepo/remove-isTruthy-isFalsy
gabrocheleau Aug 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
trie: remove isTruthy and isFalsy
  • Loading branch information
gabrocheleau committed Aug 25, 2022
commit bb15cffe2c44650d2fbe829c51b892dd3791c1e1
21 changes: 11 additions & 10 deletions packages/trie/src/trie/trie.ts
Original file line number Diff line number Diff line change
@@ -97,9 +97,9 @@ export class Trie {
/**
* Gets and/or Sets the current root of the `trie`
*/
root(value?: Buffer): Buffer {
root(value?: Buffer | null): Buffer {
if (value !== undefined) {
if (isFalsy(value)) {
if (value === null) {
value = this.EMPTY_TRIE_ROOT
}

@@ -137,7 +137,7 @@ export class Trie {
*/
async get(key: Buffer, throwIfMissing = false): Promise<Buffer | null> {
const { node, remaining } = await this.findPath(this.appliedKey(key), throwIfMissing)
let value = null
let value: Buffer | null = null
if (node && remaining.length === 0) {
value = node.value()
}
@@ -157,7 +157,7 @@ export class Trie {
}

// If value is empty, delete
if (isFalsy(value) || value.toString() === '') {
if (value === null || value.length === 0) {
return await this.del(key)
}

@@ -426,9 +426,9 @@ export class Trie {
stack: TrieNode[]
) => {
// branchNode is the node ON the branch node not THE branch node
if (isFalsy(parentNode) || parentNode instanceof BranchNode) {
if (parentNode === null || parentNode === undefined || parentNode instanceof BranchNode) {
// branch->?
if (isTruthy(parentNode)) {
if (parentNode !== null && parentNode !== undefined) {
stack.push(parentNode)
}

@@ -460,9 +460,9 @@ export class Trie {
stack.push(parentNode)
} else {
const branchNodeKey = branchNode.key()
// branch node is an leaf or extension and parent node is an exstention
// branch node is an leaf or extension and parent node is an extension
// add two keys together
// dont push the parent node
// don't push the parent node
branchNodeKey.unshift(branchKey)
key = key.concat(branchNodeKey)
parentKey = parentKey.concat(branchNodeKey)
@@ -475,8 +475,8 @@ export class Trie {
return key
}

let lastNode = stack.pop() as TrieNode
if (isFalsy(lastNode)) throw new Error('missing last node')
let lastNode = stack.pop()
if (lastNode === undefined) throw new Error('missing last node')
let parentNode = stack.pop()
const opStack: BatchDBOp[] = []

@@ -634,6 +634,7 @@ export class Trie {
for (const op of ops) {
if (op.type === 'put') {
if (isFalsy(op.value)) {
console.log('falsy op value', op.value)
throw new Error('Invalid batch db operation')
}
await this.put(op.key, op.value)