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

Trie: make NULL available as type option for put value #3020

Merged
merged 2 commits into from
Sep 12, 2023
Merged

Conversation

ScottyPoi
Copy link
Contributor

trie.put(key, null)
and
trie.put(key, Uint8Array.from([])
both should (and do) delete the value for that key:

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

--

However, Null is left out of the type options for the value paremeter:
async put(key: Uint8Array, value: Uint8Array, skipKeyTransform: boolean = false): Promise<void>

The official trie tests actually do use null as a value. The reason the test does not throw a Type error is that the null values are wrapped in a variable with type any

Since PUT does not actually accept Null values outright, users are forced to use empty Uint8Arrays, or as any to access this part of the implementation.


This PR adds | null as a type options for the value parameter, bringing into alignment with the implementation itself.

@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

Merging #3020 (ffbe758) into master (8ca49a1) will decrease coverage by 2.72%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 88.73% <ø> (?)
blockchain 92.58% <ø> (?)
client 87.33% <ø> (+0.04%) ⬆️
common 98.18% <ø> (?)
ethash ∅ <ø> (∅)
evm 69.78% <ø> (?)
rlp ∅ <ø> (?)
statemanager 84.91% <ø> (?)
trie 90.75% <100.00%> (?)
tx 96.38% <ø> (ø)
util 86.78% <ø> (?)
vm 74.66% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

@scorbajio scorbajio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@scorbajio scorbajio merged commit c1e2f95 into master Sep 12, 2023
@scorbajio scorbajio deleted the trie-put-null branch September 12, 2023 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants