Skip to content

Conversation

@ceyonur
Copy link
Collaborator

@ceyonur ceyonur commented Dec 18, 2024

Why this should be merged

Moves atomic state (repo, trie backend) to atomic pkg.

How this works

This pull request involves renaming files and updating package references to improve the organization and clarity of the codebase. The changes primarily focus on renaming the plugin/evm package to plugin/atomic and updating relevant imports and type references accordingly.

File Renaming and Package Updates:

  • Renamed plugin/evm/atomic_backend.go to plugin/atomic/atomic_backend.go and updated the package declaration from evm to atomic.
  • Renamed plugin/evm/atomic_state.go to plugin/atomic/atomic_state.go and updated the package declaration from evm to atomic.
  • Renamed plugin/evm/atomic_syncer.go to plugin/atomic/atomic_syncer.go and updated the package declaration from evm to atomic.
  • Renamed plugin/evm/atomic_syncer_test.go to plugin/atomic/atomic_syncer_test.go and updated the package declaration from evm to atomic.
  • Renamed plugin/evm/atomic_trie.go to plugin/atomic/atomic_trie.go and updated the package declaration from evm to atomic.

Import and Type Reference Updates:

  • Updated import paths and type references from evm/atomic to atomic in plugin/atomic/atomic_backend.go.
  • Updated type references from atomic.Tx to Tx in plugin/atomic/atomic_backend.go.
  • Updated type references from atomic.Tx to Tx in plugin/atomic/atomic_state.go.
  • Updated import paths and type references from evm/atomic to atomic in plugin/atomic/atomic_trie.go [1] [2].
  • Updated import paths and type references from evm/atomic to atomic in plugin/atomic/atomic_trie_iterator_test.go [1] [2].

These changes ensure that the codebase is more organized and maintainable by clearly separating the atomic functionality from the evm package.

How this was tested

Existing tests should cover his

Need to be documented?

No

Need to update RELEASES.md?

No

ceyonur and others added 29 commits December 11, 2024 16:57
Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Ceyhun Onur <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Ceyhun Onur <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Ceyhun Onur <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Ceyhun Onur <[email protected]>
Co-authored-by: Quentin McGaw <[email protected]>
Signed-off-by: Ceyhun Onur <[email protected]>
@ceyonur ceyonur marked this pull request as ready for review December 29, 2024 10:02
@ceyonur ceyonur requested review from a team and darioush as code owners December 29, 2024 10:03
@ceyonur ceyonur marked this pull request as draft December 29, 2024 10:03
@ceyonur ceyonur marked this pull request as ready for review December 29, 2024 10:32
Copy link

@darioush darioush left a comment

Choose a reason for hiding this comment

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

mostly looks good, some minor comments

plugin/evm/vm.go Outdated
return tx, nil
}

func (vm *VM) PutLastAcceptedID(ID []byte) error {

Choose a reason for hiding this comment

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

👍


var stateSyncSummaryKey = []byte("stateSyncSummary")
type BlockAcceptor interface {
PutLastAcceptedID([]byte) error

Choose a reason for hiding this comment

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

nit: seems this interface should take ids.ID

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did not want to convert it to ID from hash and then to byte for the updateVMMarkers, but yea this sounds weird as it is.

Comment on lines -159 to -161
// Prefixes for atomic trie
atomicTrieDBPrefix = []byte("atomicTrieDB")
atomicTrieMetaDBPrefix = []byte("atomicTrieMetaDB")

Choose a reason for hiding this comment

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

IMO it's somewhat more flexible to let the vm make the prefix and pass the prefixed DB to both the atomic backend and the syncer. We don't need to retain them as fields on the VM.

If you feel strongly that the prefixes should be moved it's fine, but so far the caller has been defining the prefixes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think state files/packages should contain prefixes and create prefixdb. Or really the whoever going to use it can create the prefixdb. I can't deny having them in a single place helps to look up, inspect DBs but from the modularity POV it feels like they should be belong to whoever using. In this case we should definetly move them to atomic pkg as we plan to wrap the plugin/vm.go with atomic/vm.go (so no atomic stuff should be in plugin/vm.go)

Base automatically changed from move-atomic-gossip to master December 31, 2024 08:39
@ceyonur ceyonur changed the base branch from master to seperate-atomic-pkg-base January 3, 2025 10:16
ceyonur and others added 4 commits January 3, 2025 13:30
Co-authored-by: Darioush Jalali <[email protected]>
Signed-off-by: Ceyhun Onur <[email protected]>
Co-authored-by: Darioush Jalali <[email protected]>
Signed-off-by: Ceyhun Onur <[email protected]>

## [v0.14.1](https://github.com/ava-labs/coreth/releases/tag/v0.14.1)
- Remove API eth_getAssetBalance that was used to query ANT balances (deprecated since v0.10.0)
- Remove legacy gossip handler and metrics (deprecated since v0.10.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this change be in its own PR (maybe before that PR)?

go.mod Outdated
require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/ava-labs/avalanchego v1.12.1-0.20241209214115-1dc4192013aa
github.com/ava-labs/avalanchego v1.12.2-0.20241224181600-fade5be3051d
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the bump?

Comment on lines 27 to 29
// Prefixes for atomic trie
atomicTrieDBPrefix = []byte("atomicTrieDB")
atomicTrieMetaDBPrefix = []byte("atomicTrieMetaDB")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit unneeded comment

Suggested change
// Prefixes for atomic trie
atomicTrieDBPrefix = []byte("atomicTrieDB")
atomicTrieMetaDBPrefix = []byte("atomicTrieMetaDB")
atomicTrieDBPrefix = []byte("atomicTrieDB")
atomicTrieMetaDBPrefix = []byte("atomicTrieMetaDB")

Comment on lines +120 to +125
commitInterval uint64 // commit interval, same as commitHeightInterval by default
metadataDB avalanchedatabase.Database // Underlying database containing the atomic trie metadata
trieDB *triedb.Database // Trie database
lastCommittedRoot common.Hash // trie root of the most recent commit
lastCommittedHeight uint64 // index height of the most recent commit
lastAcceptedRoot common.Hash // most recent trie root passed to accept trie or the root of the atomic trie on intialization.
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for the future/new code (to myself as well 😄) - we should write comments above fields and not to the the right, otherwise gofmt causes unneeded git diffs on other fields as soon as a field name or type gets longer/shorter than the longest/smallest.

@@ -1,7 +1,7 @@
// (c) 2020-2021, Ava Labs, Inc. All rights reserved.
// (c) 2020-2025, Ava Labs, Inc. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be updated on other files? 🤔
I'm looking into copyright thingies in ava-labs/libevm#100 because right now it's a bit of headache to keep track of those years 😕

Copy link

@darioush darioush left a comment

Choose a reason for hiding this comment

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

just nits

@ceyonur ceyonur self-assigned this Jan 6, 2025
@ceyonur ceyonur merged commit b12462a into seperate-atomic-pkg-base Jan 7, 2025
6 checks passed
@ceyonur ceyonur deleted the move-atomic-state branch January 7, 2025 13:45
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