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

relayer: method to check that write tx confirmed #9

Closed
wants to merge 1 commit into from
Closed

Conversation

tuxcanfly
Copy link
Collaborator

This PR adds a new method relayer.Check which takes a write transaction hash and returns the height at which the transaction was included in a block.

This is useful because we want to be able to pass the block height to Read and this fixes a hack which was in place in the tests.

@tuxcanfly
Copy link
Collaborator Author

tuxcanfly commented Mar 2, 2023

In this PR we have added func Check(hash *chainhash.Hash) (int64, error) which returns the height at which the bitcoin transaction was mined. But we also need another index to track the data that we wrote, because there might more than one Write([]byte) that happened, probably from other callers.

This is why I had to re-order the tests because they'd fail with two rollkit-btc: gm messages rather than one, the reason being that the first Write is called from ExampleRelayer_Write(), and for testing the most recent write, we're calling Write again in ExampleRelayer_Read(). Even now if the test is ran twice in quick succession it can fail because the last block might contain a Write transaction from the previous test. 😢

The question is what should the second index be, should it just be the index of our transaction in the block? But that doesn't help much because Read() returns an array of data blobs, in order, as it reads all the transactions in the block. How would we know from the transaction index, which index of the blobs is ours? We'd need to scan the block for data to make that map.

For now though, Read() works because rollkit's da.RetreiveBlocks expects just that i.e all the blobs that were posted.

Ideally I think we'd have a map of map[txhash] -> blob and read back the exact data we posted, by getting the blob by our tx hash.

@tuxcanfly
Copy link
Collaborator Author

For reference, I think ordinals uses satid for this which is sort of like tx output i.e. transaction hash + output index.

@tuxcanfly
Copy link
Collaborator Author

Closing in favor of #33 where this can be reused.

@tuxcanfly tuxcanfly closed this Sep 18, 2024
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

Successfully merging this pull request may close these issues.

1 participant