From 5a40b911e387f4ce12b06cc7ea703fc8c981c3e9 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 9 Aug 2024 15:14:43 -0600 Subject: [PATCH 1/7] fix validation client url scheme test --- staker/block_validator.go | 11 +++++++++++ staker/stateless_block_validator.go | 8 +------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index fc9f21cf42..bdcd1d2559 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -8,6 +8,7 @@ import ( "encoding/json" "errors" "fmt" + "net/url" "regexp" "runtime" "sync" @@ -140,6 +141,16 @@ func (c *BlockValidatorConfig) Validate() error { if err := c.ValidationServerConfigs[i].Validate(); err != nil { return fmt.Errorf("failed to validate one of the block-validator validation-server-configs. url: %s, err: %w", c.ValidationServerConfigs[i].URL, err) } + serverUrl := c.ValidationServerConfigs[i].URL + if serverUrl != "self" && serverUrl != "self-auth" { + u, err := url.Parse(serverUrl) + if err != nil { + return fmt.Errorf("failed parsing validation server's url:%s err: %w", serverUrl, err) + } + if u.Scheme != "ws" && u.Scheme != "wss" { + return fmt.Errorf("validation server's url scheme is unsupported, it should either be ws or wss, url:%s", serverUrl) + } + } } return nil } diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index c8842aedc4..e8232264fe 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -7,7 +7,6 @@ import ( "context" "errors" "fmt" - "net/url" "runtime" "testing" @@ -488,13 +487,8 @@ func (v *StatelessBlockValidator) Start(ctx_in context.Context) error { return fmt.Errorf("starting execution spawner: %w", err) } } - for i, spawner := range v.execSpawners { + for _, spawner := range v.execSpawners { if err := spawner.Start(ctx_in); err != nil { - if u, parseErr := url.Parse(v.config.ValidationServerConfigs[i].URL); parseErr == nil { - if u.Scheme != "ws" && u.Scheme != "wss" { - return fmt.Errorf("validation server's url scheme is unsupported, it should either be ws or wss, url:%s err: %w", v.config.ValidationServerConfigs[i].URL, err) - } - } return err } } From aeddc231b02f31ffbca454d7e5a1399140119329 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 9 Aug 2024 16:15:00 -0600 Subject: [PATCH 2/7] remove debug prints --- validator/server_jit/machine_loader.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/validator/server_jit/machine_loader.go b/validator/server_jit/machine_loader.go index b2bdb65322..cfa475370c 100644 --- a/validator/server_jit/machine_loader.go +++ b/validator/server_jit/machine_loader.go @@ -27,16 +27,13 @@ var DefaultJitMachineConfig = JitMachineConfig{ func getJitPath() (string, error) { var jitBinary string executable, err := os.Executable() - println("executable: ", executable) if err == nil { if strings.Contains(filepath.Base(executable), "test") || strings.Contains(filepath.Dir(executable), "system_tests") { _, thisfile, _, _ := runtime.Caller(0) projectDir := filepath.Dir(filepath.Dir(filepath.Dir(thisfile))) - println("projectDir: ", projectDir) jitBinary = filepath.Join(projectDir, "target", "bin", "jit") } else { jitBinary = filepath.Join(filepath.Dir(executable), "jit") - println("inside else: ", jitBinary) } _, err = os.Stat(jitBinary) } From a20aa41d805caa849ba768d2ee71efbb74015eba Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 9 Aug 2024 16:15:23 -0600 Subject: [PATCH 3/7] split-val-entry uses websocket --- scripts/split-val-entry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/split-val-entry.sh b/scripts/split-val-entry.sh index 8e1be0f6cc..6b3358e878 100755 --- a/scripts/split-val-entry.sh +++ b/scripts/split-val-entry.sh @@ -16,4 +16,4 @@ for port in 52000 52001; do done done echo launching nitro-node -/usr/local/bin/nitro --validation.wasm.allowed-wasm-module-roots /home/user/nitro-legacy/machines,/home/user/target/machines --node.block-validator.validation-server-configs-list='[{"jwtsecret":"/tmp/nitro-val.jwt","url":"http://127.0.0.10:52000"}, {"jwtsecret":"/tmp/nitro-val.jwt","url":"http://127.0.0.10:52001"}]' "$@" +/usr/local/bin/nitro --validation.wasm.allowed-wasm-module-roots /home/user/nitro-legacy/machines,/home/user/target/machines --node.block-validator.validation-server-configs-list='[{"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52000"}, {"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52001"}]' "$@" From c7059a3d28b47a72952a5b4742f7cead0268f36f Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Sat, 10 Aug 2024 12:02:22 -0600 Subject: [PATCH 4/7] validation_client: connect to pre-stylus --- validator/client/validation_client.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index d6743b109e..3d71e95c64 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -67,16 +67,17 @@ func (c *ValidationClient) Start(ctx context.Context) error { return errors.New("couldn't read name from server") } var stylusArchs []string - if err := c.client.CallContext(ctx, &stylusArchs, server_api.Namespace+"_stylusArchs"); err != nil { - return err - } - if len(stylusArchs) == 0 { - return fmt.Errorf("could not read stylus archs from validation server") - } - for _, stylusArch := range stylusArchs { - if stylusArch != "wavm" && stylusArch != runtime.GOARCH && stylusArch != "mock" { - return fmt.Errorf("unsupported stylus architecture: %v", stylusArch) + if err := c.client.CallContext(ctx, &stylusArchs, server_api.Namespace+"_stylusArchs"); err == nil { + if len(stylusArchs) == 0 { + return fmt.Errorf("could not read stylus archs from validation server") } + for _, stylusArch := range stylusArchs { + if stylusArch != "wavm" && stylusArch != runtime.GOARCH && stylusArch != "mock" { + return fmt.Errorf("unsupported stylus architecture: %v", stylusArch) + } + } + } else { + stylusArchs = []string{"pre-stylus"} // validation does not support stylus } var moduleRoots []common.Hash if err := c.client.CallContext(ctx, &moduleRoots, server_api.Namespace+"_wasmModuleRoots"); err != nil { From 3b339c989ade8fa81143b59fa9b7d559ab81bf30 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 12 Aug 2024 12:09:57 -0600 Subject: [PATCH 5/7] block_validator: allow empty url --- staker/block_validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index bdcd1d2559..df465cc31f 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -142,7 +142,7 @@ func (c *BlockValidatorConfig) Validate() error { return fmt.Errorf("failed to validate one of the block-validator validation-server-configs. url: %s, err: %w", c.ValidationServerConfigs[i].URL, err) } serverUrl := c.ValidationServerConfigs[i].URL - if serverUrl != "self" && serverUrl != "self-auth" { + if len(serverUrl) > 0 && serverUrl != "self" && serverUrl != "self-auth" { u, err := url.Parse(serverUrl) if err != nil { return fmt.Errorf("failed parsing validation server's url:%s err: %w", serverUrl, err) From 48810582ff43de8c60e8062b1b2bbd83c86ce187 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 12 Aug 2024 12:41:09 -0600 Subject: [PATCH 6/7] validation_client: only allow skipping stylus for non_existent method --- validator/client/validation_client.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index 3d71e95c64..abd6c87a03 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/rpc" ) type ValidationClient struct { @@ -67,7 +68,13 @@ func (c *ValidationClient) Start(ctx context.Context) error { return errors.New("couldn't read name from server") } var stylusArchs []string - if err := c.client.CallContext(ctx, &stylusArchs, server_api.Namespace+"_stylusArchs"); err == nil { + if err := c.client.CallContext(ctx, &stylusArchs, server_api.Namespace+"_stylusArchs"); err != nil { + rpcError, ok := err.(rpc.Error) + if !ok || rpcError.ErrorCode() != -32601 { + return fmt.Errorf("could not read stylus arch from server: %w", err) + } + stylusArchs = []string{"pre-stylus"} // validation does not support stylus + } else { if len(stylusArchs) == 0 { return fmt.Errorf("could not read stylus archs from validation server") } @@ -76,8 +83,6 @@ func (c *ValidationClient) Start(ctx context.Context) error { return fmt.Errorf("unsupported stylus architecture: %v", stylusArch) } } - } else { - stylusArchs = []string{"pre-stylus"} // validation does not support stylus } var moduleRoots []common.Hash if err := c.client.CallContext(ctx, &moduleRoots, server_api.Namespace+"_wasmModuleRoots"); err != nil { From 44a410798386d277161ff91c9c6ce6e4fe67adba Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 12 Aug 2024 13:20:13 -0600 Subject: [PATCH 7/7] validation client: use errors.As --- validator/client/validation_client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index abd6c87a03..05d947db3d 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -69,7 +69,8 @@ func (c *ValidationClient) Start(ctx context.Context) error { } var stylusArchs []string if err := c.client.CallContext(ctx, &stylusArchs, server_api.Namespace+"_stylusArchs"); err != nil { - rpcError, ok := err.(rpc.Error) + var rpcError rpc.Error + ok := errors.As(err, &rpcError) if !ok || rpcError.ErrorCode() != -32601 { return fmt.Errorf("could not read stylus arch from server: %w", err) }