Skip to content

Commit 4a9ee47

Browse files
authored
Switch over to Yellowstone Geyser plugin (#195)
1 parent 8b0a577 commit 4a9ee47

14 files changed

+3588
-7722
lines changed

pkg/code/async/geyser/api/gen/confirmed_block.pb.validate.go

Lines changed: 0 additions & 2685 deletions
This file was deleted.

pkg/code/async/geyser/api/gen/geyser.pb.go

Lines changed: 2714 additions & 884 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/code/async/geyser/api/gen/geyser.pb.validate.go

Lines changed: 0 additions & 2779 deletions
This file was deleted.

pkg/code/async/geyser/api/gen/geyser_grpc.pb.go

Lines changed: 185 additions & 406 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/code/async/geyser/api/gen/confirmed_block.pb.go renamed to pkg/code/async/geyser/api/gen/solana-storage.pb.go

Lines changed: 355 additions & 355 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/code/async/geyser/api/proto/geyser.proto

Lines changed: 207 additions & 157 deletions
Large diffs are not rendered by default.

pkg/code/async/geyser/api/proto/confirmed_block.proto renamed to pkg/code/async/geyser/api/proto/solana-storage.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Source: https://github.com/jito-foundation/geyser-grpc-plugin/blob/v2.2/proto/proto/confirmed_block.proto
1+
// Source: https://github.com/rpcpool/yellowstone-grpc/blob/v6.0.0%2Bsolana.2.2.12/yellowstone-grpc-proto/proto/solana-storage.proto
22

33
syntax = "proto3";
44

@@ -134,8 +134,8 @@ message Reward {
134134
}
135135

136136
message Rewards {
137-
repeated Reward rewards = 1;
138-
NumPartitions num_partitions = 2;
137+
repeated Reward rewards = 1;
138+
NumPartitions num_partitions = 2;
139139
}
140140

141141
message UnixTimestamp {

pkg/code/async/geyser/config.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const (
1313
GrpcPluginEndointConfigEnvName = envConfigPrefix + "GRPC_PLUGIN_ENDPOINT"
1414
defaultGrpcPluginEndoint = ""
1515

16+
GrpcPluginXTokenConfigEnvName = envConfigPrefix + "GRPC_PLUGIN_X_TOKEN"
17+
defaultGrpcPluginXToken = ""
18+
1619
ProgramUpdateWorkerCountConfigEnvName = envConfigPrefix + "PROGRAM_UPDATE_WORKER_COUNT"
1720
defaultProgramUpdateWorkerCount = 1024
1821

@@ -24,22 +27,18 @@ const (
2427

2528
BackupExternalDepositWorkerIntervalConfigEnvName = envConfigPrefix + "BACKUP_EXTERNAL_DEPOSIT_WORKER_INTERVAL"
2629
defaultBackupExternalDepositWorkerInterval = 15 * time.Second
27-
28-
SwapSubsidizerPublicKeyConfigEnvName = envConfigPrefix + "SWAP_SUBSIDIZER_PUBLIC_KEY"
29-
defaultSwapSubsidizerPublicKey = "invalid" // ensure something valid is set
3030
)
3131

3232
type conf struct {
3333
grpcPluginEndpoint config.String
34+
grpcPluginXToken config.String
3435

3536
programUpdateWorkerCount config.Uint64
3637
programUpdateQueueSize config.Uint64
3738

3839
backupExternalDepositWorkerInterval config.Duration
3940

4041
backupTimelockWorkerInterval config.Duration
41-
42-
swapSubsidizerPublicKey config.String
4342
}
4443

4544
// ConfigProvider defines how config values are pulled
@@ -50,15 +49,14 @@ func WithEnvConfigs() ConfigProvider {
5049
return func() *conf {
5150
return &conf{
5251
grpcPluginEndpoint: env.NewStringConfig(GrpcPluginEndointConfigEnvName, defaultGrpcPluginEndoint),
52+
grpcPluginXToken: env.NewStringConfig(GrpcPluginXTokenConfigEnvName, defaultGrpcPluginXToken),
5353

5454
programUpdateWorkerCount: env.NewUint64Config(ProgramUpdateWorkerCountConfigEnvName, defaultProgramUpdateWorkerCount),
5555
programUpdateQueueSize: env.NewUint64Config(ProgramUpdateQueueSizeConfigEnvName, defaultProgramUpdateQueueSize),
5656

5757
backupExternalDepositWorkerInterval: env.NewDurationConfig(BackupExternalDepositWorkerIntervalConfigEnvName, defaultBackupExternalDepositWorkerInterval),
5858

5959
backupTimelockWorkerInterval: env.NewDurationConfig(BackupTimelockWorkerIntervalConfigEnvName, defaultBackupTimelockWorkerInterval),
60-
61-
swapSubsidizerPublicKey: env.NewStringConfig(SwapSubsidizerPublicKeyConfigEnvName, defaultSwapSubsidizerPublicKey),
6260
}
6361
}
6462
}

pkg/code/async/geyser/consumer.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"context"
55
"time"
66

7+
"github.com/mr-tron/base58"
78
"github.com/newrelic/go-agent/v3/newrelic"
89
"github.com/pkg/errors"
910
"github.com/sirupsen/logrus"
1011

11-
"github.com/code-payments/code-server/pkg/metrics"
1212
"github.com/code-payments/code-server/pkg/code/common"
13+
"github.com/code-payments/code-server/pkg/metrics"
1314
)
1415

1516
func (p *service) consumeGeyserProgramUpdateEvents(ctx context.Context) error {
@@ -23,7 +24,7 @@ func (p *service) consumeGeyserProgramUpdateEvents(ctx context.Context) error {
2324
default:
2425
}
2526

26-
err := p.subscribeToProgramUpdatesFromGeyser(ctx, p.conf.grpcPluginEndpoint.Get(ctx))
27+
err := p.subscribeToProgramUpdatesFromGeyser(ctx, p.conf.grpcPluginEndpoint.Get(ctx), p.conf.grpcPluginXToken.Get(ctx))
2728
if err != nil && !errors.Is(err, context.Canceled) {
2829
log.WithError(err).Warn("program update consumer unexpectedly terminated")
2930
}
@@ -44,7 +45,7 @@ func (p *service) consumeGeyserSlotUpdateEvents(ctx context.Context) error {
4445
default:
4546
}
4647

47-
err := p.subscribeToSlotUpdatesFromGeyser(ctx, p.conf.grpcPluginEndpoint.Get(ctx))
48+
err := p.subscribeToSlotUpdatesFromGeyser(ctx, p.conf.grpcPluginEndpoint.Get(ctx), p.conf.grpcPluginXToken.Get(ctx))
4849
if err != nil && !errors.Is(err, context.Canceled) {
4950
log.WithError(err).Warn("slot update consumer unexpectedly terminated")
5051
}
@@ -90,13 +91,13 @@ func (p *service) programUpdateWorker(serviceCtx context.Context, id int) {
9091
p.metricStatusLock.Unlock()
9192
}()
9293

93-
publicKey, err := common.NewAccountFromPublicKeyBytes(update.Pubkey)
94+
publicKey, err := common.NewAccountFromPublicKeyBytes(update.Account.Pubkey)
9495
if err != nil {
9596
log.WithError(err).Warn("invalid public key")
9697
return
9798
}
9899

99-
program, err := common.NewAccountFromPublicKeyBytes(update.Owner)
100+
program, err := common.NewAccountFromPublicKeyBytes(update.Account.Owner)
100101
if err != nil {
101102
log.WithError(err).Warn("invalid owner account")
102103
return
@@ -107,8 +108,8 @@ func (p *service) programUpdateWorker(serviceCtx context.Context, id int) {
107108
"account": publicKey.PublicKey().ToBase58(),
108109
"slot": update.Slot,
109110
})
110-
if update.TxSignature != nil {
111-
log = log.WithField("transaction", *update.TxSignature)
111+
if update.Account.TxnSignature != nil {
112+
log = log.WithField("transaction", base58.Encode(update.Account.TxnSignature))
112113
}
113114

114115
handler, ok := p.programUpdateHandlers[program.PublicKey().ToBase58()]

0 commit comments

Comments
 (0)