This repository was archived by the owner on Nov 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
move atomic gossip #706
Merged
Merged
move atomic gossip #706
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
bc26c83
new atomic pkg
ceyonur fe45c37
Merge branch 'master' into move-atomic-txs
ceyonur 9c3e284
bump avago
ceyonur ddbbab7
bump versions
ceyonur 0ecd789
move attomic gossip
ceyonur 019bb04
lint
ceyonur aa50ce6
change newimport clk to time
ceyonur 52081a9
move utils
ceyonur 397c535
Merge branch 'seperate-atomic-pkg-base' into move-atomic-txs
ceyonur 2b13c8e
bump avago
ceyonur 2798ad6
go mod tidy
ceyonur 6bf2ff2
Merge branch 'move-atomic-txs' into move-atomic-gossip
ceyonur 278e055
update releases md
ceyonur e5f2c27
use address methods from avago
ceyonur 71babe6
bump avago
ceyonur aab47b6
bump e2e avago version
ceyonur b9b67bc
Merge branch 'move-atomic-txs' into move-atomic-gossip
ceyonur 6f1adc8
Update plugin/evm/atomic/gossip_test.go
ceyonur 876716f
Update plugin/evm/atomic/mempool.go
ceyonur 682e4bc
Update plugin/evm/config/config.go
ceyonur 38ad868
Update plugin/evm/atomic/tx_heap.go
ceyonur de328e9
Update plugin/evm/config/config.go
ceyonur 55c0be9
fix reviews
ceyonur 3ac1a1a
Merge branch 'move-atomic-gossip' of github.com:ava-labs/coreth into …
ceyonur 295417f
Merge branch 'master' into move-atomic-gossip
ceyonur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // (c) 2019-2025, Ava Labs, Inc. All rights reserved. | ||
| // See the file LICENSE for licensing terms. | ||
|
|
||
| package atomic | ||
|
|
||
| import ( | ||
| "github.com/ava-labs/avalanchego/ids" | ||
| "github.com/ava-labs/avalanchego/network/p2p/gossip" | ||
| ) | ||
|
|
||
| var ( | ||
| _ gossip.Gossipable = (*GossipAtomicTx)(nil) | ||
| _ gossip.Marshaller[*GossipAtomicTx] = (*GossipAtomicTxMarshaller)(nil) | ||
| ) | ||
|
|
||
| type GossipAtomicTxMarshaller struct{} | ||
|
|
||
| func (g GossipAtomicTxMarshaller) MarshalGossip(tx *GossipAtomicTx) ([]byte, error) { | ||
| return tx.Tx.SignedBytes(), nil | ||
| } | ||
|
|
||
| func (g GossipAtomicTxMarshaller) UnmarshalGossip(bytes []byte) (*GossipAtomicTx, error) { | ||
| tx, err := ExtractAtomicTx(bytes, Codec) | ||
| return &GossipAtomicTx{ | ||
| Tx: tx, | ||
| }, err | ||
| } | ||
|
|
||
| type GossipAtomicTx struct { | ||
| Tx *Tx | ||
| } | ||
|
|
||
| func (tx *GossipAtomicTx) GossipID() ids.ID { | ||
| return tx.Tx.ID() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // (c) 2019-2025, Ava Labs, Inc. All rights reserved. | ||
| // See the file LICENSE for licensing terms. | ||
|
|
||
| package atomic | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/ava-labs/avalanchego/ids" | ||
| "github.com/ava-labs/avalanchego/snow" | ||
| "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" | ||
| "github.com/ava-labs/avalanchego/vms/components/verify" | ||
| "github.com/prometheus/client_golang/prometheus" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestGossipAtomicTxMarshaller(t *testing.T) { | ||
| require := require.New(t) | ||
|
|
||
| want := &GossipAtomicTx{ | ||
| Tx: &Tx{ | ||
| UnsignedAtomicTx: &UnsignedImportTx{}, | ||
| Creds: []verify.Verifiable{}, | ||
| }, | ||
| } | ||
| marshaller := GossipAtomicTxMarshaller{} | ||
|
|
||
| key0, err := secp256k1.NewPrivateKey() | ||
| require.NoError(err) | ||
| err = want.Tx.Sign(Codec, [][]*secp256k1.PrivateKey{{key0}}) | ||
| require.NoError(err) | ||
|
|
||
| bytes, err := marshaller.MarshalGossip(want) | ||
| require.NoError(err) | ||
|
|
||
| got, err := marshaller.UnmarshalGossip(bytes) | ||
| require.NoError(err) | ||
| require.Equal(want.GossipID(), got.GossipID()) | ||
| } | ||
|
|
||
| func TestAtomicMempoolIterate(t *testing.T) { | ||
| txs := []*GossipAtomicTx{ | ||
| { | ||
| Tx: &Tx{ | ||
| UnsignedAtomicTx: &TestUnsignedTx{ | ||
| IDV: ids.GenerateTestID(), | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| Tx: &Tx{ | ||
| UnsignedAtomicTx: &TestUnsignedTx{ | ||
| IDV: ids.GenerateTestID(), | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| add []*GossipAtomicTx | ||
| f func(tx *GossipAtomicTx) bool | ||
| expectedTxs []*GossipAtomicTx | ||
| }{ | ||
| { | ||
| name: "func matches nothing", | ||
| add: txs, | ||
| f: func(*GossipAtomicTx) bool { | ||
| return false | ||
| }, | ||
| expectedTxs: []*GossipAtomicTx{}, | ||
| }, | ||
| { | ||
| name: "func matches all", | ||
| add: txs, | ||
| f: func(*GossipAtomicTx) bool { | ||
| return true | ||
| }, | ||
| expectedTxs: txs, | ||
| }, | ||
| { | ||
| name: "func matches subset", | ||
| add: txs, | ||
| f: func(tx *GossipAtomicTx) bool { | ||
| return tx.Tx == txs[0].Tx | ||
| }, | ||
| expectedTxs: []*GossipAtomicTx{txs[0]}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| require := require.New(t) | ||
| m, err := NewMempool(&snow.Context{}, prometheus.NewRegistry(), 10, nil) | ||
| require.NoError(err) | ||
|
|
||
| for _, add := range tt.add { | ||
| require.NoError(m.Add(add)) | ||
| } | ||
|
|
||
| matches := make([]*GossipAtomicTx, 0) | ||
| f := func(tx *GossipAtomicTx) bool { | ||
| match := tt.f(tx) | ||
|
|
||
| if match { | ||
| matches = append(matches, tx) | ||
| } | ||
|
|
||
| return match | ||
| } | ||
|
|
||
| m.Iterate(f) | ||
|
|
||
| require.ElementsMatch(tt.expectedTxs, matches) | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.