Skip to content

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

Draft
wants to merge 48 commits into
base: arr4n/strevm-poc
Choose a base branch
from

Conversation

StephenButtolph
Copy link
Contributor

No description provided.

builder.go Outdated
Comment on lines 29 to 38
// 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)

builder.go Outdated
Comment on lines 102 to 105
if gasUsed == 0 && len(txs) == 0 {
vm.logger().Info("Blocks must either settle or include transactions")
return nil, fmt.Errorf("%w: parent %#x at time %d", errBlockWithoutChanges, parent.Hash(), timestamp)
}
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 check, we would produce an empty block for every BuildBlock attempt where the queue was full. When we did this upon a new tx being issued, the number of empty blocks was kind of hard to see, but once we introduced retries I ended up accepting thousands of blocks almost immediately haha.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Already aware of this, but please keep adding temp fixes like this just in case I've missed something.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Blocks must either settle or include transactions

What's our decision here? I'm ok with allowing settlement without new transactions as long as you are. If anyone is depending on the "safe" block then they'll appreciate it. That said, if there are no transactions in the mempool then the gas price will drop and there will be arb opportunities that will result in some.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we ban empty blocks to start

vm.go Outdated
Comment on lines 195 to 196
HTTPHandlerKey = "/sae/http"
WSHandlerKey = "/sae/ws"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous paths were invalid

builder.go Outdated
Comment on lines 102 to 105
if gasUsed == 0 && len(txs) == 0 {
vm.logger().Info("Blocks must either settle or include transactions")
return nil, fmt.Errorf("%w: parent %#x at time %d", errBlockWithoutChanges, parent.Hash(), timestamp)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Already aware of this, but please keep adding temp fixes like this just in case I've missed something.

builder.go Outdated
@@ -173,6 +196,9 @@ TxLoop:

validity, err := checker.addTxToQueue(candidate.txAndSender)
if err != nil {
// 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?

@ARR4N ARR4N force-pushed the arr4n/strevm-poc branch 4 times, most recently from df735f7 to 84fb6a8 Compare June 16, 2025 20:13
@ARR4N ARR4N force-pushed the arr4n/strevm-poc branch 2 times, most recently from 59dab43 to b895b4d Compare June 23, 2025 17:15
StephenButtolph and others added 24 commits June 24, 2025 14:01
The `go.yml` and `lint.yml` CI workflows come from `libevm` as
reasonable first approximations of what we want for this repo.

The failures on the Go workflow are all to be expected because there
aren't any Go files to test, generate, nor lint. What's important is
that all workflows are running.
`goheader` only checks new issues in `libevm` because `MOD-YEAR-RANGE`
breaks otherwise (we can reintroduce this next year if we haven't moved
the code into `avalanchego` yet). The other deleted config is what
`libevm` uses to avoid linting `geth` code.

Go workflows are still expected to fail, as described in #3, and all
that matters is that they run (and `golangci-lint` _attempts_ to lint
but finds no files).
Useful abstractions for later code:

1. `BoundedSubtract(a, b, floor)` returns `max(a-b, floor)` without
underflow.
2. `MulDiv(a, b, denominator)` returns `(a*b)/denominator` without
overflow.
3. `CeilDiv(num, denom)` returns `num/denom` rounded _up_.
Allows block implementations to be read-only and not have to be aware of
the VM's that created them, which is typically necessary when calling
`Block.Verify()`, `Accept()`, or `Reject()`. These methods instead exist
on the VM as `{Verify,Accept,Reject}Block()`.

There are no explicit tests for this package as it's exercised heavily
via the actual SAE tests that will follow.
This package forms the basis of the gas clock, which will extend a
`proxytime.Time[gas.Gas]` in a future PR. The `Time.SetRateInvariants()`
functionality will be used for changing gas target without affecting gas
price, by scaling rate, target, and excess proportionally. All other
functionality is necessary for the execution thread.

Although the `CmpOpt()` configuration option might feel like overkill,
it's necessary for the more extensive, system-wide tests that come
later.

---------

Signed-off-by: Arran Schlosberg <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants