Skip to content

feat: implement handling of RPC methods that magic router uses #658

@jonasXchen

Description

@jonasXchen

The current ephemeral-rollups-sdk and ephemeral-rollups-kit (https://github.com/magicblock-labs/ephemeral-rollups-sdk) implements a class Connection to interact with the magic router. However, the same class cannot be re-used with a validator endpoint, since the validator does not implement custom magic router method handling which are required. Currently, the validator will return errors in response to custom magic router methods.

import { Connection } from "@magicblock-labs/ephemeral-rollups-kit";

// Initialize connection
const connection = await Connection.create(
  "https://devnet-router.magicblock.app",
  "wss://devnet-router.magicblock.app"
);

// ... create transaction

// Send and confirm transaction
const txHash = await connection.sendAndConfirmTransaction(
  transactionMessage,
  [userKeypair],
  { commitment: "confirmed", skipPreflight: true }
);
import { sendAndConfirmTransaction } from "@solana/web3.js";
import { ConnectionMagicRouter } from "@magicblock-labs/ephemeral-rollups-sdk";

// Initialize connection
const connection = new ConnectionMagicRouter(
  "https://devnet-router.magicblock.app/",
  { wsEndpoint: "wss://devnet-router.magicblock.app/" }
);

// ... create transaction

// Send and confirm transaction
const txHash = await sendAndConfirmTransaction(connection, tx, [payer], {
  skipPreflight: true,
  commitment: "confirmed",
});

Preferably, the same code with validator endpoint works too, so that developers can switch between router and validator connection without significant code changes. This requires the validator to support the custom RPC methods used by the router:

  • getRoutes - a custom method to query all the ER nodes known to the router
  • getBlockhashForAccounts - another custom method to query the blockhash for the provided list of accounts. The list of accounts is usually delegated writeable accounts from the transaction that needs to be signed. If the accounts are delegated to different ER nodes, the method will return an error. If the accounts are not delegated the returned blockhash is from the base chain.
  • getDelegationStatus - custom method which retrieves the delegation status of the account along with the parsed delegation record (if applicable)

Could the validator implement the handling of these custom magic router methods? @bmuddha

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions