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

Add deneb util functions #87

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ bench:
fuzz:
./scripts/fuzz.sh

fmt:
gofmt -s -w .
gofumpt -extra -w .
gci write .
go mod tidy

lint:
gofmt -d -s .
gofumpt -d -extra .
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ require (
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
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-20230209160836-829675f94811 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/ferranbt/fastssz v0.1.3 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo=
github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down Expand Up @@ -58,9 +58,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc=
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
Expand Down
27 changes: 27 additions & 0 deletions testdata/executionpayload/deneb-case0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"parent_hash": "0x07a15d53adf68538385202bd29729ee2834ddcaea852fed42fc78eadafb211dc",
"fee_recipient": "0xf97e180c050e5ab072211ad2c213eb5aee4df134",
"state_root": "0xcd4b9544c91d43292baeb682b60bf5a2e65fb03ca2d03bb313a5719885d14524",
"receipts_root": "0xc88bbb6ffab5658b295a44086ed7e77d4526e07e4025496e68a55042b24c81be",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prev_randao": "0x8cd05fe90f408b377ab9fd9a57bb77b291d02535686d72d7f25fc30225d8ea82",
"block_number": "180474",
"gas_limit": "30000000",
"gas_used": "126000",
"timestamp": "1690348728",
"extra_data": "0x4e65746865726d696e64",
"base_fee_per_gas": "7",
"block_hash": "0x6fdbdbce83765e4196c1cc104aaad70385bdda458c11703a7bc1495504191fa0",
"transactions": [
"0x03f89b8501a1f0ff40830436ef8601d1a94a201c8601d1a94a201c82520894000000000000000000000000000000000000f1c18080c08203e8e1a0018d356609f9d914c77f905a6219e3510af697acfc6136707e771ec2ea821a0701a05061b6382952f4555f6d0985859d412fedc68d14f5e0a04516a7e7d0fd486e14a075c269afc99435047b5652bf09ef3120914a6785f27f265a49f4d5743e175146",
"0x03f89b8501a1f0ff40830436f08601d1a94a201c8601d1a94a201c82520894000000000000000000000000000000000000f1c18080c08203e8e1a001922509bc49321937ef4622e9c0fe96aef63f63a8981da53462d9f3bd74ba0980a02f3ecabfde23c09e5372d3e8e4dde92797411845b5f84b12a01891108510706ea01aae2bf43f55163ee62fa8c6f2f8077a37022cb10110eaa2edb8a03f1cd1a08d",
"0x03f89b8501a1f0ff40830436f18601d1a94a201c8601d1a94a201c82520894000000000000000000000000000000000000f1c18080c08203e8e1a00153bbb63184d0a5b6d9506fe15bfaa3f63952f30c23fc15e396ae7bd243b9eb01a034ee8d5aaec48d324482b17567c0b278226c630771d532102404b524f06b123aa0196e85fbd2aa53d145e606f0af76fd5de8321e3f7d018c421fabc2e18b0c8920",
"0x03f89b8501a1f0ff40830436f28601d1a94a201c8601d1a94a201c82520894000000000000000000000000000000000000f1c18080c08203e8e1a0015829433851bdf8cc6131fe56ac88d3b0e5deb497d7212f1413962e1f35de7f80a0a3593c0030de6d8b8ff64fa92a3f0e33ec8a049db064ab5bea7287809ba7e3e6a01b184a09f23f1b523eb713be1c27476e97b26f712cc94a38126c47e97dab39b5",
"0x03f89b8501a1f0ff40830436f38601d1a94a201c8601d1a94a201c82520894000000000000000000000000000000000000f1c18080c08203e8e1a0016b9f4ba1a726d4231ce4a6a403c802591cdac33a341a2eb348f377c96d059280a00312726918b6b586cdc4278f36c06a03944cc813bf5c0abcbc5e12ae18fffb32a05a34e0bd30c7a48d3139088240d5c2615055ec3d1856d34d511191af97eef9c7",
"0x03f89b8501a1f0ff40830436f48601d1a94a201c8601d1a94a201c82520894000000000000000000000000000000000000f1c18080c08203e8e1a0016929080a720fee5d91a3f703bae83801c222555848c20d113ab49ae8d740b801a0be532f7dc7bcc4d82529ad5f1b7c114e8e199dc5c0ebb71ed2e9c27bfd1c1aa5a0048a2c78b7742ae023f3541f1ff93ce12f473f043346705bd55077265c6f488d"
],
"withdrawals": [],
"excess_data_gas": "21889024",
"data_gas_used": "786432"
}

18 changes: 18 additions & 0 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ func TestComputeHash(t *testing.T) {
require.Equal(t, "0x08751ea2076d3ecc606231495a90ba91a66a9b8fb1a2b76c333f1957a1c667c3", hash.String())
})

// 4844 deneb execution payload and header field still unstable to write tests for
// t.Run("Should compute deneb hash", func(t *testing.T) {
// jsonFile, err := os.Open("../testdata/executionpayload/deneb-case0.json")
// require.NoError(t, err)
// defer jsonFile.Close()

// payload := new(deneb.ExecutionPayload)
// require.NoError(t, DecodeJSON(jsonFile, payload))
// versionedPayload := &api.VersionedExecutionPayload{
// Version: spec.DataVersionDeneb,
// Deneb: payload,
// }

// hash, err := ComputeBlockHash(versionedPayload)
// require.NoError(t, err)
// require.Equal(t, "0x6fdbdbce83765e4196c1cc104aaad70385bdda458c11703a7bc1495504191fa0", hash.String())
// })

t.Run("Should error on unknown version", func(t *testing.T) {
payload := new(capella.ExecutionPayload)
versionedPayload := &api.VersionedExecutionPayload{
Expand Down
Loading