Skip to content

Commit 23031e8

Browse files
committed
Updates for VM program without Anchor
1 parent 7035719 commit 23031e8

File tree

8 files changed

+107
-180
lines changed

8 files changed

+107
-180
lines changed

generated/indexer/v1/model.pb.go

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

generated/indexer/v1/model.pb.validate.go

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

geyser/handler_memory.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (h *MemoryAccountWithDataUpdateHandler) onStateObserved(ctx context.Context
250250

251251
// Track delta changes to the memory account state to be persisted into the DB
252252
var dbUpdates []*cachedVirtualAccount
253-
for index, item := range state.Data.Items {
253+
for index := range state.Data.State {
254254
log := log.WithField("index", index)
255255

256256
cachedVirtualAccountState, ok := cachedState[index]
@@ -265,7 +265,7 @@ func (h *MemoryAccountWithDataUpdateHandler) onStateObserved(ctx context.Context
265265
continue
266266
}
267267

268-
isInitialized := item.IsAllocated()
268+
isInitialized := state.Data.IsAllocated(index)
269269

270270
var base58VirtualAccountAddress string
271271
var newVirtualAccountState []byte
@@ -296,7 +296,7 @@ func (h *MemoryAccountWithDataUpdateHandler) onStateObserved(ctx context.Context
296296
log.WithError(err).Warn("failure unmarshalling virtual relay account")
297297
return err
298298
}
299-
base58VirtualAccountAddress = base58.Encode(virtualAccountState.Address)
299+
base58VirtualAccountAddress = base58.Encode(virtualAccountState.Target)
300300
default:
301301
// Changelog item, which isn't being tracked in the virtual accounts DB,
302302
// so treat it as an unititialized memory item

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/code-payments/code-vm-indexer
33
go 1.23.0
44

55
require (
6-
github.com/code-payments/code-server v1.10.19-0.20241002150816-4b4b1b852853
6+
github.com/code-payments/code-server v1.10.20-0.20241028131502-fb335efd35b0
77
github.com/envoyproxy/protoc-gen-validate v1.0.4
88
github.com/golang/protobuf v1.5.4
99
github.com/jackc/pgx/v4 v4.13.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I
8080
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
8181
github.com/code-payments/code-protobuf-api v1.18.1-0.20240912180853-8e16dd113886 h1:PLbMVgpFwwhI6Ji+izq/NnJQGq41OKQ2dP3oPpUEcCA=
8282
github.com/code-payments/code-protobuf-api v1.18.1-0.20240912180853-8e16dd113886/go.mod h1:pHQm75vydD6Cm2qHAzlimW6drysm489Z4tVxC2zHSsU=
83-
github.com/code-payments/code-server v1.10.19-0.20241002150816-4b4b1b852853 h1:Bsdt7Rq0a2zCtgx4ZfFTkaco3rv3nwjimRhlkKtmthw=
84-
github.com/code-payments/code-server v1.10.19-0.20241002150816-4b4b1b852853/go.mod h1:yxU6DeVToqlBm1VQabtnC3pBb92uvZMPwCd4emZB+ZI=
83+
github.com/code-payments/code-server v1.10.20-0.20241028131502-fb335efd35b0 h1:1zfMP6cZRIoe38xOlk6XWrBcbMc+UAEDooEiAnj7nUA=
84+
github.com/code-payments/code-server v1.10.20-0.20241028131502-fb335efd35b0/go.mod h1:yxU6DeVToqlBm1VQabtnC3pBb92uvZMPwCd4emZB+ZI=
8585
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
8686
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
8787
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=

proto/indexer/model.proto

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,9 @@ message VirtualDurableNonce {
5858
}
5959

6060
message VirtualRelayAccount {
61-
Address address = 1 [(validate.rules).message.required = true];
62-
63-
Hash commitment = 2 [(validate.rules).message.required = true];
64-
65-
Hash recent_root = 3 [(validate.rules).message.required = true];
61+
Address target = 1 [(validate.rules).message.required = true];
6662

67-
Address destination = 4 [(validate.rules).message.required = true];
63+
Address destination = 2 [(validate.rules).message.required = true];
6864
}
6965

7066
message VirtualAccountStorage {

rpc/server.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ func (s *server) GetVirtualRelayAccount(ctx context.Context, req *indexerpb.GetV
188188
Result: indexerpb.GetVirtualRelayAccountResponse_OK,
189189
Item: &indexerpb.VirtualRelayAccountWithStorageMetadata{
190190
Account: &indexerpb.VirtualRelayAccount{
191-
Address: &indexerpb.Address{Value: vra.Address},
192-
Commitment: &indexerpb.Hash{Value: vra.Commitment[:]},
193-
RecentRoot: &indexerpb.Hash{Value: vra.RecentRoot[:]},
191+
Target: &indexerpb.Address{Value: vra.Target},
194192
Destination: &indexerpb.Address{Value: vra.Destination},
195193
},
196194
Storage: &indexerpb.VirtualAccountStorage{

rpc/server_test.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,22 @@ func TestGetVirtualRelayAccount_HappyPath_Memory(t *testing.T) {
121121

122122
resp, err := env.client.GetVirtualRelayAccount(env.ctx, &indexerpb.GetVirtualRelayAccountRequest{
123123
VmAccount: &indexerpb.Address{Value: vmAccount.PublicKey().ToBytes()},
124-
Address: &indexerpb.Address{Value: vra.Address},
124+
Address: &indexerpb.Address{Value: vra.Target},
125125
})
126126
require.NoError(t, err)
127127
assert.Equal(t, indexerpb.GetVirtualRelayAccountResponse_NOT_FOUND, resp.Result)
128128

129-
ramRecord := env.saveVirtualAccountToRamDb(t, vmAccount, cvm.VirtualAccountTypeRelay, base58.Encode(vra.Address), vra.Marshal())
129+
ramRecord := env.saveVirtualAccountToRamDb(t, vmAccount, cvm.VirtualAccountTypeRelay, base58.Encode(vra.Target), vra.Marshal())
130130

131131
resp, err = env.client.GetVirtualRelayAccount(env.ctx, &indexerpb.GetVirtualRelayAccountRequest{
132132
VmAccount: &indexerpb.Address{Value: vmAccount.PublicKey().ToBytes()},
133-
Address: &indexerpb.Address{Value: vra.Address},
133+
Address: &indexerpb.Address{Value: vra.Target},
134134
})
135135
require.NoError(t, err)
136136

137137
assert.Equal(t, indexerpb.GetVirtualRelayAccountResponse_OK, resp.Result)
138138

139-
assert.EqualValues(t, vra.Address, resp.Item.Account.Address.Value)
140-
assert.EqualValues(t, vra.Commitment[:], resp.Item.Account.Commitment.Value)
141-
assert.EqualValues(t, vra.RecentRoot[:], resp.Item.Account.RecentRoot.Value)
139+
assert.EqualValues(t, vra.Target, resp.Item.Account.Target.Value)
142140
assert.EqualValues(t, vra.Destination, resp.Item.Account.Destination.Value)
143141

144142
memoryStorage := resp.Item.Storage.GetMemory()
@@ -235,19 +233,13 @@ func generateVirtualTimelockAccount(owner ed25519.PublicKey) *cvm.VirtualTimeloc
235233

236234
func generateVirtualRelayAccount() *cvm.VirtualRelayAccount {
237235
var address [32]byte
238-
var commitment [32]byte
239-
var recentRoot [32]byte
240236
var destination [32]byte
241237

242238
rand.Read(address[:])
243-
rand.Read(commitment[:])
244-
rand.Read(recentRoot[:])
245239
rand.Read(destination[:])
246240

247241
return &cvm.VirtualRelayAccount{
248-
Address: address[:],
249-
Commitment: commitment,
250-
RecentRoot: recentRoot,
242+
Target: address[:],
251243
Destination: destination[:],
252244
}
253245
}

0 commit comments

Comments
 (0)