Skip to content
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7c0e6e4
feat: `worstcase` package for validity checking
ARR4N Jun 8, 2025
2d2b12e
wip
StephenButtolph Jun 9, 2025
068d02a
Make things work
StephenButtolph Jun 9, 2025
c531b1f
more fixes
StephenButtolph Jun 9, 2025
3323052
nit
StephenButtolph Jun 9, 2025
1bbbf5d
merged
StephenButtolph Jun 9, 2025
8c13c27
fix FATAL in bootstrapping
StephenButtolph Jun 9, 2025
0e779a6
Merge branch 'arr4n/strevm-poc' into StephenButtolph/strevm-poc
ARR4N Jun 10, 2025
9ba54f1
Merge branch 'arr4n/strevm-poc' into StephenButtolph/strevm-poc
ARR4N Jun 10, 2025
c3e160e
Merge branch 'arr4n/strevm-poc' into StephenButtolph/strevm-poc
ARR4N Jun 11, 2025
9c068d5
Do not expose unexecuted txs over the RPC
StephenButtolph Jun 11, 2025
1b37a75
Merge branch 'StephenButtolph/strevm-poc' of github.com:ava-labs/stre…
StephenButtolph Jun 11, 2025
b50028a
Merge branch 'arr4n/strevm-poc' into StephenButtolph/strevm-poc
ARR4N Jun 12, 2025
203fa4d
Remove unused block deletion
StephenButtolph Jun 12, 2025
136522d
Merge branch 'arr4n/strevm-poc' into StephenButtolph/strevm-poc
ARR4N Jun 14, 2025
50cda47
Merge branch 'arr4n/strevm-poc' into StephenButtolph/strevm-poc
ARR4N Jun 16, 2025
4b67ed4
Merge branch 'arr4n/strevm-poc' into StephenButtolph/strevm-poc
ARR4N Jun 16, 2025
f34d354
Add block context verification
StephenButtolph Jun 17, 2025
3bc28f3
Add block building stub
StephenButtolph Jun 17, 2025
64741e2
Add VerifyBlockAncestors hook
StephenButtolph Jun 17, 2025
25242cc
Cleanup the blocks map on reject
StephenButtolph Jun 17, 2025
ecff938
Fix multiple iterations
StephenButtolph Jun 17, 2025
d5397bc
Use stdlib rather than custom type
StephenButtolph Jun 17, 2025
cb515d8
Merge branch 'arr4n/strevm-poc' into StephenButtolph/strevm-poc
StephenButtolph Jun 18, 2025
4a82f04
wip
StephenButtolph Jun 24, 2025
9c48d50
wip
StephenButtolph Jun 24, 2025
797da31
comments
StephenButtolph Jun 24, 2025
b104885
more hooks
StephenButtolph Jun 24, 2025
06ce124
Include receipts
StephenButtolph Jun 24, 2025
4aa88ff
merged
StephenButtolph Jun 24, 2025
b6e1701
wip
StephenButtolph Jun 24, 2025
3ce2e9c
fix
StephenButtolph Jun 24, 2025
d9b9474
nits
StephenButtolph Jun 24, 2025
5ae6bb3
chore: repo setup incl. CI, license, etc. (#3)
ARR4N Jun 25, 2025
03d6c0a
fix: remove `golangci-lint` config only needed by `libevm` (#4)
ARR4N Jun 25, 2025
b586245
fix: `golangci-lint` enforces comments on exported identifiers (#6)
ARR4N Jun 25, 2025
07807e2
wip
StephenButtolph Jun 25, 2025
74ccf47
feat: `intmath` package (#5)
ARR4N Jun 27, 2025
04d5104
feat: `adaptor` package (#7)
ARR4N Jun 27, 2025
540e3ad
merged
StephenButtolph Jul 7, 2025
bfe8d91
Remove ToEngine channel
StephenButtolph Jul 8, 2025
db02f10
wip
StephenButtolph Jul 11, 2025
bbd4462
update avalanchego dep
StephenButtolph Jul 17, 2025
3b70781
feat: `proxytime` package (#8)
ARR4N Jul 23, 2025
c07db95
feat: `gastime` package
ARR4N Jul 23, 2025
4f6ed22
update dependencies
StephenButtolph Aug 13, 2025
01d692c
merged
StephenButtolph Aug 13, 2025
29dacde
merged
StephenButtolph Aug 13, 2025
74a0891
wip add p2p networking support
StephenButtolph Aug 26, 2025
d9448d9
update avalanchego
StephenButtolph Aug 26, 2025
13ad8fe
feat: `gastime` package (#9)
ARR4N Sep 10, 2025
998dcaa
Merged gastime
StephenButtolph Nov 10, 2025
07f63fd
Add p2p validators
StephenButtolph Nov 12, 2025
8f95b2a
wip
StephenButtolph Nov 13, 2025
2491889
expose more apis
StephenButtolph Nov 13, 2025
b363264
update libevm
StephenButtolph Nov 14, 2025
ee4dcf3
Include stacktrace in error log
StephenButtolph Nov 14, 2025
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
23 changes: 21 additions & 2 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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))
}
}
Copy link
Contributor Author

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)


return block, err
},
)
if err != nil {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

FYI, I've completely replaced validity.go with the worstcase package but builder.go still has this problem.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with the defer that I merged a few lines above. Still returns an error but replaces the tx.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just log this and drop the tx?

// transactions that have been removed from the mempool will be
// dropped and never included.
return nil, 0, err
}
}
Expand Down
4 changes: 2 additions & 2 deletions exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (e *executor) execute(ctx context.Context, b *Block) error {

header := types.CopyHeader(b.Header())
header.BaseFee = e.gasClock.BaseFee().ToBig()
e.log.Debug(
e.log.Info(
"Executing accepted block",
zap.Uint64("height", b.Height()),
zap.Uint64("timestamp", header.Time),
Expand Down Expand Up @@ -291,7 +291,7 @@ func (e *executor) execute(ctx context.Context, b *Block) error {
b.executed.Store(true)
e.lastExecuted.Store(b)

e.log.Debug(
e.log.Info(
"Block execution complete",
zap.Uint64("height", b.Height()),
zap.Time("gas_time", e.gasClock.AsTime()),
Expand Down
6 changes: 3 additions & 3 deletions mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (vm *VM) receiveTxs(preempt <-chan sink.Priority, pool *queue.Priority[*pen

from, err := types.Sender(vm.currSigner(), tx)
if err != nil {
vm.logger().Debug(
vm.logger().Info(
"Dropped tx due to failed sender recovery",
zap.Stringer("hash", tx.Hash()),
zap.Error(err),
Expand All @@ -64,7 +64,7 @@ func (vm *VM) receiveTxs(preempt <-chan sink.Priority, pool *queue.Priority[*pen
},
timePriority: time.Now(),
})
vm.logger().Debug(
vm.logger().Info(
"New tx in mempool",
zap.Stringer("hash", tx.Hash()),
zap.Stringer("from", from),
Expand All @@ -75,7 +75,7 @@ func (vm *VM) receiveTxs(preempt <-chan sink.Priority, pool *queue.Priority[*pen
case vm.toEngine <- snowcommon.PendingTxs:
default:
p := snowcommon.PendingTxs
vm.logger().Debug(fmt.Sprintf("%T(%s) dropped", p, p))
vm.logger().Info(fmt.Sprintf("%T(%s) dropped", p, p))
}
}
}
Expand Down
16 changes: 15 additions & 1 deletion rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@ import (
"fmt"
"os"

"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/rpcchainvm"
"github.com/ava-labs/libevm/core/types"
sae "github.com/ava-labs/strevm"
"github.com/ava-labs/strevm/adaptor"
)

const (
TargetGasPerSecond = 1_000_000
)

type hooks struct{}

func (*hooks) GasTarget(parent *types.Block) gas.Gas {
return TargetGasPerSecond
}

func main() {
vm := adaptor.Convert(new(sae.SinceGenesis))
vm := adaptor.Convert(&sae.SinceGenesis{
Hooks: &hooks{},
})

if err := rpcchainvm.Serve(context.Background(), vm); err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down
11 changes: 11 additions & 0 deletions scripts/build.sh
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"
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"
4 changes: 3 additions & 1 deletion vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"github.com/ava-labs/strevm/queue"
)

var VMID = ids.ID{'s', 't', 'r', 'e', 'v', 'm'}

// VM implements Streaming Asynchronous Execution (SAE) of EVM blocks. It
// implements all [adaptor.ChainVM] methods except for `Initialize()`, which
// MUST be handled by a harness implementation that provides the final
Expand Down Expand Up @@ -178,7 +180,7 @@ func (vm *VM) SetState(ctx context.Context, state snow.State) error {
}

func (vm *VM) Shutdown(ctx context.Context) error {
vm.logger().Debug("Shutting down VM")
vm.logger().Info("Shutting down VM")
close(vm.quit)

vm.blocks.Close()
Expand Down