Skip to content

Commit

Permalink
cluster: align hash timestamp to unix (#2430)
Browse files Browse the repository at this point in the history
Aligns timestamp format of validator registration in hash calculation to unix format. This is done to avoid any confusion between timestamp in `cluster-lock.json` and the format used to calculate lock hash. Also it aligns the timestamp format with that of `go-eth2-client` types.

category: bug
ticket: #2436
  • Loading branch information
dB2510 authored Jul 17, 2023
1 parent 05fc4aa commit 9fd6e15
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 43 deletions.
11 changes: 3 additions & 8 deletions cluster/distvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,26 +231,21 @@ func byteSliceArrayToEthHex(data [][]byte) []ethHex {
return ret
}

func distValidatorsFromV1x7OrLater(distValidators []distValidatorJSONv1x7) ([]DistValidator, error) {
func distValidatorsFromV1x7OrLater(distValidators []distValidatorJSONv1x7) []DistValidator {
var resp []DistValidator
for _, dv := range distValidators {
var shares [][]byte
for _, share := range dv.PubShares {
shares = append(shares, share)
}

reg, err := registrationFromJSON(dv.BuilderRegistration)
if err != nil {
return nil, errors.Wrap(err, "registration from json")
}

resp = append(resp, DistValidator{
PubKey: dv.PubKey,
PubShares: shares,
DepositData: depositDataFromJSON(dv.DepositData),
BuilderRegistration: reg,
BuilderRegistration: registrationFromJSON(dv.BuilderRegistration),
})
}

return resp, nil
return resp
}
8 changes: 1 addition & 7 deletions cluster/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,20 +374,14 @@ func unmarshalLockV1x7OrLater(data []byte) (lock Lock, err error) {
return Lock{}, errors.Wrap(err, "unmarshal definition")
}

vals, err := distValidatorsFromV1x7OrLater(lockJSON.Validators)
if err != nil {
return Lock{}, err
}

var nodeSignatures [][]byte

for _, ns := range lockJSON.NodeSignatures {
nodeSignatures = append(nodeSignatures, ns)
}

lock = Lock{
Definition: lockJSON.Definition,
Validators: vals,
Validators: distValidatorsFromV1x7OrLater(lockJSON.Validators),
SignatureAggregate: lockJSON.SignatureAggregate,
LockHash: lockJSON.LockHash,
NodeSignatures: nodeSignatures,
Expand Down
4 changes: 2 additions & 2 deletions cluster/manifest/testdata/TestLegacyLock_cluster.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
initial_mutation_hash: "\t~e\xaeV\x92\xf4\xbf\\mj\xd6`\x9a\x96h\x1dw\x0b\x1d\xc0Z\xc5s]\x17T\xa9\x13\x0b\x97\x95"
latest_mutation_hash: "\t~e\xaeV\x92\xf4\xbf\\mj\xd6`\x9a\x96h\x1dw\x0b\x1d\xc0Z\xc5s]\x17T\xa9\x13\x0b\x97\x95"
initial_mutation_hash: "@$n\xca\x03\xa9\x01\xa6\xa1m\xbc]\x1c\xae:\xf5@\xb3`\x1a\x8b\xde5^\xa7\xb9\xd3\xc6\x06i\x83\xa6"
latest_mutation_hash: "@$n\xca\x03\xa9\x01\xa6\xa1m\xbc]\x1c\xae:\xf5@\xb3`\x1a\x8b\xde5^\xa7\xb9\xd3\xc6\x06i\x83\xa6"
name: "test cluster"
threshold: 3
dkg_algorithm: "frost"
Expand Down
2 changes: 1 addition & 1 deletion cluster/manifest/testdata/TestLegacyLock_proto.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mutation: {
type: "dv/legacy_lock/v0.0.1"
data: {
[type.googleapis.com/cluster.manifestpb.v1.LegacyLock]: {
json: "{\"cluster_definition\":{\"name\":\"test cluster\",\"creator\":{\"address\":\"0x5050A4F4b3f9338C3472dcC01A87C76A144b3c9c\",\"config_signature\":\"0x7ac969a117c2005fc7b2ce13e3abae5461b80891d0c11d8baea2cdeac7f9def672af39c6c1ec28d897833d5918980ce326a7517d607153427eeeb36b8a6a1c1700\"},\"operators\":[{\"address\":\"0x5050A4F4b3f9338C3472dcC01A87C76A144b3c9c\",\"enr\":\"enr:-HW4QIHPUOMb34YoizKGhz7nsDNQ7hCaiuwyscmeaOQ04awdH05gDnGrZhxDfzcfHssCDeB-esi99A2RoZia6UaYBCuAgmlkgnY0iXNlY3AyNTZrMaECTUts0TYQMsqb0q652QCqTUXZ6tgKyUIzdMRRpyVNB2Y\",\"config_signature\":\"0x038c2aa1d93d3492c46d6486e9747445f7a48d0d8658489ef90e3c348f2055a8475579fa9868cc649062e858460a32c2e55a9b47eca05188f9a68e80fa82c56800\",\"enr_signature\":\"0x20b5b4ba720053c6ea35a710cdd9d81440ae3a69c204edb06184ea2328ff3a290bd00c256d71f6f4daed2f995931b38c3f6bd0b17796f4e121278073e049086800\"},{\"address\":\"0x3325a78425F17a7E487Eb5666b2bFd93aBb06c70\",\"enr\":\"enr:-HW4QDztNDqgEPAgJoHkcF4LfXyjXUo1r_xYoNv48H0PFItwYx-OnviqgfHxEz51RDOGvUMiTpXyo0HBjK5ZZ8YxS9WAgmlkgnY0iXNlY3AyNTZrMaECUx_mBoE0UD0nIxMyJ8hnrI-myDxTfppEw8W9vcsf4zc\",\"config_signature\":\"0xc73465e844871675719518b4b402bbc89d33ad32c8107192a503a921c23d400f5de154b7c2fa21c054d74c98cebb468f29b713ba070d17aa5fcbefdbc40f25d100\",\"enr_signature\":\"0x9aa50b499754e19b7e30e12d6b2d63abc916edc7810aae9f3427f7d2a3cc33ad10f84d638ccb73817cd6a6eee311a52d45ea24f0d0f5452dc845ef24749e71ca00\"},{\"address\":\"0xc48B812bB43401392c037381AcA934F4069C0517\",\"enr\":\"enr:-HW4QGSS-HN3zRfCJGISFmDT59Cpo-daC4U2vSjqPZWegHVSJklFsDs0f1fF_E7X4q8NUbR3bWDlX7IifsjQ_Xrm7QuAgmlkgnY0iXNlY3AyNTZrMaEDRid5rUqtOVFGFHUacQhfLxDhx6WT5OAw77W4chzlWws\",\"config_signature\":\"0x3d0c45744c06bd6681e9426ee3ef177ee465eee0469b5ee4028e23e698676b2a77f20ceef5a67079402414f14967b32c248f9209a406e73678d6ec28a443815b00\",\"enr_signature\":\"0x6ecb15dda256fd34ea09a04db6c140387790d6902509df81fabab3889de4980f30c5d07480b12a0d4f3c6f75f56fe8c0f2b344311e092f53cd959367c5d67f7201\"},{\"address\":\"0xd09Ad14080d4b257a819a4f579b8485Be88f086c\",\"enr\":\"enr:-HW4QGFxPElPQZLydQ9Ach--g-jHJ0N4LO6uuIvyfw-Tg2K_R-R6iMCfzGryG80gmdPQwz9asajtn3CF88-rpu38YoKAgmlkgnY0iXNlY3AyNTZrMaEDYsCgRtrM6G3dA0PG08fHnCIIug2cnPJKbQRtIdIfkPc\",\"config_signature\":\"0x51462ad01f973b79e35339d02d63425f3c6918f0de0547f8cbb205bd168f9e95582660af8774fda452d73801e76ec7a487e866206ae2d6405b2ec11c9a2582e000\",\"enr_signature\":\"0x088602fe90f2ff191ef80fb7e3e3fa3e1fe38fea41ad4de2aa0d452875c5490563a88ed5a8c32b32602e929918accd4ec5b30df0184a2da3ab507667d52b037f00\"}],\"uuid\":\"6325253F-EC73-8DD7-A9E2-8BF921119C16\",\"version\":\"v1.7.0\",\"timestamp\":\"2023-05-24T20:17:34+05:30\",\"num_validators\":2,\"threshold\":3,\"validators\":[{\"fee_recipient_address\":\"0x4c7215a3b539eb1e5849c6077dbb5722f5717a28\",\"withdrawal_address\":\"0x0b4b373970115e82ed6f4125c8fa7311e4d7defa\"},{\"fee_recipient_address\":\"0x24abf7df866baa56038367ad6145de1ee8f4a8b0\",\"withdrawal_address\":\"0xb04883e56a156a8de563afa467d49dec6a40e9a1\"}],\"dkg_algorithm\":\"frost\",\"fork_version\":\"0x00001020\",\"config_hash\":\"0xe24af47d3eb1cc995dcb47d0c960fe8923bc1783ad3068f6cb2f79d61fa5d70c\",\"definition_hash\":\"0x0dbd688eba2c92374b548f3283fdb1e9673fbb16179021d4bbc85b3ebad2ca98\"},\"distributed_validators\":[{\"distributed_public_key\":\"0xacff76ec0c853e376d49a30b6fb9aaec53d265f5d1248d5dbd0f074a5a537b0ac2524c8875d522e32db84474f52497be\",\"public_shares\":[\"0xa3feea30fa15c31057f8854242635970282ae537215a3e250dad08d4302452511c395d9648bec87714b4f31575c9b65a\",\"0x8c6428b3f82208b6646ade1ecc9a20be28f2f2681b928fbbfd65efecfb42813f7ccc1e3bcfad9e361c29e33f12f59c8a\",\"0xa08cc49bd4cb498c3169f52c3fd939c16d10d21213920c28326ada1a857c63ecedf0f596bed975a8bd0990d6ffb073b4\",\"0xa3f6ce5eedce78b8607cb6d8e3f2ba20b6743aad73f02810d9d07ac8160cc12cb1a5f69f68547a85ca6f08b442fa0ec8\"],\"deposit_data\":{\"pubkey\":\"0xacff76ec0c853e376d49a30b6fb9aaec53d265f5d1248d5dbd0f074a5a537b0ac2524c8875d522e32db84474f52497be\",\"withdrawal_credentials\":\"0x0100000000000000000000000b4b373970115e82ed6f4125c8fa7311e4d7defa\",\"amount\":\"32000000000\",\"signature\":\"0xb9f2267c573dfd26c046fbef8e5c2e102d5126e14ff488a462748564d5ccea0806fd2d4b8cc0c45dc6bc284c79ca5bea0e1ee0b7882e370f0b9481a1c6369dc0cd92a300bef7365f648aacac797856cc7cac6d51f0e8103592a0356fcefbf3f4\"},\"builder_registration\":{\"message\":{\"fee_recipient\":\"0x4c7215a3b539eb1e5849c6077dbb5722f5717a28\",\"gas_limit\":30000000,\"timestamp\":\"2021-03-23T14:00:00Z\",\"pubkey\":\"0xacff76ec0c853e376d49a30b6fb9aaec53d265f5d1248d5dbd0f074a5a537b0ac2524c8875d522e32db84474f52497be\"},\"signature\":\"0x8dde908a5e0e0ceaa9043d0460954c20114feef74c8f7ec2af582993c343aeb58006439ac9591bdb80b124f4eba2b3b70ffdb4460ebed8cc29461b67e08e83bd4075cf770bda7ef4c610602d1cd45b85822386dc13d4af5d24ad7d0ed316a3b4\"}},{\"distributed_public_key\":\"0x879ecd7484e1d5b3e70806881518248e22c3033c4adf99f4c3252932191b97b334284b00fca1913e4fd30a9bb094b29b\",\"public_shares\":[\"0xa816a77dbb19902100ffb6e9aeec49907a0bbbe14c1d7da75ffbba8ab9c9505415abaa4941aab4d3e2564fcb2913d5d8\",\"0x98eaebe6e1f24bb75723355df5c337cd154213131102e59c1782ca9e75f2b7a315d8ec6784fd2898e0b0f14cfbc355f6\",\"0xb72a34d8339f26dbcfa680cacd059b284b719a46561caad84a0aa91472139ea99860e036a588e3f9d7d81d34d11b1808\",\"0x80f18a37ae951bc6658b23b7420e68972a5071df5e08e361e4c3bf2fcbbfa5ad74cdaa3c4c665d19c3fb70351f343adb\"],\"deposit_data\":{\"pubkey\":\"0x879ecd7484e1d5b3e70806881518248e22c3033c4adf99f4c3252932191b97b334284b00fca1913e4fd30a9bb094b29b\",\"withdrawal_credentials\":\"0x010000000000000000000000b04883e56a156a8de563afa467d49dec6a40e9a1\",\"amount\":\"32000000000\",\"signature\":\"0xae7b3294921037689be3e13c837f41a299aa3dd12943c4847ec0c8897afee4e8354863d9c038489fff338d2ea1a38779004f8c3e4d62339354864aaa014b6b89b0ea8ee51d0ef79d54f4c727ae468c43e28b6424daf9d78cac8a4e5abf1aa837\"},\"builder_registration\":{\"message\":{\"fee_recipient\":\"0x24abf7df866baa56038367ad6145de1ee8f4a8b0\",\"gas_limit\":30000000,\"timestamp\":\"2021-03-23T14:00:00Z\",\"pubkey\":\"0x879ecd7484e1d5b3e70806881518248e22c3033c4adf99f4c3252932191b97b334284b00fca1913e4fd30a9bb094b29b\"},\"signature\":\"0x8a5bc9c5b71ede0457a6d9b019992e51c33aa785378ff709b327c625b519eecd313aca77291261df8b552d8751ecb27605a9e7d6ea4413e1e7fda4e8949c3ed1833aba7de26a4a06cd15f51d57669f24395a1ce6832d768d796de268921bc6d2\"}}],\"signature_aggregate\":\"0xb71c1347770a94076705376c28b03c7773f4a99a5ebef223aa1054164aa24bc5e2f56fee614e0c88dddd8f392198b180180f364f1c11a82d1ce894016a9877d0902080716be812de49853e2cd8192a9e2f8d16b87f559461d280bded903006e3\",\"lock_hash\":\"0x097e65ae5692f4bf5c6d6ad6609a96681d770b1dc05ac5735d1754a9130b9795\",\"node_signatures\":[\"0xc9772a16bd180f225ed208017ac1a3d6da5f0fc167fd7ac3bb3a95c90a5599ad4d66e4c69f589ec4cb423d3c62bd5361c61dcd44b7371023f1ef8afad606e56000\",\"0x09dd97256be0adc2d8b99c42b2acce6aa4b36095f919020f67b90c42702df331271a4e91245bcc3b876a29678bccd620dee3c2e9c7d4a57e9c361aba29442e0400\",\"0xf80a81198f476a66b87eb77044c30abd8ff1ff3e4aaa91de2fc735bdc6f07fe36e60c3fee0067e2bbc568ab65c3a598be0acd1bc6e2e11dde8bee888133f9ed800\",\"0x5b360dfd19d58b88197860190a52b8312f8a0fc66a509e77ff5028336fd94ee813b071f9abbd1dd1c7831584d40e34a4ef961ff37b75805cd6ea2a45f85cf4b300\"]}"
json: "{\"cluster_definition\":{\"name\":\"test cluster\",\"creator\":{\"address\":\"0x5050A4F4b3f9338C3472dcC01A87C76A144b3c9c\",\"config_signature\":\"0x7ac969a117c2005fc7b2ce13e3abae5461b80891d0c11d8baea2cdeac7f9def672af39c6c1ec28d897833d5918980ce326a7517d607153427eeeb36b8a6a1c1700\"},\"operators\":[{\"address\":\"0x5050A4F4b3f9338C3472dcC01A87C76A144b3c9c\",\"enr\":\"enr:-HW4QIHPUOMb34YoizKGhz7nsDNQ7hCaiuwyscmeaOQ04awdH05gDnGrZhxDfzcfHssCDeB-esi99A2RoZia6UaYBCuAgmlkgnY0iXNlY3AyNTZrMaECTUts0TYQMsqb0q652QCqTUXZ6tgKyUIzdMRRpyVNB2Y\",\"config_signature\":\"0x038c2aa1d93d3492c46d6486e9747445f7a48d0d8658489ef90e3c348f2055a8475579fa9868cc649062e858460a32c2e55a9b47eca05188f9a68e80fa82c56800\",\"enr_signature\":\"0x20b5b4ba720053c6ea35a710cdd9d81440ae3a69c204edb06184ea2328ff3a290bd00c256d71f6f4daed2f995931b38c3f6bd0b17796f4e121278073e049086800\"},{\"address\":\"0x3325a78425F17a7E487Eb5666b2bFd93aBb06c70\",\"enr\":\"enr:-HW4QDztNDqgEPAgJoHkcF4LfXyjXUo1r_xYoNv48H0PFItwYx-OnviqgfHxEz51RDOGvUMiTpXyo0HBjK5ZZ8YxS9WAgmlkgnY0iXNlY3AyNTZrMaECUx_mBoE0UD0nIxMyJ8hnrI-myDxTfppEw8W9vcsf4zc\",\"config_signature\":\"0xc73465e844871675719518b4b402bbc89d33ad32c8107192a503a921c23d400f5de154b7c2fa21c054d74c98cebb468f29b713ba070d17aa5fcbefdbc40f25d100\",\"enr_signature\":\"0x9aa50b499754e19b7e30e12d6b2d63abc916edc7810aae9f3427f7d2a3cc33ad10f84d638ccb73817cd6a6eee311a52d45ea24f0d0f5452dc845ef24749e71ca00\"},{\"address\":\"0xc48B812bB43401392c037381AcA934F4069C0517\",\"enr\":\"enr:-HW4QGSS-HN3zRfCJGISFmDT59Cpo-daC4U2vSjqPZWegHVSJklFsDs0f1fF_E7X4q8NUbR3bWDlX7IifsjQ_Xrm7QuAgmlkgnY0iXNlY3AyNTZrMaEDRid5rUqtOVFGFHUacQhfLxDhx6WT5OAw77W4chzlWws\",\"config_signature\":\"0x3d0c45744c06bd6681e9426ee3ef177ee465eee0469b5ee4028e23e698676b2a77f20ceef5a67079402414f14967b32c248f9209a406e73678d6ec28a443815b00\",\"enr_signature\":\"0x6ecb15dda256fd34ea09a04db6c140387790d6902509df81fabab3889de4980f30c5d07480b12a0d4f3c6f75f56fe8c0f2b344311e092f53cd959367c5d67f7201\"},{\"address\":\"0xd09Ad14080d4b257a819a4f579b8485Be88f086c\",\"enr\":\"enr:-HW4QGFxPElPQZLydQ9Ach--g-jHJ0N4LO6uuIvyfw-Tg2K_R-R6iMCfzGryG80gmdPQwz9asajtn3CF88-rpu38YoKAgmlkgnY0iXNlY3AyNTZrMaEDYsCgRtrM6G3dA0PG08fHnCIIug2cnPJKbQRtIdIfkPc\",\"config_signature\":\"0x51462ad01f973b79e35339d02d63425f3c6918f0de0547f8cbb205bd168f9e95582660af8774fda452d73801e76ec7a487e866206ae2d6405b2ec11c9a2582e000\",\"enr_signature\":\"0x088602fe90f2ff191ef80fb7e3e3fa3e1fe38fea41ad4de2aa0d452875c5490563a88ed5a8c32b32602e929918accd4ec5b30df0184a2da3ab507667d52b037f00\"}],\"uuid\":\"6325253F-EC73-8DD7-A9E2-8BF921119C16\",\"version\":\"v1.7.0\",\"timestamp\":\"2023-05-24T20:17:34+05:30\",\"num_validators\":2,\"threshold\":3,\"validators\":[{\"fee_recipient_address\":\"0x4c7215a3b539eb1e5849c6077dbb5722f5717a28\",\"withdrawal_address\":\"0x0b4b373970115e82ed6f4125c8fa7311e4d7defa\"},{\"fee_recipient_address\":\"0x24abf7df866baa56038367ad6145de1ee8f4a8b0\",\"withdrawal_address\":\"0xb04883e56a156a8de563afa467d49dec6a40e9a1\"}],\"dkg_algorithm\":\"frost\",\"fork_version\":\"0x00001020\",\"config_hash\":\"0xe24af47d3eb1cc995dcb47d0c960fe8923bc1783ad3068f6cb2f79d61fa5d70c\",\"definition_hash\":\"0x0dbd688eba2c92374b548f3283fdb1e9673fbb16179021d4bbc85b3ebad2ca98\"},\"distributed_validators\":[{\"distributed_public_key\":\"0xacff76ec0c853e376d49a30b6fb9aaec53d265f5d1248d5dbd0f074a5a537b0ac2524c8875d522e32db84474f52497be\",\"public_shares\":[\"0xa3feea30fa15c31057f8854242635970282ae537215a3e250dad08d4302452511c395d9648bec87714b4f31575c9b65a\",\"0x8c6428b3f82208b6646ade1ecc9a20be28f2f2681b928fbbfd65efecfb42813f7ccc1e3bcfad9e361c29e33f12f59c8a\",\"0xa08cc49bd4cb498c3169f52c3fd939c16d10d21213920c28326ada1a857c63ecedf0f596bed975a8bd0990d6ffb073b4\",\"0xa3f6ce5eedce78b8607cb6d8e3f2ba20b6743aad73f02810d9d07ac8160cc12cb1a5f69f68547a85ca6f08b442fa0ec8\"],\"deposit_data\":{\"pubkey\":\"0xacff76ec0c853e376d49a30b6fb9aaec53d265f5d1248d5dbd0f074a5a537b0ac2524c8875d522e32db84474f52497be\",\"withdrawal_credentials\":\"0x0100000000000000000000000b4b373970115e82ed6f4125c8fa7311e4d7defa\",\"amount\":\"32000000000\",\"signature\":\"0xb9f2267c573dfd26c046fbef8e5c2e102d5126e14ff488a462748564d5ccea0806fd2d4b8cc0c45dc6bc284c79ca5bea0e1ee0b7882e370f0b9481a1c6369dc0cd92a300bef7365f648aacac797856cc7cac6d51f0e8103592a0356fcefbf3f4\"},\"builder_registration\":{\"message\":{\"fee_recipient\":\"0x4c7215a3b539eb1e5849c6077dbb5722f5717a28\",\"gas_limit\":30000000,\"timestamp\":1616508000,\"pubkey\":\"0xacff76ec0c853e376d49a30b6fb9aaec53d265f5d1248d5dbd0f074a5a537b0ac2524c8875d522e32db84474f52497be\"},\"signature\":\"0x8dde908a5e0e0ceaa9043d0460954c20114feef74c8f7ec2af582993c343aeb58006439ac9591bdb80b124f4eba2b3b70ffdb4460ebed8cc29461b67e08e83bd4075cf770bda7ef4c610602d1cd45b85822386dc13d4af5d24ad7d0ed316a3b4\"}},{\"distributed_public_key\":\"0x879ecd7484e1d5b3e70806881518248e22c3033c4adf99f4c3252932191b97b334284b00fca1913e4fd30a9bb094b29b\",\"public_shares\":[\"0xa816a77dbb19902100ffb6e9aeec49907a0bbbe14c1d7da75ffbba8ab9c9505415abaa4941aab4d3e2564fcb2913d5d8\",\"0x98eaebe6e1f24bb75723355df5c337cd154213131102e59c1782ca9e75f2b7a315d8ec6784fd2898e0b0f14cfbc355f6\",\"0xb72a34d8339f26dbcfa680cacd059b284b719a46561caad84a0aa91472139ea99860e036a588e3f9d7d81d34d11b1808\",\"0x80f18a37ae951bc6658b23b7420e68972a5071df5e08e361e4c3bf2fcbbfa5ad74cdaa3c4c665d19c3fb70351f343adb\"],\"deposit_data\":{\"pubkey\":\"0x879ecd7484e1d5b3e70806881518248e22c3033c4adf99f4c3252932191b97b334284b00fca1913e4fd30a9bb094b29b\",\"withdrawal_credentials\":\"0x010000000000000000000000b04883e56a156a8de563afa467d49dec6a40e9a1\",\"amount\":\"32000000000\",\"signature\":\"0xae7b3294921037689be3e13c837f41a299aa3dd12943c4847ec0c8897afee4e8354863d9c038489fff338d2ea1a38779004f8c3e4d62339354864aaa014b6b89b0ea8ee51d0ef79d54f4c727ae468c43e28b6424daf9d78cac8a4e5abf1aa837\"},\"builder_registration\":{\"message\":{\"fee_recipient\":\"0x24abf7df866baa56038367ad6145de1ee8f4a8b0\",\"gas_limit\":30000000,\"timestamp\":1616508000,\"pubkey\":\"0x879ecd7484e1d5b3e70806881518248e22c3033c4adf99f4c3252932191b97b334284b00fca1913e4fd30a9bb094b29b\"},\"signature\":\"0x8a5bc9c5b71ede0457a6d9b019992e51c33aa785378ff709b327c625b519eecd313aca77291261df8b552d8751ecb27605a9e7d6ea4413e1e7fda4e8949c3ed1833aba7de26a4a06cd15f51d57669f24395a1ce6832d768d796de268921bc6d2\"}}],\"signature_aggregate\":\"0xb71c1347770a94076705376c28b03c7773f4a99a5ebef223aa1054164aa24bc5e2f56fee614e0c88dddd8f392198b180180f364f1c11a82d1ce894016a9877d0902080716be812de49853e2cd8192a9e2f8d16b87f559461d280bded903006e3\",\"lock_hash\":\"0x40246eca03a901a6a16dbc5d1cae3af540b3601a8bde355ea7b9d3c6066983a6\",\"node_signatures\":[\"0xc9772a16bd180f225ed208017ac1a3d6da5f0fc167fd7ac3bb3a95c90a5599ad4d66e4c69f589ec4cb423d3c62bd5361c61dcd44b7371023f1ef8afad606e56000\",\"0x09dd97256be0adc2d8b99c42b2acce6aa4b36095f919020f67b90c42702df331271a4e91245bcc3b876a29678bccd620dee3c2e9c7d4a57e9c361aba29442e0400\",\"0xf80a81198f476a66b87eb77044c30abd8ff1ff3e4aaa91de2fc735bdc6f07fe36e60c3fee0067e2bbc568ab65c3a598be0acd1bc6e2e11dde8bee888133f9ed800\",\"0x5b360dfd19d58b88197860190a52b8312f8a0fc66a509e77ff5028336fd94ee813b071f9abbd1dd1c7831584d40e34a4ef961ff37b75805cd6ea2a45f85cf4b300\"]}"
}
}
}
6 changes: 3 additions & 3 deletions cluster/manifest/testdata/lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"message": {
"fee_recipient": "0x4c7215a3b539eb1e5849c6077dbb5722f5717a28",
"gas_limit": 30000000,
"timestamp": "2021-03-23T14:00:00Z",
"timestamp": 1616508000,
"pubkey": "0xacff76ec0c853e376d49a30b6fb9aaec53d265f5d1248d5dbd0f074a5a537b0ac2524c8875d522e32db84474f52497be"
},
"signature": "0x8dde908a5e0e0ceaa9043d0460954c20114feef74c8f7ec2af582993c343aeb58006439ac9591bdb80b124f4eba2b3b70ffdb4460ebed8cc29461b67e08e83bd4075cf770bda7ef4c610602d1cd45b85822386dc13d4af5d24ad7d0ed316a3b4"
Expand All @@ -94,15 +94,15 @@
"message": {
"fee_recipient": "0x24abf7df866baa56038367ad6145de1ee8f4a8b0",
"gas_limit": 30000000,
"timestamp": "2021-03-23T14:00:00Z",
"timestamp": 1616508000,
"pubkey": "0x879ecd7484e1d5b3e70806881518248e22c3033c4adf99f4c3252932191b97b334284b00fca1913e4fd30a9bb094b29b"
},
"signature": "0x8a5bc9c5b71ede0457a6d9b019992e51c33aa785378ff709b327c625b519eecd313aca77291261df8b552d8751ecb27605a9e7d6ea4413e1e7fda4e8949c3ed1833aba7de26a4a06cd15f51d57669f24395a1ce6832d768d796de268921bc6d2"
}
}
],
"signature_aggregate": "0xb71c1347770a94076705376c28b03c7773f4a99a5ebef223aa1054164aa24bc5e2f56fee614e0c88dddd8f392198b180180f364f1c11a82d1ce894016a9877d0902080716be812de49853e2cd8192a9e2f8d16b87f559461d280bded903006e3",
"lock_hash": "0x097e65ae5692f4bf5c6d6ad6609a96681d770b1dc05ac5735d1754a9130b9795",
"lock_hash": "0x40246eca03a901a6a16dbc5d1cae3af540b3601a8bde355ea7b9d3c6066983a6",
"node_signatures": [
"0xc9772a16bd180f225ed208017ac1a3d6da5f0fc167fd7ac3bb3a95c90a5599ad4d66e4c69f589ec4cb423d3c62bd5361c61dcd44b7371023f1ef8afad606e56000",
"0x09dd97256be0adc2d8b99c42b2acce6aa4b36095f919020f67b90c42702df331271a4e91245bcc3b876a29678bccd620dee3c2e9c7d4a57e9c361aba29442e0400",
Expand Down
17 changes: 5 additions & 12 deletions cluster/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ package cluster

import (
"time"

"github.com/obolnetwork/charon/app/errors"
)

// BuilderRegistration defines pre-generated signed validator builder registration to be sent to builder network.
Expand All @@ -32,7 +30,7 @@ type builderRegistrationJSON struct {
type registrationJSON struct {
FeeRecipient ethHex `json:"fee_recipient"`
GasLimit int `json:"gas_limit"`
Timestamp string `json:"timestamp"`
Timestamp int `json:"timestamp"`
PubKey ethHex `json:"pubkey"`
}

Expand All @@ -42,27 +40,22 @@ func registrationToJSON(b BuilderRegistration) builderRegistrationJSON {
Message: registrationJSON{
FeeRecipient: b.Message.FeeRecipient,
GasLimit: b.Message.GasLimit,
Timestamp: b.Message.Timestamp.Format(time.RFC3339),
Timestamp: int(b.Message.Timestamp.Unix()),
PubKey: b.Message.PubKey,
},
Signature: b.Signature,
}
}

// registrationFromJSON converts registrationFromJSON to BuilderRegistration.
func registrationFromJSON(b builderRegistrationJSON) (BuilderRegistration, error) {
timestamp, err := time.Parse(time.RFC3339, b.Message.Timestamp)
if err != nil {
return BuilderRegistration{}, errors.Wrap(err, "parse timestamp")
}

func registrationFromJSON(b builderRegistrationJSON) BuilderRegistration {
return BuilderRegistration{
Message: Registration{
FeeRecipient: b.Message.FeeRecipient,
GasLimit: b.Message.GasLimit,
Timestamp: timestamp,
Timestamp: time.Unix(int64(b.Message.Timestamp), 0),
PubKey: b.Message.PubKey,
},
Signature: b.Signature,
}, nil
}
}
Loading

0 comments on commit 9fd6e15

Please sign in to comment.