Skip to content

Commit 8f44e22

Browse files
committed
Remove observable VMs from Geyser worker
1 parent 44d19b2 commit 8f44e22

11 files changed

Lines changed: 17 additions & 71 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ go test -run TestName ./path/to/package/...
1616

1717
# Run locally (Docker)
1818
DATA_STORAGE_TYPE=memory make run-rpc
19-
DATA_STORAGE_TYPE=memory GEYSER_WORKER_GRPC_PLUGIN_ENDPOINT=localhost:10000 GEYSER_WORKER_VM_ACCOUNT=<VM_KEY> SOLANA_RPC_ENDPOINT=http://localhost:8899 make run-geyser
19+
DATA_STORAGE_TYPE=memory GEYSER_WORKER_GRPC_PLUGIN_ENDPOINT=localhost:10000 SOLANA_RPC_ENDPOINT=http://localhost:8899 make run-geyser
2020
```
2121

2222
Proto generation (`make generate`) is currently broken due to optional fields in the Geyser proto.

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ run-geyser: build-geyser build-geyser-image
6767
-e DATA_STORAGE_TYPE=$(DATA_STORAGE_TYPE) \
6868
-e GEYSER_WORKER_GRPC_PLUGIN_ENDPOINT=$(GEYSER_WORKER_GRPC_PLUGIN_ENDPOINT) \
6969
-e GEYSER_WORKER_PROGRAM_UPDATE_WORKER_COUNT=4 \
70-
-e GEYSER_WORKER_VM_ACCOUNT=$(GEYSER_WORKER_VM_ACCOUNT) \
7170
-e POSTGRES_USER=$(POSTGRES_USER) \
7271
-e POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) \
7372
-e POSTGRES_HOST=$(POSTGRES_HOST) \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ DATA_STORAGE_TYPE=memory make run-rpc
4242
5. Run the Geyser worker locally:
4343

4444
```bash
45-
DATA_STORAGE_TYPE=memory GEYSER_WORKER_GRPC_PLUGIN_ENDPOINT=localhost:10000 GEYSER_WORKER_VM_ACCOUNT=<VM_PUBLIC_KEY> SOLANA_RPC_ENDPOINT=http://localhost:8899 make run-geyser
45+
DATA_STORAGE_TYPE=memory GEYSER_WORKER_GRPC_PLUGIN_ENDPOINT=localhost:10000 SOLANA_RPC_ENDPOINT=http://localhost:8899 make run-geyser
4646
```
4747

4848
## Getting Help

data/ram/memory/memory.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,16 @@ func (s *store) Save(_ context.Context, data *ram.Record) error {
5757
}
5858

5959
// GetAllMemoryAccounts implements ram.Store.GetAllMemoryAccounts
60-
func (s *store) GetAllMemoryAccounts(ctx context.Context, vm string) ([]string, error) {
60+
func (s *store) GetAllMemoryAccounts(ctx context.Context) ([]string, error) {
6161
s.mu.Lock()
6262
defer s.mu.Unlock()
6363

64-
items := s.findByVm(vm)
65-
if len(items) == 0 {
64+
if len(s.records) == 0 {
6665
return nil, ram.ErrAccountNotFound
6766
}
6867

6968
uniqueMemoryAccounts := make(map[string]any)
70-
for _, item := range items {
69+
for _, item := range s.records {
7170
uniqueMemoryAccounts[item.MemoryAccount] = struct{}{}
7271
}
7372

@@ -126,16 +125,6 @@ func (s *store) findByMemoryAccount(memoryAccount string) []*ram.Record {
126125
return res
127126
}
128127

129-
func (s *store) findByVm(vm string) []*ram.Record {
130-
var res []*ram.Record
131-
for _, item := range s.records {
132-
if item.Vm == vm {
133-
res = append(res, item)
134-
}
135-
}
136-
return res
137-
}
138-
139128
func (s *store) findByVmAddressAndAccountType(vm, address string, accountType vm.VirtualAccountType) []*ram.Record {
140129
var res []*ram.Record
141130
for _, item := range s.records {

data/ram/postgres/model.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,15 @@ func (m *model) dbSave(ctx context.Context, tableName string, db *sqlx.DB) error
133133
return pgutil.CheckNoRows(err, ram.ErrStaleState)
134134
}
135135

136-
func dbGetAllMemoryAccounts(ctx context.Context, tableName string, db *sqlx.DB, vm string) ([]string, error) {
136+
func dbGetAllMemoryAccounts(ctx context.Context, tableName string, db *sqlx.DB) ([]string, error) {
137137
res := []string{}
138138

139-
query := `SELECT DISTINCT(memory_account) FROM ` + tableName + `
140-
WHERE vm = $1`
139+
query := `SELECT DISTINCT(memory_account) FROM ` + tableName
141140

142141
err := db.SelectContext(
143142
ctx,
144143
&res,
145144
query,
146-
vm,
147145
)
148146
if err != nil {
149147
return nil, pgutil.CheckNoRows(err, ram.ErrAccountNotFound)

data/ram/postgres/store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func (s *store) Save(ctx context.Context, record *ram.Record) error {
4141
}
4242

4343
// GetAllMemoryAccounts implements ram.Store.GetAllMemoryAccounts
44-
func (s *store) GetAllMemoryAccounts(ctx context.Context, vm string) ([]string, error) {
45-
return dbGetAllMemoryAccounts(ctx, s.tableName, s.db, vm)
44+
func (s *store) GetAllMemoryAccounts(ctx context.Context) ([]string, error) {
45+
return dbGetAllMemoryAccounts(ctx, s.tableName, s.db)
4646
}
4747

4848
// GetAllByMemoryAccount implements ram.Store.GetAllByMemoryAccount

data/ram/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Store interface {
1818
Save(ctx context.Context, record *Record) error
1919

2020
// GetAllMemoryAccounts gets all unique memory account addresses
21-
GetAllMemoryAccounts(ctx context.Context, vm string) ([]string, error)
21+
GetAllMemoryAccounts(ctx context.Context) ([]string, error)
2222

2323
// GetAllByMemoryAccount gets all database records for a given memory account
2424
GetAllByMemoryAccount(ctx context.Context, memoryAccount string) ([]*Record, error)

data/ram/tests/tests.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func testGetAllMemoryAccounts(t *testing.T, s ram.Store) {
106106
t.Run("testGetAllMemoryAccounts", func(t *testing.T) {
107107
ctx := context.Background()
108108

109-
_, err := s.GetAllMemoryAccounts(ctx, "vm2")
109+
_, err := s.GetAllMemoryAccounts(ctx)
110110
assert.Equal(t, ram.ErrAccountNotFound, err)
111111

112112
for i := 0; i < 3; i++ {
@@ -121,10 +121,9 @@ func testGetAllMemoryAccounts(t *testing.T, s ram.Store) {
121121
}))
122122
}
123123

124-
actual, err := s.GetAllMemoryAccounts(ctx, "vm2")
124+
actual, err := s.GetAllMemoryAccounts(ctx)
125125
require.NoError(t, err)
126-
require.Len(t, actual, 1)
127-
assert.Equal(t, "memory_account_2", actual[0])
126+
require.Len(t, actual, 3)
128127
})
129128
}
130129

geyser/config.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package geyser
22

33
import (
4-
"context"
5-
"strings"
64
"time"
75

86
"github.com/code-payments/ocp-server/config"
@@ -24,9 +22,6 @@ const (
2422
ProgramUpdateQueueSizeConfigEnvName = envConfigPrefix + "PROGRAM_UPDATE_QUEUE_SIZE"
2523
defaultProgramUpdateQueueSize = 1_000_000
2624

27-
VmAccountsConfigEnvName = envConfigPrefix + "VM_ACCOUNTS"
28-
defaultVmAccounts = ""
29-
3025
MemoryAccountBackupWorkerIntervalConfigEnvName = envConfigPrefix + "MEMORY_ACCOUNT_BACKUP_WORKER_INTERVAL"
3126
defaultMemoryAccountBackupWorkerInterval = time.Minute
3227
)
@@ -38,8 +33,6 @@ type conf struct {
3833
programUpdateWorkerCount config.Uint64
3934
programUpdateQueueSize config.Uint64
4035

41-
vmAccounts config.String
42-
4336
memoryAccountBackkupWorkerInterval config.Duration
4437
}
4538

@@ -56,17 +49,8 @@ func WithEnvConfigs() ConfigProvider {
5649
programUpdateWorkerCount: env.NewUint64Config(ProgramUpdateWorkerCountConfigEnvName, defaultProgramUpdateWorkerCount),
5750
programUpdateQueueSize: env.NewUint64Config(ProgramUpdateQueueSizeConfigEnvName, defaultProgramUpdateQueueSize),
5851

59-
vmAccounts: env.NewStringConfig(VmAccountsConfigEnvName, defaultVmAccounts),
60-
6152
memoryAccountBackkupWorkerInterval: env.NewDurationConfig(MemoryAccountBackupWorkerIntervalConfigEnvName, defaultMemoryAccountBackupWorkerInterval),
6253
}
6354
}
6455
}
6556

66-
func parseVmAccountsConfig(ctx context.Context, c *conf) []string {
67-
parts := strings.Split(c.vmAccounts.Get(ctx), ",")
68-
for i, part := range parts {
69-
parts[i] = strings.TrimSpace(part)
70-
}
71-
return parts
72-
}

geyser/handler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func initializeProgramAccountUpdateHandlers(log *zap.Logger, conf *conf, solanaC
3434
solanaClient,
3535
ramStore,
3636
conf.memoryAccountBackkupWorkerInterval.Get(ctx),
37-
parseVmAccountsConfig(ctx, conf)...,
3837
),
3938
}
4039
}

0 commit comments

Comments
 (0)