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

Repository reorganisation #13

Merged
merged 3 commits into from
Apr 11, 2017
Merged

Repository reorganisation #13

merged 3 commits into from
Apr 11, 2017

Conversation

alekseysidorov
Copy link
Contributor

Closes #12

@alekseysidorov alekseysidorov changed the title WIP: Repository reorganisation Repository reorganisation Apr 5, 2017
Copy link
Contributor

@slowli slowli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review as of bb5e8a7.

Mostly good, but there are a couple of nitpicks. Besides line comments:

  • Maybe, move details/transactions.rs to the details/btc folder? It seems slightly confusing that blockchain/transactions.rs and details/transactions.rs are not related in any way
  • I don't quite agree with the naming of src/blockchain/consensus_storage.rs. In a big scheme of things, AnchoringConfig is a binding for JSON-serialized data that is stored somewhere in the blockchain state. That is, it is a "consensus storage" in the same way that tables are "consensus storage". Understandably, this is a very minor nitpick
  • Is details/sandbox.rs really needed in the main repository? As far as I understand, it is only used for sandbox testing

@@ -87,16 +87,16 @@ impl RedeemScript {
mod tests {
extern crate blockchain_explorer;

use bitcoin::util::base58::FromBase58;
// use bitcoin::util::base58::FromBase58;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the commented code be refactored back into the codebase in another PR? If not, remove it.

impl AnchoringConfig {
/// Creates default anchoring configuration from given public keys and funding transaction
/// which were created earlier by other way.
pub fn new(validators: Vec<btc::PublicKey>, tx: FundingTx) -> AnchoringConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does an initial funding tx need to be specified manually? Can't nodes find it (or multiple UTXOs) by the initial anchoring address automatically? (Possibly filtering the UTXO set, say, by the amount of bitcoins.)
Maybe, this is a matter for a new issue/PR; I won't press on solving it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the service does not use the whitelist, it simply takes transaction from the config. If you want to use the whitelist, create discussion on active collab.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, does this mean that once the initial funds are depleted, the anchoring process will stop? Seems like an issue that needs to be solved separately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change the funding_tx with the configuration_service and then if it would be suitable for anchoring it will be used as input funding transaction.
If you calculate so that you need to add funding_transacton once at month along with the changing of the btc keys, then this should not cause difficulties for the admins.

AnchoringConfig {
validators: validators,
funding_tx: tx,
fee: 1000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are hardcoded values adequate here? Do I understand correctly that this constructor is intended for testing purposes only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just default values that claim to be adequate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, implement the Default trait for AnchoringConfig then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good idea, but I can't fill funding_tx with blank value.

pub fn signatures(&self,
txid: &btc::TxId)
-> ListTable<MapTable<View, [u8], Vec<u8>>, u64, MsgAnchoringSignature> {
let prefix = [&[ANCHORING_SERVICE_ID as u8, 2], txid.as_ref()].concat();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, define table ids as constants, similarly to service/message ids?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can return to this issue after exonum storage refactoring. We need to have general solution for prefixes.

Copy link

@dj8yfo dj8yfo Apr 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Table prefix: service_id + ordinal_id_within_service + arbitrary_suffix (for entity hash, other id, etc.) ?
It'll be up to good will of following convention within service (harder to mess up with tables from core or other service). But nothing prevents messing up any other table in case of bad will.
Maybe we should write a helper function to concatenate (service_id + ordinal_id_within_service + arbitrary_suffix), which may be reused inside of state hash aggregation function to identify tables by service_id + ordinal_id_within_service.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is time to think about a common solution of this problem, something like StorageKey trait for keys and common helper functions that makes prefix creation more easy.

@alekseysidorov
Copy link
Contributor Author

  • Yes i think that transactions.rs needs to be moved into btc module.
  • We need to go deeper :) We have more important issues.
  • This needs for sandbox module because it cannot replace RpcClient in any way.

Copy link
Contributor

@slowli slowli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in concept as of f30d05c, but the opinion of service developers could be useful

Copy link
Contributor

@vldm vldm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alekseysidorov alekseysidorov merged commit a3f3fe5 into exonum:master Apr 11, 2017
@alekseysidorov alekseysidorov deleted the 12-reorganize-crate-structure branch June 1, 2017 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants