Commit fee919d
authored
fix: enode field should contain node ID, not private key (#72)
## Summary
The `enode` field in `GeneratedNodeKey` was incorrectly set to the
private key instead of the node ID (public key with 0x04 prefix
stripped).
## Issues Fixed
- Individual validator enode ConfigMaps contained private keys instead
of node IDs
- Duplicate private key data (stored in both `privateKey` and `enode`
fields)
- Misleading ConfigMap names (`besu-node-validator-X-enode` contained
private key)
## Changes
1. **Fixed `src/keys/node-key-factory.ts`**: Strip the 0x04 prefix from
the public key to derive the node ID
2. **Fixed `src/keys/node-key-factory.test.ts`**: Updated test to
validate correct behavior (enode should be 128-char hex node ID)
## Testing
- ✅ All 90 tests pass
- ✅ Verified enode field now contains correct node ID format
## Note
This bug only affected the individual validator `enode` field. The
`static-nodes.json` generation was not affected because it used the
correct `deriveNodeId()` function.
## Links
- Bug in code:
https://github.com/settlemint/network-bootstrapper/blob/184bc9469aca3d08db69f8a0a9f4cf5ce6643deb/src/keys/node-key-factory.ts#L30
- Test that validated bug:
https://github.com/settlemint/network-bootstrapper/blob/184bc9469aca3d08db69f8a0a9f4cf5ce6643deb/src/keys/node-key-factory.test.ts#L15
## Summary by Sourcery
Fix incorrect enode field derivation by using the public key (node ID)
instead of the private key, and update tests to validate the new
behavior.
Bug Fixes:
- Derive enode node ID by stripping the 0x04 prefix from the
uncompressed public key instead of reusing the private key
Tests:
- Update NodeKeyFactory tests to assert enode is a 128-character hex
node ID without 0x prefix and unique per key1 parent 347ca0a commit fee919d
3 files changed
Lines changed: 26 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
0 commit comments