-
Notifications
You must be signed in to change notification settings - Fork 733
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
Pagination of long transaction list responses #348
Comments
Just here to say i support this idea. I'm currently running into problems because of addresses with thousands of transactions in it. If we had the ability to fetch get_history in pages it would also be easier on mobile wallets during import. |
This needs to be implemented ASAP. Blockchain isn't getting any smaller. |
I highly support this feature. |
I also support the implementation of this feature, |
I've had some thoughts about doing history sensibly. Once I've fleshed them out I'll revisit this. I would want to require the new API for large histories and simply reject any such requests to the old API. |
@erasmospunk @ecdsa @SomberNight @colatkinson @racquemis @joesixpack @AdamSEY @luggs-co Pleaes leave any comments you have on my proposal to solve this, which I have started to implement: http://electrumx.readthedocs.io/en/latest/protocol-changes.html#version-1-5 |
As @bauerj mentioned on slack, using the last confirmed tx hash as I understand the main motivation for changing how status is defined is that it has a linear time complexity (in terms of size of the whole history for the scripthash), and that using the last confirmed tx hash only requires constant time. An alternative construction could be This too would have constant time complexity to update from previous status to new status when a new txn comes. However you would need an extra constant size storage to save the status itself for a scripthash.
|
Even those ideas require a server to read the whole history of any client connecting to it at least once, and as you say maintain a cache. I think the whole approach is suboptimal and unnecessary. Its only redeeming feature is its easier for client devs to work with. I want the client to bear more of the burden of it being SPV. It is going to have to become a bit smarter, but that is putting the burden in the right place - it is the SPV, and so it is responsible for convincing itself it has got the truth. I'd like to see more ideas on improving this client-side without burdening servers with cumbersome protocols. |
No, you can persist it into the DB. You don't need to load the whole history when the client connects. During initial sync, you process the transaction anyway; at that time you can compute the status.
I don't think there is an optimal solution as there are multiple non-independent things to optimise for. |
I think you misunderstood me
I don't want that to be the default behaviour the client requires of any server it connects to just to find out what happened since last week. It should have a confidence level to some height and only be requesting data from that height. It will increase its height of confidence based on results it receives from various sources to various queries, based on a statistical analysis of data it collects. Clients will be motivated to not make expensive requests, because they will become ... expensive. The user will have an option to force-refresh one or more addresses if they "appear wrong". There is a lot of scope client-side for being smart and figuring out strategies in having confidence in served data. Lying isn't easy or free. I have several ideas but I'm sure others can come up with better ones. At present no one is even trying because the status quo is offloading the costs to server operators and it's easy to argue for no change. Also today running a server is fairly inexpensive. I'm planning for data served becoming big, not staying small. It will inevitably become commercial and very likely be costed if used beyond a certain introductory level, because it won't be cheap to maintain indices of everything and serve them for free. |
@kyuupichan @SomberNight what if the status was a hash of the transaction id plus the number of transactions in that address (something like It would still need to read the transaction numbers but it doesn't need to resolve the tx hashes (that would read amplify). Something like this would do the job:
|
@erasmospunk let me think about it. I think my new history DB format that I'm intending to roll out soon actually stores the total TX count in the main history entry of a hashX if the history "overflows" about 10-ish transactions. If so determining length would be a single read, and another single read for the final tx number, and then a filesystem-lookup for the tx_hash. I might consider storing the final tx number in large histories in the main entry too.... |
@SomberNight what do you think of erasmospunk's suggestion? |
@erasmospunk any reason to not simply return a pair: (tx_hash, tx_count)? I'm not sure if the height of the tx is interesting or useful for a client |
@erasmospunk @kyuupichan I think it's a good idea. I would prefer it over the original suggestion, as having the tx count there too would resolve the naive case of lying by omission (regardless of it being intentional or accidental omission). Not sure if the final |
@kyuupichan, but current implementation would not solve initial problem. |
@sergeylappo I don't think it's realistic or practical to care about the case where a single scripthash (not all scripthashes of user!) has more than ~10k transactions in a single block... ScriptPubKeys are not meant to be reused anyway.
Which limit? The per session one? No problem; the client would just reconnect, or connect to a different server and continue syncing there. The client needs to get the same amount of information in the end; there is not much to do about that. |
@SomberNight, |
@sergeylappo @SomberNight was correct. I'm not sure you're understanding the logic. It wouldn't send you more than 1MB of tx hashes and heights at a time, but that's not a problem - if there are more, you just get them on the next request, starting where the previous one left off. You can sync Satoshi Dice's busiest address from scratch. No one block has over 10,000 txs touching 1 address. 10,000 txs fit in a single reply. |
@kyuupichan, yes misunderstood happened on my side. Everything is fine, sorry. |
One thing that came up is a client that does not watch the block headers would lose the ability to detect reorgs where a previous transaction is replaced by a lower value one. |
Yes - but I consider that part of the wallet's job. A wallet will have the state as of a height / block hash. It will need to detect if that block is no longer on the main chain, figure out the reorg height, and remove part of the state accordingly, and then rebuild state from the reorg height. This is not very hard nor resource intensive. It doesn't even require a headers subscription. We should be designing a protocol that puts computation and responsibilities on the right side of the connection; offloading everything to the server is not going to work as users and blockchains grow. |
With the I would suggest the |
A smart client has sufficient information to resolve all races itself. ElectrumX has the same issue with bitcoind and its mempool APIs, and doesn't get confused. My inclination is to put this burden on the client. That said, I'm happy to replace heights with tip hashes in various APIs if you can be more specific and convincing that it would be helpful. |
What is the status of this? https://electrumx.readthedocs.io/en/latest/protocol-methods.html#blockchain-scripthash-history sounds like it should work already but ...
I would really need this to work. :/ |
https://electrumx.readthedocs.io/en/latest/protocol-changes.html#version-1-5
electrumx/electrumx/server/session.py Lines 704 to 705 in 10a0026
|
Thanks for answering but it would be really helpful to know when to expect a fix. I need to tackle this somehow asap and could work on it but I would much rather help on a branch that others are already working on. Where is the magic happening? |
For the record, the "draft of ideas for protocol 1.5" moved to ideas for protocol 2.0. And my question stands: Is anybody working on this? Would it make sense to start implementing this? Doesn't look too complicated but I'm reluctant to maintain my own version of electrumx if upstream is not going to include it before next year or so. |
I don't think anyone is working on this atm. Electrum does not need it. The benefits are nice but marginal when compared to the work needed on both the client and server side to adapt. I think @kyuupichan is planning to do it at some point. |
Protocol will change going forwards |
What does that mean? Is the issue resolved? If it will be resolved going forward, why did you close it already? Where can I help implement and test if the solution works for us? |
ElectrumX is now only for Bitcoin and the protocol will be quite different |
Good night, sweet prince. |
We will maintain a fork of ElectrumX that supports Bitcoin (BTC). Help is welcome. |
Ok, I'm confused, probably because I'm missing some context. @kyuupichan @SomberNight - both referring to "Bitcoin"? Is someone pulling some "Bitcoin Cash is Bitcoin" nonsense? I see the line "For a future network with bigger blocks." in the project readme, so...I'm guessing I need to move over to @SomberNight for continued BTC support, correct? |
indeed, @kyuupichan means "Bitcoin SV" |
To be clear, in other words, it is NOT bitcoin. |
For anyone interested, we have a proposed protocol version 1.5 that includes pagination of long histories at spesmilo/electrumx#90 Feedback welcome there. |
Hello, is there any progress about to include this on protocol 1.5? It's becoming a must have to avoid utxo/history access lost. |
@mkpuig this project was moved to https://github.com/spesmilo/electrumx |
what would be wrong with instructing it to break it down into managable bytes and reassembly post receipt but prior to the release? |
Currently, if the server generates an extremely long response, it simply returns an error message, such as
If the client receives this message, it will just hang indefinitely while attempting to sync.
Proposed Solution
Implement pagination in relevant methods, using block heights as a range. This has a couple advantages:
last height - n
wheren
is e.g. 6Affected RPC Methods
blockchain.address.get_history
blockchain.address.get_mempool
blockchain.address.listunspent
blockchain.scripthash.get_history
blockchain.scripthash.listunspent
It seems to me like the simplest solution would be to bump the protocol version number, and add optional pagination parameters to each of these methods. The version bump would allow clients to detect support for this, and thus be able to opt to get only the new txs during sync.
The text was updated successfully, but these errors were encountered: