< veleiro>
found the problem. couldnt get the depends build to work, but i removed /usr/local/lib/libboost* and /usr/local/include/boost* and reinstalled libboost-all-dev. thanks for the advice sipa
< cfields>
jeremyrubin: started reviewing your checkqueue, but the emplacer distracted me. Will pick up where I left off tomorrow.
< wumpus>
let's try to make cfields network refactor (https://github.com/bitcoin/bitcoin/pull/8085/files) happen , it's been open so long now, line-wise there's a lot of changes so he keeps having to rebase it
< wumpus>
/home/user/projects/bitcoin/bitcoin/src/test/addrman_tests.cpp:336:471: warning: stack frame size of 328360 bytes in function 'addrman_tests::addrman_delete::test_method' [-Wframe-larger-than=] whoa :) luckily only in the tests
< sipa>
what is a reasonable max frame size?
< wumpus>
largest in the normal core code is a stack frame size of 67256 bytes in function 'ThreadSocketHandler', which is peculiar but not that bad
< wumpus>
64k or so for non-recursive code? most is far below that, even <10kB
< wumpus>
whopping 'warning: stack frame size of 984520 bytes in function 'net_tests::caddrdb_read::test_method'
< sipa>
8654 introduces a 9 kB struct in CTransactionSignatureChecker
< wumpus>
peanuts
< sipa>
984kB sounds like mild overkill, indeex
< sipa>
indeed
< sipa>
also, agree on making the net refactor happen
< jonasschnelli>
Yes. Net factor should happen... I have the PR running since a couple of days...
< sipa>
cfields: nice work with the network refactor, and sorry for not having the courage earlier to read through 34 commits (it wasn't all that bad)
< * sipa>
is slightly annoyed with the introduction of many 'for('s and 'if('s, but seems we're not consistent about that already anyway
< cfields>
sipa: thanks. np about review. I haven't been pushy about it because it's pretty rough to get through. The next round should be much easier since after this PR it's mostly self-contained
< cfields>
and yes, sorry about the fors and ifs. I know that one bugs you. That's a habit that I can't seem to get out of
< sipa>
i realize it's just preference, and i'm sure the existing spaces bother you too :p
< cfields>
mm, I should get vim to fix that for me
< cfields>
not at all, they're only reminders that i forgot to space my changes around it (while re-reading post-commit, of course)
< jeremyrubin>
cfields: be sure to look on the latest; I fixed it i beleive
< jeremyrubin>
cfields: yeah you weren't looking at the one i sent you yest
< cfields>
morcos: aha, probably so
< morcos>
cfields: i wonder if we need to think a bit more carefully about that pull. is there anything other than the RPC tests that might be depending on wallets being synced onces cs_main is released
< morcos>
for instance you could imagine someone using bitcoin core has come to depend on that behavior
< morcos>
not saying it shouldn't eventually be changed, but seems like something that requires a bit more thought
< cfields>
morcos: think more about 7946, you mean?
< morcos>
yeah
< jeremyrubin>
cfields: oops I'm wrong you were sorry -- i need to fix my github notifs they suck
< sipa>
morcos: 8660? sure you have the right number?
< morcos>
what the RPC tests are uncovering is that the wallet can now be out of sync with the blockchain.
< cfields>
morcos: now that you mention it, i wonder if blocknotify is affected
< jeremyrubin>
sipa: morcos is referring to the already merged one
< morcos>
yeoops 8680
< jeremyrubin>
oops nvm
< cfields>
ok nm, blocknotify uses the same signal, so the wallet would already be synced there
< sipa>
cfields: for 8680, isn't it possible to use ping/waitforpong instead?
< morcos>
sipa: the issues isn't fixing it for the RPC tests
< morcos>
the issue is whether there are things other than the rpc tests that were relying on wallet always being synced with blockchain once cs_main was released
< cfields>
sipa: isn't that just punting the problem to "now we assume we're all synced" at a different point?
< morcos>
also ping/waitforpong would happen to work i think with the current architecture, but not necessarily in the future right..
< sipa>
morcos: i don't think we can get rid of the synchronizing behaviour of ping/pong without breaking half the network software
< morcos>
sipa: there is a difference between it always synchronizing network behavior and synchronizing other thigns right? it just happens that the processing of messages happens in the same thread as the wallet syncing code now
< morcos>
so you couldn't get to the pong until you'd synced the wallets, but that doesn't seem like something that would necessarily always be true
< sipa>
morcos: i see
< sipa>
yes, i think we should prepare for a case where wallet syncing happens entirely in the background
< sipa>
and can lag behind more than one block
< sipa>
and network synchronizing messages don't change that
< cfields>
i suppose that's why sdaftuar was thinking more in terms of wait_for_wallet()
< morcos>
sipa: agreed. and i think #7946 has forced that issue to be we have to think about that for 0.13. b/c as far as RPC is concerned the wallet syncing can be happening several blocks behind now.
< morcos>
sorry, for master, not 0.13. i'm still behind. :)
< BlueMatt>
so what probably should happen, to avoid changing the api, is that any time you call into wallet it blocks until it has a consistent state with current blockchain
< cfields>
in the event that we start moving towards more async behavior, i think it's only natural to start introducing blocking rpcs
< BlueMatt>
otherwise you get an inconsistent rpc api - getblockheight will tell you something and then wallet will be behind that
< BlueMatt>
which is a hugely surprising api change
< cfields>
heh
< morcos>
cfields: i thought you just typed super fast
< BlueMatt>
moving wallet sync out of main thread is an important goal - and unlocking cs_main for it is a first step
< BlueMatt>
but an api change like that is probaly just not ok
< sipa>
that does make sense
< sipa>
just have the wallet rcps wait for sync
< morcos>
but what exactly should they wait for
< BlueMatt>
being up-to-date with the chain state at the call entry
< morcos>
as you're catching up the blockheight could still be increasing i think
< BlueMatt>
or, maybe, lock cs_main...
< cfields>
morcos: you'd need to pass in the synced-to-x height to the wallet rpc :(
< morcos>
i guess what i just described is an existing problem, so maybe thats ok, b/c cs_main is released anyway
< BlueMatt>
i mean, ok, what makes the rpc consistent? if the rpc request blocks, then its not crazy to make the state returned consistent with where the chainstate was when you entered the rpc, because otherwise the client is multithreaded and thats gonna be broken no matter what we do
< cfields>
morcos: but, if you've specifically waited for a certain height/hash, and it's blocked/returned until that's hit, then you're at least synced to that height for the next call
< cfields>
(ignoring invalidate/reconsider, which ruin all of that)
< morcos>
cfields: yes. agreed. i think we should fix it that much.
< cfields>
morcos: well, the new rpcs in #8680 do all that we've described here. We could just wrap the old ones around those...
< morcos>
cfields: yes that sounds right... i think we need to call getblockheight from the wallet calls and then use your new calls to wait for that
< sipa>
well the wallet can remember independently up to what block hash it is synced
< sipa>
which afaik it does not do now
< morcos>
sipa: i think you want to avoid querying the wallet mid-block
< BlueMatt>
sipa: oh? I thought it did?
< BlueMatt>
It used to at least be on-disk, too
< sipa>
morcos: eh, yes, how does that matter?
< sipa>
BlueMatt: yes, but that isn't uodated for every block
< BlueMatt>
ahh, well, ok, lets update it (in memory) for every block :p
< sipa>
agree
< morcos>
sipa: if the wallet rpcs aren't synced using cory's mechanism then when you check the wallet you don't know if its in the middle of syncing some next block (that maybe you weren't waiting for)
< morcos>
but actually, i guess you still don't know that
< morcos>
shoot
< morcos>
so maybe we need to lock the wallet around the SyncWithWallets loops?
< sipa>
hmm?
< cfields>
brb
< morcos>
sipa: isn't there nothing that stops a getbalance() call from happening in the middle of a SyncWithWallets() loop for a given blcok
< sipa>
so i'm not sure the out of syncness matters to external observers... if you used to wait for a block and then later do and RPC query, it has always been possible that yet another block got processed in between
< morcos>
yes
< morcos>
but now half of another block could be processed
< sipa>
what matters is consistency of wallet rpcs with its own state of the chain
< morcos>
which seems somehow worse
< BlueMatt>
sipa: its very, very, strange to get a balance response that is valid as of the middle of a block, but will change before the end of the block
< BlueMatt>
I'm not sure that ever used to be pososible
< morcos>
it didn't it was protected by cs_main previously
< sipa>
what is the middle of a block?
< sipa>
how can the middle of a block be observed?
< morcos>
don't you just loop through the txs and call SyncWithWallets individually for each one
< sipa>
the only problem is using main's tip to determine wallet confirmations etc
< sipa>
the wallet should use its own tip idea to determine confirmations, instead of main's
< morcos>
why can't you ask for the balance in the rpc thread while you are in the middle of that loop
< sipa>
i think that's fine; it won't be counted as confirmed until it's done
< sipa>
(with the change to use the wallet's idea of the tip)
< morcos>
sipa: its hard to imagine an exact problem, but it just seems an odd change
< morcos>
whats the downside to locking the wallet around that loop?
< sipa>
ah, now i understand what you mean
< sipa>
to prevent a partially updated wallet
< sipa>
i think that's fine, yes
< sipa>
but i think it can be avoided
< morcos>
now someone just has to remember these ideas we've discussed. on that note, lunch time. :)
< BlueMatt>
indeed, but we should :)
< sipa>
enjoy nourishment
< cfields>
back. all fixed? :)
< cfields>
morcos: lunch thought: i suppose we'll need the same fencing for individual transactions + wallet interactions
< morcos>
cfields: how do you mean?
< cfields>
morcos: now that i'm poking around, i can't come up with a realistic example
< cfields>
morcos: i was thinking about cases where the mempool holds a tx that the wallet isn't in sync with yet, where the mempool presence would lead the rpc caller to expect a wallet entry
< sipa>
i believe we've had a related discussion to this before
< sipa>
about whether or not external notifications should be sent before or after wallet updates
< sipa>
or something like that
< sipa>
because in some cases you want the update as soon as possible, but if you're going to use it to trigger a wallet request, the wallet should be updated first
< wumpus>
probably there should be an external notification for the core as well as the wallet
< wumpus>
if you want to be updated of the wallet processing some information, you'd listen for the wallet notification, if you want to know as soon as possible after the core rpocessed something you'd listen for the core notification
< sipa>
yup, agree
< sipa>
if the wallet is going to be asynchronously updated from the rest, it should have independent notifications too
< wumpus>
and in the hypothetical case with with multiple wallets you'd want to register for *that* wallet you're interested in
< wumpus>
right
< wumpus>
it would make a lot of sense for wallet processing to be asynchronous
< wumpus>
and indeed, in that case there's no use in getting a signal after the wallet got the signal
< wumpus>
it still has to start processing
< wumpus>
what you need is a notification from the wallet itself that it processed
< jonasschnelli>
we have one! -walletnotify *duck*
< sipa>
yes, but we'd also need a notification from the wallet that it processed a block
< jonasschnelli>
Yes. Maybe an signal short after when the wallet bestblock was updated.
< wumpus>
right
< jonasschnelli>
Though this works agains in the opposite direction then the possible plan of decoupling the wallet process.
< jonasschnelli>
(if the core side is consuming the event)
< sipa>
parse error
< jonasschnelli>
In case we want the wallet be capable of running without the validation (utxo-set/mempool) we should be carefully add signals (or lets say additional coupling between those elements)
< wumpus>
no, the wallet would be emitting the event
< jtimon>
I'll be afk during the meeting but will read later
< wumpus>
the core side doesn't subscribe to it or anything
< wumpus>
'has wallet processed block' is only something that external clients may care about, maybe the GUI, but certainly not the core
< btcdrak>
saved by DCMA filters "The uploader has not made this video available in your country."
< jonasschnelli>
morcos: hey! happy birthday.
< petertodd>
kanzure: happy birthday to anyone who considers themselves born on this date
< kanzure>
much better.
< petertodd>
btcdrak: the copyright on happy birthday got overturned :)
< btcdrak>
petertodd: click the link
< wumpus>
anyone with proposed topics?
< petertodd>
btcdrak: oh, that's a great song
< sipa>
wumpus: just one: we have quite a queue of things for 0.13.1, and i'd like to encourage people to review
< BlueMatt>
real topic: segwit-cb bip
< btcdrak>
wumpus: birthday cake
< kanzure>
not a topic proposal, but i would like to eventually get a resolution on the after_failure weirdness
< jonasschnelli>
I just wanted to let you know that there will be two hack days on monday and tuesday 10th and 11th of October after the SB conference in Milan.
< petertodd>
jonasschnelli: I'll be there
< gmaxwell>
btcdrak: the list was just based the top participants in the past.
< jonasschnelli>
More info and registration will follow...
< wumpus>
yes last week there was an ACTION for "Support for compact blocks together with segwit" (#8393), there has been a bit of review activity in last days, what's the status there?
< gmaxwell>
wumpus: I've been doing some testing. There aren't many segwit transactions on testnet currently. I was going to call for people to create more once I got more testing setup.
< sipa>
BlueMatt: i haven't reviewed the changes for the bip you suggested - does it require any code changes to the bitcoin core pr?
< wumpus>
#info jonasschnelli: I just wanted to let you know that there will be two hack days on monday and tuesday 10th and 11th of October after the SB conference in Milan. More info and registration will follow...
< BlueMatt>
sipa: possibly, two options, though, one minor, one slightly more
< btcdrak>
maybe we can ask roasbeef to help tx generation there
< wumpus>
gmaxwell: more segwit transactions would help, yes :)
< btcdrak>
jl2012: is everything you are working correctly tagged (or not) for 0.13.1?
< BlueMatt>
so, to quote github issue "The last commit changes the protocol entirely, adding a cmpctack message. This has the advantage that you could implement receiving of some version of compactlocks without implementing sending that encoding, as well as simplifying the protocol slightly (instead of having to check if the current protocol version is higher-priority according to your probably-compile-time list of supported version you know
< BlueMatt>
which version you're using directly from the ack message) at the expensee of complicating the implementation somewhat (now you have to add support for another message type and special-case version 1). The last commit is definitely not worth it if we dont anticipate adding more than one or so more versions, but might be worth it if we anticipate compact blocks version 4, 5, 6 at some point. I'll bring this up in the IRC meeting later
< BlueMatt>
today."
< BlueMatt>
essentially, the current proposal is that you annoucne the set of compact block versions you want at startup (BIP text says before you send any pong or other compact block messages)
< BlueMatt>
and each sendcmpct announce implies that you are willing to encode to those
< jl2012>
btcdrak: including those already tagged, I think 8685, 8654 and 8635 are also for 0.13.1
< BlueMatt>
and you send them in the priority of what you want to receive
< BlueMatt>
and the version you use to send is the first one you receive from the other side that you also sent
< jl2012>
at least we may consider to include in 0.13.1
< BlueMatt>
and you use the highest-priority one the other side also announced to decode
< sipa>
i'm not a fan of changing the code again after all testing, but i do agree it's a cleaner solution, and will make things easier for future extensions
< BlueMatt>
so this is obviously somewhat complicated
< BlueMatt>
and the solution would be to introduce a cmpctack which you use to pick the one you want to encode to
< sipa>
cmpctack containing the version you picked?
< wumpus>
jl2012: (tagged. number of pulls for 0.13.1 does seem to be getting a bit out of hand)
< gmaxwell>
can we have some discussion about this outside of the meeting, I want to ask some questions but I think it'll be a design rathole right now. :)
< BlueMatt>
simplifying the which-do-i-use-to-decode code from "for each sendcmpct msg received, is this higher priority than the previously-highest-prirotiy one" to "the one I saw in a sendcmpct"
< BlueMatt>
in practice the proposed cmpctack is way more code, but a bit simpler
< sipa>
BlueMatt: ok, i'll review and adapt the pr
< BlueMatt>
s/""the one I saw in a sendcmpct"/""the one I saw in a cmpctack"/g
< sipa>
gmaxwell: ok
< BlueMatt>
I, personally, dont really like the cmpctack idea
< sdaftuar>
i do like the cmpctack idea!
< sipa>
so what alternative do you propose?
< BlueMatt>
certainly if we plan on having lots of versions, it is simpler protocol-wise
< jl2012>
wumpus: most of mine are pretty trivial. I am no able to do more than that anyway
< BlueMatt>
if we only ever have version 1 and 2 and maybe like a 3, then the previous proposal seems perfectly ok to me
< morcos>
My viewpoint is that we suffer a history of technical debt, and we have a chance now while compact blocks are new to kind of clean up the protocol messages with a bit less fuss
< sipa>
morcos: agree
< BlueMatt>
sipa: either way I'm proposing to switch the priority order to first-is-highest from last-is-highest
< wumpus>
jl2012: agreed
< morcos>
so we shoudl take the added changes now to be happier later with a better design
< luke-jr>
would it ever make sense to support a per-block encoding? for example, if nodes at some point want to pass blocks along as-is from peer A to other peers when possible
< BlueMatt>
note that we have to introduce a backwards compatibility hack if we do cmpctack
< gmaxwell>
I think it's fine to clean things up. But at some point the correct 'upgrade' is to just introduce a seperate mechenism sendcmpt2 and drop the old one, rather than extending.
< sipa>
BlueMatt: just say that if no ack is ever sent, it is implicitly for v1
< luke-jr>
BlueMatt: do we? old CBs will die with segwit anyway..
< BlueMatt>
sipa: this implies you have to announce sendcmpct version 1
< gmaxwell>
past some point trying to create a forever design just guarentees technical debt of a different kind. :)
< BlueMatt>
which the proposal for creating a cmpctack would not do
< morcos>
we should maybe do as gmaxwell said and discuss after meeting, but i don't think we actually need a hack, you just need to still tell 0.13 nodes that you support v1 and they only understand that by sending them a sendcmpct 1
< morcos>
but it doesn't hurt to send that to everyone
< BlueMatt>
alternatively: compact block version 3 can be called something other than compact blocks
< BlueMatt>
then you can do whatever :P
< sipa>
BlueMatt: hahaha
< sipa>
i could live with that too.
< gmaxwell>
BlueMatt: yea, thats what I was saying, effectively.
< gmaxwell>
besides the general framework here has limitations, further latency optinization should basically be a non-goal, because the fiber approach is vastly better in that respect.
< BlueMatt>
anyway, its taken 15 minutes to explain what the issues are, so maybe decide later, or let other topics go ahead first
< wumpus>
I don't think any other topics have been (seriously) proposed
< wumpus>
so go ahead
< jl2012>
I got to go. See you
< morcos>
proposed topic: picking a segwit rollout date and announcing this in a wider format
< wumpus>
see you later jl2012
< sipa>
jl2012: good night
< sipa>
BlueMatt: how about just sending sendcmpct2 for v2 :)
< * sipa>
hides
< gmaxwell>
morcos: I think the blocker there was basically having all the things merged in 0.13 branch that we believe would be needed on our end.
< btcdrak>
need review of these backport #8679, should be simple enough
< BlueMatt>
though I think the second misses the fact that you have to use sendcmpct instead of cmpctack if its version 1
< instagibbs_>
oh hi. znc bouncer is broke or something.
< morcos>
gmaxwell: yeah i've been a bit out of touch, and i can see that makes sense.. but i also think it would be nice to give as much warning to the community as possible as to when we are proposing to actually release this
< gmaxwell>
morcos: yes, a message that says "This will happen soon, our side waiting for X" to give people a chance to raise any concerns would be reasonable, I think.
< instagibbs_>
/release/activate/ ?
< morcos>
instagibbs_: yes, both
< CodeShark>
we've been giving that message for several weeks already ;)
< wumpus>
#topic picking a segwit rollout date and announcing this in a wider format
< instagibbs_>
I've been pointing out the remaining milestone list, but it's a bit opaque for people who aren't actively reviewing stuff
< gmaxwell>
I went around to soem forks and asked for what their scheduling looked like and the response I got was basically 'after it's deployed in the network'
< sipa>
we can't propose a rollout date before knowing when we can have 0.13.1 out, and there are quite a few things to work out for that
< morcos>
sipa: yeah i suppose i agree
< CodeShark>
I'd rather not pile on additional scheduling issues externally unless we're confident
< achow101>
is a 0.12.2 backport still happening?
< instagibbs_>
Would the amount of lead time differ once we've merged all remaining issuess?
< wumpus>
yes it seems 0.13.1 is a lot more work than expected
< wumpus>
achow101: I don't think so
< btcdrak>
achow101: segwit needs compact block relay, so very unlikely.
< achow101>
ok
< luke-jr>
"needs"?
< wumpus>
achow101: getting this into 0.13 in the first place and assuring it is correct is a lot of work, I doubt anyone can pile up the extra work for 0.12
< BlueMatt>
luke-jr: yea, what? segwit doesnt NEED it
< instagibbs_>
And no one seems to be demanding it, more importantly
< BlueMatt>
just might be painful if you dont have it
< btcdrak>
unless you are happy with bigger blocks being relayed without it...
< btcdrak>
anyway. weeds.
< sipa>
yes, weeds
< instagibbs_>
Which PRs need the most attention at this point
< gmaxwell>
achow101: no we pretty much decided to not do a 0.12. backport over a month ago.
< wumpus>
weeds?
< sipa>
wumpus: "we're getting into the weeds"
< wumpus>
ohh
< gmaxwell>
achow101: not worth the risk and resource investment, and no one was jumping to do it. From measurements and feedback we've found that virtually no one uses backport releases.
< instagibbs_>
mfw pieter is explaining English idioms
< CodeShark>
in the netherlands that might have a different meaning ;)
< jonasschnelli>
heh
< wumpus>
yes, 0.12 just isn't a very important topic right now, let's focus on moving forward
< wumpus>
CodeShark: yes :)
< luke-jr>
also, if someone really needs 0.12, they can put it behind a 0.13.1 node
< wumpus>
next topic?
< wumpus>
#topic rpc sync assumptions
< gmaxwell>
luke-jr: precisely, and any sw backport would create the disruption people were trying to avoid in staying with an older version.
< gmaxwell>
wumpus: I don't understand why people thought it was a problem that getbalance could return a "mid block" response.
< morcos>
just to be clear, the change to reduce cs_main locks is only for 0.14, so we don't have to worry about rpc sync assumptions for 0.13.1 right?
< cfields>
so, marcos pointed out that the reason that the rpc tests are failing and fix is needed is that we broke some timing assumptions by optimizing some stuff
< cfields>
so the question is: are those assumptions ok to break (just fix the tests), or are they part of the api?
< gmaxwell>
I think the question should be what do we think the best behavior is. And if the best behavior changes the API, we should do it and document the change.
< jeremyrubin>
WalletSync expected to occur in test
< jonasschnelli>
Do we assume the wallet has processed a transaction after getting informed of a blockupdate?
< jeremyrubin>
*under the lock
< luke-jr>
does "mid block" include "numbers are being changed, so the value is unlike either the previous OR the next correct value"?
< wumpus>
gmaxwell: I don't know either, there's no guarantee that blocks are atomically processed by the wallet
< sipa>
we can make it atomic, as pointed out by morcos earlier
< jonasschnelli>
s/blockupdate/tipupdate
< wumpus>
but is it necessary?
< morcos>
luke-jr: it reflects the full effect of some of the txs in the block but not all
< gmaxwell>
my understanding is that the tests are doing things like handing a node a block, then instantly checking the wallet, and expecting it to be fully consistent with the block right away. Is this understanding correct?
< sipa>
my alternative is that we make the wallet aware of the current tip it knows about, and we let confirmations be computed based on that
< sipa>
that means that mid-block update you can see unconfirmed transactions
< BlueMatt>
jonasschnelli: ex: you do a getblockheight rpc call - under previous versions if you then do a getbalance that balance is up to date to that block, this is no longer true
< wumpus>
the tests need proper synchronization commands, some of those need to be implemented, I don't think we need to change the whole API for that
< morcos>
wumpus: well before we get to the atomic block question, there is the question of whether if you wait for the blockchain to be synced to some height, and then query the wallet whether you are getting wallet values of at least that height (mid-block or not)
< cfields>
gmaxwell: correct. as soon as the height/hash is reflected, they assume the wallet is synced with that height/hash
< wumpus>
(besides adding those syncronization commands)
< jonasschnelli>
Can we not just have the wallets bestblock in getwalletinfo and use it for sync with getchaintips?
< BlueMatt>
sipa: I think mid-block updates is a blatant violation of the "principal of least surprise"
< gmaxwell>
morcos: okay, I think sipa's suggestion would address that esp with coupled with a way of asking for the wallet's tip.
< wumpus>
morcos: well it would make sense for the wallet to track where it is, synchronization-wise, absolutely
< gmaxwell>
BlueMatt: uh then we need to remove unconfirmed transactions too?!
< wumpus>
morcos: and for thtat info to be available externally
< luke-jr>
showing a best-wallet-block would make the whole mid-block state even more broken IMO (what best-block will it show mid-state?)
< sipa>
BlueMatt: there can always be unconfirmed transactions in the wallet
< BlueMatt>
and, further, if wallet is allowed to return something that is not up to date with the start of the call, this changes literally our entire api....so now anyone using the rpc has to go re-audit all of their uses of it???
< sipa>
luke-jr: the previous one
< BlueMatt>
sipa: huh? I mean things mid-block...am I missing what you said?
< gmaxwell>
luke-jr: it will update its state when its done processing updates, of course.
< morcos>
fixing the mid-block thing seems pretty trivial to me, why wouldnt' we just do that
< jonasschnelli>
luke-jr: the bestblock should only be updated after fully processing? Right?
< BlueMatt>
sipa: i was under the impression you indicated that you would see txn which come later in that block as unconfirmed, while txn earlier in the block are marked confirmed
< gmaxwell>
Why are people regarding mid block as a bug?!?
< sipa>
BlueMatt: no
< gmaxwell>
at _any_ time a transaction can show up and appear in the wallet, unrelated to any blocks.
< morcos>
gmaxwell: b/c its not a feature?
< sipa>
BlueMatt: mid-update you would see the transactions of the new block as unconfirmed
< luke-jr>
that seems the most obvious behaviour, but if you look at bestblock+balance, I would think them a pair, yet balance might be bestblock+partOfNextBlock in reality?
< morcos>
i mean does anyone want that
< BlueMatt>
ahh, yes, ok, so i was just confused....txn which appear in wallet before the block has processed seems reasonable
< gmaxwell>
Unless you want to remove unconfirmed transactions that will always happen.
< sipa>
i also don't think there is any problem with grabbing a wallet lock during the update
< wumpus>
so if changing the balance mid-block is regarded as a bug, that should apply to all other state too: the transaction list, for example. It should hold all updates until it processed the entire block
< sipa>
which would prevent seeing a mid-update state
< sipa>
i'm just questioning if it is necessary
< gmaxwell>
it seems strange to me to hurt concurrency to protect a property that we don't actually have (due to unconfirmed transactions)
< wumpus>
I don't think using the lock for that is a good thing
< wumpus>
agree with gmaxwell
< jonasschnelli>
From the wallet perspective processing doesn't matter, you just want to see confirmations... can slowly appear on a tx list IMO
< cfields>
wumpus: right, that made me cringe. That seems like a major layer violation
< morcos>
wumpus: gmaxwell: but can you explain what concurrency we are hurting?
< morcos>
i'm not suggesting we put cs_main covering those again
< wumpus>
morcos: you have to hold the lock *all* the time while processing the block
< BlueMatt>
gmaxwell: if it were listing your *confirmed* balance as mid-block, then it would be an issue
< sipa>
wumpus: no
< gmaxwell>
Wallet processing shouldn't stall when the node is processing a block, at least not any more than strictly necessary.
< BlueMatt>
which I believe is what people are worried about
< sipa>
wumpus: the proposal is to grab cs_wallet during the wallet updating for the block
< * luke-jr>
wonders if there's a good way to use listsinceblock
< sipa>
wumpus: which happens in its entirety after main processes the block
< morcos>
i'm just suggesting we use cs_wallet or some other lock that prevents a wallet specific call from returning until you are no longer in the middle of a loop that calls SyncWithWallets (on a given block)
< sipa>
wumpus: cs_main isn't even held at the point
< wumpus>
sipa: I know, but you'd still be holding the wallet lock longer than necessary
< BlueMatt>
to be fair, all of this should move onto a background thread in the future anyway
< gmaxwell>
morcos: so now wallet calls will stall block processing? (when the block processing waits to take that lock?)
< wumpus>
BlueMatt: agreed on that
< sipa>
yes, and it may be harder to maining if we parallellize/asynchronize things more
< wumpus>
wallet block processing should be async at some point
< BlueMatt>
so this would be a temporary fix that we should consider something which will happen on a background thread...lets not get too focused on blocking block processing with it
< sipa>
morcos: do you think there is a problem with showing the transactions from the being-processed-block as unconfirmed during the update?
< morcos>
gmaxwell: hmmm, yes i suppose while thats in the main thread thats a bad idea
< jonasschnelli>
IMO the wallet should process a copy of the block on its own, own thread
< sipa>
jonasschnelli: yes yes
< CodeShark>
^]
< wumpus>
sipa: probably it will already be in the wallet as unconfirmed anyhow
< sipa>
jonasschnelli: i think everyone agrees on that
< gmaxwell>
BlueMatt: I'm fine with temporary fixes, I'm just confused as to why anything needs to be fixed here except some unrealistic expectations in the tests.
< sipa>
gmaxwell: i believe the current situation is broken
< gmaxwell>
sipa: great. I'd like to understand why.
< sipa>
mid-update you can see half of the block reflected as confirmed transactions, and miss other transactions from that same block
< BlueMatt>
gmaxwell: two issues: getbalance, by default, shows your *confirmed* balance, so you expect that to be consistent...right now it is not clear (I maybe wrong) that it might not show *half* of your actually confirmed balance
< morcos>
sipa: i think i need to go look more carefully at what SyncWithWallets does with txs from the block, but for instance, coudl you end up removing a conflicted tx, then showing a balance, without having addd the replacement tx yet. i think yes, and i think thats would be confusing
< gmaxwell>
okay, I agree showing confirmed for some and not others is odd. Showing some and not others, however I think is fine, and consistent with the normal behavior.
< cfields>
let's not focus on the details here. The question at hand (mine, anyway), is whether the blocking behavior from 0.13 is considered part of the api, or if it's ok to deviate. If the answer is the latter, we can just fix the tests and move on.
< sipa>
cfields: blocking what behaviour?
< sipa>
0.13 does not have this change
< sipa>
cfields: i think there is something that needs to be fixed in master, that is deeper than fixing up tests
< sipa>
cfields: but it may not be much
< cfields>
sipa: right, 0.13 doesn't give up the lock
< sipa>
indeed, 0.13 is totally fine
< BlueMatt>
gmaxwell: second, we are making an API change here, which it seems to me is probably going to break clients: previously if you called getblockheigh, and then getbalance, getbalance will be up-to-date at least as of that block...this is no longer true. I can absolutely see clients having assumed this
< wumpus>
"okay, I agree showing confirmed for some and not others is odd" absolutely. This would break the assumption that curtip-block which tx was confirmed in is the number of confirmations
< gmaxwell>
cfields: That the wallet blocks shouldn't be part of the api. Certian consistency properties might reasonably be. I'm actually dubious that seeing confirmations incrementally is actually a problem.
< gmaxwell>
BlueMatt: no, thats not really true either, since the chain can reorg between those two calls.
< cfields>
sipa: right. and now master has changed that behavior. So if the behavior is considered to be part of the api, we need to revert it
< jonasschnelli>
Why can't we not just use SyncWithWallets or mempool and add a SyncBlockWithWallet(blockcopy) for added and removed tips? Process it in a wallet-thread (similar to periodic flushes) and use cs_wallet there?
< morcos>
ok, how about i write up an issue
< cfields>
(I don't believe that and I'd -1 it. Just clarifying)
< morcos>
i don't think we should revert the change
< wumpus>
we shouldn't revert anything that prevents future paralellization/concurrency
< sipa>
i think the step was a step in the right direction, and we should continue it
< sipa>
but we have time in 0.14 to figure out exactly how
< wumpus>
if there is a need to 'force everything to wait for thewallet' that's a big -1 from me too
< morcos>
i think we should make it so that the existing rpc calls returns omething that make sense. two issues 1) once you've waited for a certain height, that once you ask for balance you get a balance of at least that height 2) whether mid-block updates are ok
< gmaxwell>
how does this concurrency interact with the wallet's mempool interaction. The wallet cares if tx are in mempool or not, will a wallet look unconfirmed and fallen out of the mempool briefly while it's confirming?
< morcos>
1) needs fixing, 2) needs more investigation
< cfields>
agreed. ok, that answers my question.
< morcos>
1) can be fixed with cfields existing code from 8680 without harming any concurrency
< sipa>
morcos: 1) is easily fixed by reporting the wallet height rather than the core height
< jonasschnelli>
morcos: isn't 1) and 2) solvable from the wallet side?
< wumpus>
wallet height and core height are different things
< sdaftuar>
sipa: yes, but that would be api-breaking right?
< wumpus>
it has always been possible to confound these, but that has to change
< sipa>
sdaftuar: i believe not
< sdaftuar>
i think that's the right idea though
< gmaxwell>
Well it means that someone might need to look in a different place for the wallet height, no?
< sipa>
sdaftuar: if we make 0.14 report the wallet height, i believe it will look equivalent to 0.13
< wumpus>
gmaxwell: yes, it'd need to be a wallet RPC
< morcos>
sipa: the issue is people probably already use getblockcount and then ask for balances
< wumpus>
either on getwalletinfo or getwalletblockcount
< morcos>
but they do that in their code
< sipa>
morcos: so, make getblockcount by default report the wallet height
< wumpus>
bah
< morcos>
that seems like a crazy change
< gmaxwell>
morcos: thats okay, we would release note that in 0.14. If it's the right behavior to change we shouldn't hesitate to do so here.
< sipa>
why? it's exactly what we've been doing all the time
< wumpus>
change getblockcount to a wallet call?!
< jonasschnelli>
no
< sdaftuar>
that means you need wallet support to use that rpc?
< CodeShark>
bad idea
< morcos>
i think we're getting a bit too worked up
< sdaftuar>
blech
< wumpus>
what if there is no wallet built in?
< sipa>
sigh
< jonasschnelli>
no blockcount!
< gmaxwell>
that woudl be kind of odd, but it's 99% of the time used as a wallet call, ... and we have getblockchaininfo....
< wumpus>
what if there are multiple wallets? ask them all, return the max value?
< BlueMatt>
gmaxwell: certain people have reorg handling code, this api change will not trigger their reorg handling code and will still break clients!
< sipa>
so deprepcate the RPC
< jonasschnelli>
Just give out the bestblockhash in getwalletinfo
< BlueMatt>
it is absolutely not unreasonable for this change to break rpc clients
< sipa>
and introduce a wallet-specific one and main-specific one
< morcos>
its easy enough to make wallet balance calls wait on their own until either the wallet reports a height that matches chainactive height or using cfields mechanism, that slows nothing other than that wallet call and solves 1
< cfields>
why not just have getblockcount block until the block is finished processing (all signals, not wallet specific)? New apis can be async
< wumpus>
yes, there needs to be a wallet-specific one
< sipa>
cfields: that's just delaying the problem
< BlueMatt>
what morcos said
< gmaxwell>
BlueMatt: look, the API is not, should not, and cannot be a suicide pact. We're talking about an change in a major version, and one that would only require minor changes. _WE CAN CHANGE THE API_.
< sipa>
cfields: because that's no longer possible if the wallet works asynchronously
< BlueMatt>
just block wallet calls until they are caught up
< gmaxwell>
Especially in a minor way like "get your height for purpose X this way instead of that"
< wumpus>
wallet processing blocking wallet calls is OK
< BlueMatt>
there is a simple solution to this that doesnt require all the users audit their codebase
< BlueMatt>
that isnt even a big deal
< wumpus>
wallet processing blocking core calls is not
< BlueMatt>
but you're arguing we change the api because its simpler?
< BlueMatt>
just block wallet rpc calls until its caught up at the start of the cs_wallet lock
< BlueMatt>
yes, wumpus, dont think anyone is arguing for that
< gmaxwell>
I haven't heard anything suggested that doesn't require having the wallet and block processing block each other.
< BlueMatt>
noooo
< BlueMatt>
wait, wut?
< morcos>
wumpus: yes, see cory's code in 8680, can easily adopt all wallet calls to use that (or ask the wallet for its height but then they might have to poll) and weight until it hits what chainactive was at the start of the call
< BlueMatt>
the proposal is that rpc calls might block until the wallet has caught up to where main chainstate is
< morcos>
gmaxwell: yeah i think you're misunderstanding
< sipa>
morcos: yup... but at some point we'd want to get rid of that too, i think
< BlueMatt>
the wallet processing can still be in a background thread, or on the main thread, or whatever
< wumpus>
morcos: yes, that makes sense
< gmaxwell>
and I think it's insane to degrade concurrency for an obscure property that anyone who wants can retain by using an appropritate call to ask where the wallet is vs where the blockchain is.
< BlueMatt>
it just has to catch up before the rpc will return
< BlueMatt>
gmaxwell: we arent degregading concurrency except that rpc calls might block, afaict
< BlueMatt>
and then we're returning more up-to-date info anyway
< BlueMatt>
so thats not even so bad
< morcos>
might block but would still return before they would have in 0.13!!!
< cfields>
BlueMatt: and it only blocks as long sa it would've before
< BlueMatt>
true
< gmaxwell>
what was suggested above was the block processing taking the wallet lock; which would bidirectionally block each other.
< sipa>
gmaxwell: no
< morcos>
gmaxwell: that was a proposal to solve problem 2 (the mid block)
< BlueMatt>
that was to a different issue
< BlueMatt>
there are two issues
< BlueMatt>
well, potential issues
< sipa>
the proposal was that _the wallet_ would grab _the wallet lock_ while it was updating its state for a new block
< morcos>
that problem needs more investigation to determine a) whether it needs solving and b) whether there is a simple solution. i agree with your objection to my first suggested solution
< morcos>
sipa: yes but thats only a good idea when thats not running in teh same thread as block processing in the middle of block processing, otherwise some other independent wallet call holds up block processing
< sipa>
are there other topics? i don't think we need to figure this out completely right now
< gmaxwell>
morcos: Sounds fine to me.
< wumpus>
I think it's better to take this outside the meeting. Any other topics?
< morcos>
wumpus: ha , too late!
< wumpus>
morcos: heh same idea
< cfields>
this can be handled with signals btw, no need to grab actual locks. StartProcessing() -> block rpc -> FinishedProcessing() unblock
< cfields>
yes, later is fine. That got more heated than I expected :)
< cfields>
though, we still have the question of what to do about the tests.
< sipa>
morcos: yes, i'm not saying that's what we should or shouldn't do... just clarifying what the idea was
< morcos>
does 8680 fix the tests or not really?
< wumpus>
cfields: I think your pull is fine for that, as a temp fix at least
< morcos>
i think 8680 seems reasonable to me
< wumpus>
right
< sipa>
let's merge 8680 to fix the annoyance with the test
< cfields>
morcos: i believe so, but not 100% because of the nature
< sipa>
but open a tracker issue to reconsider
< cfields>
(i'm not 100%, sorry)
< wumpus>
#action merge 8680 to fix the annoyance with the test
< michagogo>
<i>8m warning</i>
< wumpus>
michagogo: looks like we're out of topics sooner than out of time
< cfields>
ok, I can slim that down to only the rpc used by the tests then
< wumpus>
cfields: ack
< sipa>
cfields: thanks
< wumpus>
#endmeeting
< lightningbot>
Meeting ended Thu Sep 8 19:52:49 2016 UTC. Information about MeetBot at http://wiki.debian.org/MeetBot . (v 0.1.4)
< wumpus>
michagogo: yes we've been missing you lately!
< michagogo>
(Where lately = >1 year, I think…)
< instagibbs_>
michagogo: work from home, your hair will get fuller, and silkier with the reduced stress
< MarcoFalke>
michagogo: Let someone drive for you and use the time to catch up on stuff.
< michagogo>
It's a good thing I scripted gitian builds, so at least I can kick those off and let them run at home
< michagogo>
instagibbs_: unfortunately that's not an option for various reasons
< michagogo>
MarcoFalke: I wish that were feasible, but I'm provided with free public transportation and don't have a car
< phantomcircuit>
which pr changed the wallet handling to be background?
< gmaxwell>
Sorry for contributing to confusion above. I probably misunderstood people, but it sounded to me that people were saying that the wallet operating non-concurrently was part of the API and that we couldn't change it. I agree its a minor part of the api but think we must change it. Making all the blocks 'confirmedness' updates to the wallet atomic seems reasonable to me (though I'm dubious anyt
< gmaxwell>
hing would actually be broken by that which isn't already broken)
< jonasschnelli>
phantomcircuit: i guess there is no PR for that?
< michagogo>
I try to figure out how to get rides whenever I can, but that's not very often
< phantomcircuit>
jonasschnelli: o.O ?
< jonasschnelli>
It was just a discussion.
< gmaxwell>
I don't think "would be an api change" should ever be an argument against something in a major release, and it was kind of worrying me to hear people talking that way... esp. since the current api stinks in a number of minor ways and needs improving. "Would be a rather disruptive API change relative to the benefits" would be a fine argument, but it wasn't what I was hearing, maybe it was implici
< gmaxwell>
t. Though I think making the wallet and block processing mutually concurrent has a lot of obvious benefits.
< morcos>
phantomcircuit: 7964 (its not background, it just happens outside of cs_main now)
< CodeShark>
gmaxwell: if it breaks deployed apps, it's a potential issue - otherwise, it isn't
< sipa>
gmaxwell: absolutely - i think everything that was proposed would never grab cs_main and cs_wallet at the same time (even though they're in the same thread for now)
< morcos>
gmaxwell: i think thats a fair summary. in the future it probably makes sense for someone (like me in this case) to write up a small issue before the meeting, so people aren't trying to read about a somewhat nuanced issue in interlaced realtime chat
< jonasschnelli>
gmaxwell: I guess it depends from which angle you are looking at it. Current users expect (API) that getblockchaininfo represents the state of the wallet...
< jonasschnelli>
Which I agree we should keep for 0.13.x
< phantomcircuit>
morcos: that seems to be something about c++11 consistency
< jonasschnelli>
But afterwards, I think is a good signal to have own wallet process state calls
< CodeShark>
I'm in favor of any change that further decouples the wallet from the rest of the app ;)
< jonasschnelli>
To slowly make people aware of that the wallet might gets more of its own state/processes
< BlueMatt>
gmaxwell: sorry, indeed that was my implied argument
< BlueMatt>
gmaxwell: I agree, making an api change is generally fine
< BlueMatt>
but making one that is pervasive across the entire api for such a minor gain seems insane
< BlueMatt>
and generally making a massively pervasive change across the entire api isnt ideal unless its easy to explain how to change your clients to work with it
< gmaxwell>
jonasschnelli: I think we should keep things for 0.13, sure. though take care, there is no way to perform multiple RPCs atomically. So if you call getblockchaininfo then interact with the wallet, the world might have changed out from under you, .. in any version. :P
< BlueMatt>
gmaxwell: and, generally, I'd prefer for things like that to have an -wrapentireapitomakeitbackwardscompatible option
< gmaxwell>
BlueMatt: okay, my view is that having the wallet and node be concurrent is not a minor gain. (esp since that also means multiple wallets being concurrent with each other, ultimately)
< jonasschnelli>
Yes. Indeed. But users expect – in normal non reorg operations – that getblockchaininfo at least reports a height already processed by a wallet
< jonasschnelli>
*the wallet
< sipa>
well, one question is where do people "wait" for getblockcount to go up, and then take wallet action based on it?
< sipa>
i guess we don't know
< MarcoFalke>
I am fine with breaking the wallet api, but we should make it explicit and not silent.
< BlueMatt>
gmaxwell: oops, sure, I agree this case is a major gain
< sipa>
but it seems much more something unit tests do, because they now exactly what is going to happen
< MarcoFalke>
Eg. include the blockhash/height in every wallet call
< BlueMatt>
if it werent also trivial to keep the api consistent I might have a different view
< cfields>
gmaxwell: to be clear, I don't think the concern (from me, anyway) was "is this an api change", so I suppose I framed the question very poorly. The concern was more "did we break reasonable assumptions by making this more async?"
< jonasschnelli>
I guess the problem really apperars when you listen to notifications (ZMQ)
< sipa>
jonasschnelli: it does not
< jonasschnelli>
Right.. we face the problem during the RPC tests...
< kanzure>
if the wallet does its own block processing, that might be interesting, it could even consume the same notifications as third-party apps would be expected to (like zeromq or rpc communication)
< sipa>
we can control when the notification is sent out
< jonasschnelli>
But I guess you will run more often into this concurrency issues when calling RPC off a ZMQ not.
< morcos>
phantomcircuit: oops. 7946
< sipa>
i think it may be the case that the only ones affected by the asynchronicity is unit tests
< phantomcircuit>
morcos: ty
< sipa>
(that's independent from the partial update thing, which we can fix in various other ways)
< kanzure>
wait why would anyone wait for getblockcount to go up...? there is no conceivable reason i could see to do that.
< sipa>
"i do X, and i wait for Y to happen" is something you can't do in production env
< kanzure>
we are talking about syncing two separate processes that are supposedly monitoring a blockchain right?
< sipa>
no
< gmaxwell>
cfields: basically the tests failing proved its an API change, maybe not an important one, but absolutely a change.
< sipa>
we're even talking about something that happens entirely within one thread :)
< cfields>
kanzure: quick example: tracking how many confirmations your txs have and displaying on your site
< kanzure>
cfields: that would make sense to me, but sipa is talking about one thread?
< cfields>
not saying it's wise, but I can imagine that happening in the wild
< phantomcircuit>
kanzure: you need more imagination
< sipa>
kanzure: oh, ignoring the external process of course
< phantomcircuit>
listsinceblock
< kanzure>
i have recently spent a bunch of time writing and validating software that does blockchain syncing between two stores where one is considered truthy and the other is considered a laggard
< sipa>
kanzure: but all wallet updates and main updates happen within one thread in core
< kanzure>
listsinceblock is also something you shouldn't use. you should instead compute the most recent common block and then get the list of different blocks that your laggy side needs to consider.
< phantomcircuit>
kanzure: listsinceblock is the thing people (not me) have been suggesting for years
< kanzure>
looking at a block counter is backwards because it could go up and down
< kanzure>
and treating it as a monotonic clock is what i would expect most application developers to do heh
< kanzure>
i didn't look at the origiating issue that brought up this topic, so i'm sure my context is wrong here
< phantomcircuit>
kanzure: wallet processing of blocks is put into the background, wallet rpc calls can then return results reflecting a partial processing of a block
< phantomcircuit>
ie tx a/b are both in block c but only a shows in the rpc calls
< kanzure>
btw when people above are talking about "unit tests" they mean the rpc tests right?
< sipa>
kanzure: yes
< cfields>
kanzure: unit tests in bitcoind-speak :)
< kanzure>
re: async, then yes i would suggest using zeromq notifications in the testing framework to get information about internal state or for how long to wait (instead of sleeps etc)
< phantomcircuit>
kanzure: they're talking about the functional tests
< phantomcircuit>
not the unit tests
< cfields>
kanzure: the question isn't about how to get the info, it's about what the caller expects. you can query for the current height, then call into the wallet and expect to see tx's from that height, only to find that they haven't been processed yet.
< kanzure>
right... so you could naively sleep to wait for the wallet to be done, or you can query the wallet state (instead of chain height of the non-wallet components)
< cfields>
so who's wrong? the rpc for returning a height without fully processing? or the user for expecting them to be in sync?
< kanzure>
er in this case isn't the rpc test also the user?
< sipa>
so i believe there is a slight difference between normal users and the rpc tests
< cfields>
yea, i was just phrasing more generally
< sipa>
in that rpc tests control the entire world, and use more simplistic means to measure progress
< cfields>
sipa: yes. i doubt many rpc users/scripts are hammering on block-height in tightish loops :)
< cfields>
hope not, anyway
< kanzure>
so- for example- imagine you are operating a lot of bitcoin infrastructure. you do a bunch of per-block processing. when you are running functional/integration tests, you can't run your test checks immediately after issuing a command because things take a while. so when do you expect to run? well you setup a hook and you ask your infrastructure to ping your tester as soon as the data's available, or you poll for some internal state.
< kanzure>
(and polling is considered not ideal)
< sipa>
and non-polling methods exist
< sipa>
we have -walletnotify for exactly this
< kanzure>
walletnotify should certainly be used by the rpc tests
< sipa>
this raises another point: walletnotify should probably fire after all of a block's transactions are processed
< kanzure>
i would like zeromq notifications and -*notify notifications to be unified somehow, and eventually have much more distinct notifications for different events going on
< kanzure>
changing walletnotify behavior and when it fires is sort of unkind to the users that rely on its existing behavior :)
< cfields>
kanzure: and #8680 introduces blocking calls. So you could "./bitcoin-cli waitfornewblock && ./dosomething.sh", which would essentially be blocknotify. Obviously the same could be done for wallet stuff
< CodeShark>
I would like all pub/sub stuff in a separate layer ;)
< CodeShark>
especially if it requires deep knowledge of account structure
< kanzure>
i feel like users are going to not understand how to use waitfornewblock. how are you going to stop them from treating that as a monotonic counter for each new lbock...?
< cfields>
kanzure: that's a hack, hidden for users, just for tests. It's a pretty bad idea to take action on an event so vague :)
< kanzure>
btw i (sheepishly) made a one-line proposal about throwing a component into bitcoind to keep track of external application state, specifically to store a range or diff-set of blocks that an external application should be aware about, and then the implementation proposal would be "please integrate against this" and we give the user an endpoint for saying "my application has processed the latest diff-workload x". but this might be too ...
< kanzure>
... kitchen-sinky.
< kanzure>
oh it's for testing. hm.
< cfields>
i was just using it as an example of an async approach.
< kanzure>
(the "diff-workload x" is specifically referring to a set of new blocks some of hwich might override previous blocks the other application was aware about. this makes the interface explicitly expose a concept of reorgs.)
< kanzure>
CodeShark: in your link i'm not seeing any tests for that library...
< CodeShark>
the whole thing needs to be repackaged
< CodeShark>
just giving it as an example of how I think an API should work
< kanzure>
cfields: fwiw once i switched to notifications inside my own tests (for some external infrastructure) re: bitcoind integration, everything went much faster and i had much more information about failures. far less timeouts too.
< cfields>
kanzure: what would bitcoind do with the knowledge that the application is done processing?
< sipa>
can we talk about solutions instead of vague design concerns?
< kanzure>
cfields: nothing. it's for the benefit of the application. once bitcoind is informed about the application's new state, it can discard the old diff information. that's about all it would do...
< CodeShark>
two subscription layers - one low level, the other much higher level
< CodeShark>
the low level layer only gives you basic events like new tip or new tx
< CodeShark>
dunno why sipa doesn't like to discuss architecture :(
< CodeShark>
it
< CodeShark>
it's a serious problem for the ecosystem right now that there's no good way for people to build apps
< cfields>
sipa: the more I think about it, the more I think that there needs to be a wallet rpc for getbalanceat(height)
< cfields>
i can't think of anything that doesn't introduce more problems except for explicit/atomic calls
< kanzure>
should be a blockhash not a height
< cfields>
sure
< sipa>
cfields: that makes sense
< cfields>
I think the reason today's discussion devolved so quickly is because "getblockcount" is impossible to define, because there's no global height. So the only fix is to ensure that we're asking a specific interface a specific question. Then there's no way of being out of sync because you've specified your constraints
< * sipa>
goes for a walk, without phonr
< sipa>
be back in a while
< cfields>
cya
< CodeShark>
cfields: right
< CodeShark>
there's no such thing as "what's the current state of the network?"
< cfields>
then it's just a matter of how to handle the api. returning "come back later", blocking until there's an answer, or some callback mechanism.
< cfields>
arguably if you need a callback, you should be using a different interface. as kanzure suggested above. I'm of the opinion that blocking is the way to go because that lets the user chain his own callback
< kanzure>
blocking in what context? rpc ?
< CodeShark>
depends on what model you're after - I think async is generally cleaner but requires a bit more clientside framework
< cfields>
kanzure: yes, rpc blocks for a specified time (or forever) and returns when it has an answer, or timeout, or shutdown
< kanzure>
oh. i've had so may issues with rpc socket timeouts that i haven't traced down yet that i would recommend not considering that direction heh.
< kanzure>
(but also i haven't been able to make good reports about these problems, so they don't really count.)
< cfields>
kanzure: heh, i was actually surprised i didn't bump into those during testing. good to know :)
< kanzure>
well i think what i was doing could be considered "torture testing" and weird stuff, so.... yeah..
< kanzure>
to some degree aren't we already tracking peer state on the p2p layer? e.g. like which chains the peers seem to be following lately?
< kanzure>
or is that purely a function of the banning behavior heh
< cfields>
lately?
< kanzure>
(by virtue that you could ban everyone feeding you unhelpful data, as opposed to tracking which blocks you think peers have already)
< kanzure>
nevermind. just an abstract thought, it's not important, i was thinking that "peer communication" is sometimes similar to "application communication" but more one-way. anyway, just a minor distraction.
< cfields>
we keep tabs on what they shouldn't be sending, but i don't remember to what extent
< CodeShark>
a peer can query for inventory at any time regardless of whether it is in agreement with the node's best chain
< CodeShark>
I think peers get sent invs whenever there are tip changes regardless
< gmaxwell>
"(and polling is considered not ideal)
< gmaxwell>
"
< gmaxwell>
This bugs me. Polling is highly reliable. And we're taking about things that have inherent latencies in real of seconds to tends of minutes.
< phantomcircuit>
polling is the correct way to interact with the wallet
< gmaxwell>
I do not know why people eschew polling as often as they do... there are contexts where its exactly the right tool and keeping track of a wallet state is likely one of them.
< phantomcircuit>
if you're not polling you're doing it wrong
< kanzure>
well one trivial example is in scenarios where you have long-term polling, you will miss the update and spend extra time waiting
< kanzure>
this is apparent in scenarios with, say, exponential backoff
< phantomcircuit>
kanzure, call listtransactions
< phantomcircuit>
does the list contain a transaction you have previously seen?
< kanzure>
instead of hoping you catch wallet state transitions by polling, what about just having the wallet notify you directly of each change event? then you consume the feed/queue of events.
< phantomcircuit>
yes? great do nothing
< phantomcircuit>
no? increase the list size
< phantomcircuit>
handle reorgs? need to call the blockchain things and do a bunch of work
< kanzure>
which application are you imagining for listtransactions in particular?
< phantomcircuit>
anything which needs to know that a payment has been made
< kanzure>
i don't know what the behavior of listtransactions is. how does it behave when a transaction has been removed from your chaintip..?
< phantomcircuit>
kanzure: it's buried in the list and has -1 confirmations
< kanzure>
for how long...? it occurs to me that listtransactions is probably a wallet-specific rpc command and that's why i know so little about it.
< kanzure>
getting notified when a transaction is about to be permanently removed from that list sonuds like a useful thing, but you could probably infer that detail from polling regularly and knowing the lifecycle i guess.
< phantomcircuit>
kanzure, listtransactions only shows you transactions in your wallet
< phantomcircuit>
nothing is ever removed from the list there's just a parameter which truncates the list
< phantomcircuit>
listtransactions "*" 4294967295
< phantomcircuit>
will give you all the transactions your wallet has ever seen
< kanzure>
incremental updates and messaging would not require so much data transfer all at once. :)
< phantomcircuit>
kanzure, messaging is unreliable
< phantomcircuit>
polling is inherently reliable
< phantomcircuit>
fin
< sipa>
we shouldn't make assumptions about how people use the api
< kanzure>
my above concerns are mostly about polling interval
< kanzure>
and blockheight can't be a heartbeat
< BlueMatt>
sipa: https://github.com/TheBlueMatt/bitcoin/commit/96cef326f9184aefd1c562f64a21298a15f0adde simplifies the total diff from master to be more readable, to me...it matches the bip, but another way to look at it is that you have two booleans: which version of compact blocks they want (which you use to send to them) and whether they will send us segwit cmpctblocks...you simply introduce the the do-they-support-v2 bool as an additional
< BlueMatt>
check before requesting cmpcblocks and otherwise dont need the complicated other semantics
< BlueMatt>
(warning: mostly untested...it compiles, though :p)
< BlueMatt>
ehh, nvm, need to fix a bug there, but I'm tired so will do it later/tomorrow