Skip to content
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

the data is not flowing when the filter applied to an account #535

Open
oksuz opened this issue Feb 8, 2025 · 2 comments
Open

the data is not flowing when the filter applied to an account #535

oksuz opened this issue Feb 8, 2025 · 2 comments

Comments

@oksuz
Copy link

oksuz commented Feb 8, 2025

Hi,

I am currently listening new markets on raydium with the following rpc/ws subscription:

  conn.onProgramAccountChange(raydium.MAINNET_PROGRAM_ID.OPENBOOK_MARKET, handler, conn.commitment, [
    {
      dataSize: raydium.MARKET_STATE_LAYOUT_V3.span,
    },
    {
      memcmp: {
        offset: raydium.MARKET_STATE_LAYOUT_V3.offsetOf('baseMint'),
        bytes: splToken.NATIVE_MINT.toBase58(),
      },
    },
  ]);

I applied same filter to my geyser subscription and monitored both. when the new market is created or the market account is updated, the data comes from rpc's websocket yet doesn't come from geyser grpc:

here is the my subscription:

  const accountFilter: SubscribeRequestFilterAccountsFilter[] = [];

  accountFilter.push({
    datasize: String(raydium.MARKET_STATE_LAYOUT_V3.span),
  });

  accountFilter.push({
    memcmp: {
      offset: String(raydium.MARKET_STATE_LAYOUT_V3.offsetOf('baseMint')),
      base58: splToken.NATIVE_MINT.toBase58(),
    },
  });

  const cmd: SubscribeRequest = {
    slots: {},
    accounts: {
      client: {
        account: [raydium.MAINNET_PROGRAM_ID.OPENBOOK_MARKET.toBase58()],
        owner: [],
        filters: accountFilter,
      },
    },
    transactions: {},
    blocks: {},
    blocksMeta: {},
    entry: {},
    transactionsStatus: {},
    accountsDataSlice: [],
    commitment: CommitmentLevel.CONFIRMED,
  };

am I missing something ?

@oksuz oksuz changed the title even though applied the filter, the data is not flowing for an account update the data is not flowing when the filter applied to an account Feb 8, 2025
@fanatid
Copy link
Collaborator

fanatid commented Feb 10, 2025

  accountFilter.push({
    datasize: String(raydium.MARKET_STATE_LAYOUT_V3.span),
  });

^ I think should be dataSize not datasize

@oksuz
Copy link
Author

oksuz commented Feb 11, 2025

@fanatid it is defined as datasize at the definition file so it didn't let me set as dataSize. I've ignored it with // @ts-ignore and set dataSize but it threw exception without a message . Anyways I've removed this dataSize filter and left the memcmp filter as is

  accountFilter.push({
    memcmp: {
      offset: String(raydium.MARKET_STATE_LAYOUT_V3.offsetOf('baseMint')),
      base58: splToken.NATIVE_MINT.toBase58(),
    },
  });

still didn't get any data.

you can try the following example. it'll apply the same filter both geyser grpc and rpc-websocket

  const openBookMarket = new PublicKey('srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX');
  const nativeMint = new PublicKey('So11111111111111111111111111111111111111112');

 solanaConnection.onProgramAccountChange(
    openBookMarket,
    (accountInfo) => {
      console.log(`account info from ws:`, accountInfo);
    },
    'confirmed',
    [
      {
        memcmp: {
          offset: 85,
          bytes: nativeMint.toBase58(),
        },
      },
    ],
  );

  const accountFilter: SubscribeRequestFilterAccountsFilter[] = [];

  accountFilter.push({
    memcmp: {
      offset: '85',
      base58: nativeMint.toBase58(),
    },
  });

  const cmd: SubscribeRequest = {
    slots: {},
    accounts: {
      client: {
        account: [openBookMarket.toBase58()],
        owner: [],
        filters: accountFilter,
      },
    },
    transactions: {},
    blocks: {},
    blocksMeta: {},
    entry: {},
    transactionsStatus: {},
    accountsDataSlice: [],
    commitment: CommitmentLevel.CONFIRMED,
  };

  return new Promise((resolve, reject) => {
    client.on('data', (data) => {
      console.log(`account info from geyser:`, data);
    });

    client.write(cmd, (err) => {
      console.log(err);
    });

    client.on('error', () => {
      reject();
    });

    client.on('end', () => {
      resolve(true);
    });
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants