-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Read registry_address from block with REQUEST_CONFIRMATIONS_REQUIRED #8309
Read registry_address from block with REQUEST_CONFIRMATIONS_REQUIRED #8309
Conversation
self.data.write().contract_address = service_contract_addr; | ||
if let Some(block_hash) = get_confirmed_block_hash(&*client, REQUEST_CONFIRMATIONS_REQUIRED) { | ||
// update contract address from registry | ||
let service_contract_addr = client.registry_address(self.name.clone(), BlockId::Hash(block_hash)).unwrap_or_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.
I'm not sure whether it will work with not archive nodes. cc @tomusdrw
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.
right, the state might be pruned get_confirmed_block_hash
could return the oldest ancestor possible in that case, but then the call to reigistry_address
will race with the pruning. We really need some way to block pruning while we inspect state by using some kind of extended BlockId
.
this should be also reviewed by @svyatonik |
Using a constant number of confirmations is a little tenuous. Can we add a |
@rphmeier There were originally a I think the original |
@debris @rphmeier Thanks for pointing to this. This code should work only if we're synchronized ( @rphmeier I guess number of confirmation is an universal decision (and afair our UI and I guess most of DApps use the similar approach). Thanks for pointing that there's another way, though. @sorpaas could you please add TODO for this. @sorpaas Thanks for helping with this TODO :) It is a little bigger than just fixing |
@svyatonik Okay. Will do! |
yeah. since it's only 3 blocks behind the head of the chain (minimum pruning we allow for now is 8) this is probably not a problem, but it's an assumption that can be broken well outside of this module. Although if this is triggered while we're importing many blocks and not just at the head of the chain, there is a pretty bad race condition. The finality stuff isn't useful to most DApps since they're on the mainnet, so their only choice is to rely on confirmations until CasperFFG. But where possible, it's more correct and safer to use finality. It's not something the codebase supports yet but it will soon. |
@@ -0,0 +1,12 @@ | |||
use ethcore::client::{Client, BlockChainClient, BlockId}; |
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.
Could you please add license preamble to the beginning of the file?
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.
Or maybe just make this function a member of TrustedClient
? Both have similar purpose.
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.
@svyatonik I added license preamble. Looks like for cases using get_confirmed_block_hash
we need to directly dealt with a Client
reference but not TrustedClient
. So just thought this would be less complicated if we don't do some refactoring.
And regarding license preamble, I realized that they still say 2015-2017
, do we need to change all of them to 2015-2018
?
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.
Don't think so - guess it will be enough for new file only. Thanks!
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.
Okay. Got it!
Also please do not forget to add TODO about using finality when possible (see my big comment above). Thanks! |
@svyatonik Sorry I missed that! |
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.
LGTM
Use REQUEST_CONFIRMATIONS_REQUIRED instead of the latest block. Fix one TODO item in code comment.