-
Notifications
You must be signed in to change notification settings - Fork 295
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
feat: Create standalone instances of Aztec Node and RPC Server #2486
Closed
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9b02d53
WIP
PhilWindle 5798a4a
WIP
PhilWindle 2107fb6
Merge branch 'master' into pw/devnet
PhilWindle bb04391
WIP
PhilWindle 61594a1
Merge branch 'master' into pw/devnet
PhilWindle ed810e7
Fix
PhilWindle 5e6e8b2
Merge fixes
PhilWindle 3b9e08e
Fixes
PhilWindle 4518654
Fix
PhilWindle 1343d91
fix
PhilWindle f2821aa
Update version
PhilWindle 0223f16
yarn lock
PhilWindle a11de0f
Fix
PhilWindle 395f24e
WIP
PhilWindle 6dfee39
Fix
PhilWindle 7fbc059
Fix
PhilWindle 51ab998
Serialise node info
PhilWindle 236634e
Fixes
PhilWindle ec7ef72
Fixes
PhilWindle f65c0fa
WIP
PhilWindle f98b077
Merge branch 'master' into pw/devnet
PhilWindle 657b780
WIP
PhilWindle ee9f7d2
Merge branch 'master' into pw/devnet
PhilWindle c9f7c27
Remove old terraform
PhilWindle 5c7336f
WIP
PhilWindle 471159b
Cleanup
PhilWindle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ node_modules | |
build/ | ||
.idea | ||
cmake-build-debug | ||
.bootstrapped | ||
.terraform | ||
.bootstrapped |
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
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,68 @@ | ||
#!/usr/bin/env -S node --no-warnings | ||
import { createDebugLogger } from '@aztec/foundation/log'; | ||
import { createAztecNodeRpcServer } from '@aztec/types'; | ||
|
||
import http from 'http'; | ||
import Koa from 'koa'; | ||
import Router from 'koa-router'; | ||
|
||
import { AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '../index.js'; | ||
|
||
const { SERVER_PORT = 8081, API_PREFIX = '' } = process.env; | ||
|
||
const logger = createDebugLogger('aztec:node'); | ||
|
||
/** | ||
* Creates the node from provided config | ||
*/ | ||
async function createAndDeployAztecNode() { | ||
const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars() }; | ||
|
||
return await AztecNodeService.createAndSync(aztecNodeConfig); | ||
} | ||
|
||
/** | ||
* Creates a router for helper API endpoints of the Aztec RPC Server. | ||
* @param apiPrefix - The prefix to use for all api requests | ||
* @returns - The router for handling status requests. | ||
*/ | ||
export function createStatusRouter(apiPrefix: string) { | ||
const router = new Router({ prefix: `${apiPrefix}` }); | ||
router.get('/status', (ctx: Koa.Context) => { | ||
ctx.status = 200; | ||
}); | ||
return router; | ||
} | ||
|
||
/** | ||
* Create and start a new Aztec Node HTTP Server | ||
*/ | ||
async function main() { | ||
logger.info(`Setting up Aztec Node...`); | ||
|
||
const aztecNode = await createAndDeployAztecNode(); | ||
|
||
const shutdown = async () => { | ||
logger.info('Shutting down...'); | ||
await aztecNode.stop(); | ||
process.exit(0); | ||
}; | ||
|
||
process.once('SIGINT', shutdown); | ||
process.once('SIGTERM', shutdown); | ||
|
||
const rpcServer = createAztecNodeRpcServer(aztecNode); | ||
const app = rpcServer.getApp(API_PREFIX); | ||
const apiRouter = createStatusRouter(API_PREFIX); | ||
app.use(apiRouter.routes()); | ||
app.use(apiRouter.allowedMethods()); | ||
|
||
const httpServer = http.createServer(app.callback()); | ||
httpServer.listen(+SERVER_PORT); | ||
logger.info(`Aztec Node JSON-RPC Server listening on port ${SERVER_PORT}`); | ||
} | ||
|
||
main().catch(err => { | ||
logger.error(err); | ||
process.exit(1); | ||
}); |
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 |
---|---|---|
@@ -1,4 +1,2 @@ | ||
export * from './aztec-node/config.js'; | ||
export * from './aztec-node/server.js'; | ||
export * from './rpc/http_rpc_server.js'; | ||
export * from './rpc/http_rpc_client.js'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have been using entrypoint pretty liberally, but I'd push for having just
yarn
asentrypoint
, andstart
as itscommand
. Not really important though unless we try to make this consistent across the board.