Skip to content

Conversation

@ceyonur
Copy link
Collaborator

@ceyonur ceyonur commented May 26, 2025

Why this should be merged

This PR moves atomic block extension and relevant code to atomic pkg

Note: some "extra" changes are introduced with TODOs. These are to prevent UTs being failed an will be cleaned up with upcoming PRs.

How this works

This pull request introduces significant refactoring and feature updates to the EVM plugin, primarily focusing on modularizing the atomic VM functionality, improving error handling, and enhancing code organization. The changes include renaming and restructuring files, updating error handling, and introducing a new VM wrapper for atomic extensions.

Refactoring and Modularization:

  • File restructuring: Renamed several files under plugin/evm/atomic to plugin/evm/atomic/vm for better modularity and organization. For example, atomic_block_extension.go was renamed to block_extension.go and tx_semantic_verifier.go was moved to the vm subdirectory. [1] [2] [3]

  • New VM wrapper: Introduced a new VM struct in plugin/evm/atomic/vm/vm.go to encapsulate the atomic extension logic, providing a cleaner and more extensible interface. This includes the WrapVM function and the Initialize method for setting up the VM and its extensions.

Code Enhancements:

  • Error handling improvements: Updated error variables to be exported (ErrMissingUTXOs, ErrEmptyBlock) for better consistency and usage across the codebase. [1] [2] [3]

  • Refactored method calls: Replaced direct calls to atomicBackend and mempool with corresponding methods (AtomicBackend(), AtomicMempool()) for improved encapsulation and abstraction. [1] [2] [3] [4]

Dependency Updates:

  • Atomic package usage: Updated references in tx_semantic_verifier.go and related files to use the atomic package explicitly, improving clarity and dependency management. For example, atomic.CalculateDynamicFee and atomic.Codec.Unmarshal are now used. [1] [2]

  • Test updates: Adjusted test files (export_tx_test.go, import_tx_test.go) to reflect the new atomicvm package structure and updated imports accordingly. [1] [2]

Additional Changes:

  • Extension configuration: Added validation for the Config struct in plugin/evm/extension/config.go and introduced a new SetExtensionConfig method in the ExtensibleVM interface for better configuration management. [1] [2]

These changes collectively enhance the maintainability, readability, and modularity of the EVM plugin codebase.

How this was tested

Existing tests

Note:

Need to be documented?

No

Need to update RELEASES.md?

No

ceyonur and others added 8 commits May 27, 2025 18:20
Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com>
Signed-off-by: Ceyhun Onur <ceyhunonur54@gmail.com>
Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com>
Signed-off-by: Ceyhun Onur <ceyhunonur54@gmail.com>
Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com>
Signed-off-by: Ceyhun Onur <ceyhunonur54@gmail.com>
@ceyonur ceyonur marked this pull request as ready for review May 27, 2025 21:02
@ceyonur ceyonur requested a review from a team as a code owner May 27, 2025 21:02
@ceyonur ceyonur force-pushed the atomic-block-extension branch from 2ddb618 to d477ea2 Compare June 4, 2025 09:01
Base automatically changed from atomic-block-extension to master June 5, 2025 00:10
@ARR4N
Copy link
Collaborator

ARR4N commented Jun 5, 2025

Please resolve the merge conflicts so we're not reviewing out-of-date code.

This PR is also unfocussed, hence being a 3500-line delta. Why does file restructuring need to be done at the same time as dependency updates, creating a new VM wrapper, etc.? It makes it extremely difficult to review as we have to understand so many interlocking parts at the same time.

@ceyonur
Copy link
Collaborator Author

ceyonur commented Jun 5, 2025

Please resolve the merge conflicts so we're not reviewing out-of-date code.

This PR is also unfocussed, hence being a 3500-line delta. Why does file restructuring need to be done at the same time as dependency updates, creating a new VM wrapper, etc.? It makes it extremely difficult to review as we have to understand so many interlocking parts at the same time.

This is because the previous PR was squashed, doing a rebase now

@ceyonur ceyonur marked this pull request as draft June 5, 2025 11:52
@ceyonur ceyonur marked this pull request as ready for review June 5, 2025 14:33
Copy link
Contributor

@alarso16 alarso16 left a comment

Choose a reason for hiding this comment

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

fwict looks good, but the recursive initialization doesn't seem super great

Copy link
Collaborator

@ARR4N ARR4N left a comment

Choose a reason for hiding this comment

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

I spoke with @StephenButtolph about wrapper VMs and all of the problems arise when there's a non 1:1 mapping between wrapping and inner blocks (e.g. multiple proposervm outer blocks could reference the same inner block). I don't see this arising in this refactor, but noting so we all keep it in mind.

@ceyonur ceyonur added this pull request to the merge queue Jun 6, 2025
Merged via the queue into master with commit ef1fb30 Jun 6, 2025
14 of 15 checks passed
@ceyonur ceyonur deleted the atomic-vm-block-extender branch June 6, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants