mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
Update spec tests to v1.6.0-alpha.0 (#15306)
This commit is contained in:
10
WORKSPACE
10
WORKSPACE
@@ -255,7 +255,7 @@ filegroup(
|
||||
url = "https://github.com/ethereum/EIPs/archive/5480440fe51742ed23342b68cf106cefd427e39d.tar.gz",
|
||||
)
|
||||
|
||||
consensus_spec_version = "v1.5.0"
|
||||
consensus_spec_version = "v1.6.0-alpha.0"
|
||||
|
||||
bls_test_version = "v0.1.1"
|
||||
|
||||
@@ -271,7 +271,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-cI+DJe3BXlZ0lr28w3USi2lnYOUUfdi/YZ3nJuRiiYU=",
|
||||
integrity = "sha256-W7oKvoM0nAkyitykRxAw6kmCvjYC01IqiNJy0AmCnMM=",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/general.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -287,7 +287,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-eBLWqO/RdcqsANmA/rwkJ4kI+LCL+Q0RmIDq6z85lYQ=",
|
||||
integrity = "sha256-ig7/zxomjv6buBWMom4IxAJh3lFJ9+JnY44E7c8ZNP8=",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/minimal.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -303,7 +303,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-ab0H0WTzhSwYJ2a+GHVbUMoNRActJw18EmX3o5hhDi0",
|
||||
integrity = "sha256-mjx+MkXtPhCNv4c4knLYLIkvIdpF7WTjx/ElvGPQzSo=",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/mainnet.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -318,7 +318,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-Wy3YcJxoXiKQwrGgJecrtjtdokc4X/VUNBmyQXJf0Oc=",
|
||||
integrity = "sha256-u0RkIZIeGttb3sInR31mO64aBSwxALqO5SYIPlqEvPo=",
|
||||
strip_prefix = "consensus-specs-" + consensus_spec_version[1:],
|
||||
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
3
changelog/tt_uni.md
Normal file
3
changelog/tt_uni.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Changed
|
||||
|
||||
- Update spec tests to v1.6.0-alpha.0
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
// IMPORTANT: Use one field per line and sort these alphabetically to reduce conflicts.
|
||||
var placeholderFields = []string{
|
||||
"ATTESTATION_DEADLINE",
|
||||
"BLOB_SCHEDULE",
|
||||
"BLOB_SIDECAR_SUBNET_COUNT_FULU",
|
||||
"EIP6110_FORK_EPOCH",
|
||||
"EIP6110_FORK_VERSION",
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"aggregate_test.yaml.go",
|
||||
"aggregate_verify_test.yaml.go",
|
||||
"doc.go",
|
||||
"fast_aggregate_verify_test.yaml.go",
|
||||
"sign_test.yaml.go",
|
||||
"verify_test.yaml.go",
|
||||
],
|
||||
importpath = "github.com/OffchainLabs/prysm/v6/testing/spectest/general/phase0/bls",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"aggregate_test.go",
|
||||
"aggregate_verify_test.go",
|
||||
"fast_aggregate_verify_test.go",
|
||||
"sign_test.go",
|
||||
"verify_test.go",
|
||||
],
|
||||
data = [
|
||||
"@consensus_spec_tests_general//:test_data",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
tags = ["spectest"],
|
||||
deps = [
|
||||
"//crypto/bls:go_default_library",
|
||||
"//crypto/bls/common:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"//testing/spectest/utils:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"@com_github_ghodss_yaml//:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -1,58 +0,0 @@
|
||||
package bls
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls"
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls/common"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/util"
|
||||
"github.com/ghodss/yaml"
|
||||
)
|
||||
|
||||
func TestAggregate(t *testing.T) {
|
||||
t.Run("blst", testAggregate)
|
||||
}
|
||||
|
||||
func testAggregate(t *testing.T) {
|
||||
testFolders, testFolderPath := utils.TestFolders(t, "general", "phase0", "bls/aggregate/bls")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", "general", "phase0", "bls/aggregate/bls")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
file, err := util.BazelFileBytes(path.Join(testFolderPath, folder.Name(), "data.yaml"))
|
||||
require.NoError(t, err)
|
||||
test := &AggregateTest{}
|
||||
require.NoError(t, yaml.Unmarshal(file, test))
|
||||
var sigs []common.Signature
|
||||
for _, s := range test.Input {
|
||||
sigBytes, err := hex.DecodeString(s[2:])
|
||||
require.NoError(t, err)
|
||||
sig, err := bls.SignatureFromBytes(sigBytes)
|
||||
require.NoError(t, err)
|
||||
sigs = append(sigs, sig)
|
||||
}
|
||||
if len(test.Input) == 0 {
|
||||
if test.Output != "" {
|
||||
t.Fatalf("Output Aggregate is not of zero length:Output %s", test.Output)
|
||||
}
|
||||
return
|
||||
}
|
||||
sig := bls.AggregateSignatures(sigs)
|
||||
if strings.Contains(folder.Name(), "aggregate_na_pubkeys") {
|
||||
if sig != nil {
|
||||
t.Errorf("Expected nil signature, received: %v", sig)
|
||||
}
|
||||
return
|
||||
}
|
||||
outputBytes, err := hex.DecodeString(test.Output[2:])
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, outputBytes, sig.Marshal())
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// Code generated by yaml_to_go. DO NOT EDIT.
|
||||
// source: aggregate.yaml
|
||||
|
||||
package bls
|
||||
|
||||
type AggregateTest struct {
|
||||
Input []string `json:"input"`
|
||||
Output string `json:"output" ssz:"size=96"`
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package bls
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls"
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls/common"
|
||||
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/util"
|
||||
"github.com/ghodss/yaml"
|
||||
)
|
||||
|
||||
func TestAggregateVerify(t *testing.T) {
|
||||
t.Run("blst", testAggregateVerify)
|
||||
}
|
||||
|
||||
func testAggregateVerify(t *testing.T) {
|
||||
testFolders, testFolderPath := utils.TestFolders(t, "general", "phase0", "bls/aggregate_verify/bls")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", "general", "phase0", "bls/aggregate_verify/bls")
|
||||
}
|
||||
for i, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
file, err := util.BazelFileBytes(path.Join(testFolderPath, folder.Name(), "data.yaml"))
|
||||
require.NoError(t, err)
|
||||
test := &AggregateVerifyTest{}
|
||||
require.NoError(t, yaml.Unmarshal(file, test))
|
||||
pubkeys := make([]common.PublicKey, 0, len(test.Input.Pubkeys))
|
||||
msgs := make([][32]byte, 0, len(test.Input.Messages))
|
||||
for _, pubKey := range test.Input.Pubkeys {
|
||||
pkBytes, err := hex.DecodeString(pubKey[2:])
|
||||
require.NoError(t, err)
|
||||
pk, err := bls.PublicKeyFromBytes(pkBytes)
|
||||
if err != nil {
|
||||
if test.Output == false && errors.Is(err, common.ErrInfinitePubKey) {
|
||||
return
|
||||
}
|
||||
t.Fatalf("cannot unmarshal pubkey: %v", err)
|
||||
}
|
||||
pubkeys = append(pubkeys, pk)
|
||||
}
|
||||
for _, msg := range test.Input.Messages {
|
||||
msgBytes, err := hex.DecodeString(msg[2:])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 32, len(msgBytes))
|
||||
msgs = append(msgs, bytesutil.ToBytes32(msgBytes))
|
||||
}
|
||||
sigBytes, err := hex.DecodeString(test.Input.Signature[2:])
|
||||
require.NoError(t, err)
|
||||
sig, err := bls.SignatureFromBytes(sigBytes)
|
||||
if err != nil {
|
||||
if test.Output == false {
|
||||
return
|
||||
}
|
||||
t.Fatalf("Cannot unmarshal input to signature: %v", err)
|
||||
}
|
||||
|
||||
verified := sig.AggregateVerify(pubkeys, msgs)
|
||||
if verified != test.Output {
|
||||
t.Fatalf("Signature does not match the expected verification output. "+
|
||||
"Expected %#v but received %#v for test case %d", test.Output, verified, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Code generated by yaml_to_go. DO NOT EDIT.
|
||||
// source: aggregate_verify.yaml
|
||||
|
||||
package bls
|
||||
|
||||
type AggregateVerifyTest struct {
|
||||
Input struct {
|
||||
Pubkeys []string `json:"pubkeys"`
|
||||
Messages []string `json:"messages"`
|
||||
Signature string `json:"signature"`
|
||||
} `json:"input"`
|
||||
Output bool `json:"output"`
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
// Package bls includes tests to ensure conformity with the Ethereum BLS cryptography specification.
|
||||
// See https://github.com/ethereum/consensus-spec-tests/tree/master/tests/general/phase0/bls for details.
|
||||
package bls
|
||||
@@ -1,73 +0,0 @@
|
||||
package bls
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls"
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls/common"
|
||||
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/util"
|
||||
"github.com/ghodss/yaml"
|
||||
)
|
||||
|
||||
func TestFastAggregateVerify(t *testing.T) {
|
||||
t.Run("blst", testFastAggregateVerify)
|
||||
}
|
||||
|
||||
func testFastAggregateVerify(t *testing.T) {
|
||||
testFolders, testFolderPath := utils.TestFolders(t, "general", "phase0", "bls/fast_aggregate_verify/bls")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", "general", "phase0", "bls/fast_aggregate_verify/bls")
|
||||
}
|
||||
for i, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
file, err := util.BazelFileBytes(path.Join(testFolderPath, folder.Name(), "data.yaml"))
|
||||
require.NoError(t, err)
|
||||
test := &FastAggregateVerifyTest{}
|
||||
require.NoError(t, yaml.Unmarshal(file, test))
|
||||
|
||||
pubkeys := make([]common.PublicKey, len(test.Input.Pubkeys))
|
||||
for j, raw := range test.Input.Pubkeys {
|
||||
pkBytes, err := hex.DecodeString(raw[2:])
|
||||
require.NoError(t, err)
|
||||
pk, err := bls.PublicKeyFromBytes(pkBytes)
|
||||
if err != nil {
|
||||
if test.Output == false && errors.Is(err, common.ErrInfinitePubKey) {
|
||||
return
|
||||
}
|
||||
t.Fatalf("cannot unmarshal pubkey: %v", err)
|
||||
}
|
||||
pubkeys[j] = pk
|
||||
}
|
||||
|
||||
msg := test.Input.Message
|
||||
// TODO(#7632): Remove when https://github.com/ethereum/consensus-spec-tests/issues/22 is resolved.
|
||||
if msg == "" {
|
||||
msg = test.Input.Messages
|
||||
}
|
||||
msgBytes, err := hex.DecodeString(msg[2:])
|
||||
require.NoError(t, err)
|
||||
sigBytes, err := hex.DecodeString(test.Input.Signature[2:])
|
||||
require.NoError(t, err)
|
||||
sig, err := bls.SignatureFromBytes(sigBytes)
|
||||
if err != nil {
|
||||
if test.Output == false {
|
||||
return
|
||||
}
|
||||
t.Fatalf("Cannot unmarshal input to signature: %v", err)
|
||||
}
|
||||
|
||||
verified := sig.FastAggregateVerify(pubkeys, bytesutil.ToBytes32(msgBytes))
|
||||
if verified != test.Output {
|
||||
t.Fatalf("Signature does not match the expected verification output. "+
|
||||
"Expected %#v but received %#v for test case %d", test.Output, verified, i)
|
||||
}
|
||||
t.Log("Success")
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
// Code generated by yaml_to_go. DO NOT EDIT.
|
||||
// source: fast_aggregate_verify.yaml
|
||||
|
||||
package bls
|
||||
|
||||
type FastAggregateVerifyTest struct {
|
||||
Input struct {
|
||||
Pubkeys []string `json:"pubkeys"`
|
||||
Message string `json:"message"`
|
||||
// TODO(#7632): Remove when https://github.com/ethereum/consensus-spec-tests/issues/22 is resolved.
|
||||
Messages string `json:"messages"`
|
||||
Signature string `json:"signature"`
|
||||
} `json:"input"`
|
||||
Output bool `json:"output"`
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package bls
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls"
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls/common"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/util"
|
||||
"github.com/ghodss/yaml"
|
||||
)
|
||||
|
||||
func TestSign(t *testing.T) {
|
||||
t.Run("blst", testSign)
|
||||
}
|
||||
|
||||
func testSign(t *testing.T) {
|
||||
testFolders, testFolderPath := utils.TestFolders(t, "general", "phase0", "bls/sign/bls")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", "general", "phase0", "bls/sign/bls")
|
||||
}
|
||||
for i, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
file, err := util.BazelFileBytes(path.Join(testFolderPath, folder.Name(), "data.yaml"))
|
||||
require.NoError(t, err)
|
||||
test := &SignMsgTest{}
|
||||
require.NoError(t, yaml.Unmarshal(file, test))
|
||||
pkBytes, err := hex.DecodeString(test.Input.Privkey[2:])
|
||||
require.NoError(t, err)
|
||||
sk, err := bls.SecretKeyFromBytes(pkBytes)
|
||||
if err != nil {
|
||||
if test.Output == "" &&
|
||||
(errors.Is(err, common.ErrZeroKey) || errors.Is(err, common.ErrSecretUnmarshal)) {
|
||||
return
|
||||
}
|
||||
t.Fatalf("cannot unmarshal secret key: %v", err)
|
||||
}
|
||||
msgBytes, err := hex.DecodeString(test.Input.Message[2:])
|
||||
require.NoError(t, err)
|
||||
sig := sk.Sign(msgBytes)
|
||||
|
||||
if !sig.Verify(sk.PublicKey(), msgBytes) {
|
||||
t.Fatal("could not verify signature")
|
||||
}
|
||||
|
||||
outputBytes, err := hex.DecodeString(test.Output[2:])
|
||||
require.NoError(t, err)
|
||||
|
||||
if !bytes.Equal(outputBytes, sig.Marshal()) {
|
||||
t.Fatalf("Test Case %d: Signature does not match the expected output. "+
|
||||
"Expected %#x but received %#x", i, outputBytes, sig.Marshal())
|
||||
}
|
||||
t.Log("Success")
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// Code generated by yaml_to_go. DO NOT EDIT.
|
||||
// source: sign_msg.yaml
|
||||
|
||||
package bls
|
||||
|
||||
type SignMsgTest struct {
|
||||
Input struct {
|
||||
Privkey string `json:"privkey"`
|
||||
Message string `json:"message"`
|
||||
} `json:"input"`
|
||||
Output string `json:"output"`
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package bls
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls"
|
||||
"github.com/OffchainLabs/prysm/v6/crypto/bls/common"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/spectest/utils"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/util"
|
||||
"github.com/ghodss/yaml"
|
||||
)
|
||||
|
||||
func TestVerify(t *testing.T) {
|
||||
t.Run("blst", testVerify)
|
||||
}
|
||||
|
||||
func testVerify(t *testing.T) {
|
||||
testFolders, testFolderPath := utils.TestFolders(t, "general", "phase0", "bls/verify/bls")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", "general", "phase0", "bls/verify/bls")
|
||||
}
|
||||
for i, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
file, err := util.BazelFileBytes(path.Join(testFolderPath, folder.Name(), "data.yaml"))
|
||||
require.NoError(t, err)
|
||||
test := &VerifyMsgTest{}
|
||||
require.NoError(t, yaml.Unmarshal(file, test))
|
||||
|
||||
pkBytes, err := hex.DecodeString(test.Input.Pubkey[2:])
|
||||
require.NoError(t, err)
|
||||
pk, err := bls.PublicKeyFromBytes(pkBytes)
|
||||
if err != nil {
|
||||
if test.Output == false && errors.Is(err, common.ErrInfinitePubKey) {
|
||||
return
|
||||
}
|
||||
t.Fatalf("cannot unmarshal pubkey: %v", err)
|
||||
}
|
||||
msgBytes, err := hex.DecodeString(test.Input.Message[2:])
|
||||
require.NoError(t, err)
|
||||
|
||||
sigBytes, err := hex.DecodeString(test.Input.Signature[2:])
|
||||
require.NoError(t, err)
|
||||
sig, err := bls.SignatureFromBytes(sigBytes)
|
||||
if err != nil {
|
||||
if test.Output == false {
|
||||
return
|
||||
}
|
||||
t.Fatalf("Cannot unmarshal input to signature: %v", err)
|
||||
}
|
||||
|
||||
verified := sig.Verify(pk, msgBytes)
|
||||
if verified != test.Output {
|
||||
t.Fatalf("Signature does not match the expected verification output. "+
|
||||
"Expected %#v but received %#v for test case %d", test.Output, verified, i)
|
||||
}
|
||||
t.Log("Success")
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
// Code generated by yaml_to_go. DO NOT EDIT.
|
||||
// source: verify.yaml
|
||||
|
||||
package bls
|
||||
|
||||
type VerifyMsgTest struct {
|
||||
Input struct {
|
||||
Pubkey string `json:"pubkey"`
|
||||
Message string `json:"message"`
|
||||
Signature string `json:"signature"`
|
||||
} `json:"input"`
|
||||
Output bool `json:"output"`
|
||||
}
|
||||
Reference in New Issue
Block a user