Skip to content

Commit

Permalink
Merge branch 'master' into fix-arbitrator-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower authored Aug 13, 2024
2 parents 27332b2 + c4c2489 commit f48f69b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
3 changes: 3 additions & 0 deletions cmd/nitro-val/nitro_val.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"math"
_ "net/http/pprof" // #nosec G108
"os"
"os/signal"
Expand Down Expand Up @@ -66,6 +67,8 @@ func mainImpl() int {
}
stackConf := DefaultValidationNodeStackConfig
stackConf.DataDir = "" // ephemeral
stackConf.HTTPBodyLimit = math.MaxInt
stackConf.WSReadLimit = math.MaxInt64
nodeConfig.HTTP.Apply(&stackConf)
nodeConfig.WS.Apply(&stackConf)
nodeConfig.Auth.Apply(&stackConf)
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
2 changes: 1 addition & 1 deletion scripts/split-val-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]' "$@"
11 changes: 11 additions & 0 deletions staker/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/url"
"regexp"
"runtime"
"sync"
Expand Down Expand Up @@ -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 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)
}
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
}
Expand Down
8 changes: 1 addition & 7 deletions staker/stateless_block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"errors"
"fmt"
"net/url"
"runtime"
"testing"

Expand Down Expand Up @@ -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
}
}
Expand Down
23 changes: 15 additions & 8 deletions validator/client/validation_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -68,14 +69,20 @@ func (c *ValidationClient) Start(ctx context.Context) error {
}
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)
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)
}
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")
}
for _, stylusArch := range stylusArchs {
if stylusArch != "wavm" && stylusArch != runtime.GOARCH && stylusArch != "mock" {
return fmt.Errorf("unsupported stylus architecture: %v", stylusArch)
}
}
}
var moduleRoots []common.Hash
Expand Down
3 changes: 0 additions & 3 deletions validator/server_jit/machine_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit f48f69b

Please sign in to comment.