Skip to content

Commit e0084b9

Browse files
committed
getValidatorWeight, disable partial sync, rm tmp debug out
1 parent 69bc39e commit e0084b9

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

local/blockchain.go

+12-32
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"time"
1717

1818
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
19-
"github.com/ethereum/go-ethereum/log"
2019

2120
"github.com/ava-labs/avalanchego/vms/avm"
2221
"github.com/ava-labs/avalanchego/vms/components/avax"
@@ -97,6 +96,17 @@ func (ln *localNetwork) getNode() node.Node {
9796
return node
9897
}
9998

99+
func (ln *localNetwork) getValidatorWeight() uint64 {
100+
switch ln.networkID {
101+
case avagoConstants.FujiID:
102+
return genesis.FujiParams.MinValidatorStake
103+
case avagoConstants.MainnetID:
104+
return genesis.MainnetParams.MinValidatorStake
105+
default:
106+
return genesis.LocalParams.MinValidatorStake
107+
}
108+
}
109+
100110
// get node client URI for an arbitrary node in the network
101111
func (ln *localNetwork) getClientURI() (string, error) {
102112
clientURI := ""
@@ -115,30 +125,6 @@ func (ln *localNetwork) getClientURI() (string, error) {
115125
return clientURI, nil
116126
}
117127

118-
/*
119-
func (ln *localNetwork) getClientURI() (string, error) {
120-
node := ln.getNode()
121-
clientURI := fmt.Sprintf("http://%s:%d", node.GetURL(), node.GetAPIPort())
122-
ln.log.Info("getClientURI",
123-
zap.String("nodeName", node.GetName()),
124-
zap.String("uri", clientURI))
125-
return clientURI, nil
126-
}
127-
*/
128-
/*
129-
// get network URI for wallet
130-
func (ln *localNetwork) GetNetworkURI() (string, error) {
131-
switch ln.networkID {
132-
case avagoConstants.MainnetID:
133-
return "", fmt.Errorf("not supported")
134-
case avagoConstants.FujiID:
135-
return constants.FujiAPIEndpoint, nil
136-
default:
137-
return ln.getClientURI()
138-
}
139-
}
140-
*/
141-
142128
func (ln *localNetwork) CreateBlockchains(
143129
ctx context.Context,
144130
chainSpecs []network.BlockchainSpec, // VM name + genesis bytes
@@ -318,12 +304,10 @@ func (ln *localNetwork) installCustomChains(
318304
preloadTXs = append(preloadTXs, subnetID)
319305
}
320306
}
321-
ln.log.Info(logging.Blue.Wrap(logging.Bold.Wrap("create wallet")))
322307
w, err := newWallet(ctx, clientURI, preloadTXs, ln.walletPrivateKey)
323308
if err != nil {
324309
return nil, err
325310
}
326-
ln.log.Info(logging.Blue.Wrap(logging.Bold.Wrap(" wallet is ready")))
327311
// get subnet specs for all new subnets to create
328312
// for the list of requested blockchains, we take those that have undefined subnet id
329313
// and use the provided subnet spec. if not given, use an empty default subnet spec
@@ -880,15 +864,12 @@ func newWallet(
880864
}
881865
}
882866
kc := secp256k1fx.NewKeychain(privateKey)
883-
log.Info("aboout to fetch state", uri, kc.Addresses())
884867
primaryAVAXState, err := primary.FetchState(ctx, uri, kc.Addresses())
885868
if err != nil {
886869
return nil, err
887870
}
888-
log.Info("primaryAVAXState", primaryAVAXState)
889871
pCTX, xCTX, utxos := primaryAVAXState.PCTX, primaryAVAXState.XCTX, primaryAVAXState.UTXOs
890872
pClient := platformvm.NewClient(uri)
891-
log.Info("pClient using uri", uri)
892873
pTXs := make(map[ids.ID]*txs.Tx)
893874
for _, id := range preloadTXs {
894875
txBytes, err := pClient.GetTx(ctx, id)
@@ -911,7 +892,6 @@ func newWallet(
911892
w.pSigner = psigner.New(kc, w.pBackend)
912893
w.pWallet = p.NewWallet(w.pBuilder, w.pSigner, pClient, w.pBackend)
913894

914-
log.Info("pWallet", w.pWallet)
915895
xBackend := x.NewBackend(xCTX, xUTXOs)
916896
xBuilder := xbuilder.New(kc.Addresses(), xCTX, xBackend)
917897
xSigner := xsigner.New(kc, xBackend)
@@ -972,7 +952,7 @@ func (ln *localNetwork) addPrimaryValidators(
972952
NodeID: nodeID,
973953
Start: uint64(time.Now().Add(validationStartOffset).Unix()),
974954
End: uint64(time.Now().Add(validationDuration).Unix()),
975-
Wght: genesis.LocalParams.MinValidatorStake,
955+
Wght: ln.getValidatorWeight(),
976956
},
977957
Subnet: ids.Empty,
978958
},

local/network.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,12 @@ func NewDefaultConfigNNodes(binaryPath string, numNodes uint32, networkID uint32
363363
}
364364
if !utils.IsPublicNetwork(networkID) {
365365
nodeConfig.IsBeacon = true
366-
} else {
366+
}
367+
/* disable partial sync for now
368+
else {
367369
nodeConfig.Flags[config.PartialSyncPrimaryNetworkKey] = true
368370
}
371+
*/
369372
nodeConfigs = append(nodeConfigs, nodeConfig)
370373
port += 2
371374
}

0 commit comments

Comments
 (0)