Skip to content

Commit

Permalink
feat(proto): Add _v2 fields to support wrapperspb.Uint64Value (#157)
Browse files Browse the repository at this point in the history
* feat(proto): Add _v2 fields to support wrapperspb.Uint64Value

* refactor(proto): Remove deprecated fields

* Add subcommittee_index_v2

* refactor: Simplify clock drift calculation
  • Loading branch information
samcm authored Aug 21, 2023
1 parent 0cccf4b commit 4e8b4fd
Show file tree
Hide file tree
Showing 33 changed files with 2,662 additions and 1,442 deletions.
2 changes: 2 additions & 0 deletions pkg/mimicry/mimicry.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/wrapperspb"
)

type Mimicry struct {
Expand Down Expand Up @@ -168,6 +169,7 @@ func (m *Mimicry) createNewClientMeta(ctx context.Context) (*xatu.ClientMeta, er
Implementation: xatu.Implementation,
Os: runtime.GOOS,
ClockDrift: uint64(m.clockDrift.Milliseconds()),
ClockDriftV2: wrapperspb.UInt64(uint64(m.clockDrift.Milliseconds())),
Labels: m.Config.Labels,
}, nil
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/mimicry/p2p/execution/event_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethpandaops/xatu/pkg/proto/xatu"
"github.com/sirupsen/logrus"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

func (p *Peer) handleTransaction(ctx context.Context, eventTime time.Time, event *types.Transaction) (*xatu.DecoratedEvent, error) {
Expand All @@ -23,7 +24,7 @@ func (p *Peer) handleTransaction(ctx context.Context, eventTime time.Time, event

now := time.Now()
if meta != nil {
now = now.Add(time.Duration(meta.ClockDrift) * time.Millisecond)
now = now.Add(time.Duration(meta.ClockDriftV2.Value) * time.Millisecond)
}

tx, err := event.MarshalBinary()
Expand Down Expand Up @@ -71,10 +72,12 @@ func (p *Peer) getTransactionData(ctx context.Context, event *types.Transaction,

extra := &xatu.ClientMeta_AdditionalMempoolTransactionData{
Nonce: event.Nonce(),
NonceV2: wrapperspb.UInt64(event.Nonce()),
GasPrice: event.GasPrice().String(),
From: from.String(),
To: to,
Gas: event.Gas(),
GasV2: wrapperspb.UInt64(event.Gas()),
Value: event.Value().String(),
Hash: event.Hash().String(),
Size: strconv.FormatFloat(float64(event.Size()), 'f', 0, 64),
Expand Down
155 changes: 102 additions & 53 deletions pkg/proto/eth/v1/attestation.pb.go

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions pkg/proto/eth/v1/attestation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package xatu.eth.v1;

option go_package = "github.com/ethpandaops/xatu/pkg/proto/eth/v1";

import "google/protobuf/wrappers.proto";
import "google/protobuf/descriptor.proto";
import "pkg/proto/eth/v1/checkpoint.proto";

Expand All @@ -18,23 +19,29 @@ message Attestation {
}

message AttestationData {
uint64 slot = 1;
uint64 slot = 1 [ deprecated = true ];

uint64 index = 2;
uint64 index = 2 [ deprecated = true ];

string beacon_block_root = 3 [json_name="beacon_block_root"];

Checkpoint source = 4;

Checkpoint target = 5;

google.protobuf.UInt64Value slot_v2 = 6 [json_name="slot_v2"];

google.protobuf.UInt64Value index_v2 = 7 [json_name="index_v2"];
}

message AggregateAttestationAndProof {
uint64 aggregator_index = 1 [json_name="aggregator_index"];
uint64 aggregator_index = 1 [json_name="aggregator_index", deprecated=true];

Attestation aggregate = 3;

string selection_proof = 2 [json_name="selection_proof"];

google.protobuf.UInt64Value aggregator_index_v2 = 4 [json_name="aggregator_index_v2"];
}

message SignedAggregateAttestationAndProof {
Expand Down
373 changes: 204 additions & 169 deletions pkg/proto/eth/v1/beacon_block.pb.go

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions pkg/proto/eth/v1/beacon_block.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ package xatu.eth.v1;

option go_package = "github.com/ethpandaops/xatu/pkg/proto/eth/v1";

import "google/protobuf/wrappers.proto";
import "google/protobuf/descriptor.proto";
import "pkg/proto/eth/v1/attestation.proto";

message BeaconBlock {
uint64 slot = 1;
uint64 slot = 1 [ deprecated=true ];

uint64 proposer_index = 2 [ json_name = "proposer_index" ];
uint64 proposer_index = 2 [ json_name = "proposer_index", deprecated=true ];

string parent_root = 3 [ json_name = "parent_root" ];

string state_root = 4 [ json_name = "state_root" ];

BeaconBlockBody body = 5;

google.protobuf.UInt64Value slot_v2 = 6 [ json_name = "slot_v2" ];

google.protobuf.UInt64Value proposer_index_v2 = 7 [ json_name = "proposer_index_v2" ];
}

message SignedBeaconBlock {
Expand Down
50 changes: 34 additions & 16 deletions pkg/proto/eth/v1/checkpoint.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pkg/proto/eth/v1/checkpoint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ package xatu.eth.v1;
option go_package = "github.com/ethpandaops/xatu/pkg/proto/eth/v1";

import "google/protobuf/descriptor.proto";
import "google/protobuf/wrappers.proto";

message Checkpoint {
uint64 epoch = 1;
uint64 epoch = 1 [ deprecated=true ];

string root = 2;

google.protobuf.UInt64Value epoch_v2 = 3 [ json_name = "epoch_v2" ];
}
Loading

0 comments on commit 4e8b4fd

Please sign in to comment.