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 81 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 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
aad2f5f
remove multicoin/deprecated apis
ceyonur Dec 19, 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
f17d97c
decouple atomic logic from statesyncers
ceyonur Dec 28, 2024
b5777f4
remove unused provider
ceyonur Dec 28, 2024
9c148ff
Merge branch 'move-atomic-gossip' into move-atomic-state
ceyonur Dec 29, 2024
803e50a
fix linter
ceyonur Dec 29, 2024
d45cd2e
Merge branch 'move-atomic-state' into move-atomic-sync
ceyonur Dec 29, 2024
0b40185
nits
ceyonur Dec 29, 2024
4ef96e8
Update plugin/evm/vm.go
ceyonur Dec 30, 2024
caa305d
Update plugin/evm/vm.go
ceyonur Dec 30, 2024
104bab7
Merge branch 'move-atomic-state' into move-atomic-sync
ceyonur Dec 30, 2024
62479e3
Merge branch 'move-atomic-sync' of github.com:ava-labs/coreth into mo…
ceyonur Dec 30, 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
f651bad
Reviews
ceyonur Jan 6, 2025
39da24e
Merge branch 'move-atomic-state' into move-atomic-sync
ceyonur Jan 6, 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
6d54408
Merge branch 'move-atomic-state' into move-atomic-sync
ceyonur Jan 6, 2025
705da44
Merge branch 'move-atomic-state' into remove-deprecated-apis
ceyonur Jan 7, 2025
460264c
fix tests
ceyonur Jan 7, 2025
9d1af78
update releases md
ceyonur Jan 7, 2025
8186291
Merge branch 'move-atomic-state' into remove-deprecated-apis
ceyonur Jan 7, 2025
b12462a
Merge pull request #709 from ava-labs/move-atomic-state
ceyonur Jan 7, 2025
ab526d4
Update RELEASES.md
ceyonur Jan 7, 2025
06e5064
Update plugin/evm/vm_test.go
ceyonur Jan 7, 2025
7aad0ec
replace deprecated Add64
ceyonur Jan 7, 2025
40f9827
fix ineff assign
ceyonur Jan 7, 2025
f328a6c
Merge branch 'seperate-atomic-pkg-base' into remove-deprecated-apis
ceyonur Jan 7, 2025
11bc6e8
merge master to atomic base branch (#744)
ceyonur Jan 14, 2025
22591f3
Merge branch 'seperate-atomic-pkg-base' into move-atomic-sync
ceyonur Jan 14, 2025
29cc131
Merge branch 'seperate-atomic-pkg-base' into remove-deprecated-apis
ceyonur Jan 15, 2025
072dcf1
Revert removed test
ceyonur Jan 15, 2025
7a3b1b7
Reviews
ceyonur Jan 15, 2025
f56376a
move node types and handlings to separate packages (#729)
ceyonur Jan 16, 2025
dfd2e9b
create new codec with correct type
ceyonur Jan 16, 2025
1ab7a7a
unexport codec
ceyonur Jan 16, 2025
152317d
reviews
ceyonur Jan 17, 2025
bd65190
Merge pull request #752 from ava-labs/sync-type-codec
ceyonur Jan 17, 2025
492b3dd
use concrete returns / callsite interfaces where possible (#756)
darioush Jan 17, 2025
c985df7
Merge pull request #723 from ava-labs/move-atomic-sync
ceyonur Jan 20, 2025
ba22dcc
Merge branch 'master' into merge-master-atomic-base
ceyonur Jan 20, 2025
6bf036c
remove unused var
ceyonur Jan 20, 2025
457a67c
Merge pull request #757 from ava-labs/merge-master-atomic-base
ceyonur Jan 20, 2025
b62ee48
Merge branch 'seperate-atomic-pkg-base' into remove-deprecated-apis
ceyonur Jan 20, 2025
551bd96
remove newImportTx
ceyonur Jan 20, 2025
709d51c
Merge pull request #711 from ava-labs/remove-deprecated-apis
ceyonur Jan 21, 2025
d926bb8
Merge branch 'master' into seperate-atomic-pkg-base
ceyonur Feb 6, 2025
ed2b36f
Merge branch 'seperate-atomic-pkg-base' of github.com:ava-labs/coreth…
ceyonur Feb 6, 2025
9a47375
Merge commit '2e4e6bd' into seperate-atomic-pkg-base
ceyonur Feb 20, 2025
5c0c97f
Merge branch 'master' into seperate-atomic-pkg-base
ceyonur Feb 21, 2025
cfdd80b
fix ap3 import
ceyonur Feb 21, 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
5 changes: 0 additions & 5 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,6 @@ func (g *Genesis) toBlock(db ethdb.Database, triedb *triedb.Database) *types.Blo
for key, value := range account.Storage {
statedb.SetState(addr, key, value)
}
if account.MCBalance != nil {
for coinID, value := range account.MCBalance {
statedb.AddBalanceMultiCoin(addr, coinID, value)
}
}
}
root := statedb.IntermediateRoot(false)
head.Root = root
Expand Down
4 changes: 0 additions & 4 deletions core/state/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ type DumpAccount struct {
Root hexutil.Bytes `json:"root"`
CodeHash hexutil.Bytes `json:"codeHash"`
Code hexutil.Bytes `json:"code,omitempty"`
IsMultiCoin bool `json:"isMultiCoin"`
Storage map[common.Hash]string `json:"storage,omitempty"`
Address *common.Address `json:"address,omitempty"` // Address only present in iterative (line-by-line) mode
AddressHash hexutil.Bytes `json:"key,omitempty"` // If we don't have address, we can output the key

}

// Dump represents the full dump in a collected format, as one large map.
Expand Down Expand Up @@ -107,7 +105,6 @@ func (d iterativeDump) OnAccount(addr *common.Address, account DumpAccount) {
Nonce: account.Nonce,
Root: account.Root,
CodeHash: account.CodeHash,
IsMultiCoin: account.IsMultiCoin,
Code: account.Code,
Storage: account.Storage,
AddressHash: account.AddressHash,
Expand Down Expand Up @@ -156,7 +153,6 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
Nonce: data.Nonce,
Root: data.Root[:],
CodeHash: data.CodeHash,
IsMultiCoin: data.IsMultiCoin,
AddressHash: it.Key,
}
address *common.Address
Expand Down
13 changes: 5 additions & 8 deletions core/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func TestDump(t *testing.T) {
"nonce": 0,
"root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"isMultiCoin": false,
"address": "0x0000000000000000000000000000000000000001",
"key": "0x1468288056310c82aa4c01a7e12a10f8111a0560e72b700555479031b86c357d"
},
Expand All @@ -90,7 +89,6 @@ func TestDump(t *testing.T) {
"nonce": 0,
"root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"isMultiCoin": false,
"address": "0x0000000000000000000000000000000000000002",
"key": "0xd52688a8f926c816ca1e079067caba944f158e764817b83fc43594370ca9cf62"
},
Expand All @@ -100,7 +98,6 @@ func TestDump(t *testing.T) {
"root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"codeHash": "0x87874902497a5bb968da31a2998d8f22e949d1ef6214bcdedd8bae24cca4b9e3",
"code": "0x03030303030303",
"isMultiCoin": false,
"address": "0x0000000000000000000000000000000000000102",
"key": "0xa17eacbc25cda025e81db9c5c62868822c73ce097cee2a63e33a2e41268358a1"
}
Expand Down Expand Up @@ -138,10 +135,10 @@ func TestIterativeDump(t *testing.T) {
// check that DumpToCollector contains the state objects that are in trie
got := b.String()
want := `{"root":"0x0ffca661efa3b7504ac015083994c94fd7d0d24db60354c717c936afcced762a"}
{"balance":"22","nonce":0,"root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","isMultiCoin":false,"address":"0x0000000000000000000000000000000000000001","key":"0x1468288056310c82aa4c01a7e12a10f8111a0560e72b700555479031b86c357d"}
{"balance":"1337","nonce":0,"root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","isMultiCoin":false,"address":"0x0000000000000000000000000000000000000000","key":"0x5380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a"}
{"balance":"0","nonce":0,"root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","codeHash":"0x87874902497a5bb968da31a2998d8f22e949d1ef6214bcdedd8bae24cca4b9e3","code":"0x03030303030303","isMultiCoin":false,"address":"0x0000000000000000000000000000000000000102","key":"0xa17eacbc25cda025e81db9c5c62868822c73ce097cee2a63e33a2e41268358a1"}
{"balance":"44","nonce":0,"root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","isMultiCoin":false,"address":"0x0000000000000000000000000000000000000002","key":"0xd52688a8f926c816ca1e079067caba944f158e764817b83fc43594370ca9cf62"}
{"balance":"22","nonce":0,"root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","address":"0x0000000000000000000000000000000000000001","key":"0x1468288056310c82aa4c01a7e12a10f8111a0560e72b700555479031b86c357d"}
{"balance":"1337","nonce":0,"root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","address":"0x0000000000000000000000000000000000000000","key":"0x5380c7b7ae81a58eb98d9c78de4a1fd7fd9535fc953ed2be602daaa41767312a"}
{"balance":"0","nonce":0,"root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","codeHash":"0x87874902497a5bb968da31a2998d8f22e949d1ef6214bcdedd8bae24cca4b9e3","code":"0x03030303030303","address":"0x0000000000000000000000000000000000000102","key":"0xa17eacbc25cda025e81db9c5c62868822c73ce097cee2a63e33a2e41268358a1"}
{"balance":"44","nonce":0,"root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","codeHash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","address":"0x0000000000000000000000000000000000000002","key":"0xd52688a8f926c816ca1e079067caba944f158e764817b83fc43594370ca9cf62"}
`
if got != want {
t.Errorf("DumpToCollector mismatch:\ngot: %s\nwant: %s\n", got, want)
Expand All @@ -152,7 +149,7 @@ func TestNull(t *testing.T) {
s := newStateEnv()
address := common.HexToAddress("0x823140710bf13990e4500136726d8b55")
s.state.CreateAccount(address)
//value := common.FromHex("0x823140710bf13990e4500136726d8b55")
// value := common.FromHex("0x823140710bf13990e4500136726d8b55")
var value common.Hash

s.state.SetState(address, common.Hash{}, value)
Expand Down
3 changes: 0 additions & 3 deletions core/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,11 @@ func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error {
return nil
}

type GenesisMultiCoinBalance map[common.Hash]*big.Int

// GenesisAccount is an account in the state of the genesis block.
type GenesisAccount struct {
Code []byte `json:"code,omitempty"`
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
Balance *big.Int `json:"balance" gencodec:"required"`
MCBalance GenesisMultiCoinBalance `json:"mcbalance,omitempty"`
Nonce uint64 `json:"nonce,omitempty"`
PrivateKey []byte `json:"secretKey,omitempty"` // for tests
}
Expand Down
6 changes: 0 additions & 6 deletions core/types/gen_genesis_account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions peer/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func (n *network) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID u

log.Debug("received AppRequest from node", "nodeID", nodeID, "requestID", requestID, "requestLen", len(request))

// TODO: investigate if we can move all these network logic to new SDK handlers
var req message.Request
if _, err := n.codec.Unmarshal(request, &req); err != nil {
log.Debug("forwarding AppRequest to SDK network", "nodeID", nodeID, "requestID", requestID, "requestLen", len(request), "err", err)
Expand Down
3 changes: 0 additions & 3 deletions plugin/evm/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/coreth/plugin/evm/atomic"
"github.com/ava-labs/coreth/plugin/evm/client"
"github.com/ava-labs/coreth/plugin/evm/upgrade/ap3"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
)
Expand All @@ -35,8 +34,6 @@ var (
errNoAddresses = errors.New("no addresses provided")
errNoSourceChain = errors.New("no source chain provided")
errNilTxID = errors.New("nil transaction ID")

initialBaseFee = big.NewInt(ap3.InitialBaseFee)
)

// SnowmanAPI introduces snowman specific functionality to the evm
Expand Down
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
}
Loading
Loading