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

Truncated fork version hex results in corrupted data #277

Closed
samczsun opened this issue Aug 30, 2022 · 0 comments · Fixed by #395
Closed

Truncated fork version hex results in corrupted data #277

samczsun opened this issue Aug 30, 2022 · 0 comments · Fixed by #395

Comments

@samczsun
Copy link

$ git --no-pager diff
diff --git a/server/utils.go b/server/utils.go
index 020b64d..43c2c5d 100644
--- a/server/utils.go
+++ b/server/utils.go
@@ -86,6 +86,7 @@ func ComputeDomain(domainType types.DomainType, forkVersionHex string, genesisVa
        }
        var forkVersion [4]byte
        copy(forkVersion[:], forkVersionBytes[:4])
+       fmt.Println(hexutil.Encode(forkVersion[:]))
        return types.ComputeDomain(domainType, forkVersion, genesisValidatorsRoot), nil
 }

$ go run main.go -relays https://0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000@example.com -genesis-fork-version 0xabcd
INFO[2022-08-30T01:24:39-07:00] mev-boost v0.7.11-dev                         module=cli
INFO[2022-08-30T01:24:39-07:00] Using genesis fork version: 0xabcd            module=cli
INFO[2022-08-30T01:24:39-07:00] using 1 relays                                module=cli relays="[{0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 https://0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000@example.com}]"
0xabcd6364
INFO[2022-08-30T01:24:39-07:00] listening on localhost:18550                  module=cli
^Csignal: interrupt

hexutil.Decode uses hex.DecodeString internally which reuses the input buffer:

https://cs.opensource.google/go/go/+/refs/tags/go1.19:src/encoding/hex/hex.go;l=118-124;drc=7f92ccea5ca5832a1dc63c02fc71db2d698f7915

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant