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

util: Add ssz roots capability for withdrawals hash tree root #2488

Merged
merged 8 commits into from Jan 18, 2023

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented Jan 18, 2023

In preparation for moving the ssz root gen capability for withdrawals, this PR adds ssz types and root gen utility method which can be later easily deployed

will just need to switch all Block.genWithdrawlsTrieRoot to Block.genWithdrawalsSSZRoot method when the spec moves to ssz root

@codecov
Copy link

codecov bot commented Jan 18, 2023

Codecov Report

Merging #2488 (8bbb708) into master (8bcdb48) will increase coverage by 1.74%.
The diff coverage is 95.45%.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 89.50% <77.77%> (-0.07%) ⬇️
blockchain 90.04% <ø> (ø)
client 87.91% <ø> (ø)
common 95.89% <ø> (ø)
devp2p 91.68% <ø> (+0.05%) ⬆️
ethash ∅ <ø> (∅)
evm ?
rlp ∅ <ø> (∅)
statemanager 89.61% <ø> (ø)
trie 90.36% <ø> (ø)
tx 97.80% <ø> (ø)
util 85.11% <100.00%> (+0.30%) ⬆️
vm 85.85% <ø> (ø)

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

Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

Basically nits but would like some of the naming conventions a little bit clearer. Code looks great though!

@@ -103,6 +103,15 @@ export class Withdrawal {
return Withdrawal.toBufferArray(this)
}

toValue() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is nice! I wonder if we should add something like this for blob txns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes its good 👍 picked idea from ssz code structure

packages/util/src/ssz.ts Outdated Show resolved Hide resolved
packages/block/src/block.ts Outdated Show resolved Hide resolved
packages/block/src/block.ts Outdated Show resolved Hide resolved
g11tech and others added 4 commits January 18, 2023 21:47
Co-authored-by: acolytec3 <17355484+acolytec3@users.noreply.github.com>
Co-authored-by: acolytec3 <17355484+acolytec3@users.noreply.github.com>
Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

Looks great!

@acolytec3 acolytec3 merged commit 6508bf9 into master Jan 18, 2023
@holgerd77 holgerd77 deleted the g11tech/sszwithdrawalsroot branch January 19, 2023 13:05

const withdrawalsValue = withdrawals.map((wt) => wt.toValue())
st.deepEqual(
withdrawalsValue.map((wt) => `0x${wt.address.toString('hex')}`),

Choose a reason for hiding this comment

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

0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4

const withdrawalsValue = withdrawals.map((wt) => wt.toValue())
st.deepEqual(
withdrawalsValue.map((wt) => `0x${wt.address.toString('hex')}`),
withdrawalsJson.map((wt) => wt.address)

Choose a reason for hiding this comment

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

0x990De5Cc9Cc644F0703f6A09e084470a949eC370

st.deepEqual(
withdrawalsValue.map((wt) => `0x${wt.address.toString('hex')}`),
withdrawalsJson.map((wt) => wt.address)
)
st.end()

Choose a reason for hiding this comment

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

0x990De5Cc9Cc644F0703f6A09e084470a949eC370

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.

None yet

4 participants