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

Deneb - web3signer #12767

Merged
merged 42 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ad860f9
wip
james-prysm Aug 18, 2023
8ba9e78
adding deneb block
james-prysm Aug 18, 2023
4224b51
adding in support for blobs and fixing unit tests for deneb
james-prysm Aug 21, 2023
4d788b6
fixing linting
james-prysm Aug 21, 2023
f05526a
gaz
james-prysm Aug 21, 2023
33e8f9b
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 8, 2023
fb264b4
adding support for new web3signer version
james-prysm Sep 8, 2023
72ecb90
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 8, 2023
188f91a
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 12, 2023
5f6148a
fixing tag name
james-prysm Sep 12, 2023
558fa0e
addressing feedback
james-prysm Sep 12, 2023
023916b
fixing tests
james-prysm Sep 12, 2023
82ba95e
adding unit test for review
james-prysm Sep 12, 2023
1e19c93
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 12, 2023
307abf4
updating test name
james-prysm Sep 12, 2023
57f890f
updating unit tests and length logic
james-prysm Sep 13, 2023
6406809
adding in lengthfor root
james-prysm Sep 13, 2023
5a2af5e
adjusting max blob length
james-prysm Sep 19, 2023
2599c31
fixing mock
james-prysm Sep 19, 2023
9be1706
fixing another mock
james-prysm Sep 19, 2023
e9ce9d8
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 19, 2023
2fa0c52
gaz
james-prysm Sep 19, 2023
400ef23
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 20, 2023
6ca8ca7
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 20, 2023
dd42b1e
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 26, 2023
f8b4b58
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 26, 2023
0a53b89
adding network configs
james-prysm Sep 27, 2023
a62a4c6
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 27, 2023
d9a28bd
removing duplicate
james-prysm Sep 28, 2023
eb40cda
Merge branch 'develop' into deneb-web3signer
james-prysm Sep 28, 2023
7a1e48a
Merge branch 'develop' into deneb-web3signer
nisdas Sep 29, 2023
49f460e
Merge branch 'develop' into deneb-web3signer
james-prysm Oct 9, 2023
415da49
changing based on nishant's feedback
james-prysm Oct 12, 2023
ad21475
Merge branch 'develop' into deneb-web3signer
james-prysm Oct 12, 2023
05ff368
Update validator/keymanager/remote-web3signer/v1/requests.go
james-prysm Oct 13, 2023
2e6f2cd
Update validator/keymanager/remote-web3signer/metrics.go
james-prysm Oct 13, 2023
fb01148
sammy's suggestions
james-prysm Oct 13, 2023
b32e2ac
Merge branch 'develop' into deneb-web3signer
james-prysm Oct 13, 2023
24b1cd7
removing temp file
james-prysm Oct 16, 2023
109d4cb
Merge branch 'develop' into deneb-web3signer
nisdas Oct 16, 2023
69543ab
Merge refs/heads/develop into deneb-web3signer
prylabs-bulldozer[bot] Oct 16, 2023
00099a9
Merge refs/heads/develop into deneb-web3signer
prylabs-bulldozer[bot] Oct 16, 2023
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
17 changes: 10 additions & 7 deletions encoding/ssz/htrutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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) {
Copy link
Contributor

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)

Copy link
Contributor Author

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.

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
Copy link
Member

Choose a reason for hiding this comment

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

this looks odd, the reason we did

(value + 31)/32

is so that the ending chunk if it isnt fully occupied ( < 32 bytes) is still
correctly addressed as 1 full chunk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)
Expand Down
52 changes: 52 additions & 0 deletions encoding/ssz/htrutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,58 @@ func TestTransactionsRoot(t *testing.T) {
}
}

func TestByteSliceRoot(t *testing.T) {
tests := []struct {
name string
slice []byte
maxLength uint64
want [32]byte
wantErr bool
}{
{
name: "nil",
slice: nil,
want: [32]byte{245, 165, 253, 66, 209, 106, 32, 48, 39, 152, 239, 110, 211, 9, 151, 155, 67, 0, 61, 35, 32, 217, 240, 232, 234, 152, 49, 169, 39, 89, 251, 75},
},
{
name: "empty",
slice: []byte{},
want: [32]byte{245, 165, 253, 66, 209, 106, 32, 48, 39, 152, 239, 110, 211, 9, 151, 155, 67, 0, 61, 35, 32, 217, 240, 232, 234, 152, 49, 169, 39, 89, 251, 75},
},
{
name: "byte slice 3 values",
slice: []byte{1, 2, 3},
want: [32]byte{20, 159, 26, 252, 247, 204, 44, 159, 161, 135, 211, 195, 106, 59, 220, 149, 199, 163, 228, 155, 113, 118, 64, 126, 173, 223, 102, 1, 241, 158, 164, 185},
},
{
name: "byte slice 32 values",
slice: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
want: [32]byte{7, 30, 46, 77, 237, 240, 59, 126, 232, 232, 232, 6, 145, 210, 31, 18, 117, 12, 217, 40, 204, 141, 90, 236, 241, 128, 221, 45, 126, 39, 39, 202},
},
{
name: "over max length",
slice: make([]byte, fieldparams.RootLength+1),
want: [32]byte{},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.maxLength == 0 {
tt.maxLength = fieldparams.RootLength
}
got, err := ssz.ByteSliceRoot(tt.slice, tt.maxLength)
if (err != nil) != tt.wantErr {
t.Errorf("ByteSliceRoot() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("ByteSliceRoot() got = %v, want %v", got, tt.want)
}
})
}
}

func TestPackByChunk_SingleList(t *testing.T) {
tests := []struct {
name string
Expand Down
6 changes: 3 additions & 3 deletions testing/endtoend/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ lighthouse_archive_name = "lighthouse-%s-x86_64-unknown-linux-gnu-portable.tar.g
def e2e_deps():
http_archive(
name = "web3signer",
urls = ["https://artifacts.consensys.net/public/web3signer/raw/names/web3signer.tar.gz/versions/23.3.1/web3signer-23.3.1.tar.gz"],
sha256 = "32dfbfd8d5900f19aa426d3519724dd696e6529b7ec2f99e0cb1690dae52b3d6",
urls = ["https://artifacts.consensys.net/public/web3signer/raw/names/web3signer.tar.gz/versions/23.9.0/web3signer-23.9.0.tar.gz"],
sha256 = "7af5cd0589f6105f2267b6c9e6eedda077d597e6410975e1687a6a20e7f1518c",
build_file = "@prysm//testing/endtoend:web3signer.BUILD",
strip_prefix = "web3signer-23.3.1",
strip_prefix = "web3signer-23.9.0",
)

http_archive(
Expand Down
15 changes: 11 additions & 4 deletions validator/keymanager/remote-web3signer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ searching `Consensys' Web3Signer API specification`

issue: https://github.com/prysmaticlabs/prysm/issues/9994

## Support

WIP
API interface: https://github.com/ethereum/remote-signing-api

## Features

### CLI

WIP
detailed info found on https://docs.prylabs.network/docs/wallet/web3signer

Flags used on validator client
- `--validators-external-signer-url=http://localhost:9000`

with hex keys
- `--validators-external-signer-public-keys=0xa99a...e44c,0xb89b...4a0b`

with url
- `--validators-external-signer-public-keys=https://web3signer.com/api/v1/eth2/publicKeys`

### API

Expand Down
Loading
Loading