-
Notifications
You must be signed in to change notification settings - Fork 699
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
Blocks backfilling option - 0 Empty implementations #2343
Changes from all commits
6108e6a
76dbcc4
586dcbc
a4bfddd
16b8cef
f67ba0a
b34e974
e8fe105
33e0829
f8b3178
4b38a58
f6c3bb0
518f88b
143934e
78cc14b
76ce1e1
69199fc
fa7f02d
0c9b208
d6f49fc
5b058f7
bf308c8
0720496
3e70e97
6c1a40a
fa12327
ca3c6e9
004c787
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ package metervm | |
import ( | ||
"context" | ||
|
||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/avalanchego/snow/engine/snowman/block" | ||
) | ||
|
||
|
@@ -78,3 +79,37 @@ func (vm *blockVM) GetStateSummary(ctx context.Context, height uint64) (block.St | |
vm.blockMetrics.getStateSummary.Observe(duration) | ||
return summary, nil | ||
} | ||
|
||
func (vm *blockVM) BackfillBlocksEnabled(ctx context.Context) (ids.ID, uint64, error) { | ||
if vm.ssVM == nil { | ||
return ids.Empty, 0, block.ErrStateSyncableVMNotImplemented | ||
} | ||
|
||
start := vm.clock.Time() | ||
blkID, blkHeight, err := vm.ssVM.BackfillBlocksEnabled(ctx) | ||
end := vm.clock.Time() | ||
duration := float64(end.Sub(start)) | ||
if err != nil { | ||
vm.blockMetrics.backfillBlocksEnabled.Observe(duration) | ||
return ids.Empty, blkHeight, err | ||
} | ||
vm.blockMetrics.backfillBlocksEnabled.Observe(duration) | ||
return blkID, blkHeight, nil | ||
} | ||
|
||
func (vm *blockVM) BackfillBlocks(ctx context.Context, blocks [][]byte) (ids.ID, uint64, error) { | ||
if vm.ssVM == nil { | ||
return ids.Empty, 0, block.ErrStateSyncableVMNotImplemented | ||
} | ||
|
||
start := vm.clock.Time() | ||
nextWantedBlkID, nextWantedBlkHeight, err := vm.ssVM.BackfillBlocks(ctx, blocks) | ||
end := vm.clock.Time() | ||
duration := float64(end.Sub(start)) | ||
if err != nil { | ||
vm.blockMetrics.backfillBlocks.Observe(duration) | ||
return nextWantedBlkID, nextWantedBlkHeight, err | ||
} | ||
vm.blockMetrics.backfillBlocks.Observe(duration) | ||
return nextWantedBlkID, nextWantedBlkHeight, nil | ||
} | ||
Comment on lines
+83
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is all we need to extende the interface in the metervm, so I figured I coded it in this first PR to reduce diffs down the line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change of this PR, where the new interface is introduced and its usage described