diff --git a/app/app.go b/app/app.go index 01768b0da..7be6b55bb 100644 --- a/app/app.go +++ b/app/app.go @@ -95,6 +95,7 @@ type Config struct { ProcDirectory string ConsensusProtocol string Nickname string + TargetGasLimit uint TestConfig TestConfig } @@ -490,7 +491,7 @@ func wireCoreWorkflow(ctx context.Context, life *lifecycle.Manager, conf Config, dutyDB := dutydb.NewMemDB(deadlinerFunc("dutydb")) - vapi, err := validatorapi.NewComponent(eth2Cl, allPubSharesByKey, nodeIdx.ShareIdx, feeRecipientFunc, conf.BuilderAPI, seenPubkeys) + vapi, err := validatorapi.NewComponent(eth2Cl, allPubSharesByKey, nodeIdx.ShareIdx, feeRecipientFunc, conf.BuilderAPI, uint(cluster.GetTargetGasLimit()), seenPubkeys) if err != nil { return err } diff --git a/app/peerinfo/peerinfo.go b/app/peerinfo/peerinfo.go index 788af6c52..3f570372e 100644 --- a/app/peerinfo/peerinfo.go +++ b/app/peerinfo/peerinfo.go @@ -202,7 +202,7 @@ func (p *PeerInfo) sendOnce(ctx context.Context, now time.Time) { name := p2p.PeerName(peerID) - p.nicknames[name] = resp.Nickname + p.nicknames[name] = resp.GetNickname() log.Info(ctx, "Peer name to nickname mappings", z.Any("nicknames", p.nicknames)) // Validator git hash with regex. diff --git a/cluster/definition.go b/cluster/definition.go index 0f8e07e3e..0112dafe6 100644 --- a/cluster/definition.go +++ b/cluster/definition.go @@ -110,11 +110,11 @@ func NewDefinition(name string, numVals int, threshold int, feeRecipientAddresse return Definition{}, errors.New("the version does not support partial deposits", z.Str("version", def.Version)) } - if targetGasLimit != 0 && !supportTargetGasLimit(def.Version) { + if def.TargetGasLimit != 0 && !supportTargetGasLimit(def.Version) { return Definition{}, errors.New("the version does not support custom target gas limit", z.Str("version", def.Version)) } - if targetGasLimit == 0 && supportTargetGasLimit(def.Version) { + if def.TargetGasLimit == 0 && supportTargetGasLimit(def.Version) { return Definition{}, errors.New("target gas limit should be set", z.Str("version", def.Version)) } diff --git a/cluster/manifest/cluster_test.go b/cluster/manifest/cluster_test.go index e6a77168b..80e06da44 100644 --- a/cluster/manifest/cluster_test.go +++ b/cluster/manifest/cluster_test.go @@ -13,6 +13,30 @@ import ( manifestpb "github.com/obolnetwork/charon/cluster/manifestpb/v1" ) +const ( + v1_10 = "v1.10.0" + v1_9 = "v1.9.0" + v1_8 = "v1.8.0" + v1_7 = "v1.7.0" + v1_6 = "v1.6.0" + v1_5 = "v1.5.0" + v1_4 = "v1.4.0" + v1_3 = "v1.3.0" + v1_2 = "v1.2.0" + v1_1 = "v1.1.0" + v1_0 = "v1.0.0" +) + +func isAnyVersion(version string, list ...string) bool { + for _, v := range list { + if version == v { + return true + } + } + + return false +} + func TestDuplicateENRs(t *testing.T) { seed := 0 random := rand.New(rand.NewSource(int64(seed))) diff --git a/cluster/manifest/load_test.go b/cluster/manifest/load_test.go index c6524b7ad..4cb3f490d 100644 --- a/cluster/manifest/load_test.go +++ b/cluster/manifest/load_test.go @@ -111,10 +111,16 @@ func testLoadLegacy(t *testing.T, version string) { var opts []func(*cluster.Definition) opts = append(opts, cluster.WithVersion(version)) - if version < "v1.5.0" { + if isAnyVersion(version, v1_0, v1_1, v1_2, v1_3, v1_4) { opts = append(opts, cluster.WithLegacyVAddrs(testutil.RandomETHAddress(), testutil.RandomETHAddress())) } + if isAnyVersion(version, v1_0, v1_1, v1_2, v1_3, v1_4, v1_5, v1_6, v1_7, v1_8, v1_9) { + opts = append(opts, func(d *cluster.Definition) { d.TargetGasLimit = 0 }) + } else { + opts = append(opts, func(d *cluster.Definition) { d.TargetGasLimit = 36000000 }) + } + seed := 0 random := rand.New(rand.NewSource(int64(seed))) lock, _, _ := cluster.NewForT(t, rand.Intn(10), k, n, seed, random, opts...) diff --git a/cluster/manifest/mutationlegacylock.go b/cluster/manifest/mutationlegacylock.go index 21b25f025..bc023f466 100644 --- a/cluster/manifest/mutationlegacylock.go +++ b/cluster/manifest/mutationlegacylock.go @@ -150,6 +150,7 @@ func transformLegacyLock(input *manifestpb.Cluster, signed *manifestpb.SignedMut DkgAlgorithm: lock.DKGAlgorithm, ForkVersion: lock.ForkVersion, ConsensusProtocol: lock.ConsensusProtocol, + TargetGasLimit: uint32(lock.TargetGasLimit), Validators: vals, Operators: ops, }, nil diff --git a/cluster/manifestpb/v1/manifest.pb.go b/cluster/manifestpb/v1/manifest.pb.go index f2b05b4ee..1e3172f70 100644 --- a/cluster/manifestpb/v1/manifest.pb.go +++ b/cluster/manifestpb/v1/manifest.pb.go @@ -33,6 +33,7 @@ type Cluster struct { Operators []*Operator `protobuf:"bytes,7,rep,name=operators,proto3" json:"operators,omitempty"` // Operators is the list of operators of the cluster. Validators []*Validator `protobuf:"bytes,8,rep,name=validators,proto3" json:"validators,omitempty"` // Validators is the list of validators of the cluster. ConsensusProtocol string `protobuf:"bytes,9,opt,name=consensus_protocol,json=consensusProtocol,proto3" json:"consensus_protocol,omitempty"` // ConsensusProtocol is the consensus protocol name preferred by the cluster, e.g. "abft". + TargetGasLimit uint32 `protobuf:"varint,10,opt,name=target_gas_limit,json=targetGasLimit,proto3" json:"target_gas_limit,omitempty"` // TargetGasLimit is the custom target gas limit for transactions. unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -130,6 +131,13 @@ func (x *Cluster) GetConsensusProtocol() string { return "" } +func (x *Cluster) GetTargetGasLimit() uint32 { + if x != nil { + return x.TargetGasLimit + } + return 0 +} + // Mutation mutates the cluster manifest. type Mutation struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -562,7 +570,7 @@ var file_cluster_manifestpb_v1_manifest_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, - 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x99, 0x03, 0x0a, 0x07, 0x43, 0x6c, 0x75, + 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x03, 0x0a, 0x07, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x15, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x13, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x4d, 0x75, 0x74, 0x61, @@ -588,57 +596,60 @@ var file_cluster_manifestpb_v1_manifest_proto_rawDesc = []byte{ 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0x60, 0x0a, 0x08, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x83, 0x01, 0x0a, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x65, - 0x64, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x08, 0x6d, 0x75, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x70, 0x62, - 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6d, 0x75, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x1c, - 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x59, 0x0a, 0x12, - 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, - 0x73, 0x74, 0x12, 0x43, 0x0a, 0x09, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, - 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, - 0x67, 0x6e, 0x65, 0x64, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6d, 0x75, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x36, 0x0a, 0x08, 0x4f, 0x70, 0x65, 0x72, 0x61, - 0x74, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, - 0x03, 0x65, 0x6e, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x72, 0x22, - 0xe8, 0x01, 0x0a, 0x09, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x0a, - 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, - 0x70, 0x75, 0x62, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, - 0x52, 0x09, 0x70, 0x75, 0x62, 0x53, 0x68, 0x61, 0x72, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x66, - 0x65, 0x65, 0x5f, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x66, 0x65, 0x65, 0x52, - 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x2d, 0x0a, 0x12, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x77, 0x69, 0x74, - 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3a, - 0x0a, 0x19, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x17, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4a, 0x73, 0x6f, 0x6e, 0x22, 0x51, 0x0a, 0x0d, 0x56, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x0a, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x20, 0x2e, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, - 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, - 0x72, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0x20, 0x0a, - 0x0a, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x4c, 0x6f, 0x63, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6a, - 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6a, 0x73, 0x6f, 0x6e, 0x22, - 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x62, 0x6f, 0x6c, 0x6e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x2f, 0x63, 0x68, 0x61, 0x72, 0x6f, 0x6e, 0x2f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, - 0x72, 0x2f, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x76, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x67, + 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x60, + 0x0a, 0x08, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, + 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, + 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x22, 0x83, 0x01, 0x0a, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x4d, 0x75, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x08, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, + 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x75, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x59, 0x0a, 0x12, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, + 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x09, + 0x6d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x25, 0x2e, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, + 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x4d, 0x75, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x22, 0x36, 0x0a, 0x08, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x18, 0x0a, + 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x72, 0x22, 0xe8, 0x01, 0x0a, 0x09, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x5f, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x53, + 0x68, 0x61, 0x72, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x66, 0x65, 0x65, 0x5f, 0x72, 0x65, 0x63, + 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x66, 0x65, 0x65, 0x52, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, + 0x6e, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x77, 0x69, 0x74, + 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, + 0x6c, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x17, 0x62, 0x75, 0x69, + 0x6c, 0x64, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x4a, 0x73, 0x6f, 0x6e, 0x22, 0x51, 0x0a, 0x0d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x2e, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, + 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x22, 0x20, 0x0a, 0x0a, 0x4c, 0x65, 0x67, 0x61, 0x63, + 0x79, 0x4c, 0x6f, 0x63, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6a, 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6a, 0x73, 0x6f, 0x6e, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x42, 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6f, 0x62, 0x6f, 0x6c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x63, 0x68, 0x61, + 0x72, 0x6f, 0x6e, 0x2f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2f, 0x6d, 0x61, 0x6e, 0x69, + 0x66, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/cluster/manifestpb/v1/manifest.proto b/cluster/manifestpb/v1/manifest.proto index 2ccea05fb..4959b8966 100644 --- a/cluster/manifestpb/v1/manifest.proto +++ b/cluster/manifestpb/v1/manifest.proto @@ -17,6 +17,7 @@ message Cluster { repeated Operator operators = 7; // Operators is the list of operators of the cluster. repeated Validator validators = 8; // Validators is the list of validators of the cluster. string consensus_protocol = 9; // ConsensusProtocol is the consensus protocol name preferred by the cluster, e.g. "abft". + uint32 target_gas_limit = 10; // TargetGasLimit is the custom target gas limit for transactions. } // Mutation mutates the cluster manifest. diff --git a/cmd/addvalidators.go b/cmd/addvalidators.go index 17edc90c6..9fc06de71 100644 --- a/cmd/addvalidators.go +++ b/cmd/addvalidators.go @@ -131,7 +131,7 @@ func runAddValidatorsSolo(ctx context.Context, conf addValidatorsConfig) (err er conf.WithdrawalAddrs = repeatAddr(conf.WithdrawalAddrs[0], conf.NumVals) } - vals, secrets, shareSets, err := genNewVals(len(cluster.GetOperators()), int(cluster.GetThreshold()), cluster.GetForkVersion(), conf) + vals, secrets, shareSets, err := genNewVals(ctx, len(cluster.GetOperators()), int(cluster.GetThreshold()), cluster.GetForkVersion(), cluster.GetTargetGasLimit(), conf) if err != nil { return err } @@ -203,16 +203,21 @@ func runAddValidatorsSolo(ctx context.Context, conf addValidatorsConfig) (err er } // builderRegistration returns a builder registration object using the provided inputs. -func builderRegistration(secret tbls.PrivateKey, pubkey tbls.PublicKey, feeRecipientAddr string, forkVersion []byte) (*eth2v1.SignedValidatorRegistration, error) { +func builderRegistration(ctx context.Context, secret tbls.PrivateKey, pubkey tbls.PublicKey, feeRecipientAddr string, forkVersion []byte, targetGasLimit uint32) (*eth2v1.SignedValidatorRegistration, error) { timestamp, err := eth2util.ForkVersionToGenesisTime(forkVersion) if err != nil { return nil, errors.Wrap(err, "invalid fork version") } + if targetGasLimit == 0 { + log.Warn(ctx, "", errors.New("custom target gas limit not supported, setting to default", z.Uint("default_gas_limit", registration.DefaultGasLimit))) + targetGasLimit = registration.DefaultGasLimit + } + reg, err := registration.NewMessage( eth2p0.BLSPubKey(pubkey), feeRecipientAddr, - registration.DefaultGasLimit, + uint64(targetGasLimit), timestamp, ) if err != nil { @@ -384,7 +389,7 @@ func validateConf(conf addValidatorsConfig) error { } // genNewVals returns a list of new validators, their corresponding private keys and threshold keyshares from the provided config. -func genNewVals(numOps, threshold int, forkVersion []byte, conf addValidatorsConfig) ([]*manifestpb.Validator, []tbls.PrivateKey, [][]tbls.PrivateKey, error) { +func genNewVals(ctx context.Context, numOps, threshold int, forkVersion []byte, targetGasLimit uint32, conf addValidatorsConfig) ([]*manifestpb.Validator, []tbls.PrivateKey, [][]tbls.PrivateKey, error) { // Generate new validators var ( vals []*manifestpb.Validator @@ -439,7 +444,7 @@ func genNewVals(numOps, threshold int, forkVersion []byte, conf addValidatorsCon } // Generate builder registration - builderReg, err := builderRegistration(secret, pubkey, feeRecipientAddr, forkVersion) + builderReg, err := builderRegistration(ctx, secret, pubkey, feeRecipientAddr, forkVersion, targetGasLimit) if err != nil { return nil, nil, nil, err } diff --git a/cmd/createcluster.go b/cmd/createcluster.go index d372d03c8..2be1eec06 100644 --- a/cmd/createcluster.go +++ b/cmd/createcluster.go @@ -145,7 +145,7 @@ func bindClusterFlags(flags *pflag.FlagSet, config *clusterConfig) { flags.Int64Var(&config.testnetConfig.GenesisTimestamp, "testnet-genesis-timestamp", 0, "Genesis timestamp of the custom test network.") flags.IntSliceVar(&config.DepositAmounts, "deposit-amounts", nil, "List of partial deposit amounts (integers) in ETH. Values must sum up to exactly 32ETH.") flags.StringVar(&config.ConsensusProtocol, "consensus-protocol", "", "Preferred consensus protocol name for the cluster. Selected automatically when not specified.") - flags.UintVar(&config.TargetGasLimit, "target-gas-limit", 30000000, "Preferred target gas limit for transactions.") + flags.UintVar(&config.TargetGasLimit, "target-gas-limit", 36000000, "Preferred target gas limit for transactions.") } func bindInsecureFlags(flags *pflag.FlagSet, insecureKeys *bool) { @@ -279,7 +279,7 @@ func runCreateCluster(ctx context.Context, w io.Writer, conf clusterConfig) erro return err } - valRegs, err := createValidatorRegistrations(def.FeeRecipientAddresses(), secrets, def.ForkVersion, conf.SplitKeys) + valRegs, err := createValidatorRegistrations(ctx, def.FeeRecipientAddresses(), secrets, def.ForkVersion, conf.SplitKeys, conf.TargetGasLimit) if err != nil { return err } @@ -472,7 +472,7 @@ func signDepositDatas(secrets []tbls.PrivateKey, withdrawalAddresses []string, n } // signValidatorRegistrations returns a slice of validator registrations for each private key in secrets. -func signValidatorRegistrations(secrets []tbls.PrivateKey, feeAddresses []string, forkVersion []byte, useCurrentTimestamp bool) ([]core.VersionedSignedValidatorRegistration, error) { +func signValidatorRegistrations(secrets []tbls.PrivateKey, feeAddresses []string, forkVersion []byte, useCurrentTimestamp bool, targetGasLimit uint) ([]core.VersionedSignedValidatorRegistration, error) { if len(secrets) != len(feeAddresses) { return nil, errors.New("insufficient fee addresses") } @@ -503,7 +503,7 @@ func signValidatorRegistrations(secrets []tbls.PrivateKey, feeAddresses []string unsignedReg, err := registration.NewMessage( eth2p0.BLSPubKey(pk), feeAddress, - registration.DefaultGasLimit, + uint64(targetGasLimit), timestamp, ) if err != nil { @@ -624,12 +624,17 @@ func createDepositDatas(withdrawalAddresses []string, network string, secrets [] } // createValidatorRegistrations creates a slice of builder validator registrations using the provided parameters and returns it. -func createValidatorRegistrations(feeAddresses []string, secrets []tbls.PrivateKey, forkVersion []byte, useCurrentTimestamp bool) ([]core.VersionedSignedValidatorRegistration, error) { +func createValidatorRegistrations(ctx context.Context, feeAddresses []string, secrets []tbls.PrivateKey, forkVersion []byte, useCurrentTimestamp bool, targetGasLimit uint) ([]core.VersionedSignedValidatorRegistration, error) { if len(feeAddresses) != len(secrets) { return nil, errors.New("insufficient fee addresses") } - return signValidatorRegistrations(secrets, feeAddresses, forkVersion, useCurrentTimestamp) + if targetGasLimit == 0 { + log.Warn(ctx, "", errors.New("custom target gas limit not supported, setting to default", z.Uint("default_gas_limit", registration.DefaultGasLimit))) + targetGasLimit = registration.DefaultGasLimit + } + + return signValidatorRegistrations(secrets, feeAddresses, forkVersion, useCurrentTimestamp, targetGasLimit) } // writeLock creates a cluster lock and writes it to disk for all peers. diff --git a/cmd/createdkg.go b/cmd/createdkg.go index bcfd75cab..8b66c06e2 100644 --- a/cmd/createdkg.go +++ b/cmd/createdkg.go @@ -85,7 +85,7 @@ func bindCreateDKGFlags(cmd *cobra.Command, config *createDKGConfig) { cmd.Flags().IntSliceVar(&config.DepositAmounts, "deposit-amounts", nil, "List of partial deposit amounts (integers) in ETH. Values must sum up to exactly 32ETH.") cmd.Flags().StringSliceVar(&config.OperatorENRs, operatorENRs, nil, "[REQUIRED] Comma-separated list of each operator's Charon ENR address.") cmd.Flags().StringVar(&config.ConsensusProtocol, "consensus-protocol", "", "Preferred consensus protocol name for the cluster. Selected automatically when not specified.") - cmd.Flags().UintVar(&config.TargetGasLimit, "target-gas-limit", 30000000, "Preferred target gas limit for transactions.") + cmd.Flags().UintVar(&config.TargetGasLimit, "target-gas-limit", 36000000, "Preferred target gas limit for transactions.") mustMarkFlagRequired(cmd, operatorENRs) } diff --git a/core/validatorapi/validatorapi.go b/core/validatorapi/validatorapi.go index 49a86eb53..863127719 100644 --- a/core/validatorapi/validatorapi.go +++ b/core/validatorapi/validatorapi.go @@ -33,8 +33,8 @@ import ( ) const ( - gasLimit = 30000000 - zeroAddress = "0x0000000000000000000000000000000000000000" + defaultGasLimit = 30000000 + zeroAddress = "0x0000000000000000000000000000000000000000" ) // SlotFromTimestamp returns the Ethereum slot associated to a timestamp, given the genesis configuration fetched @@ -86,7 +86,7 @@ func NewComponentInsecure(_ *testing.T, eth2Cl eth2wrap.Client, shareIdx int) (* // NewComponent returns a new instance of the validator API core workflow component. func NewComponent(eth2Cl eth2wrap.Client, allPubSharesByKey map[core.PubKey]map[int]tbls.PublicKey, - shareIdx int, feeRecipientFunc func(core.PubKey) string, builderEnabled bool, seenPubkeys func(core.PubKey), + shareIdx int, feeRecipientFunc func(core.PubKey) string, builderEnabled bool, targetGasLimit uint, seenPubkeys func(core.PubKey), ) (*Component, error) { var ( sharesByKey = make(map[eth2p0.BLSPubKey]eth2p0.BLSPubKey) @@ -168,6 +168,7 @@ func NewComponent(eth2Cl eth2wrap.Client, allPubSharesByKey map[core.PubKey]map[ shareIdx: shareIdx, feeRecipientFunc: feeRecipientFunc, builderEnabled: builderEnabled, + targetGasLimit: targetGasLimit, swallowRegFilter: log.Filter(), }, nil } @@ -178,6 +179,7 @@ type Component struct { insecureTest bool feeRecipientFunc func(core.PubKey) string builderEnabled bool + targetGasLimit uint swallowRegFilter z.Field // getVerifyShareFunc maps public shares (what the VC thinks as its public key) @@ -1276,13 +1278,20 @@ func (c Component) getAggregateSyncCommSelection(ctx context.Context, psigsBySlo // ProposerConfig returns the proposer configuration for all validators. func (c Component) ProposerConfig(ctx context.Context) (*eth2exp.ProposerConfigResponse, error) { + var targetGasLimit uint + if c.targetGasLimit == 0 { + log.Warn(ctx, "", errors.New("custom target gas limit not supported, setting to default", z.Uint("default_gas_limit", defaultGasLimit))) + targetGasLimit = defaultGasLimit + } else { + targetGasLimit = c.targetGasLimit + } resp := eth2exp.ProposerConfigResponse{ Proposers: make(map[eth2p0.BLSPubKey]eth2exp.ProposerConfig), Default: eth2exp.ProposerConfig{ // Default doesn't make sense, disable for now. FeeRecipient: zeroAddress, Builder: eth2exp.Builder{ Enabled: false, - GasLimit: gasLimit, + GasLimit: targetGasLimit, }, }, } @@ -1313,7 +1322,7 @@ func (c Component) ProposerConfig(ctx context.Context) (*eth2exp.ProposerConfigR FeeRecipient: c.feeRecipientFunc(pubkey), Builder: eth2exp.Builder{ Enabled: c.builderEnabled, - GasLimit: gasLimit, + GasLimit: targetGasLimit, Overrides: map[string]string{ "timestamp": strconv.FormatInt(timestamp.Unix(), 10), "public_key": string(pubkey), diff --git a/core/validatorapi/validatorapi_internal_test.go b/core/validatorapi/validatorapi_internal_test.go index 1d5ceda69..990c5accc 100644 --- a/core/validatorapi/validatorapi_internal_test.go +++ b/core/validatorapi/validatorapi_internal_test.go @@ -31,7 +31,7 @@ func TestMismatchKeysFunc(t *testing.T) { t.Run("no mismatch", func(t *testing.T) { allPubSharesByKey := map[core.PubKey]map[int]tbls.PublicKey{corePubKey: {shareIdx: pubkey}} // Maps self to self since not tbls - vapi, err := NewComponent(nil, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := NewComponent(nil, allPubSharesByKey, shareIdx, nil, false, defaultGasLimit, nil) require.NoError(t, err) pk, err := vapi.getPubKeyFunc(eth2Pubkey) require.NoError(t, err) @@ -47,7 +47,7 @@ func TestMismatchKeysFunc(t *testing.T) { pubshare := *(*tbls.PublicKey)(pkb) allPubSharesByKey := map[core.PubKey]map[int]tbls.PublicKey{corePubKey: {shareIdx: pubkey, shareIdx + 1: pubshare}} - vapi, err := NewComponent(nil, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := NewComponent(nil, allPubSharesByKey, shareIdx, nil, false, defaultGasLimit, nil) require.NoError(t, err) resp, err := vapi.getPubKeyFunc(eth2p0.BLSPubKey(pubshare)) // Ask for a mismatching key @@ -65,7 +65,7 @@ func TestMismatchKeysFunc(t *testing.T) { pubshare := eth2p0.BLSPubKey(pk) allPubSharesByKey := map[core.PubKey]map[int]tbls.PublicKey{corePubKey: {shareIdx: pubkey}} - vapi, err := NewComponent(nil, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := NewComponent(nil, allPubSharesByKey, shareIdx, nil, false, defaultGasLimit, nil) require.NoError(t, err) _, err = vapi.getPubKeyFunc(pubshare) // Ask for a mismatching key diff --git a/core/validatorapi/validatorapi_test.go b/core/validatorapi/validatorapi_test.go index d5304b491..1a03ef0d2 100644 --- a/core/validatorapi/validatorapi_test.go +++ b/core/validatorapi/validatorapi_test.go @@ -192,7 +192,7 @@ func TestSubmitAttestations_Verify(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) vapi.RegisterPubKeyByAttestation(func(ctx context.Context, slot, commIdx, valCommIdx uint64) (core.PubKey, error) { @@ -300,7 +300,7 @@ func TestSignAndVerify(t *testing.T) { allPubSharesByKey := map[core.PubKey]map[int]tbls.PublicKey{corePubKey: {shareIdx: pubkey}} // Maps self to self since not tbls // Setup validatorapi component. - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) vapi.RegisterPubKeyByAttestation(func(context.Context, uint64, uint64, uint64) (core.PubKey, error) { return core.PubKeyFromBytes(pubkey[:]) @@ -436,7 +436,7 @@ func TestComponent_SubmitProposalsWithWrongVCData(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) t.Run("full block fails", func(t *testing.T) { @@ -534,7 +534,7 @@ func TestComponent_SubmitProposal(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) // Prepare unsigned beacon block @@ -628,7 +628,7 @@ func TestComponent_SubmitProposal_Gnosis(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) // Prepare unsigned beacon block @@ -725,7 +725,7 @@ func TestComponent_SubmitProposalInvalidSignature(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) // Prepare unsigned beacon block @@ -794,7 +794,7 @@ func TestComponent_SubmitProposalInvalidBlock(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) vapi.RegisterGetDutyDefinition(func(ctx context.Context, duty core.Duty) (core.DutyDefinitionSet, error) { @@ -919,7 +919,7 @@ func TestComponent_SubmitBlindedProposal(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, 30000000, nil) require.NoError(t, err) // Prepare unsigned beacon block @@ -1009,7 +1009,7 @@ func TestComponent_SubmitBlindedProposalInvalidSignature(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, 30000000, nil) require.NoError(t, err) // Prepare unsigned beacon block @@ -1083,7 +1083,7 @@ func TestComponent_SubmitBlindedProposalInvalidBlock(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, 30000000, nil) require.NoError(t, err) vapi.RegisterGetDutyDefinition(func(ctx context.Context, duty core.Duty) (core.DutyDefinitionSet, error) { @@ -1211,7 +1211,7 @@ func TestComponent_SubmitVoluntaryExit(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) // Prepare unsigned voluntary exit @@ -1281,7 +1281,7 @@ func TestComponent_SubmitVoluntaryExitInvalidSignature(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) // Register subscriber @@ -1337,7 +1337,7 @@ func TestComponent_Duties(t *testing.T) { } // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) opts := ð2api.ProposerDutiesOpts{ @@ -1363,7 +1363,7 @@ func TestComponent_Duties(t *testing.T) { } // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) opts := ð2api.AttesterDutiesOpts{ @@ -1389,7 +1389,7 @@ func TestComponent_Duties(t *testing.T) { } // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) opts := ð2api.SyncCommitteeDutiesOpts{ @@ -1425,7 +1425,7 @@ func TestComponent_SubmitValidatorRegistration(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, 30000000, nil) require.NoError(t, err) unsigned := testutil.RandomValidatorRegistration(t) @@ -1503,7 +1503,7 @@ func TestComponent_SubmitValidatorRegistrationInvalidSignature(t *testing.T) { require.NoError(t, err) // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, true, 30000000, nil) require.NoError(t, err) unsigned := testutil.RandomValidatorRegistration(t) @@ -1558,7 +1558,7 @@ func TestComponent_TekuProposerConfig(t *testing.T) { // Construct the validator api component vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, func(core.PubKey) string { return feeRecipient - }, true, nil) + }, true, 30000000, nil) require.NoError(t, err) resp, err := vapi.ProposerConfig(ctx) @@ -1727,7 +1727,7 @@ func TestComponent_SubmitAggregateAttestationVerify(t *testing.T) { } // Construct the validator api component - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) done := make(chan struct{}) @@ -1859,7 +1859,7 @@ func TestComponent_SubmitSyncCommitteeContributionsVerify(t *testing.T) { } // Construct validatorapi component. - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) done := make(chan struct{}) @@ -1941,7 +1941,7 @@ func TestComponent_ValidatorCache(t *testing.T) { } } - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, 1, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, 1, nil, false, 30000000, nil) require.NoError(t, err) // request validators that are completely cached @@ -2013,7 +2013,7 @@ func TestComponent_GetAllValidators(t *testing.T) { require.NoError(t, err) // Construct validatorapi component. - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) opts := ð2api.ValidatorsOpts{ @@ -2050,7 +2050,7 @@ func TestComponent_GetClusterValidatorsWithError(t *testing.T) { require.NoError(t, err) // Construct validatorapi component. - vapi, err := validatorapi.NewComponent(bmock, make(map[core.PubKey]map[int]tbls.PublicKey), shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, make(map[core.PubKey]map[int]tbls.PublicKey), shareIdx, nil, false, 30000000, nil) require.NoError(t, err) opts := ð2api.ValidatorsOpts{ @@ -2127,7 +2127,7 @@ func TestComponent_AggregateSyncCommitteeSelectionsVerify(t *testing.T) { } // Construct the validator api component. - vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, nil) + vapi, err := validatorapi.NewComponent(bmock, allPubSharesByKey, shareIdx, nil, false, 30000000, nil) require.NoError(t, err) vapi.RegisterAwaitAggSigDB(func(ctx context.Context, duty core.Duty, pubkey core.PubKey) (core.SignedData, error) { diff --git a/dkg/dkg.go b/dkg/dkg.go index ee890dde4..23dd97528 100644 --- a/dkg/dkg.go +++ b/dkg/dkg.go @@ -111,7 +111,7 @@ func Run(ctx context.Context, conf Config) (err error) { } // This DKG only supports a few specific config versions. - if def.Version != "v1.6.0" && def.Version != "v1.7.0" && def.Version != "v1.8.0" { + if def.Version != "v1.6.0" && def.Version != "v1.7.0" && def.Version != "v1.8.0" && def.Version != "v1.9.0" && def.Version != "v1.10.0" { return errors.New("only v1.6.0, v1.7.0 and v1.8.0 cluster definition versions supported") } @@ -267,7 +267,7 @@ func Run(ctx context.Context, conf Config) (err error) { ex, shares, def.FeeRecipientAddresses(), - registration.DefaultGasLimit, + uint64(def.TargetGasLimit), nodeIdx, def.ForkVersion, ) @@ -638,11 +638,16 @@ func signAndAggValidatorRegistrations( ex *exchanger, shares []share, feeRecipients []string, - gasLimit uint64, + targetGasLimit uint64, nodeIdx cluster.NodeIdx, forkVersion []byte, ) ([]core.VersionedSignedValidatorRegistration, error) { - parSig, valRegs, err := signValidatorRegistrations(shares, nodeIdx.ShareIdx, feeRecipients, gasLimit, forkVersion) + if targetGasLimit == 0 { + log.Warn(ctx, "", errors.New("custom target gas limit not supported, setting to default", z.Uint("default_gas_limit", registration.DefaultGasLimit))) + targetGasLimit = registration.DefaultGasLimit + } + + parSig, valRegs, err := signValidatorRegistrations(shares, nodeIdx.ShareIdx, feeRecipients, targetGasLimit, forkVersion) if err != nil { return nil, err } diff --git a/dkg/dkg_test.go b/dkg/dkg_test.go index 44c161813..2a74566f9 100644 --- a/dkg/dkg_test.go +++ b/dkg/dkg_test.go @@ -42,6 +42,30 @@ import ( "github.com/obolnetwork/charon/testutil" ) +const ( + v1_10 = "v1.10.0" + v1_9 = "v1.9.0" + v1_8 = "v1.8.0" + v1_7 = "v1.7.0" + v1_6 = "v1.6.0" + v1_5 = "v1.5.0" + v1_4 = "v1.4.0" + v1_3 = "v1.3.0" + v1_2 = "v1.2.0" + v1_1 = "v1.1.0" + v1_0 = "v1.0.0" +) + +func isAnyVersion(version string, list ...string) bool { + for _, v := range list { + if version == v { + return true + } + } + + return false +} + func TestDKG(t *testing.T) { const ( nodes = 3 @@ -108,6 +132,11 @@ func TestDKG(t *testing.T) { if test.version != "" { opts = append(opts, cluster.WithVersion(test.version)) } + if isAnyVersion(test.version, v1_0, v1_1, v1_2, v1_3, v1_4, v1_5, v1_6, v1_7, v1_8, v1_9) { + opts = append(opts, func(d *cluster.Definition) { d.TargetGasLimit = 0 }) + } else { + opts = append(opts, func(d *cluster.Definition) { d.TargetGasLimit = 30000000 }) + } seed := 1 random := rand.New(rand.NewSource(int64(seed)))