Skip to content

Commit

Permalink
Merge pull request #163 from ethpandaops/feat/blockv2
Browse files Browse the repository at this point in the history
feat(sentry): add v2 events
  • Loading branch information
Savid authored Aug 22, 2023
2 parents 1f5dfaf + e84f064 commit 6025aa9
Show file tree
Hide file tree
Showing 53 changed files with 11,168 additions and 3,836 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
22 changes: 10 additions & 12 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 All @@ -34,30 +34,30 @@ func (p *Peer) handleTransaction(ctx context.Context, eventTime time.Time, event

decoratedEvent := &xatu.DecoratedEvent{
Event: &xatu.Event{
Name: xatu.Event_MEMPOOL_TRANSACTION,
Name: xatu.Event_MEMPOOL_TRANSACTION_V2,
DateTime: timestamppb.New(now),
},
Meta: &xatu.Meta{
Client: meta,
},
Data: &xatu.DecoratedEvent_MempoolTransaction{
MempoolTransaction: fmt.Sprintf("0x%x", tx),
Data: &xatu.DecoratedEvent_MempoolTransactionV2{
MempoolTransactionV2: fmt.Sprintf("0x%x", tx),
},
}

additionalData, err := p.getTransactionData(ctx, event, meta, now)
if err != nil {
p.log.WithError(err).Error("Failed to get extra transaction data")
} else {
decoratedEvent.Meta.Client.AdditionalData = &xatu.ClientMeta_MempoolTransaction{
MempoolTransaction: additionalData,
decoratedEvent.Meta.Client.AdditionalData = &xatu.ClientMeta_MempoolTransactionV2{
MempoolTransactionV2: additionalData,
}
}

return decoratedEvent, nil
}

func (p *Peer) getTransactionData(ctx context.Context, event *types.Transaction, meta *xatu.ClientMeta, eventTime time.Time) (*xatu.ClientMeta_AdditionalMempoolTransactionData, error) {
func (p *Peer) getTransactionData(ctx context.Context, event *types.Transaction, meta *xatu.ClientMeta, eventTime time.Time) (*xatu.ClientMeta_AdditionalMempoolTransactionV2Data, error) {
var to string
if event.To() != nil {
to = event.To().String()
Expand All @@ -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
Loading

0 comments on commit 6025aa9

Please sign in to comment.