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

cluster: fix hashing of legacy checksummed addresses #1156

Merged
merged 4 commits into from
Sep 23, 2022

Conversation

corverroos
Copy link
Contributor

Fixes issue of "invalid lock hash" when older versions of cluster locks contains checksummed addresses.

category: bug
ticket: #1153

PubShares: [][]byte{
testutil.RandomBytes32(), // TODO(corver): Change sigs to Bytes48.
testutil.RandomBytes32(),
t.Run(version, func(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just wrapped this in a subtest


// TestExamples tests whether charon is backwards compatible with all examples.
func TestExamples(t *testing.T) {
lockFiles, err := filepath.Glob("examples/*lock*")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added /examples folder which contains real world examples that we need to support

@@ -103,10 +92,10 @@ type Definition struct {
Threshold int `json:"threshold" ssz:"uint64" config_hash:"5" definition_hash:"5"`

// FeeRecipientAddress 20 byte Ethereum address.
FeeRecipientAddress []byte `json:"fee_recipient_address,0xhex" ssz:"Bytes20" config_hash:"6" definition_hash:"6"`
FeeRecipientAddress EthAddr `json:"fee_recipient_address,0xhex" ssz:"Bytes20" config_hash:"6" definition_hash:"6"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we cannot use bytes for internal representation of addresses since that looses checksummed information, so store as string rather.

// Field (0) 'Address'
hh.PutBytes([]byte(to0xHex(o.Address)))
continue
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactored if/else

@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Base: 52.90% // Head: 52.95% // Increases project coverage by +0.04% 🎉

Coverage data is based on head (4dfb769) compared to base (431e1b4).
Patch coverage: 75.58% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1156      +/-   ##
==========================================
+ Coverage   52.90%   52.95%   +0.04%     
==========================================
  Files         131      131              
  Lines       15301    15302       +1     
==========================================
+ Hits         8095     8103       +8     
+ Misses       6029     6019      -10     
- Partials     1177     1180       +3     
Impacted Files Coverage Δ
core/validatorapi/validatorapi.go 56.32% <ø> (ø)
cluster/helpers.go 59.23% <41.66%> (-0.90%) ⬇️
cluster/ssz.go 77.82% <72.72%> (-2.51%) ⬇️
cluster/definition.go 53.78% <83.87%> (+3.78%) ⬆️
cluster/operator.go 84.21% <100.00%> (+3.88%) ⬆️
cluster/test_cluster.go 86.60% <100.00%> (ø)
core/validatorapi/teku.go 90.00% <100.00%> (ø)
dkg/disk.go 52.23% <100.00%> (ø)
dkg/dkg.go 49.44% <100.00%> (ø)
core/dutydb/memory.go 66.38% <0.00%> (-0.85%) ⬇️
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@dB2510 dB2510 left a comment

Choose a reason for hiding this comment

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

LGTM

"address": "",
"enr": "enr:-JG4QG2QA-0OTnzUAmWtYuuAJ5QwhQRQTT0pTBuapBHgU75sBAnBZieYVR8fpHMzRc66sqgDYkhMJicLdz1ejhXjRV-GAYJFBnlQgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQORVX5d5U7HULLj_qfh0qP6RrO35tieBwJcKGj4GNBaiYN0Y3CCDhqDdWRwgg4u",
"nonce": 0,
"config_signature": null,
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to populate these "null" fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are examples of real world locks. I didn't generate them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where did you get them from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

our cluster, charon create cluster, and a user's cluster

@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label Sep 23, 2022
@obol-bulldozer obol-bulldozer bot merged commit 1b582bd into main Sep 23, 2022
@obol-bulldozer obol-bulldozer bot deleted the corver/checkaddrs branch September 23, 2022 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants