Skip to content

Commit

Permalink
Merge branch 'master' into allow-issue-tx-with-partial-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Nov 26, 2024
2 parents 077c935 + 94be34a commit dc1f7bf
Show file tree
Hide file tree
Showing 22 changed files with 184 additions and 146 deletions.
26 changes: 15 additions & 11 deletions tests/antithesis/avalanchego/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ func main() {

kc := secp256k1fx.NewKeychain(genesis.EWOQKey)
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: c.URIs[0],
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := primary.MakeWallet(
ctx,
c.URIs[0],
kc,
kc,
primary.WalletConfig{},
)
require.NoError(err, "failed to initialize wallet")
tc.Log().Info("synced wallet",
zap.Duration("duration", time.Since(walletSyncStartTime)),
Expand Down Expand Up @@ -120,11 +122,13 @@ func main() {
uri := c.URIs[i%len(c.URIs)]
kc := secp256k1fx.NewKeychain(key)
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{},
)
require.NoError(err, "failed to initialize wallet")
tc.Log().Info("synced wallet",
zap.Duration("duration", time.Since(walletSyncStartTime)),
Expand Down Expand Up @@ -153,7 +157,7 @@ func main() {
type workload struct {
id int
log logging.Logger
wallet primary.Wallet
wallet *primary.Wallet
addrs set.Set[ids.ShortID]
uris []string
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/x/transfer/virtuous.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() {
xContext := xBuilder.Context()
avaxAssetID := xContext.AVAXAssetID

wallets := make([]primary.Wallet, len(testKeys))
wallets := make([]*primary.Wallet, len(testKeys))
shortAddrs := make([]ids.ShortID, len(testKeys))
for i := range wallets {
shortAddrs[i] = testKeys[i].PublicKey().Address()
Expand Down
18 changes: 10 additions & 8 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,18 @@ func NewPrivateKey(tc tests.TestContext) *secp256k1.PrivateKey {
}

// Create a new wallet for the provided keychain against the specified node URI.
func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) primary.Wallet {
func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) *primary.Wallet {
tc.Log().Info("initializing a new wallet",
zap.Stringer("nodeID", nodeURI.NodeID),
zap.String("URI", nodeURI.URI),
)
baseWallet, err := primary.MakeWallet(tc.DefaultContext(), &primary.WalletConfig{
URI: nodeURI.URI,
AVAXKeychain: keychain,
EthKeychain: keychain,
})
baseWallet, err := primary.MakeWallet(
tc.DefaultContext(),
nodeURI.URI,
keychain,
keychain,
primary.WalletConfig{},
)
require.NoError(tc, err)
wallet := primary.NewWalletWithOptions(
baseWallet,
Expand All @@ -87,12 +89,12 @@ func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmp
}

// OutputWalletBalances outputs the X-Chain and P-Chain balances of the provided wallet.
func OutputWalletBalances(tc tests.TestContext, wallet primary.Wallet) {
func OutputWalletBalances(tc tests.TestContext, wallet *primary.Wallet) {
_, _ = GetWalletBalances(tc, wallet)
}

// GetWalletBalances retrieves the X-Chain and P-Chain balances of the provided wallet.
func GetWalletBalances(tc tests.TestContext, wallet primary.Wallet) (uint64, uint64) {
func GetWalletBalances(tc tests.TestContext, wallet *primary.Wallet) (uint64, uint64) {
require := require.New(tc)
var (
xWallet = wallet.X()
Expand Down
17 changes: 10 additions & 7 deletions tests/fixture/tmpnet/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type Subnet struct {
}

// Retrieves a wallet configured for use with the subnet
func (s *Subnet) GetWallet(ctx context.Context, uri string) (primary.Wallet, error) {
func (s *Subnet) GetWallet(ctx context.Context, uri string) (*primary.Wallet, error) {
keychain := secp256k1fx.NewKeychain(s.OwningKey)

// Only fetch the subnet transaction if a subnet ID is present. This won't be true when
Expand All @@ -101,12 +101,15 @@ func (s *Subnet) GetWallet(ctx context.Context, uri string) (primary.Wallet, err
subnetIDs = append(subnetIDs, s.SubnetID)
}

return primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: keychain,
EthKeychain: keychain,
SubnetIDs: subnetIDs,
})
return primary.MakeWallet(
ctx,
uri,
keychain,
keychain,
primary.WalletConfig{
SubnetIDs: subnetIDs,
},
)
}

// Issues the subnet creation transaction and retains the result. The URI of a node is
Expand Down
15 changes: 9 additions & 6 deletions vms/example/xsvm/cmd/chain/create/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ func createFunc(c *cobra.Command, args []string) error {
// NewWalletFromURI fetches the available UTXOs owned by [kc] on the network
// that [uri] is hosting.
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: config.URI,
AVAXKeychain: kc,
EthKeychain: kc,
SubnetIDs: []ids.ID{config.SubnetID},
})
wallet, err := primary.MakeWallet(
ctx,
config.URI,
kc,
kc,
primary.WalletConfig{
SubnetIDs: []ids.ID{config.SubnetID},
},
)
if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions vms/platformvm/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type Network struct {
*p2p.Network

log logging.Logger
txVerifier TxVerifier
mempool *gossipMempool
partialSyncPrimaryNetwork bool
appSender common.AppSender
Expand Down Expand Up @@ -175,7 +174,6 @@ func New(
return &Network{
Network: p2pNetwork,
log: log,
txVerifier: txVerifier,
mempool: gossipMempool,
partialSyncPrimaryNetwork: partialSyncPrimaryNetwork,
appSender: appSender,
Expand Down
12 changes: 7 additions & 5 deletions wallet/subnet/primary/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ func ExampleWallet() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [LocalAPIURI] is hosting.
walletSyncStartTime := time.Now()
wallet, err := MakeWallet(ctx, &WalletConfig{
URI: LocalAPIURI,
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := MakeWallet(
ctx,
LocalAPIURI,
kc,
kc,
WalletConfig{},
)
if err != nil {
log.Fatalf("failed to initialize wallet with: %s\n", err)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting and registers [subnetID].
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
SubnetIDs: []ids.ID{subnetID},
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{
SubnetIDs: []ids.ID{subnetID},
},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
12 changes: 7 additions & 5 deletions wallet/subnet/primary/examples/add-primary-validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting.
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
12 changes: 7 additions & 5 deletions wallet/subnet/primary/examples/c-chain-export/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting.
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
12 changes: 7 additions & 5 deletions wallet/subnet/primary/examples/c-chain-import/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting.
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
15 changes: 9 additions & 6 deletions wallet/subnet/primary/examples/convert-subnet-to-l1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting and registers [subnetID].
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
SubnetIDs: []ids.ID{subnetID},
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{
SubnetIDs: []ids.ID{subnetID},
},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
12 changes: 7 additions & 5 deletions wallet/subnet/primary/examples/create-asset/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting.
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
15 changes: 9 additions & 6 deletions wallet/subnet/primary/examples/create-chain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting and registers [subnetID].
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
SubnetIDs: []ids.ID{subnetID},
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{
SubnetIDs: []ids.ID{subnetID},
},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
12 changes: 7 additions & 5 deletions wallet/subnet/primary/examples/create-locked-stakeable/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting.
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
12 changes: 7 additions & 5 deletions wallet/subnet/primary/examples/create-subnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting.
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
15 changes: 9 additions & 6 deletions wallet/subnet/primary/examples/disable-l1-validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ func main() {
// MakeWallet fetches the available UTXOs owned by [kc] on the network that
// [uri] is hosting and registers [validationID].
walletSyncStartTime := time.Now()
wallet, err := primary.MakeWallet(ctx, &primary.WalletConfig{
URI: uri,
AVAXKeychain: kc,
EthKeychain: kc,
ValidationIDs: []ids.ID{validationID},
})
wallet, err := primary.MakeWallet(
ctx,
uri,
kc,
kc,
primary.WalletConfig{
ValidationIDs: []ids.ID{validationID},
},
)
if err != nil {
log.Fatalf("failed to initialize wallet: %s\n", err)
}
Expand Down
Loading

0 comments on commit dc1f7bf

Please # to comment.