-
Notifications
You must be signed in to change notification settings - Fork 76
Fallback to getblock when getrawtransaction fails on Genesis TX #119
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
base: mempool
Are you sure you want to change the base?
Conversation
|
Fixes the issue described, but I will let other electrs champions actually review the PR. electrsmempool backend |
|
How about when using dark mode |
get out |
|
Approach Nack, (Too magical) I am not in favor of this solution because at the end of the day this only solves for a single network Mainnet. For an application that supports various networks, Signet, Testnet, etc ... This would lead to inconsistent behavior across use cases. |
|
why don't we fetch the whole genesis block, extract the coinbase transaction, and then cache it somewhere? |
|
|
Just don't use light mode and this isn't an issue |
d849d02 to
523268e
Compare
portlandhodl
left a comment
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.
I am not in a position to approve or reject anything with that said here are my thoughts.
On the level of the bigger picture. My preference is not to overload the underlying forwarding calls to Bitcoin Core instead wrapping or defining a new fn()/trait with the overloaded functionality. I don't maintain anything here so it's just my opinion.
| #[cfg(not(feature = "liquid"))] | ||
| Err(e) | ||
| if e.to_string().contains( | ||
| "genesis block coinbase is not considered an ordinary transaction", |
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.
Common issue with Bitcoin Core is that errors are not enumerated, the error number value is considered more stable.
|
|
||
| // Assert that there's only 1 tx, the previous block hash is all zeroes, and not using verbose | ||
| if verbose | ||
| || block.txdata.len() != 1 |
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.
Nit: Genesis blocks currently always have 1 TXN, but might not in the future + peoples own Regtest instances. A greater than 0 check would be better and still gives you safe access to [] accessor.
Edit: Because of the way the merkleroot in the header works, There isn't a need to put gaurdrails around accessing element 0 because at minimum a block will always have a single transaction in your array.
| // Assert that there's only 1 tx, the previous block hash is all zeroes, and not using verbose | ||
| if verbose | ||
| || block.txdata.len() != 1 | ||
| || block.header.prev_blockhash != BlockHash::default() |
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.
Nit: Not needed if you already have genesis TXN which is always a block at height 0, so previous hash is always 0...0
In light mode, the block summary /txs for genesis block is borked thanks to RPC error.