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

bump to avago that uses getSubnet API calls in wallet #727

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ linters-settings:
- name: useless-break
disabled: false
staticcheck:
go: '~1.21.7'
# https://staticcheck.io/docs/options#checks
checks:
- "all"
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/ava-labs/avalanche-network-runner

go 1.21.11
go 1.21.12

toolchain go1.22.3

require (
github.com/ava-labs/avalanchego v1.11.8
github.com/ava-labs/coreth v0.13.5-rc.0
github.com/ava-labs/avalanchego v1.11.11-0.20240814014627-2eef64141457
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180
github.com/ethereum/go-ethereum v1.13.8
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0
github.com/onsi/ginkgo/v2 v2.13.1
Expand All @@ -23,7 +23,7 @@ require (
golang.org/x/sync v0.6.0
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.33.0
google.golang.org/protobuf v1.34.2
)

require (
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ 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.11.8 h1:Q/der5bC/q3BQbIqxT7nNC0F30c+6X1G/eQzzMQ2CLk=
github.com/ava-labs/avalanchego v1.11.8/go.mod h1:aPYTETkM0KjtC7vFwPO6S8z2L0QTKaXjVUi98pTdNO4=
github.com/ava-labs/coreth v0.13.5-rc.0 h1:PJQbR9o2RrW3j9ba4r1glXnmM2PNAP3xR569+gMcBd0=
github.com/ava-labs/coreth v0.13.5-rc.0/go.mod h1:cm5c12xo5NiTgtbmeduv8i2nYdzgkczz9Wm3yiwwTRU=
github.com/ava-labs/avalanchego v1.11.11-0.20240814014627-2eef64141457 h1:yT27Bn/2+SnJR1YPIscqznSlvpnR3TEGfbS7wdB1Gmg=
github.com/ava-labs/avalanchego v1.11.11-0.20240814014627-2eef64141457/go.mod h1:UkyrRDXK2E15Lq2abyae2Pt+JsWvgsg1pe0/AtoMyAM=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180 h1:6aIHp7wbyGVYdhHVQUbG7BEcbCMEQ5SYopPPJyipyvk=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade.0.20240813194342-7635a96aa180/go.mod h1:/wNBVq7J7wlC2Kbov7kk6LV5xZvau7VF9zwTVOeyAjY=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down Expand Up @@ -997,8 +997,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
33 changes: 17 additions & 16 deletions local/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/fx"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
Expand Down Expand Up @@ -267,7 +268,7 @@ func (ln *localNetwork) installCustomChains(
platformCli := platformvm.NewClient(clientURI)

// wallet needs txs for all previously created subnets
var preloadTXs []ids.ID
var alreadyCreatedSubnetIDs []ids.ID
for _, chainSpec := range chainSpecs {
// if subnet id for the blockchain is specified, we need to add the subnet id
// tx info to the wallet so blockchain creation does not fail
Expand All @@ -278,11 +279,11 @@ func (ln *localNetwork) installCustomChains(
if err != nil {
return nil, err
}
preloadTXs = append(preloadTXs, subnetID)
alreadyCreatedSubnetIDs = append(alreadyCreatedSubnetIDs, subnetID)
}
}

w, err := newWallet(ctx, clientURI, preloadTXs)
w, err := newWallet(ctx, clientURI, alreadyCreatedSubnetIDs)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -826,7 +827,7 @@ type wallet struct {
func newWallet(
ctx context.Context,
uri string,
preloadTXs []ids.ID,
subnetIDs []ids.ID,
) (*wallet, error) {
kc := secp256k1fx.NewKeychain(genesis.EWOQKey)
primaryAVAXState, err := primary.FetchState(ctx, uri, kc.Addresses())
Expand All @@ -835,24 +836,24 @@ func newWallet(
}
pCTX, xCTX, utxos := primaryAVAXState.PCTX, primaryAVAXState.XCTX, primaryAVAXState.UTXOs
pClient := platformvm.NewClient(uri)
pTXs := make(map[ids.ID]*txs.Tx)
for _, id := range preloadTXs {
txBytes, err := pClient.GetTx(ctx, id)
if err != nil {
return nil, err
}
tx, err := txs.Parse(txs.Codec, txBytes)
subnetOwners := map[ids.ID]fx.Owner{}
for _, subnetID := range subnetIDs {
subnetInfo, err := pClient.GetSubnet(ctx, subnetID)
if err != nil {
return nil, err
}
pTXs[id] = tx
owner := secp256k1fx.OutputOwners{}
owner.Locktime = subnetInfo.Locktime
owner.Threshold = subnetInfo.Threshold
owner.Addrs = subnetInfo.ControlKeys
subnetOwners[subnetID] = &owner
}
pUTXOs := common.NewChainUTXOs(constants.PlatformChainID, utxos)
xUTXOs := common.NewChainUTXOs(xCTX.BlockchainID, utxos)
var w wallet
w.addr = genesis.EWOQKey.PublicKey().Address()
w.pCTX = pCTX
w.pBackend = p.NewBackend(pCTX, pUTXOs, pTXs)
w.pBackend = p.NewBackend(pCTX, pUTXOs, subnetOwners)
w.pBuilder = pbuilder.New(kc.Addresses(), pCTX, w.pBackend)
w.pSigner = psigner.New(kc, w.pBackend)
w.pWallet = p.NewWallet(w.pBuilder, w.pSigner, pClient, w.pBackend)
Expand Down Expand Up @@ -1020,15 +1021,15 @@ func (ln *localNetwork) removeSubnetValidators(
}
platformCli := platformvm.NewClient(clientURI)
// wallet needs txs for all previously created subnets
preloadTXs := make([]ids.ID, len(removeSubnetSpecs))
subnetIDs := make([]ids.ID, len(removeSubnetSpecs))
for i, removeSubnetSpec := range removeSubnetSpecs {
subnetID, err := ids.FromString(removeSubnetSpec.SubnetID)
if err != nil {
return err
}
preloadTXs[i] = subnetID
subnetIDs[i] = subnetID
}
w, err := newWallet(ctx, clientURI, preloadTXs)
w, err := newWallet(ctx, clientURI, subnetIDs)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion local/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/ava-labs/avalanchego/snow/uptime"
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/staking"
"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
Expand Down Expand Up @@ -148,7 +149,7 @@ func (node *localNode) AttachPeer(ctx context.Context, router router.InboundHand
InboundMsgThrottler: throttling.NewNoInboundThrottler(),
Network: peer.TestNetwork,
Router: router,
VersionCompatibility: version.GetCompatibility(node.networkID),
VersionCompatibility: version.GetCompatibility(upgrade.InitiallyActiveTime),
MySubnets: set.Set[ids.ID]{},
Beacons: validators.NewManager(),
NetworkID: node.networkID,
Expand Down
3 changes: 2 additions & 1 deletion local/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ava-labs/avalanchego/message"
"github.com/ava-labs/avalanchego/network/peer"
"github.com/ava-labs/avalanchego/staking"
"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/ips"
Expand Down Expand Up @@ -93,7 +94,7 @@ func verifyProtocol(

knownPeersFilter, knownPeersSalt := peer.TestNetwork.KnownPeers()

myVersion := version.GetCompatibility(constants.MainnetID).Version()
myVersion := version.GetCompatibility(upgrade.InitiallyActiveTime).Version()

verMsg, err := mc.Handshake(
constants.MainnetID,
Expand Down
Loading