Skip to content

Commit

Permalink
Merge branch 'main' into fuji-subnets
Browse files Browse the repository at this point in the history
  • Loading branch information
arturrez committed Aug 22, 2024
2 parents 2fca8cb + 5042342 commit bb6d31f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
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 @@ -36,6 +36,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 @@ -290,7 +291,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 @@ -301,10 +302,10 @@ func (ln *localNetwork) installCustomChains(
if err != nil {
return nil, err
}
preloadTXs = append(preloadTXs, subnetID)
alreadyCreatedSubnetIDs = append(alreadyCreatedSubnetIDs, subnetID)
}
}
w, err := newWallet(ctx, clientURI, preloadTXs, ln.walletPrivateKey)
w, err := newWallet(ctx, clientURI, alreadyCreatedSubnetIDs, ln.walletPrivateKey)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -845,7 +846,7 @@ type wallet struct {
func newWallet(
ctx context.Context,
uri string,
preloadTXs []ids.ID,
subnetIDs []ids.ID,
walletPrivateKey string,
) (*wallet, error) {
var (
Expand All @@ -870,24 +871,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(avagoConstants.PlatformChainID, utxos)
xUTXOs := common.NewChainUTXOs(xCTX.BlockchainID, utxos)
var w wallet
w.addr = privateKey.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 @@ -1055,15 +1056,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, ln.walletPrivateKey)
w, err := newWallet(ctx, clientURI, subnetIDs, ln.walletPrivateKey)
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

0 comments on commit bb6d31f

Please sign in to comment.