attestantio / vouch

Apache License 2.0
112 stars 28 forks source link

Dirk account manager gets rejected by Nimbus 24.2.0 #180

Closed catwith1hat closed 8 months ago

catwith1hat commented 8 months ago

After upgrading Vouch to the master branch, my Nimbus CL rejects the validator setup and makes Vouch panic on startup. That's because Vouch queries Nimbus with duplicate validator keys in its call to /eth/v1/beacon/states/head/validators and Nimbus returns a 404 as a response. Here is the log. You can see that the validator 0xb9792fde317e268[...]ddaaf2fb8623da is included in the query 3 times.

Feb 09 13:45:51 node4 vouch[15859]: {"level":"info","time":"2024-02-09T13:45:51+01:00","message":"Starting dirk account manager"}
Feb 09 13:45:51 node4 vouch[15859]: {"level":"debug","service":"client","impl":"http","id":"16a90de6","address":"localhost:4040","endpoint":"/eth/v1/beacon/states/head/validators?id=0xb9792fde317e2687329b1443805fa638bf445334d6f68c1b6b9ba4b3af55d2897cca0c59eadc9bfd39ddaaf2fb8623da,0xaa57e4f6e6360651520fb256ab6828ce759be76003293cac2d06d6c5b8138a25c493a95b2b82ac54d7a51bfbee12afd1,0xa3cdb2083c13cb6f7c4dc0f8fc230bf60b2a3b2309885a4aede3f0f9aa45027b5dc4cc03f2077dec7e52798d3d47a563,0xb9792fde317e2687329b1443805fa638bf445334d6f68c1b6b9ba4b3af55d2897cca0c59eadc9bfd39ddaaf2fb8623da,0xaa57e4f6e6360651520fb256ab6828ce759be76003293cac2d06d6c5b8138a25c493a95b2b82ac54d7a51bfbee12afd1,0xa3cdb2083c13cb6f7c4dc0f8fc230bf60b2a3b2309885a4aede3f0f9aa45027b5dc4cc03f2077dec7e52798d3d47a563,0xa3cdb2083c13cb6f7c4dc0f8fc230bf60b2a3b2309885a4aede3f0f9aa45027b5dc4cc03f2077dec7e52798d3d47a563,0xb9792fde317e2687329b1443805fa638bf445334d6f68c1b6b9ba4b3af55d2897cca0c59eadc9bfd39ddaaf2fb8623da,0xaa57e4f6e6360651520fb256ab6828ce759be76003293cac2d06d6c5b8138a25c493a95b2b82ac54d7a51bfbee12afd1","status_code":400,"status_code":400,"response":{"code":400,"message":"Non-unique validator identifier value(s)","stacktraces":["b9792fde317e2687329b1443805fa638bf445334d6f68c1b6b9ba4b3af55d2897cca0c59eadc9bfd39ddaaf2fb8623da"]},"time":"2024-02-09T13:45:51+01:00","message":"GET failed"}
Feb 09 13:45:51 node4 vouch[15859]: {"level":"error","error":"failed to start account manager: failed to start dirk account manager service: failed to fetch initial validator states: failed to refresh validators: failed to obtain validators: failed to request validators: GET failed with status 400: {\"code\":400,\"message\":\"Non-unique validator identifier value(s)\",\"stacktraces\":[\"b9792fde317e2687329b1443805fa638bf445334d6f68c1b6b9ba4b3af55d2897cca0c59eadc9bfd39ddaaf2fb8623da\"]}","time":"2024-02-09T13:45:51+01:00","message":"Failed to initialise services"}
Feb 09 13:45:51 node4 systemd[1]: vouch-N4-I0.service: Main process exited, code=exited, status=1/FAILURE

Config:

$ cat /nix/store/i0q2qdya37pzd0ik8nwyfy1xd7ckgy8j-vouch-cfg/vouch.yml
accountmanager:
  dirk:
    accounts:
    - holesky/0_0_0
    - holesky/1_0_0
    - holesky/2_0_0
    endpoints:
    - dirk-holesky-1:8294

vouch-1.7.6 works fine, and the regression is introduced in https://github.com/attestantio/vouch/commit/88456040331c43bc1a8c7c32d47d7f70c2993aa4 . Before the commit, all pubKeys come from the account map, which is filled in Line 206 of services.go. account[k] = v implicilty dedups even when the statement is executed multiple times, for identical k/v. Post-commit, all pubKeys come from L209 pubKeys = append(pubKeys, k) which no longer dedups.

But why do we even have duplicates? My accounts list in my vouch.yml lists the holesky wallet three times with three different accounts. The loop in L167-183 will be called on each line. For each line the loop will find the wallet name holesky, open it and add that object to the wallets array in L180 with wallets = append(wallets, wallet). So now we have the holesky wallet opened three times. In the gofunc around L195, the holesky wallet will be found to have three accounts, all of which match the verification regexp, so 3 accounts are add. As the gofunc will be run for each element of the 3-element wallets array, we end up with 9 pubkeys.

https://github.com/attestantio/vouch/pull/179 fixes this.

catwith1hat commented 8 months ago

Fixed with #179