Skip to content

Commit

Permalink
feat: update to v2 events
Browse files Browse the repository at this point in the history
  • Loading branch information
Savid committed Aug 22, 2023
1 parent d6b70ca commit 6aff1fc
Show file tree
Hide file tree
Showing 51 changed files with 10,436 additions and 3,672 deletions.
2 changes: 0 additions & 2 deletions pkg/mimicry/mimicry.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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 @@ -169,7 +168,6 @@ 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
10 changes: 4 additions & 6 deletions pkg/mimicry/p2p/execution/event_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,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.ClockDriftV2.Value) * time.Millisecond)
now = now.Add(time.Duration(meta.ClockDrift) * time.Millisecond)
}

tx, err := event.MarshalBinary()
Expand Down Expand Up @@ -70,14 +70,12 @@ func (p *Peer) getTransactionData(ctx context.Context, event *types.Transaction,
return nil, err
}

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

Large diffs are not rendered by default.

38 changes: 26 additions & 12 deletions pkg/proto/eth/v1/attestation.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";

// Note: largely inspired by https://github.com/prysmaticlabs/prysm/tree/develop/proto/eth/v1
// Note: largely inspired by
// https://github.com/prysmaticlabs/prysm/tree/develop/proto/eth/v1

package xatu.eth.v1;

Expand All @@ -11,42 +12,55 @@ import "google/protobuf/descriptor.proto";
import "pkg/proto/eth/v1/checkpoint.proto";

message Attestation {
string aggregation_bits = 1 [json_name="aggregation_bits"];
string aggregation_bits = 1 [ json_name = "aggregation_bits" ];

string signature = 2;

AttestationData data = 3;
}

message AttestationV2 {
string aggregation_bits = 1 [ json_name = "aggregation_bits" ];

string signature = 2;

AttestationDataV2 data = 3;
}

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

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

string beacon_block_root = 3 [json_name="beacon_block_root"];
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"];
message AttestationDataV2 {
google.protobuf.UInt64Value slot = 1 [ json_name = "slot" ];

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

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

CheckpointV2 source = 4;

CheckpointV2 target = 5;
}

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

Attestation aggregate = 3;

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

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

message SignedAggregateAttestationAndProof {
AggregateAttestationAndProof message = 1;

string signature = 2;
}

Loading

0 comments on commit 6aff1fc

Please sign in to comment.