-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Deneb - web3signer #12767
Deneb - web3signer #12767
Changes from 16 commits
ad860f9
8ba9e78
4224b51
4d788b6
f05526a
33e8f9b
fb264b4
72ecb90
188f91a
5f6148a
558fa0e
023916b
82ba95e
1e19c93
307abf4
57f890f
6406809
5a2af5e
2599c31
9be1706
e9ce9d8
2fa0c52
400ef23
6ca8ca7
dd42b1e
f8b4b58
0a53b89
a62a4c6
d9a28bd
eb40cda
7a1e48a
49f460e
415da49
ad21475
05ff368
2e6f2cd
fb01148
b32e2ac
24b1cd7
109d4cb
69543ab
00099a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,8 +95,9 @@ func SlashingsRoot(slashings []uint64) ([32]byte, error) { | |
// ExecutionPayload. | ||
func TransactionsRoot(txs [][]byte) ([32]byte, error) { | ||
txRoots := make([][32]byte, 0) | ||
maxLength := fieldparams.MaxBytesPerTxLength + 31 // nearest number divisible by root length (32) | ||
for i := 0; i < len(txs); i++ { | ||
rt, err := transactionRoot(txs[i]) | ||
rt, err := ByteSliceRoot(txs[i], uint64(maxLength)) // getting the transaction root here | ||
if err != nil { | ||
return [32]byte{}, err | ||
} | ||
|
@@ -141,19 +142,21 @@ func WithdrawalSliceRoot(withdrawals []*enginev1.Withdrawal, limit uint64) ([32] | |
return MixInLength(bytesRoot, bytesRootBufRoot), nil | ||
} | ||
|
||
func transactionRoot(tx []byte) ([32]byte, error) { | ||
chunkedRoots, err := PackByChunk([][]byte{tx}) | ||
// ByteSliceRoot is a helper func to merkleize an arbitrary List[Byte, N] | ||
// this func runs Chunkify + MerkleizeVector | ||
// max length is dividable by 32 ( root length ) | ||
func ByteSliceRoot(slice []byte, maxLength uint64) ([32]byte, error) { | ||
chunkedRoots, err := PackByChunk([][]byte{slice}) | ||
if err != nil { | ||
return [32]byte{}, err | ||
} | ||
|
||
maxLength := (fieldparams.MaxBytesPerTxLength + 31) / 32 | ||
bytesRoot, err := BitwiseMerkleize(chunkedRoots, uint64(len(chunkedRoots)), uint64(maxLength)) | ||
maxRootLength := maxLength / fieldparams.RootLength | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks odd, the reason we did
is so that the ending chunk if it isnt fully occupied ( < 32 bytes) is still There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me revert this then, maybe there's a better way to do this |
||
bytesRoot, err := BitwiseMerkleize(chunkedRoots, uint64(len(chunkedRoots)), maxRootLength) | ||
if err != nil { | ||
return [32]byte{}, errors.Wrap(err, "could not compute merkleization") | ||
} | ||
bytesRootBuf := new(bytes.Buffer) | ||
if err := binary.Write(bytesRootBuf, binary.LittleEndian, uint64(len(tx))); err != nil { | ||
if err := binary.Write(bytesRootBuf, binary.LittleEndian, uint64(len(slice))); err != nil { | ||
return [32]byte{}, errors.Wrap(err, "could not marshal length") | ||
} | ||
bytesRootBufRoot := make([]byte, 32) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is a little odd, we should be able to hash arbitrary byte slices with the exact same algorithm, why would we restrict to chunked inputs? (multiple of 32 that is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we should add a new function instead of BitwiseMerkleize for this perhaps? that is chunked.