-
Notifications
You must be signed in to change notification settings - Fork 0
Support avalanchego usage #2
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
base: arr4n/strevm-poc
Are you sure you want to change the base?
Changes from 9 commits
7c0e6e4
2d2b12e
068d02a
c531b1f
3323052
1bbbf5d
8c13c27
0e779a6
9ba54f1
c3e160e
9c068d5
1b37a75
b50028a
203fa4d
136522d
50cda47
4b67ed4
f34d354
3bc28f3
64741e2
25242cc
ecff938
d5397bc
cb515d8
4a82f04
9c48d50
797da31
b104885
06ce124
4aa88ff
b6e1701
3ce2e9c
d9b9474
5ae6bb3
03d6c0a
b586245
07807e2
74ccf47
04d5104
540e3ad
bfe8d91
db02f10
bbd4462
3b70781
c07db95
4f6ed22
01d692c
29dacde
74a0891
d9448d9
13ad8fe
998dcaa
07f63fd
8f95b2a
2491889
b363264
ee4dcf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import ( | |
| "slices" | ||
|
|
||
| "github.com/arr4n/sink" | ||
| snowcommon "github.com/ava-labs/avalanchego/snow/engine/common" | ||
| "github.com/ava-labs/avalanchego/vms/components/gas" | ||
| "github.com/ava-labs/libevm/core/state" | ||
| "github.com/ava-labs/libevm/core/types" | ||
|
|
@@ -21,7 +22,20 @@ func (vm *VM) buildBlock(ctx context.Context, timestamp uint64, parent *Block) ( | |
| block, err := sink.FromPriorityMutex( | ||
| ctx, vm.mempool, sink.MaxPriority, | ||
| func(_ <-chan sink.Priority, pool *queue.Priority[*pendingTx]) (*Block, error) { | ||
| return vm.buildBlockWithCandidateTxs(timestamp, parent, pool) | ||
| block, err := vm.buildBlockWithCandidateTxs(timestamp, parent, pool) | ||
|
|
||
| // TODO: This shouldn't be done immediately, there should be some | ||
| // retry delay if block building failed. | ||
| if pool.Len() > 0 { | ||
| select { | ||
| case vm.toEngine <- snowcommon.PendingTxs: | ||
| default: | ||
| p := snowcommon.PendingTxs | ||
| vm.logger().Info(fmt.Sprintf("%T(%s) dropped", p, p)) | ||
| } | ||
| } | ||
|
|
||
| return block, err | ||
| }, | ||
| ) | ||
| if err != nil { | ||
|
|
@@ -84,7 +98,8 @@ func (vm *VM) buildBlockWithCandidateTxs(timestamp uint64, parent *Block, candid | |
| return nil, err | ||
| } | ||
| if gasUsed == 0 && len(txs) == 0 { | ||
| return nil, errNoopBlock | ||
| vm.logger().Info("Blocks must either settle or include transactions") | ||
| return nil, fmt.Errorf("%w: parent %#x at time %d", errNoopBlock, parent.Hash(), timestamp) | ||
| } | ||
|
|
||
| b := vm.newBlock(types.NewBlock( | ||
|
|
@@ -179,6 +194,10 @@ func (vm *VM) buildBlockOnHistory(lastSettled, parent *Block, timestamp uint64, | |
| "Unknown error from worst-case transaction checking", | ||
| zap.Error(err), | ||
| ) | ||
|
|
||
| // TODO: It is not acceptable to return an error here, as all | ||
|
||
| // transactions that have been removed from the mempool will be | ||
| // dropped and never included. | ||
| return nil, 0, err | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
| set -o pipefail | ||
|
|
||
| VMID="sr96zN6VeXJ4y5fY5EFziQrPSiy4LJPUMJGQsSLEW4t5bHWPw" | ||
StephenButtolph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| BINARY_PATH="$HOME/.avalanchego/plugins/$VMID" | ||
| echo "Building SAE EVM at $BINARY_PATH" | ||
| go build -o "$BINARY_PATH" "./rpc/"*.go | ||
| echo "Built SAE EVM at $BINARY_PATH" | ||
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.
Without this, we will only attempt to build a block if a new tx is issued. We won't attempt to build a block once we are ready to settle a new state (and give us space to issue new txs)