Skip to content

Commit 5e7ab4b

Browse files
committed
solana changes
1 parent bae283a commit 5e7ab4b

File tree

6 files changed

+119
-143
lines changed

6 files changed

+119
-143
lines changed

framework/components/blockchain/blockchain.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
// Input is a blockchain network configuration params
88
type Input struct {
9+
// Common EVM fields
910
Type string `toml:"type" validate:"required,oneof=anvil geth besu solana" envconfig:"net_type"`
1011
Image string `toml:"image"`
1112
PullImage bool `toml:"pull_image"`
@@ -16,10 +17,10 @@ type Input struct {
1617
DockerCmdParamsOverrides []string `toml:"docker_cmd_params"`
1718
Out *Output `toml:"out"`
1819

19-
// solana only fields
20+
// Solana fields
2021
// publickey to mint when solana-test-validator starts
21-
PublicKey string `toml:"public_key"`
22-
ContractsDir string `toml:"contracts_dir"`
22+
PublicKey string `toml:"public_key" validate:"required"`
23+
ContractsDir string `toml:"contracts_dir" validate:"required"`
2324
}
2425

2526
// Output is a blockchain network output, ChainID and one or more nodes that forms the network

framework/components/blockchain/solana.go

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"os"
7+
"path/filepath"
78
"strconv"
89
"time"
910

@@ -31,30 +32,33 @@ var idJSONRaw = `
3132

3233
func defaultSolana(in *Input) {
3334
if in.Image == "" {
34-
in.Image = "solanalabs/solana:v1.18.26"
35+
in.Image = "f4hrenh9it/solana"
3536
}
3637
if in.Port == "" {
37-
in.Port = "8899"
38+
in.Port = "8545"
39+
}
40+
if in.WSPort == "" {
41+
in.WSPort = "8546"
3842
}
3943
}
4044

4145
func newSolana(in *Input) (*Output, error) {
4246
defaultSolana(in)
4347
ctx := context.Background()
44-
wsPortNumberStr, err := wsPort(in.Port)
45-
if err != nil {
46-
return nil, err
47-
}
48+
//wsPortNumberStr, err := wsPort(in.Port)
49+
//if err != nil {
50+
// return nil, err
51+
//}
4852
framework.L.Info().Msg("Creating solana container")
4953
bindPort := fmt.Sprintf("%s/tcp", in.Port)
5054
containerName := framework.DefaultTCName("blockchain-solana-node")
51-
wsBindPort := fmt.Sprintf("%s/tcp", wsPortNumberStr)
55+
wsBindPort := fmt.Sprintf("%s/tcp", in.WSPort)
5256

5357
configYml, err := os.CreateTemp("", "config.yml")
5458
if err != nil {
5559
return nil, err
5660
}
57-
configYmlRaw = fmt.Sprintf(configYmlRaw, in.Port, wsPortNumberStr)
61+
configYmlRaw = fmt.Sprintf(configYmlRaw, in.Port, in.WSPort)
5862
_, err = configYml.WriteString(configYmlRaw)
5963
if err != nil {
6064
return nil, err
@@ -69,6 +73,12 @@ func newSolana(in *Input) (*Output, error) {
6973
return nil, err
7074
}
7175

76+
contractsDir, err := filepath.Abs(in.ContractsDir)
77+
if err != nil {
78+
return nil, err
79+
}
80+
81+
framework.L.Info().Any("Port", in.Port).Any("WSPort", in.WSPort).Send()
7282
req := testcontainers.ContainerRequest{
7383
AlwaysPullImage: in.PullImage,
7484
Image: in.Image,
@@ -83,35 +93,40 @@ func newSolana(in *Input) (*Output, error) {
8393
WithStartupTimeout(30 * time.Second).
8494
WithPollInterval(100 * time.Millisecond),
8595
HostConfigModifier: func(h *container.HostConfig) {
86-
h.PortBindings = framework.MapTheSamePort(bindPort)
87-
h.PortBindings[nat.Port(wsBindPort)] = []nat.PortBinding{
88-
{
89-
HostIP: "0.0.0.0",
90-
HostPort: wsBindPort,
96+
h.PortBindings = nat.PortMap{
97+
nat.Port(bindPort): []nat.PortBinding{
98+
{
99+
HostIP: "0.0.0.0",
100+
HostPort: bindPort,
101+
},
102+
},
103+
nat.Port(wsBindPort): []nat.PortBinding{
104+
{
105+
HostIP: "0.0.0.0",
106+
HostPort: wsBindPort,
107+
},
91108
},
92109
}
93110
h.Mounts = append(h.Mounts, mount.Mount{
94111
Type: mount.TypeBind,
95-
Source: in.ContractsDir,
112+
Source: contractsDir,
96113
Target: "/programs",
97114
ReadOnly: false,
98115
})
99116
},
100-
LifecycleHooks: []testcontainers.ContainerLifecycleHooks{
117+
Files: []testcontainers.ContainerFile{
101118
{
102-
PostStarts: []testcontainers.ContainerHook{
103-
func(ctx context.Context, container testcontainers.Container) error {
104-
err = container.CopyFileToContainer(ctx, configYml.Name(), "/root/.config/solana/cli/config.yml", 0644)
105-
if err != nil {
106-
return err
107-
}
108-
err = container.CopyFileToContainer(ctx, idJSON.Name(), "/root/.config/solana/cli/id.json", 0644)
109-
return err
110-
},
111-
},
119+
HostFilePath: configYml.Name(),
120+
ContainerFilePath: "/data/config.yml",
121+
FileMode: 0644,
122+
},
123+
{
124+
HostFilePath: idJSON.Name(),
125+
ContainerFilePath: "/data/id.json",
126+
FileMode: 0644,
112127
},
113128
},
114-
Entrypoint: []string{"sh", "-c", fmt.Sprintf("mkdir -p /root/.config/solana/cli && solana-test-validator --rpc-port %s --mint %s", in.Port, in.PublicKey)},
129+
Entrypoint: []string{"sh", "-c", "solana-test-validator -C /data/config.yml --bind-address=0.0.0.0 --mint=" + in.PublicKey},
115130
}
116131

117132
c, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
@@ -125,14 +140,14 @@ func newSolana(in *Input) (*Output, error) {
125140
if err != nil {
126141
return nil, err
127142
}
128-
mp, err := c.MappedPort(ctx, nat.Port(bindPort))
129-
if err != nil {
130-
return nil, err
131-
}
132-
wsmp, err := c.MappedPort(ctx, nat.Port(wsBindPort))
133-
if err != nil {
134-
return nil, err
135-
}
143+
//mp, err := c.MappedPort(ctx, nat.Port(bindPort))
144+
//if err != nil {
145+
// return nil, err
146+
//}
147+
//wsmp, err := c.MappedPort(ctx, nat.Port(wsBindPort))
148+
//if err != nil {
149+
// return nil, err
150+
//}
136151

137152
framework.L.Info().Msg("Started Solana container")
138153

@@ -143,9 +158,9 @@ func newSolana(in *Input) (*Output, error) {
143158
ContainerName: containerName,
144159
Nodes: []*Node{
145160
{
146-
HostWSUrl: fmt.Sprintf("ws://%s:%s", host, wsmp.Port()),
147-
HostHTTPUrl: fmt.Sprintf("http://%s:%s", host, mp.Port()),
148-
DockerInternalWSUrl: fmt.Sprintf("ws://%s:%s", containerName, wsPortNumberStr),
161+
HostWSUrl: fmt.Sprintf("ws://%s:%s", host, in.Port),
162+
HostHTTPUrl: fmt.Sprintf("http://%s:%s", host, in.WSPort),
163+
DockerInternalWSUrl: fmt.Sprintf("ws://%s:%s", containerName, in.WSPort),
149164
DockerInternalHTTPUrl: fmt.Sprintf("http://%s:%s", containerName, in.Port),
150165
},
151166
},

framework/examples/myproject/go.mod

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ require (
3333
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
3434
github.com/armon/go-metrics v0.4.1 // indirect
3535
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
36-
github.com/atotto/clipboard v0.1.4 // indirect
3736
github.com/avast/retry-go v3.0.0+incompatible // indirect
3837
github.com/awalterschulze/gographviz v2.0.3+incompatible // indirect
3938
github.com/aws/aws-sdk-go v1.45.25 // indirect
@@ -51,7 +50,6 @@ require (
5150
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 // indirect
5251
github.com/aws/aws-sdk-go-v2/service/sts v1.33.0 // indirect
5352
github.com/aws/smithy-go v1.22.1 // indirect
54-
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
5553
github.com/benbjohnson/clock v1.3.5 // indirect
5654
github.com/beorn7/perks v1.0.1 // indirect
5755
github.com/bits-and-blooms/bitset v1.13.0 // indirect
@@ -60,19 +58,9 @@ require (
6058
github.com/bytedance/sonic v1.12.3 // indirect
6159
github.com/bytedance/sonic/loader v0.2.0 // indirect
6260
github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b // indirect
63-
github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8 // indirect
64-
github.com/catppuccin/go v0.2.0 // indirect
6561
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
6662
github.com/cespare/xxhash v1.1.0 // indirect
6763
github.com/cespare/xxhash/v2 v2.3.0 // indirect
68-
github.com/charmbracelet/bubbles v0.20.0 // indirect
69-
github.com/charmbracelet/bubbletea v1.1.1 // indirect
70-
github.com/charmbracelet/huh v0.6.0 // indirect
71-
github.com/charmbracelet/huh/spinner v0.0.0-20241028115900-20a4d21717a8 // indirect
72-
github.com/charmbracelet/lipgloss v0.13.0 // indirect
73-
github.com/charmbracelet/x/ansi v0.2.3 // indirect
74-
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
75-
github.com/charmbracelet/x/term v0.2.0 // indirect
7664
github.com/cloudwego/base64x v0.1.4 // indirect
7765
github.com/cloudwego/iasm v0.2.0 // indirect
7866
github.com/coder/websocket v1.8.12 // indirect
@@ -83,7 +71,6 @@ require (
8371
github.com/coreos/go-semver v0.3.1 // indirect
8472
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
8573
github.com/cpuguy83/dockercfg v0.3.2 // indirect
86-
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
8774
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
8875
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
8976
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@@ -98,7 +85,6 @@ require (
9885
github.com/dustin/go-humanize v1.0.1 // indirect
9986
github.com/edsrzf/mmap-go v1.1.0 // indirect
10087
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
101-
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
10288
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
10389
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
10490
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb // indirect
@@ -173,18 +159,14 @@ require (
173159
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
174160
github.com/kylelemons/godebug v1.1.0 // indirect
175161
github.com/leodido/go-urn v1.4.0 // indirect
176-
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
177162
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
178163
github.com/magiconair/properties v1.8.7 // indirect
179164
github.com/mailru/easyjson v0.7.7 // indirect
180165
github.com/mattn/go-colorable v0.1.13 // indirect
181166
github.com/mattn/go-isatty v0.0.20 // indirect
182-
github.com/mattn/go-localereader v0.0.1 // indirect
183-
github.com/mattn/go-runewidth v0.0.16 // indirect
184167
github.com/miekg/dns v1.1.56 // indirect
185168
github.com/mitchellh/copystructure v1.0.0 // indirect
186169
github.com/mitchellh/go-homedir v1.1.0 // indirect
187-
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
188170
github.com/mitchellh/mapstructure v1.5.0 // indirect
189171
github.com/mitchellh/reflectwalk v1.0.1 // indirect
190172
github.com/mmcloughlin/addchain v0.4.0 // indirect
@@ -198,9 +180,6 @@ require (
198180
github.com/modern-go/reflect2 v1.0.2 // indirect
199181
github.com/montanaflynn/stats v0.7.1 // indirect
200182
github.com/morikuni/aec v1.0.0 // indirect
201-
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
202-
github.com/muesli/cancelreader v0.2.2 // indirect
203-
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
204183
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
205184
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
206185
github.com/oklog/ulid v1.3.1 // indirect
@@ -209,8 +188,6 @@ require (
209188
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect
210189
github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect
211190
github.com/opentracing/opentracing-go v1.2.0 // indirect
212-
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
213-
github.com/pelletier/go-toml v1.9.5 // indirect
214191
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
215192
github.com/pierrec/lz4/v4 v4.1.21 // indirect
216193
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
@@ -225,10 +202,8 @@ require (
225202
github.com/prometheus/exporter-toolkit v0.10.1-0.20230714054209-2f4150c63f97 // indirect
226203
github.com/prometheus/procfs v0.15.1 // indirect
227204
github.com/prometheus/prometheus v0.47.2-0.20231010075449-4b9c19fe5510 // indirect
228-
github.com/rivo/uniseg v0.4.7 // indirect
229205
github.com/rogpeppe/go-internal v1.13.1 // indirect
230206
github.com/rs/zerolog v1.33.0 // indirect
231-
github.com/russross/blackfriday/v2 v2.1.0 // indirect
232207
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
233208
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
234209
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
@@ -249,9 +224,7 @@ require (
249224
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
250225
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
251226
github.com/ugorji/go/codec v1.2.12 // indirect
252-
github.com/urfave/cli/v2 v2.27.5 // indirect
253227
github.com/x448/float16 v0.8.4 // indirect
254-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
255228
github.com/yusufpapurcu/wmi v1.2.3 // indirect
256229
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
257230
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect

0 commit comments

Comments
 (0)