Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: lazy storage diff parsing #1019

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/parsers/operations/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (p Transaction) Parse(ctx context.Context, data noderpc.Operation, store pa
}
}

func (p Transaction) parseSmartRollupParams(data noderpc.Operation, tx *operation.Operation) error {
func (p Transaction) parseSmartRollupParams(_ noderpc.Operation, tx *operation.Operation) error {
if len(tx.Parameters) == 0 {
return tx.Entrypoint.Set(consts.DefaultEntrypoint)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/parsers/protocols/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (m Migration) contractMigrations(
return nil
}

func (m Migration) vestingMigration(ctx context.Context, tx models.Transaction, head noderpc.Header, currentProtocol protocol.Protocol) error {
func (m Migration) vestingMigration(ctx context.Context, _ models.Transaction, head noderpc.Header, currentProtocol protocol.Protocol) error {
addresses, err := m.ctx.RPC.GetContractsByBlock(ctx, head.Level)
if err != nil {
return err
Expand Down
22 changes: 16 additions & 6 deletions internal/parsers/storage/lazy_babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type LazyBabylon struct {

ptrMap map[int64]int64
temporaryPointers map[int64]*ast.BigMap
allocated map[int64]struct{}
}

// NewLazyBabylon -
Expand All @@ -33,6 +34,7 @@ func NewLazyBabylon(repo bigmapdiff.Repository, operations operation.Repository,

ptrMap: make(map[int64]int64),
temporaryPointers: make(map[int64]*ast.BigMap),
allocated: make(map[int64]struct{}),
}
}

Expand Down Expand Up @@ -123,6 +125,9 @@ func (b *LazyBabylon) checkPointers(result *noderpc.OperationResult, storage *as
if ptr < 0 {
continue
}
if _, ok := b.temporaryPointers[ptr]; ok {
continue
}

default:
ptr := lsd.ID
Expand All @@ -135,6 +140,9 @@ func (b *LazyBabylon) checkPointers(result *noderpc.OperationResult, storage *as
if ptr < 0 {
continue
}
if _, ok := b.temporaryPointers[ptr]; ok {
continue
}

}
return ErrUnknownTemporaryPointer
Expand Down Expand Up @@ -281,6 +289,7 @@ func (b *LazyBabylon) handleBigMapDiffAlloc(ctx context.Context, diff *noderpc.L
if ptr > -1 {
operation.BigMapActions = append(operation.BigMapActions, b.createBigMapDiffAction("alloc", address, &ptr, nil, operation))
}
b.allocated[ptr] = struct{}{}

return b.handleBigMapDiffUpdate(ctx, diff, ptr, address, operation, store)
}
Expand Down Expand Up @@ -347,19 +356,20 @@ func (b *LazyBabylon) updateTemporaryPointers(src, dst int64) {

func (b *LazyBabylon) getCopyBigMapDiff(ctx context.Context, src int64, address string) (bmd []bigmapdiff.BigMapDiff, err error) {
if src > -1 {
if _, ok := b.allocated[src]; ok {
return b.getDiffsFromUpdates(src)
}
states, err := b.repo.GetByPtr(ctx, address, src)
if err != nil {
return nil, err
}

bmd = make([]bigmapdiff.BigMapDiff, 0, len(states))
for i := range states {
bmd = append(bmd, states[i].ToDiff())
}
} else {
bmd, err = b.getDiffsFromUpdates(src)
if err != nil {
return nil, err
}
return bmd, nil
}
return

return b.getDiffsFromUpdates(src)
}
Loading