-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enhance P2P sync testing infrastructure
This PR introduces significant improvements to the P2P sync testing framework: Core Changes: - Add test reporting functionality with a new dashboard integration - Implement node type detection (Juno/Pathfinder) with version reporting - Add `--disable-l1-verification` flag to Juno configuration Test Infrastructure: - Separate source and target node configurations in sync tests - Add proper RPC port management for all sync test scenarios - Enable Pathfinder from Juno sync test in CI workflow - Remove unused devnet network test New Features: - Add progress reporting with detailed metrics - Implement test status tracking (In Progress/Passed/Failed) - Add error handling and reporting capabilities - Track average block processing time
- Loading branch information
1 parent
1e09ec0
commit 2373758
Showing
13 changed files
with
262 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const SYNC_CONFIG = { | ||
CHECK_INTERVAL: 10_000, // 10 seconds | ||
STALL_TIMEOUT: 5, // 1 minute | ||
NODE_READY_ATTEMPTS: 5, | ||
NODE_READY_INTERVAL: 5_000, | ||
}; | ||
|
||
export const REPORTING_CONFIG = { | ||
enabled: true, | ||
endpoint: 'https://starknet-p2p-testing-dashboard.onrender.com/update', | ||
testId: Date.now().toString(), | ||
}; | ||
|
||
export const NODE_TYPES = { | ||
JUNO: 'Juno', | ||
PATHFINDER: 'Pathfinder', | ||
UNKNOWN: 'Unknown' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import fetch from 'node-fetch'; | ||
import { NODE_TYPES } from './config.mjs'; | ||
|
||
export class NodeDetector { | ||
static async detect(url) { | ||
const junoVersion = await this._detectJuno(url); | ||
if (junoVersion) { | ||
return { type: NODE_TYPES.JUNO, version: junoVersion }; | ||
} | ||
|
||
const pathfinderVersion = await this._detectPathfinder(url); | ||
if (pathfinderVersion) { | ||
return { type: NODE_TYPES.PATHFINDER, version: pathfinderVersion }; | ||
} | ||
|
||
return { type: NODE_TYPES.UNKNOWN, version: 'Unknown' }; | ||
} | ||
|
||
static async _detectJuno(url) { | ||
try { | ||
const response = await fetch(url, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ | ||
method: "juno_version", | ||
jsonrpc: "2.0", | ||
id: 0 | ||
}) | ||
}); | ||
|
||
const data = await response.json(); | ||
return data.result || null; | ||
} catch { | ||
return null; | ||
} | ||
} | ||
|
||
static async _detectPathfinder(url) { | ||
try { | ||
const response = await fetch(`${url}/rpc/pathfinder/v0_1`, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ | ||
method: "pathfinder_version", | ||
jsonrpc: "2.0", | ||
id: 0 | ||
}) | ||
}); | ||
|
||
const data = await response.json(); | ||
return data.result || null; | ||
} catch { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import fetch from 'node-fetch'; | ||
import { REPORTING_CONFIG } from './config.mjs'; | ||
|
||
export class TestReporter { | ||
constructor(sourceNode, targetNode, targetBlockNumber) { | ||
this.config = { | ||
...REPORTING_CONFIG, | ||
sourceNode, | ||
targetNode, | ||
targetBlockNumber | ||
}; | ||
} | ||
|
||
async reportProgress(blockNumber, startTime, errors = []) { | ||
if (!this.config.enabled) return; | ||
|
||
try { | ||
const payload = { | ||
type: "updateTest", | ||
data: { | ||
id: this.config.testId, | ||
sourceNode: this.config.sourceNode.type, | ||
sourceVersion: this.config.sourceNode.version, | ||
targetNode: this.config.targetNode.type, | ||
targetVersion: this.config.targetNode.version, | ||
status: this._getStatus(blockNumber, errors), | ||
startTime: new Date(startTime).toISOString(), | ||
blocksProcessed: blockNumber, | ||
totalBlocks: this.config.targetBlockNumber, | ||
avgBlockTime: this._calculateAvgBlockTime(blockNumber, startTime), | ||
errors | ||
} | ||
}; | ||
|
||
const response = await fetch(this.config.endpoint, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify(payload) | ||
}); | ||
|
||
return response.status; | ||
} catch (error) { | ||
console.warn(`Warning: Failed to report progress: ${error.message}`); | ||
return null; | ||
} | ||
} | ||
|
||
_getStatus(blockNumber, errors) { | ||
if (errors.length > 0) return "Failed"; | ||
if (blockNumber >= this.config.targetBlockNumber) return "Passed"; | ||
return "In Progress"; | ||
} | ||
|
||
_calculateAvgBlockTime(blockNumber, startTime) { | ||
if (blockNumber <= 0) return "0.000"; | ||
return ((Date.now() - startTime) / blockNumber / 1000).toFixed(3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.