This repository was archived by the owner on May 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathrun_full.go
More file actions
110 lines (90 loc) · 2.55 KB
/
Copy pathrun_full.go
File metadata and controls
110 lines (90 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package nodesync
import (
"context"
"fmt"
"time"
"github.com/celestiaorg/celestia-node/nodebuilder/node"
"github.com/celestiaorg/test-infra/testkit"
"github.com/celestiaorg/test-infra/testkit/nodekit"
"github.com/celestiaorg/test-infra/testkit/common"
"github.com/testground/sdk-go/network"
"github.com/testground/sdk-go/run"
"github.com/testground/sdk-go/runtime"
)
func RunFullNode(runenv *runtime.RunEnv, initCtx *run.InitContext) error {
ctx, cancel := context.WithTimeout(
context.Background(),
time.Minute*time.Duration(runenv.IntParam("execution-time")),
)
defer cancel()
err := nodekit.SetLoggersLevel("DEBUG")
if err != nil {
return err
}
syncclient := initCtx.SyncClient
netclient := network.NewClient(syncclient, runenv)
netclient.MustWaitNetworkInitialized(ctx)
config := network.Config{
Network: "default",
Enable: true,
Default: network.LinkShape{
Latency: time.Duration(runenv.IntParam("latency")),
Bandwidth: common.GetBandwidthValue(runenv.StringParam("bandwidth")),
},
CallbackState: "network-configured",
RoutingPolicy: network.AllowAll,
}
config.IPv4 = runenv.TestSubnet
// using the assigned `GlobalSequencer` id per each of instance
// to fill in the last 2 octects of the new IP address for the instance
ipC := byte((initCtx.GlobalSeq >> 8) + 1)
ipD := byte(initCtx.GlobalSeq)
config.IPv4.IP = append(config.IPv4.IP[0:2:2], ipC, ipD)
err = netclient.ConfigureNetwork(ctx, &config)
if err != nil {
return err
}
bridgeNode, err := common.GetBridgeNode(ctx, syncclient, initCtx.GroupSeq, runenv.IntParam("bridge"))
if err != nil {
return err
}
ndhome := fmt.Sprintf("/.celestia-full-%d", initCtx.GlobalSeq)
runenv.RecordMessage(ndhome)
ip, err := initCtx.NetClient.GetDataNetworkIP()
if err != nil {
return err
}
trustedPeers := []string{bridgeNode.Maddr}
cfg := nodekit.NewConfig(node.Full, ip, trustedPeers, bridgeNode.TrustedHash)
nd, err := nodekit.NewNode(
ndhome,
node.Full,
cfg,
)
if err != nil {
return err
}
err = nd.Start(ctx)
if err != nil {
return err
}
eh, err := nd.HeaderServ.GetByHeight(ctx, uint64(runenv.IntParam("block-height")))
if err != nil {
return err
}
runenv.RecordMessage("Reached Block#%d contains Hash: %s",
runenv.IntParam("block-height"),
eh.Commit.BlockID.Hash.String())
if nd.HeaderServ.IsSyncing() {
runenv.RecordFailure(fmt.Errorf("full node is still syncing the past"))
}
err = nd.Stop(ctx)
if err != nil {
return err
}
_, err = syncclient.SignalEntry(ctx, testkit.FinishState)
if err != nil {
return err
}
return err
}