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

transactions() on beta 5 has some issues with cursors. #1825

Open
andy-thomason opened this issue Apr 12, 2024 · 4 comments
Open

transactions() on beta 5 has some issues with cursors. #1825

andy-thomason opened this issue Apr 12, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@andy-thomason
Copy link

Hi Everyone. I'm enjoying exploring the codebase and doing some experiments with the public beta 5 endpoint.

I don't have a particular template to work from, so I'm making some assumptions here:

Given

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = FuelClient::new("https://beta-5.fuel.network/graphql")?;

    get_transactions(&client, 0).await?;

    Ok(())
}

async fn get_transactions(client: &FuelClient, start_block: u32) -> anyhow::Result<()> {
    use fuel_core_client::client::types::primitives::TransactionId;
    let tx = TransactionId::zeroed();
    let mut cursor = (start_block != 0).then_some(format!("{start_block}#0x{tx}"));
    let results = 10;
    for _ in 0.. {
        let req = PaginationRequest {cursor, results, direction: PageDirection::Forward };
        let txs = client.transactions(req).await?;

        cursor = txs.cursor;

        for tx in txs.results {
            println!("{tx:#?}");
        }
    }
    Ok(())
}

Two things go wrong.

  1. If we initialise with a cursor with a form of block#0x0000...0000 then the endpoint hangs.
  2. If we initialise with a cursor of None, the next cursor has the block number formatted in hex
    such as Some("0000000a#0x49c6fee039066353084bdf8585930bba4cd9e89433c2abce3f8c7c35c9b8ac4e")
    which fails because the endpoint expects a decimal number.

Am I being an idiot, or should these two expectations be met?

@andy-thomason
Copy link
Author

I'm using the release/v0.22.1 fuel-core.

@Voxelot
Copy link
Member

Voxelot commented Apr 12, 2024

Nice finds! These are real bugs, the SortedTxCursor decodes block height using u32::from_str(block_height) but the display impl for BlockHeight does indeed use <Self as fmt::LowerHex>::fmt(&self, f).

BlockHeight used to be a type-alias for u32, and this bug must've slipped in when we migrated to using a dedicated newtype for BlockHeight.

Oddly, this should've been covered by the tests::tx::get_transactions() integration test so we need to do some investigation into why this test is passing.

@Voxelot Voxelot added the bug Something isn't working label Apr 12, 2024
@hummusonrails
Copy link

Hi @andy-thomason 👋,

Thank you for taking the initiative to open this bug report in fuel-core! You taking the time to report back on the bugs you found shows a lot about your commitment to open source and your contribution is highly valued! 🌟

Given your interest and expertise, we believe you would be an excellent candidate for the Fuel Developer Champions program. It's a fantastic opportunity to collaborate more closely with our team, deepen your engagement, get access to bounty programs for members of the program, champions swag, and more initiatives are in the works as the program continues to evolve. 🚀

Please consider joining us by checking out the start-here repo for the program.

Looking forward to welcoming you into the program!

Ben

@andy-thomason
Copy link
Author

Thanks for the encouragement, Ben.

I'll check with our team at Superchain Network about the programme.

It is good to see new projects in this space and it is all great food for our cross chain
indexer investigations.

We are setting up a node on our network to do more tests and I'm just building out
a proof-of-concept for a block sucker and log scraper - stage one on our journey.

Andy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants