Skip to content
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

Seperate atomic pkg base #733

Draft
wants to merge 39 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bc26c83
new atomic pkg
ceyonur Dec 11, 2024
fe45c37
Merge branch 'master' into move-atomic-txs
ceyonur Dec 11, 2024
9c3e284
bump avago
ceyonur Dec 11, 2024
ddbbab7
bump versions
ceyonur Dec 11, 2024
0ecd789
move attomic gossip
ceyonur Dec 13, 2024
019bb04
lint
ceyonur Dec 14, 2024
aa50ce6
change newimport clk to time
ceyonur Dec 15, 2024
52081a9
move utils
ceyonur Dec 15, 2024
d93257b
remove extra heaps files
ceyonur Dec 15, 2024
0b10cc4
move database to own pkg
ceyonur Dec 15, 2024
8eb3056
move atomic trie/state/backend to separaet pkg
ceyonur Dec 18, 2024
397c535
Merge branch 'seperate-atomic-pkg-base' into move-atomic-txs
ceyonur Dec 23, 2024
1815741
bump avago
ceyonur Dec 23, 2024
2b13c8e
bump avago
ceyonur Dec 23, 2024
2798ad6
go mod tidy
ceyonur Dec 23, 2024
6bf2ff2
Merge branch 'move-atomic-txs' into move-atomic-gossip
ceyonur Dec 23, 2024
278e055
update releases md
ceyonur Dec 23, 2024
e5f2c27
use address methods from avago
ceyonur Dec 24, 2024
71babe6
bump avago
ceyonur Dec 24, 2024
aab47b6
bump e2e avago version
ceyonur Dec 24, 2024
b9b67bc
Merge branch 'move-atomic-txs' into move-atomic-gossip
ceyonur Dec 24, 2024
6f1adc8
Update plugin/evm/atomic/gossip_test.go
ceyonur Dec 24, 2024
876716f
Update plugin/evm/atomic/mempool.go
ceyonur Dec 24, 2024
682e4bc
Update plugin/evm/config/config.go
ceyonur Dec 24, 2024
38ad868
Update plugin/evm/atomic/tx_heap.go
ceyonur Dec 24, 2024
de328e9
Update plugin/evm/config/config.go
ceyonur Dec 24, 2024
55c0be9
fix reviews
ceyonur Dec 24, 2024
3ac1a1a
Merge branch 'move-atomic-gossip' of github.com:ava-labs/coreth into …
ceyonur Dec 24, 2024
9c148ff
Merge branch 'move-atomic-gossip' into move-atomic-state
ceyonur Dec 29, 2024
803e50a
fix linter
ceyonur Dec 29, 2024
0b40185
nits
ceyonur Dec 29, 2024
2f1dbc5
Update plugin/evm/vm_test.go
ceyonur Jan 3, 2025
936bb59
Update plugin/evm/syncervm_test.go
ceyonur Jan 3, 2025
4019a34
review fix
ceyonur Jan 3, 2025
266a55f
Merge branch 'move-atomic-state' of github.com:ava-labs/coreth into m…
ceyonur Jan 3, 2025
7598938
Merge branch 'master' into seperate-atomic-pkg-base
ceyonur Jan 6, 2025
1958ee8
Merge branch 'seperate-atomic-pkg-base' into move-atomic-state
ceyonur Jan 6, 2025
b12462a
Merge pull request #709 from ava-labs/move-atomic-state
ceyonur Jan 7, 2025
11bc6e8
merge master to atomic base branch (#744)
ceyonur Jan 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
33 changes: 33 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,36 @@ Please make sure your contributions adhere to our coding guidelines:
Before you submit a feature request, please check and make sure that it isn't
possible through some other means.

## Mocks

Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/mockgen) and `//go:generate` commands in the code.

* To **re-generate all mocks**, use the command below from the root of the project:

```sh
go generate -run "go.uber.org/mock/mockgen" ./...
```

* To **add** an interface that needs a corresponding mock generated:
* if the file `mocks_generate_test.go` exists in the package where the interface is located, either:
* modify its `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface (preferred); or
* add another `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface according to specific mock generation settings
* if the file `mocks_generate_test.go` does not exist in the package where the interface is located, create it with content (adapt as needed):

```go
// Copyright (C) 2025-2025, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package mypackage

//go:generate go run go.uber.org/mock/mockgen -package=${GOPACKAGE} -destination=mocks_test.go . YourInterface
```

Notes:
1. Ideally generate all mocks to `mocks_test.go` for the package you need to use the mocks for and do not export mocks to other packages. This reduces package dependencies, reduces production code pollution and forces to have locally defined narrow interfaces.
1. Prefer using reflect mode to generate mocks than source mode, unless you need a mock for an unexported interface, which should be rare.
* To **remove** an interface from having a corresponding mock generated:
1. Edit the `mocks_generate_test.go` file in the directory where the interface is defined
1. If the `//go:generate` mockgen command line:
* generates a mock file for multiple interfaces, remove your interface from the line
* generates a mock file only for the interface, remove the entire line. If the file is empty, remove `mocks_generate_test.go` as well.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ jobs:
run: echo "TIMEOUT=1200s" >> "$GITHUB_ENV"
- run: go mod download
shell: bash
- name: go mod tidy
run: |
go mod tidy
git diff --exit-code
- name: Mocks are up to date
shell: bash
run: |
grep -lr -E '^// Code generated by MockGen\. DO NOT EDIT\.$' . | xargs -r rm
go generate -run "go.uber.org/mock/mockgen" ./...
git add --intent-to-add --all
git diff --exit-code
- run: ./scripts/build.sh evm
shell: bash
- run: ./scripts/build_test.sh
Expand Down
2 changes: 1 addition & 1 deletion consensus/dummy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The dynamic fee algorithm aims to adjust the base fee to handle network congesti

- EIP-1559 is intended for Ethereum where a block is produced roughly every 10s
- C-Chain typically produces blocks every 2 seconds, but the dynamic fee algorithm needs to handle the case that the network quiesces and there are no blocks for a long period of time
- Since C-Chain produces blocks at a different cadence, it adapts EIP-1559 to sum the amount of gas consumed within a 10 second interval instead of using only the amount of gas consumed in the parent block
- Since C-Chain produces blocks at a different cadence, it adapts EIP-1559 to sum the amount of gas consumed within a 10-second interval instead of using only the amount of gas consumed in the parent block

## Consensus Engine Callbacks

Expand Down
2 changes: 1 addition & 1 deletion core/state/pruner/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const (
// stateBloomFilePrefix is the filename prefix of state bloom filter.
stateBloomFilePrefix = "statebloom"

// stateBloomFilePrefix is the filename suffix of state bloom filter.
// stateBloomFileSuffix is the filename suffix of state bloom filter.
stateBloomFileSuffix = "bf.gz"

// stateBloomFileTempSuffix is the filename suffix of state bloom filter
Expand Down
14 changes: 0 additions & 14 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,6 @@ type LegacyPool struct {
signer types.Signer
mu sync.RWMutex

// [currentStateLock] is required to allow concurrent access to address nonces
// and balances during reorgs and gossip handling.
currentStateLock sync.Mutex
// closed when the transaction pool is stopped. Any goroutine can listen
// to this to be notified if it should shut down.
generalShutdownChan chan struct{}
Expand Down Expand Up @@ -685,9 +682,6 @@ func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) erro
// validateTx checks whether a transaction is valid according to the consensus
// rules and adheres to some heuristic limits of the local node (price and size).
func (pool *LegacyPool) validateTx(tx *types.Transaction, local bool) error {
pool.currentStateLock.Lock()
defer pool.currentStateLock.Unlock()

opts := &txpool.ValidationOptionsWithState{
State: pool.currentState,
Rules: pool.chainconfig.Rules(
Expand Down Expand Up @@ -1500,9 +1494,7 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
return
}
pool.currentHead.Store(newHead)
pool.currentStateLock.Lock()
pool.currentState = statedb
pool.currentStateLock.Unlock()
pool.pendingNonces = newNoncer(statedb)

// Inject any transactions discarded due to reorgs
Expand All @@ -1515,9 +1507,6 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
// future queue to the set of pending transactions. During this process, all
// invalidated transactions (low nonce, low balance) are deleted.
func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.Transaction {
pool.currentStateLock.Lock()
defer pool.currentStateLock.Unlock()

// Track the promoted transactions to broadcast them at once
var promoted []*types.Transaction

Expand Down Expand Up @@ -1724,9 +1713,6 @@ func (pool *LegacyPool) truncateQueue() {
// is always explicitly triggered by SetBaseFee and it would be unnecessary and wasteful
// to trigger a re-heap is this function
func (pool *LegacyPool) demoteUnexecutables() {
pool.currentStateLock.Lock()
defer pool.currentStateLock.Unlock()

// Iterate over all accounts and demote any non-executable transactions
gasLimit := pool.currentHead.Load().GasLimit
for addr, list := range pool.pending {
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/js/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestHaltBetweenSteps(t *testing.T) {
}
}

// testNoStepExec tests a regular value transfer (no exec), and accessing the statedb
// TestNoStepExec tests a regular value transfer (no exec), and accessing the statedb
// in 'result'
func TestNoStepExec(t *testing.T) {
execTracer := func(code string) []byte {
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/logger/access_list_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (al accessList) equal(other accessList) bool {
return true
}

// accesslist converts the accesslist to a types.AccessList.
// accessList converts the accesslist to a types.AccessList.
func (al accessList) accessList() types.AccessList {
acl := make(types.AccessList, 0, len(al))
for addr, slots := range al {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
golang.org/x/sys v0.28.0
golang.org/x/text v0.21.0
golang.org/x/time v0.3.0
golang.org/x/tools v0.22.0
google.golang.org/protobuf v1.34.2
gopkg.in/natefinch/lumberjack.v2 v2.0.0
)
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.12.2-0.20241224161435-3998475d671d h1:QCtjS4ANcNfCdL6Z2sKpanDVJNt1MU0bUyVdW0g5zuU=
github.com/ava-labs/avalanchego v1.12.2-0.20241224161435-3998475d671d/go.mod h1:cDoT0Hq3P+/XfCyVvzrBj66yoid2I5LnMuj7LIkap+o=
github.com/ava-labs/avalanchego v1.12.2-0.20241224181600-fade5be3051d h1:iPlsqC9pIy4emCo8wyI/VmVmfljpzmw58ZqahVdcehI=
github.com/ava-labs/avalanchego v1.12.2-0.20241224181600-fade5be3051d/go.mod h1:dKawab3nXqwI7ZcOFatTOv//l1V0t8MRBnhXoOqbN4E=
github.com/ava-labs/avalanchego v1.12.2-0.20250106102004-902377d447ba h1:7t2ORGM53sqdsczNZGFQIK99of9yeetCld90keJ47Os=
github.com/ava-labs/avalanchego v1.12.2-0.20250106102004-902377d447ba/go.mod h1:oK/C7ZGo5cAEayBKBoawh2EpOo3E9gD1rpd9NAM0RkQ=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
Expand Down Expand Up @@ -586,8 +582,6 @@ go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lI
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
Expand Down Expand Up @@ -693,8 +687,6 @@ golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -865,6 +857,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
File renamed without changes.
79 changes: 79 additions & 0 deletions plugin/evm/atomic/atomictest/shared_memories.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package atomictest

import (
"testing"

"github.com/ava-labs/avalanchego/chains/atomic"
"github.com/ava-labs/avalanchego/ids"
"github.com/stretchr/testify/assert"
)

type SharedMemories struct {
ThisChain atomic.SharedMemory
PeerChain atomic.SharedMemory
thisChainID ids.ID
peerChainID ids.ID
}

func (s *SharedMemories) AddItemsToBeRemovedToPeerChain(ops map[ids.ID]*atomic.Requests) error {
for _, reqs := range ops {
puts := make(map[ids.ID]*atomic.Requests)
puts[s.thisChainID] = &atomic.Requests{}
for _, key := range reqs.RemoveRequests {
val := []byte{0x1}
puts[s.thisChainID].PutRequests = append(puts[s.thisChainID].PutRequests, &atomic.Element{Key: key, Value: val})
}
if err := s.PeerChain.Apply(puts); err != nil {
return err
}
}
return nil
}

func (s *SharedMemories) AssertOpsApplied(t *testing.T, ops map[ids.ID]*atomic.Requests) {
t.Helper()
for _, reqs := range ops {
// should be able to get put requests
for _, elem := range reqs.PutRequests {
val, err := s.PeerChain.Get(s.thisChainID, [][]byte{elem.Key})
if err != nil {
t.Fatalf("error finding puts in peerChainMemory: %s", err)
}
assert.Equal(t, elem.Value, val[0])
}

// should not be able to get remove requests
for _, key := range reqs.RemoveRequests {
_, err := s.ThisChain.Get(s.peerChainID, [][]byte{key})
assert.EqualError(t, err, "not found")
}
}
}

func (s *SharedMemories) AssertOpsNotApplied(t *testing.T, ops map[ids.ID]*atomic.Requests) {
t.Helper()
for _, reqs := range ops {
// should not be able to get put requests
for _, elem := range reqs.PutRequests {
_, err := s.PeerChain.Get(s.thisChainID, [][]byte{elem.Key})
assert.EqualError(t, err, "not found")
}

// should be able to get remove requests (these were previously added as puts on peerChain)
for _, key := range reqs.RemoveRequests {
val, err := s.ThisChain.Get(s.peerChainID, [][]byte{key})
assert.NoError(t, err)
assert.Equal(t, []byte{0x1}, val[0])
}
}
}

// TODO: once tests are moved to atomic package, unexport this function
func NewSharedMemories(atomicMemory *atomic.Memory, thisChainID, peerChainID ids.ID) *SharedMemories {
return &SharedMemories{
ThisChain: atomicMemory.NewSharedMemory(thisChainID),
PeerChain: atomicMemory.NewSharedMemory(peerChainID),
thisChainID: thisChainID,
peerChainID: peerChainID,
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// (c) 2020-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package atomic
package atomictest

import (
"math/big"
Expand All @@ -17,8 +17,11 @@ import (
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/utils/wrappers"
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/plugin/evm/atomic"
)

const testCodecVersion = 0

var TestTxCodec codec.Manager

func init() {
Expand All @@ -28,7 +31,7 @@ func init() {
errs := wrappers.Errs{}
errs.Add(
c.RegisterType(&TestUnsignedTx{}),
TestTxCodec.RegisterCodec(CodecVersion, c),
TestTxCodec.RegisterCodec(testCodecVersion, c),
)

if errs.Errored() {
Expand All @@ -50,7 +53,7 @@ type TestUnsignedTx struct {
EVMStateTransferV error
}

var _ UnsignedAtomicTx = &TestUnsignedTx{}
var _ atomic.UnsignedAtomicTx = &TestUnsignedTx{}

// GasUsed implements the UnsignedAtomicTx interface
func (t *TestUnsignedTx) GasUsed(fixedFee bool) (uint64, error) { return t.GasUsedV, nil }
Expand Down Expand Up @@ -82,19 +85,19 @@ func (t *TestUnsignedTx) SignedBytes() []byte { return t.SignedBytesV }
func (t *TestUnsignedTx) InputUTXOs() set.Set[ids.ID] { return t.InputUTXOsV }

// SemanticVerify implements the UnsignedAtomicTx interface
func (t *TestUnsignedTx) SemanticVerify(backend *Backend, stx *Tx, parent AtomicBlockContext, baseFee *big.Int) error {
func (t *TestUnsignedTx) SemanticVerify(backend *atomic.VerifierBackend, stx *atomic.Tx, parent atomic.AtomicBlockContext, baseFee *big.Int) error {
return t.SemanticVerifyV
}

// EVMStateTransfer implements the UnsignedAtomicTx interface
func (t *TestUnsignedTx) EVMStateTransfer(ctx *snow.Context, state StateDB) error {
func (t *TestUnsignedTx) EVMStateTransfer(ctx *snow.Context, state atomic.StateDB) error {
return t.EVMStateTransferV
}

var TestBlockchainID = ids.GenerateTestID()

func GenerateTestImportTxWithGas(gasUsed uint64, burned uint64) *Tx {
return &Tx{
func GenerateTestImportTxWithGas(gasUsed uint64, burned uint64) *atomic.Tx {
return &atomic.Tx{
UnsignedAtomicTx: &TestUnsignedTx{
IDV: ids.GenerateTestID(),
GasUsedV: gasUsed,
Expand All @@ -110,8 +113,8 @@ func GenerateTestImportTxWithGas(gasUsed uint64, burned uint64) *Tx {
}
}

func GenerateTestImportTx() *Tx {
return &Tx{
func GenerateTestImportTx() *atomic.Tx {
return &atomic.Tx{
UnsignedAtomicTx: &TestUnsignedTx{
IDV: ids.GenerateTestID(),
AcceptRequestsBlockchainIDV: TestBlockchainID,
Expand All @@ -125,8 +128,8 @@ func GenerateTestImportTx() *Tx {
}
}

func GenerateTestExportTx() *Tx {
return &Tx{
func GenerateTestExportTx() *atomic.Tx {
return &atomic.Tx{
UnsignedAtomicTx: &TestUnsignedTx{
IDV: ids.GenerateTestID(),
AcceptRequestsBlockchainIDV: TestBlockchainID,
Expand All @@ -146,7 +149,7 @@ func GenerateTestExportTx() *Tx {
}
}

func NewTestTx() *Tx {
func NewTestTx() *atomic.Tx {
txType := rand.Intn(2)
switch txType {
case 0:
Expand All @@ -158,8 +161,8 @@ func NewTestTx() *Tx {
}
}

func NewTestTxs(numTxs int) []*Tx {
txs := make([]*Tx, 0, numTxs)
func NewTestTxs(numTxs int) []*atomic.Tx {
txs := make([]*atomic.Tx, 0, numTxs)
for i := 0; i < numTxs; i++ {
txs = append(txs, NewTestTx())
}
Expand Down
18 changes: 18 additions & 0 deletions plugin/evm/atomic/atomictest/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// (c) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package atomictest

import (
avalancheatomic "github.com/ava-labs/avalanchego/chains/atomic"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/coreth/plugin/evm/atomic"
)

func ConvertToAtomicOps(tx *atomic.Tx) (map[ids.ID]*avalancheatomic.Requests, error) {
id, reqs, err := tx.AtomicOps()
if err != nil {
return nil, err
}
return map[ids.ID]*avalancheatomic.Requests{id: reqs}, nil
}
2 changes: 1 addition & 1 deletion plugin/evm/atomic/export_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (utx *UnsignedExportTx) Burned(assetID ids.ID) (uint64, error) {

// SemanticVerify this transaction is valid.
func (utx *UnsignedExportTx) SemanticVerify(
backend *Backend,
backend *VerifierBackend,
stx *Tx,
parent AtomicBlockContext,
baseFee *big.Int,
Expand Down
Loading