8000 nethermind perf tests by pk910 · Pull Request #86 · ethpandaops/spamoor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

nethermind perf tests #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions scenarios/taskrunner/config_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,16 @@ func extractContractReferences(task Task) []string {
return refs
}

// extractContractRef extracts contract name from a reference string like {contract:name}
// extractContractRef extracts contract name from a reference string like {contract:name} or {contract:name:nonce}
func extractContractRef(str string) string {
if strings.HasPrefix(str, "{contract:") && strings.HasSuffix(str, "}") {
return str[10 : len(str)-1]
content := str[10 : len(str)-1]
// Handle both {contract:name} and {contract:name:nonce} formats
// Split by colon and take the first part as the contract name
parts := strings.Split(content, ":")
if len(parts) >= 1 {
return parts[0]
}
}
return ""
}
Expand Down
92 changes: 65 additions & 27 deletions scenarios/taskrunner/placeholders.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@ import (
// If stripPrefix is true, removes the 0x prefix from addresses (for use in bytecode/calldata)
func ProcessContractPlaceholders(str string, registry *ContractRegistry, stripPrefix bool) (string, error) {
contractRegex := regexp.MustCompile(`\{contract:([^}:]+)(?::(\d+))?\}`)
contractMatches := contractRegex.FindAllStringSubmatch(str, -1)

processed := str
for _, match := range contractMatches {
if len(match) < 2 {
continue
// Use ReplaceAllStringFunc to replace each match as we find it
processed := contractRegex.ReplaceAllStringFunc(str, func(match string) string {
// Re-parse the match to extract parts
submatch := contractRegex.FindStringSubmatch(match)
if len(submatch) < 2 {
return match // Return original if parsing fails
}
contractName := match[1]

contractName := submatch[1]
contractAddr, exists := registry.Get(contractName)
if !exists {
return "", fmt.Errorf("contract '%s' not found in registry", contractName)
// Return original match - this will cause an error to be returned later
return match
}

var addressStr string
// Check if child address calculation is requested
if len(match) > 2 && match[2] != "" {
if len(submatch) > 2 && submatch[2] != "" {
// Parse nonce for child address calculation
nonce, err := strconv.ParseUint(match[2], 10, 64)
nonce, err := strconv.ParseUint(submatch[2], 10, 64)
if err != nil {
return "", fmt.Errorf("invalid nonce value for contract '%s': %s", contractName, match[2])
// Return original match - this will cause an error to be returned later
return match
}
// Calculate child contract address
childAddr := crypto.CreateAddress(contractAddr, nonce)
Expand All @@ -50,7 +54,28 @@ func ProcessContractPlaceholders(str string, registry *ContractRegistry, stripPr
addressStr = addressStr[2:]
}

processed = strings.Replace(processed, match[0], addressStr, 1)
return addressStr
})

// Check if any placeholders were left unreplaced (indicating errors)
if contractRegex.MatchString(processed) {
// Find the first unresolved placeholder to report error
matches := contractRegex.FindAllStringSubmatch(processed, -1)
for _, match := range matches {
if len(match) >= 2 {
contractName := match[1]
if _, exists := registry.Get(contractName); !exists {
return "", fmt.Errorf("contract '%s' not found in registry", contractName)
}
// If contract exists but placeholder is still there, it's a nonce parsing error
if len(match) > 2 && match[2] != "" {
if _, err := strconv.ParseUint(match[2], 10, 64); err != nil {
return "", fmt.Errorf("invalid nonce value for contract '%s': %s", contractName, match[2])
}
}
}
}
return "", fmt.Errorf("failed to process some contract placeholders")
}

return processed, nil
Expand All @@ -69,45 +94,58 @@ func ProcessBasicPlaceholders(str string, txIdx uint64, stepIdx int, stripPrefix

// Replace {random} with random uint256
randomRegex := regexp.MustCompile(`\{random\}`)
for randomRegex.MatchString(processed) {
processed = randomRegex.ReplaceAllStringFunc(processed, func(match string) string {
randomVal, err := generateRandomUint256()
if err != nil {
return "", fmt.Errorf("failed to generate random value: %w", err)
return match // Will cause error to be returned later
}
processed = randomRegex.ReplaceAllString(processed, randomVal)
}
return randomVal
})

// Replace {random:N} with random number between 0 and N
randomRangeRegex := regexp.MustCompile(`\{random:(\d+)\}`)
matches := randomRangeRegex.FindAllStringSubmatch(processed, -1)
for _, match := range matches {
if len(match) != 2 {
continue
processed = randomRangeRegex.ReplaceAllStringFunc(processed, func(match string) string {
submatch := randomRangeRegex.FindStringSubmatch(match)
if len(submatch) != 2 {
return match
}
maxVal, err := strconv.ParseUint(match[1], 10, 64)
maxVal, err := strconv.ParseUint(submatch[1], 10, 64)
if err != nil {
return "", fmt.Errorf("invalid random range: %s", match[1])
return match // Will cause error to be returned later
}
randomVal, err := generateRandomInRange(maxVal)
if err != nil {
return "", fmt.Errorf("failed to generate random value in range: %w", err)
return match // Will cause error to be returned later
}
return fmt.Sprintf("%d", randomVal)
})

// Check for any unresolved {random:N} placeholders (indicating errors)
if randomRangeRegex.MatchString(processed) {
matches := randomRangeRegex.FindAllStringSubmatch(processed, -1)
for _, match := range matches {
if len(match) == 2 {
if _, err := strconv.ParseUint(match[1], 10, 64); err != nil {
return "", fmt.Errorf("invalid random range: %s", match[1])
}
}
}
processed = strings.Replace(processed, match[0], fmt.Sprintf("%d", randomVal), 1)
return "", fmt.Errorf("failed to process some random range placeholders")
}

// Replace {randomaddr} with random address
randomAddrRegex := regexp.MustCompile(`\{randomaddr\}`)
for randomAddrRegex.MatchString(processed) {
processed = randomAddrRegex.ReplaceAllStringFunc(processed, func(match string) string {
randomAddr, err := generateRandomAddress()
if err != nil {
return "", fmt.Errorf("failed to generate random address: %w", err)
return match // Will cause error to be returned later
}
// Strip 0x prefix if requested (for bytecode/calldata usage)
if stripPrefix && strings.HasPrefix(randomAddr, "0x") {
randomAddr = randomAddr[2:]
}
processed = randomAddrRegex.ReplaceAllString(processed, randomAddr)
}
return randomAddr
})

return processed, nil
}
Expand Down
Loading
0