Skip to content

Commit

Permalink
Fix Deneb Bid Signing (#9)
Browse files Browse the repository at this point in the history
* Update zrnt to fixed version

* Fix deneb slot calculation from signed beacon block
  • Loading branch information
marioevz authored Sep 14, 2023
1 parent 0a70254 commit ec533c6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 57 deletions.
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (

require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/allegro/bigcache v1.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -23,7 +24,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230404150825-93eff0a72e22 // indirect
github.com/cockroachdb/pebble v0.0.0-20230821143352-55b44ac08de8 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.10.0 // indirect
Expand Down Expand Up @@ -70,17 +71,18 @@ require (
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.9.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/ethereum/go-ethereum => github.com/lightclient/go-ethereum v1.10.10-0.20230822214239-edf4ab3a0003
replace github.com/ethereum/go-ethereum => github.com/lightclient/go-ethereum v1.10.10-0.20230829211949-79f3c2d9c96b

replace github.com/protolambda/eth2api => github.com/marioevz/eth2api v0.0.0-20230823170424-c49aeeefbc40

replace github.com/protolambda/zrnt => github.com/marioevz/zrnt v0.26.2-0.20230830002615-6770fa799a31
replace github.com/protolambda/zrnt => github.com/marioevz/zrnt v0.26.2-0.20230913212925-b3d7bca98b12
22 changes: 13 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMd
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
Expand All @@ -30,15 +32,15 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cockroachdb/datadriven v1.0.2 h1:H9MtNqVoVhvd9nCBwOyDjUEdZCREqbIdCJD93PBm/jA=
github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877 h1:1MLK4YpFtIEo3ZtMA5C795Wtv5VuUnrXX7mQG+aHg6o=
github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8=
github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk=
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
github.com/cockroachdb/pebble v0.0.0-20230404150825-93eff0a72e22 h1:2Nwgec/S3FkQW3r807JL9+D2xb2XU9zbRCotvQWLIfY=
github.com/cockroachdb/pebble v0.0.0-20230404150825-93eff0a72e22/go.mod h1:9lRMC4XN3/BLPtIp6kAKwIaHu369NOf2rMucPzipz50=
github.com/cockroachdb/pebble v0.0.0-20230821143352-55b44ac08de8 h1:2fNOyQqrHSjFdqnKqSLj9W7eGTcqKujJPA8vAuT1zN8=
github.com/cockroachdb/pebble v0.0.0-20230821143352-55b44ac08de8/go.mod h1:bynZ3gvVyhlvjLI7PT6dmZ7g76xzJ7HpxfjgkzCGz6s=
github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ=
github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
Expand Down Expand Up @@ -206,15 +208,15 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y=
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/lightclient/go-ethereum v1.10.10-0.20230822214239-edf4ab3a0003 h1:cpyBAHdWNvnTXrLjO93Ks1TOQ7SqIiykwjSI2a+WAXA=
github.com/lightclient/go-ethereum v1.10.10-0.20230822214239-edf4ab3a0003/go.mod h1:ajli8dy5OcMaIkZSOEApZPUesGX6S9jPduNnfnISGWY=
github.com/lightclient/go-ethereum v1.10.10-0.20230829211949-79f3c2d9c96b h1:dglsK4NuDRreW5+/0EoTFxCiZwkRZay/aDoOul2lca0=
github.com/lightclient/go-ethereum v1.10.10-0.20230829211949-79f3c2d9c96b/go.mod h1:UWQqzN9473khWbdvlh2QjYXX0ykhKT1OuPYus9Hgv+o=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/marioevz/eth-clients v0.0.0-20230823175101-fdc85382188d h1:X5kDuhc/KJmftpz4lr1xGLQeLMsXScF0ui77rvyclto=
github.com/marioevz/eth-clients v0.0.0-20230823175101-fdc85382188d/go.mod h1:LZb4HPhmomFs5C3Rxj57X83yp3qzQHgB/xDAsvrFmDw=
github.com/marioevz/eth2api v0.0.0-20230823170424-c49aeeefbc40 h1:XjtFopxKQTfRvzPiVkWATIxmTzN+i068THS3r9KLoaA=
github.com/marioevz/eth2api v0.0.0-20230823170424-c49aeeefbc40/go.mod h1:hcwWCT4sF1X7KsMZ535MvDZVk5M20Uyj+x2LARZjQsM=
github.com/marioevz/zrnt v0.26.2-0.20230830002615-6770fa799a31 h1:Ce9yBXc1xf8zT6y3D+InCG9O/LOctot5z5bY0OEPNEM=
github.com/marioevz/zrnt v0.26.2-0.20230830002615-6770fa799a31/go.mod h1:MzAcHPo2QQIx+IEPdxXMiqKtYRUlszz7RA/fhAuOm1I=
github.com/marioevz/zrnt v0.26.2-0.20230913212925-b3d7bca98b12 h1:GYaGAbG2PvKazxtrpxesu2TRgn2gWt24xmte72wftOA=
github.com/marioevz/zrnt v0.26.2-0.20230913212925-b3d7bca98b12/go.mod h1:MzAcHPo2QQIx+IEPdxXMiqKtYRUlszz7RA/fhAuOm1I=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
Expand Down Expand Up @@ -386,6 +388,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -483,6 +487,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down Expand Up @@ -525,8 +531,6 @@ gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/R
gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
57 changes: 32 additions & 25 deletions mock/mock_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,10 @@ type MessageSlotEnvelope struct {
SlotEnvelope SlotEnvelope `json:"message" yaml:"message"`
}

type DenebMessageSlotEnvelope struct {
MessageSlotEnvelope MessageSlotEnvelope `json:"signed_blinded_block" yaml:"signed_blinded_block"`
}

func (m *MockBuilder) HandleSubmitBlindedBlock(
w http.ResponseWriter, req *http.Request,
) {
Expand All @@ -1106,29 +1110,32 @@ func (m *MockBuilder) HandleSubmitBlindedBlock(
return
}


// First try to find out the slot to get the version of the block
var messageSlotEnvelope MessageSlotEnvelope
if err := json.Unmarshal(requestBytes, &messageSlotEnvelope); err != nil {
logrus.WithFields(logrus.Fields{
"builder_id": m.cfg.id,
"err": err,
}).Error("Unable to parse request body")
http.Error(w, "Unable to parse request body", http.StatusBadRequest)
return
var slot beacon.Slot
{
var messageSlotEnvelope MessageSlotEnvelope
if err := json.Unmarshal(requestBytes, &messageSlotEnvelope); err == nil {
slot = messageSlotEnvelope.SlotEnvelope.Slot
}

if slot == 0 {
// Try with deneb
var denebMessageSlotEnvelope DenebMessageSlotEnvelope
if err := json.Unmarshal(requestBytes, &denebMessageSlotEnvelope); err == nil {
slot = denebMessageSlotEnvelope.MessageSlotEnvelope.SlotEnvelope.Slot
}
}
}

var (
signedBeaconResponse common.SignedBeaconResponse
)
if m.cfg.spec.SlotToEpoch(
messageSlotEnvelope.SlotEnvelope.Slot,
) >= m.cfg.spec.DENEB_FORK_EPOCH {
if m.cfg.spec.SlotToEpoch(slot) >= m.cfg.spec.DENEB_FORK_EPOCH {
signedBeaconResponse = &deneb.SignedBlindedBlockContents{}
} else if m.cfg.spec.SlotToEpoch(
messageSlotEnvelope.SlotEnvelope.Slot,
) >= m.cfg.spec.CAPELLA_FORK_EPOCH {
} else if m.cfg.spec.SlotToEpoch(slot) >= m.cfg.spec.CAPELLA_FORK_EPOCH {
signedBeaconResponse = &capella.SignedBeaconResponse{}
} else if m.cfg.spec.SlotToEpoch(messageSlotEnvelope.SlotEnvelope.Slot) >= m.cfg.spec.BELLATRIX_FORK_EPOCH {
} else if m.cfg.spec.SlotToEpoch(slot) >= m.cfg.spec.BELLATRIX_FORK_EPOCH {
signedBeaconResponse = &bellatrix.SignedBeaconResponse{}
} else {
logrus.WithFields(logrus.Fields{
Expand All @@ -1153,11 +1160,11 @@ func (m *MockBuilder) HandleSubmitBlindedBlock(
}

// Look up the payload in the history of bids
builtBid, ok := m.builtPayloads[messageSlotEnvelope.SlotEnvelope.Slot]
builtBid, ok := m.builtPayloads[slot]
if !ok {
logrus.WithFields(logrus.Fields{
"builder_id": m.cfg.id,
"slot": messageSlotEnvelope.SlotEnvelope.Slot,
"slot": slot,
}).Error("Could not find payload in history")
http.Error(w, "Unable to get payload", http.StatusInternalServerError)
return
Expand All @@ -1173,11 +1180,11 @@ func (m *MockBuilder) HandleSubmitBlindedBlock(
m.receivedSignedBeaconBlocksMutex.Unlock()

// Obtain the public key used to validate the signed beacon response
pubkey := m.validatorPublicKeys[signedBeaconResponse.Slot()]
if pubkey == nil {
pubkey, ok := m.validatorPublicKeys[signedBeaconResponse.Slot()]
if pubkey == nil || !ok {
logrus.WithFields(logrus.Fields{
"builder_id": m.cfg.id,
"slot": messageSlotEnvelope.SlotEnvelope.Slot,
"slot": slot,
}).Error("Could not find public key in history")
http.Error(
w,
Expand All @@ -1190,7 +1197,7 @@ func (m *MockBuilder) HandleSubmitBlindedBlock(
if err != nil {
logrus.WithFields(logrus.Fields{
"builder_id": m.cfg.id,
"slot": messageSlotEnvelope.SlotEnvelope.Slot,
"slot": slot,
}).Error("Could not convert public key")
http.Error(
w,
Expand All @@ -1201,12 +1208,12 @@ func (m *MockBuilder) HandleSubmitBlindedBlock(
}

unblindedResponse, err := builtBid.ValidateReveal(
pk, signedBeaconResponse, m.cfg.spec, messageSlotEnvelope.SlotEnvelope.Slot, m.cl.Config.GenesisValidatorsRoot,
pk, signedBeaconResponse, m.cfg.spec, slot, m.cl.Config.GenesisValidatorsRoot,
)
if err != nil {
logrus.WithFields(logrus.Fields{
"builder_id": m.cfg.id,
"slot": messageSlotEnvelope.SlotEnvelope.Slot,
"slot": slot,
"err": err,
}).Error("Error validating signed beacon response")
http.Error(
Expand Down Expand Up @@ -1236,10 +1243,10 @@ func (m *MockBuilder) HandleSubmitBlindedBlock(
errOnPayloadReveal := m.cfg.errorOnPayloadReveal
m.cfg.mutex.Unlock()
if errOnPayloadReveal != nil {
if err := errOnPayloadReveal(messageSlotEnvelope.SlotEnvelope.Slot); err != nil {
if err := errOnPayloadReveal(slot); err != nil {
logrus.WithFields(logrus.Fields{
"builder_id": m.cfg.id,
"slot": messageSlotEnvelope.SlotEnvelope.Slot,
"slot": slot,
"err": err,
}).Error("Simulated error")
http.Error(
Expand Down
8 changes: 4 additions & 4 deletions mock/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,12 @@ func genPayloadInvalidator(
_, err = rand.Read(header.ReceiptHash[:])
copy(ed.ReceiptsRoot[:], header.ReceiptHash[:])
case INVALIDATE_PAYLOAD_BEACON_ROOT:
if header.BeaconRoot == nil {
header.BeaconRoot = new(el_common.Hash)
if header.ParentBeaconRoot == nil {
header.ParentBeaconRoot = new(el_common.Hash)
}
_, err = rand.Read(header.BeaconRoot[:])
_, err = rand.Read(header.ParentBeaconRoot[:])
if beaconRoot != nil {
copy(beaconRoot[:], header.BeaconRoot[:])
copy(beaconRoot[:], header.ParentBeaconRoot[:])
}
default:
panic(fmt.Errorf(
Expand Down
15 changes: 6 additions & 9 deletions types/deneb/deneb.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type UnblindedResponseData struct {
}

func (b *BuilderBid) ValidateReveal(publicKey *blsu.Pubkey, signedBeaconResponse common.SignedBeaconResponse, spec *beacon.Spec, slot beacon.Slot, genesisValidatorsRoot *tree.Root) (*common.UnblindedResponse, error) {

sbb, ok := signedBeaconResponse.(*SignedBlindedBlockContents)
if !ok {
return nil, fmt.Errorf("invalid signed beacon response")
Expand All @@ -73,11 +72,14 @@ func (b *BuilderBid) ValidateReveal(publicKey *blsu.Pubkey, signedBeaconResponse
if beaconBlock.HashTreeRoot(spec, tree.GetHashFn()) != blockRoot {
return nil, fmt.Errorf("unblinded block root does not match")
}

dom := beacon.ComputeDomain(beacon.DOMAIN_BEACON_PROPOSER, spec.ForkVersion(slot), *genesisValidatorsRoot)
forkVersion := spec.ForkVersion(slot)
if forkVersion != spec.DENEB_FORK_VERSION {
return nil, fmt.Errorf("invalid fork version")
}
dom := beacon.ComputeDomain(beacon.DOMAIN_BEACON_PROPOSER, forkVersion, *genesisValidatorsRoot)
signingRoot := beacon.ComputeSigningRoot(blockRoot, dom)
if !blsu.Verify(publicKey, signingRoot[:], s) {
return nil, fmt.Errorf("block invalid signature")
return nil, fmt.Errorf("invalid block signature")
}

for i, signedBlindedBlobSidecar := range sbb.SignedBlindedBlobSidecars {
Expand Down Expand Up @@ -119,11 +121,6 @@ func (b *BuilderBid) ValidateReveal(publicKey *blsu.Pubkey, signedBeaconResponse
}, nil
}

func (sbb *SignedBlindedBlockContents) Validate(pk *blsu.Pubkey, spec *beacon.Spec, slot beacon.Slot, genesisValidatorsRoot *tree.Root, ep common.ExecutionPayload, bb common.BlobsBundle) error {

return nil
}

type BlobsBundle struct {
*deneb.BlobsBundle
Source *api.BlobsBundleV1
Expand Down
12 changes: 6 additions & 6 deletions types/deneb/deneb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func TestDenebBidBuilding(t *testing.T) {

func TestBidHashTreeRoot(t *testing.T) {
for i, tc := range []struct {
jsonBid string
expectedHash string
jsonBid string
expectedHTR string
}{
{
jsonBid: `{
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestBidHashTreeRoot(t *testing.T) {
"value": "8400000000000000",
"pubkey": "0x95fde78acd5f6886ddaf5d0056610167c513d09c1c0efabbc7cdcc69beea113779c4a81e2d24daafc5387dbf6ac5fe48"
}`,
expectedHash: "0xfdc1374279c7f4ac309ded5f9e028f60f07eafdb012f835f1ef4969a76e750c4",
expectedHTR: "0xed095772eca7c6c826a33e9945380a749b2d88f347f018ed46d97582c5f9a955",
},
} {
t.Run(fmt.Sprintf("htr-%d", i), func(t *testing.T) {
Expand All @@ -144,9 +144,9 @@ func TestBidHashTreeRoot(t *testing.T) {
t.Errorf("failed to unmarshal json: %v", err)
}
bidHash := builderBid.HashTreeRoot(configs.Mainnet, tree.GetHashFn())
expectedHash := el_common.HexToHash(tc.expectedHash)
if !bytes.Equal(bidHash[:], expectedHash[:]) {
t.Errorf("expected hash %s, got %s", expectedHash, bidHash)
expectedHTR := el_common.HexToHash(tc.expectedHTR)
if !bytes.Equal(bidHash[:], expectedHTR[:]) {
t.Errorf("expected hash %s, got %s", expectedHTR, bidHash)
}
})
}
Expand Down

0 comments on commit ec533c6

Please sign in to comment.