Skip to content

Commit f5eda11

Browse files
committed
update networkHub dependency
1 parent 3ff0766 commit f5eda11

File tree

8 files changed

+38
-232
lines changed

8 files changed

+38
-232
lines changed

cmd/txsimulation/lifecycle/validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (v *ValidatorLifecycle) setQueuedReceipt() error {
176176
limit := uint64(1000)
177177
var id thor.Bytes32
178178
for {
179-
events, err := v.stack.Staker().FilterValidatorQueued(nil, &api.Options{Limit: limit, Offset: offset}, logdb.ASC)
179+
events, err := v.stack.Staker().FilterValidatorQueued(nil, &api.Options{Limit: &limit, Offset: offset}, logdb.ASC)
180180
if err != nil {
181181
slog.Error("failed to filter validator queued events", "error", err, "id", v.id)
182182
return err

cmd/txsimulation/validators/validations.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ func (s *Service) checkExited(id thor.Address) (*validation.Validation, error) {
156156
CompleteIterations: periodDetails.CompletedPeriods,
157157
Status: validation.Status(val.Status),
158158
StartBlock: periodDetails.StartBlock,
159-
LockedVET: val.Stake,
160-
PendingUnlockVET: big.NewInt(0),
161-
QueuedVET: val.QueuedStake,
162-
CooldownVET: big.NewInt(0),
163-
WithdrawableVET: withdrawable,
164-
Weight: val.Weight,
159+
LockedVET: val.Stake.Uint64(),
160+
PendingUnlockVET: 0,
161+
QueuedVET: val.QueuedStake.Uint64(),
162+
CooldownVET: 0,
163+
WithdrawableVET: withdrawable.Uint64(),
164+
Weight: val.Weight.Uint64(),
165165
}
166166

167167
if periodDetails.ExitBlock != math.MaxUint32 {
@@ -269,12 +269,12 @@ func (s *Service) unpackValidators(result *api.CallResult) (map[thor.Address]*va
269269
CompleteIterations: completedPeriods[i],
270270
Status: statuses[i],
271271
StartBlock: startBlocks[i],
272-
LockedVET: validatorLockedVETs[i],
273-
PendingUnlockVET: big.NewInt(0),
274-
CooldownVET: big.NewInt(0),
275-
WithdrawableVET: big.NewInt(0),
276-
QueuedVET: validatorQueuedStakes[i],
277-
Weight: validatorLockedWeights[i],
272+
LockedVET: validatorLockedVETs[i].Uint64(),
273+
PendingUnlockVET: 0,
274+
CooldownVET: 0,
275+
WithdrawableVET: 0,
276+
QueuedVET: validatorQueuedStakes[i].Uint64(),
277+
Weight: validatorLockedWeights[i].Uint64(),
278278
}
279279
if exitBlocks[i] != uint32(math.MaxUint32) {
280280
v.ExitBlock = &exitBlocks[i]

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ require (
1515
github.com/cqroot/prompt v0.9.4
1616
github.com/ethereum/go-ethereum v1.8.14
1717
github.com/stretchr/testify v1.10.0
18-
github.com/vechain/thor/v2 v2.3.2-0.20250828095955-7ac607de33ad
18+
github.com/vechain/thor/v2 v2.3.2-0.20250828134807-dcd18366eac2
1919
)
2020

2121
require (
2222
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad
2323
github.com/jedib0t/go-pretty/v6 v6.6.7
2424
github.com/pkg/errors v0.9.1
25-
github.com/vechain/networkhub v0.0.5-0.20250819120439-71315d6e4883
25+
github.com/vechain/networkhub v0.0.5-0.20250828131643-f75f96d2f3f6
2626
)
2727

2828
require (

go.sum

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,10 @@ github.com/vechain/go-ethereum v1.8.15-0.20241126085506-c74017ec91b2 h1:ch3DqXvl
167167
github.com/vechain/go-ethereum v1.8.15-0.20241126085506-c74017ec91b2/go.mod h1:yPUCNmntAh1PritrMfSi7noK+9vVPStZX3wgh3ieaY0=
168168
github.com/vechain/goleveldb v1.0.1-0.20220809091043-51eb019c8655 h1:CbHcWpCi7wOYfpoErRABh3Slyq9vO0Ay/EHN5GuJSXQ=
169169
github.com/vechain/goleveldb v1.0.1-0.20220809091043-51eb019c8655/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
170-
github.com/vechain/networkhub v0.0.5-0.20250819120439-71315d6e4883 h1:Si2C1MlTKKx2ZsJD0/iP5zrm4i4aIhKArYCrkzYap2E=
171-
github.com/vechain/networkhub v0.0.5-0.20250819120439-71315d6e4883/go.mod h1:aF1ovictX85iXRvN++DAKKFbK2mcHTGG8hBriuRhNUo=
172-
github.com/vechain/thor/v2 v2.3.2-0.20250827110455-884e037e0806 h1:Nw8M+0NUsBP2DQIrM8siYzOjusrR3nfwVqSdW0MG5BI=
173-
github.com/vechain/thor/v2 v2.3.2-0.20250827110455-884e037e0806/go.mod h1:STGXqeAwg9qHV/q5QlAAA/VvWcC2eAeGAAYuYUUUosg=
174-
github.com/vechain/thor/v2 v2.3.2-0.20250827150046-83ed5c2af598 h1:Lik9ZWD3TiMx7RQzenAwiXJPXnStVkW1MbIWjjuHNIs=
175-
github.com/vechain/thor/v2 v2.3.2-0.20250827150046-83ed5c2af598/go.mod h1:STGXqeAwg9qHV/q5QlAAA/VvWcC2eAeGAAYuYUUUosg=
176-
github.com/vechain/thor/v2 v2.3.2-0.20250828095955-7ac607de33ad h1:LxuIj/+stmcielHmUlCPJ0pDmMyhkDdAD4two0odzGU=
177-
github.com/vechain/thor/v2 v2.3.2-0.20250828095955-7ac607de33ad/go.mod h1:STGXqeAwg9qHV/q5QlAAA/VvWcC2eAeGAAYuYUUUosg=
170+
github.com/vechain/networkhub v0.0.5-0.20250828131643-f75f96d2f3f6 h1:XPrUrArEco7/NiH7dfPQO3ygQjma1oKj2PJrmHUSOFM=
171+
github.com/vechain/networkhub v0.0.5-0.20250828131643-f75f96d2f3f6/go.mod h1:OuNmua7Py5+4wYRtyCo0DFbrV7L8x+bqzFC7mJGnvAE=
172+
github.com/vechain/thor/v2 v2.3.2-0.20250828134807-dcd18366eac2 h1:sDxiailtDWZEMF+VWQfcp+/VT5eFljdAvNt5DF9IJIc=
173+
github.com/vechain/thor/v2 v2.3.2-0.20250828134807-dcd18366eac2/go.mod h1:STGXqeAwg9qHV/q5QlAAA/VvWcC2eAeGAAYuYUUUosg=
178174
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
179175
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
180176
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=

hayabusa/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func (c *Config) Apply(genesis *genesis.CustomGenesis) {
5454
Balance: (*devgenesis.HexOrDecimal256)(big.NewInt(0)),
5555
Energy: (*devgenesis.HexOrDecimal256)(big.NewInt(0)),
5656
})
57-
stakerIndex = len(genesis.Accounts) - 1
5857
}
5958

6059
// params config - set max-block-proposers

hayabusa/network.go

Lines changed: 17 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ import (
44
"context"
55
"fmt"
66
"log/slog"
7-
"os"
87
"strconv"
98
"sync"
10-
"time"
119

1210
"github.com/ethereum/go-ethereum/common"
13-
"github.com/vechain/hayabusa-e2e/utils"
1411
"github.com/vechain/networkhub/environments/local"
1512
networkhubNetwork "github.com/vechain/networkhub/network"
1613
"github.com/vechain/networkhub/network/node"
@@ -20,80 +17,44 @@ import (
2017
)
2118

2219
type Network struct {
23-
ctx context.Context
24-
config *Config
25-
network *local.Local
26-
genesis *genesis.CustomGenesis
27-
nodes []node.Config
28-
usedPorts []int // to track used ports for cleanup
20+
ctx context.Context
21+
config *Config
22+
network *local.Local
23+
genesis *genesis.CustomGenesis
24+
nodes []node.Config
2925

3026
mu sync.Mutex
3127
}
3228

3329
func NewNetwork(config *Config, ctx context.Context) (*Network, error) {
34-
buildMutex.Lock()
35-
defer buildMutex.Unlock()
36-
3730
if err := config.Validate(); err != nil {
3831
return nil, err
3932
}
4033

41-
repo := "git@github.com:vechain/thor.git"
42-
43-
workingDir, ok := os.LookupEnv("THOR_WORKING_DIR")
44-
var thorBuilder *thorbuilder.Config
45-
if ok {
46-
thorBuilder = &thorbuilder.Config{
47-
BuildConfig: &thorbuilder.BuildConfig{
48-
ExistingPath: workingDir,
49-
DebugBuild: config.Debug,
50-
},
51-
}
52-
} else {
53-
slog.Warn("THOR_WORKING_DIR not set, using default repo/branch")
54-
thorBuilder = &thorbuilder.Config{
55-
DownloadConfig: &thorbuilder.DownloadConfig{
56-
RepoUrl: repo,
57-
Branch: "release/hayabusa",
58-
IsReusable: true,
59-
},
60-
}
61-
builder := thorbuilder.New(thorBuilder)
62-
err := builder.Download()
63-
if err != nil {
64-
return nil, fmt.Errorf("failed to download thor: %w", err)
65-
}
66-
workingDir = builder.DownloadPath
67-
}
68-
6934
nodes := make([]node.Config, 0)
7035
genesis := Genesis(config)
71-
usedPorts := make([]int, 0, config.Nodes*2)
7236
for i := range config.Nodes {
73-
node, apiPort, p2pPort := makeNode(config, i, ValidatorAccounts[i], genesis)
37+
node := makeNode(config, i, ValidatorAccounts[i], genesis)
7438
nodes = append(nodes, node)
75-
usedPorts = append(usedPorts, apiPort, p2pPort)
7639
}
7740

7841
network := local.NewEnv()
7942
netConfig := &networkhubNetwork.Network{
8043
BaseID: config.Name,
8144
Nodes: nodes,
82-
ThorBuilder: thorBuilder,
45+
ThorBuilder: thorbuilder.DefaultConfig(),
8346
}
84-
builder := thorbuilder.New(netConfig.ThorBuilder)
85-
builder.Download()
8647
if _, err := network.LoadConfig(netConfig); err != nil {
8748
return nil, fmt.Errorf("failed to load network config: %w", err)
8849
}
8950

51+
fmt.Println("The nodes are: ", nodes)
9052
return &Network{
91-
ctx: ctx,
92-
config: config,
93-
network: network,
94-
genesis: genesis,
95-
nodes: nodes,
96-
usedPorts: usedPorts,
53+
ctx: ctx,
54+
config: config,
55+
network: network,
56+
genesis: genesis,
57+
nodes: nodes,
9758
}, nil
9859
}
9960

@@ -106,13 +67,9 @@ func (n *Network) Genesis() *genesis.CustomGenesis {
10667
}
10768

10869
func (n *Network) Stop() {
109-
n.mu.Lock()
110-
defer n.mu.Unlock()
111-
11270
if err := n.network.StopNetwork(); err != nil {
11371
slog.Error("🛑 failed to stop network", "error", err)
11472
}
115-
globalPortManager.RemovePorts(n.config.Name)
11673
}
11774

11875
func (n *Network) NodeConfigs() []node.Config {
@@ -130,12 +87,6 @@ func (n *Network) NodeLifecycles() map[string]node.Lifecycle {
13087
}
13188

13289
func (n *Network) Start() error {
133-
n.mu.Lock()
134-
defer n.mu.Unlock()
135-
136-
buildMutex.Lock()
137-
defer buildMutex.Unlock()
138-
13990
go func() {
14091
<-n.ctx.Done()
14192
slog.Info("context done, cleaning up network")
@@ -146,51 +97,19 @@ func (n *Network) Start() error {
14697
return err
14798
}
14899

149-
for _, nodeConfig := range n.nodes {
150-
if err := nodeConfig.HealthCheck(0, 30*time.Second); err != nil {
151-
return err
152-
}
153-
}
154-
155-
if err := utils.WaitForPeersConnection(n.nodes, n.ctx); err != nil {
156-
return fmt.Errorf("failed to connect all nodes: %w", err)
157-
}
158-
159100
return nil
160101
}
161102

162103
func (n *Network) AttachNode(buildConfig *thorbuilder.Config, additionalArgs map[string]string) error {
163-
n.mu.Lock()
164-
defer n.mu.Unlock()
165-
buildMutex.Lock()
166-
defer buildMutex.Unlock()
167-
168-
builder := thorbuilder.New(buildConfig)
169-
170-
if err := builder.Download(); err != nil {
171-
return fmt.Errorf("failed to download builder: %w", err)
172-
}
173-
path, err := builder.Build()
174-
if err != nil {
175-
return fmt.Errorf("failed to build node: %w", err)
176-
}
177-
178-
node, apiPort, p2pPort := makeNode(n.config, len(n.nodes), ValidatorAccounts[len(n.nodes)], n.genesis)
179-
node.SetExecArtifact(path)
180-
node.SetAdditionalArgs(additionalArgs)
181-
n.nodes = append(n.nodes, node)
182-
n.usedPorts = append(n.usedPorts, apiPort, p2pPort)
183-
if err := n.network.AttachNode(node); err != nil {
104+
node := makeNode(n.config, len(n.nodes), ValidatorAccounts[len(n.nodes)], n.genesis)
105+
if err := n.network.AttachNode(node, buildConfig, additionalArgs); err != nil {
184106
return fmt.Errorf("failed to attach node: %w", err)
185107
}
186-
if err := node.HealthCheck(0, 30*time.Second); err != nil {
187-
return fmt.Errorf("failed to health check attached node: %w", err)
188-
}
189108

190109
return nil
191110
}
192111

193-
func makeNode(config *Config, i int, signer *NodePair, customGenesis *genesis.CustomGenesis) (node.Config, int, int) {
112+
func makeNode(config *Config, i int, signer *NodePair, customGenesis *genesis.CustomGenesis) node.Config {
194113
verbosity := 3
195114
if config.Verbosity > 0 {
196115
verbosity = config.Verbosity
@@ -207,16 +126,11 @@ func makeNode(config *Config, i int, signer *NodePair, customGenesis *genesis.Cu
207126
nodeID = fmt.Sprintf("%s-%s", config.Name, nodeID)
208127
}
209128

210-
apiPort := globalPortManager.NewPort(config.Name)
211-
p2pPort := globalPortManager.NewPort(config.Name)
212-
213129
return &node.BaseNode{
214130
ID: nodeID,
215131
Key: common.Bytes2Hex(signer.Node.D.Bytes()),
216132
Genesis: customGenesis,
217133
Verbosity: verbosity,
218134
AdditionalArgs: additionalArgs,
219-
APIAddr: fmt.Sprintf("0.0.0.0:%d", apiPort),
220-
P2PListenPort: p2pPort,
221-
}, apiPort, p2pPort
135+
}
222136
}

hayabusa/port_manager.go

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)