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

Basic blockchain types and Tipset methods #28

Merged
merged 15 commits into from
Nov 25, 2019

Conversation

dutterbutter
Copy link
Contributor

@dutterbutter dutterbutter commented Nov 21, 2019

Changes introduced in this PR:

  • Added Blockheader, Block, Ticket, Tipset types
  • Added Tipset utility methods (len, is_empty, key, min_ticket etc.)
  • Started errors.rs for blockchain component

Stubbed functions:

  • new

new which will be used to assemble blocks into a TipSet.

Todo:

  • Add component logic to mod.rs

Closes #9, closes #23

* Defined block header and block structures
* Defined ticket structure with vrfproof type
* Defined tipset structure and wip new_tip_set fn with tests
* Added utility methods to the Tipset type
* Updated comments
* Linted using clippy and rustfmt
* Fix min_ticket return statement
* update comments
@GregTheGreek
Copy link
Member

GregTheGreek commented Nov 21, 2019

Fyi If you write:

Closes #9, #23 this should auto close them on merge

Copy link
Member

@ansermino ansermino left a comment

Choose a reason for hiding this comment

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

I think we should use doc comments for the function documentation (/// instead of //).

Also -- just wanted to point out the use of pub on fields in the BlockHeader struct (and elsewhere), I think this is generally a bad practice, but until we have a better sense of how we are constructing the blocks we can probably leave as is.

blockchain/src/blocks/tipset.rs Outdated Show resolved Hide resolved
@ansermino
Copy link
Member

Fyi If you write:

Closes #9, #23 this should auto close them on merge

That only closes the first one iirc

@dutterbutter
Copy link
Contributor Author

I think we should use doc comments for the function documentation (/// instead of //).

Also -- just wanted to point out the use of pub on fields in the BlockHeader struct (and elsewhere), I think this is generally a bad practice, but until we have a better sense of how we are constructing the blocks we can probably leave as is.

I added pub to fields that were also exported in go implementation, let me know if you want them removed

Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

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

Looks good, just minor questions/ comments. One thing I would suggest is we default to making functions private over public unless actually needed to be public. Reason for this is to not crowd possible imports and expose functions/parameters that should not be accessed outside of this module or crate

blockchain/src/blocks/block.rs Outdated Show resolved Hide resolved
blockchain/src/blocks/ticket.rs Outdated Show resolved Hide resolved
blockchain/src/blocks/tipset.rs Outdated Show resolved Hide resolved
blockchain/src/blocks/tipset.rs Outdated Show resolved Hide resolved
blockchain/src/blocks/block.rs Outdated Show resolved Hide resolved
* Added Tipset comment
* Added clone to TipSetKeys
* Referenced Address type from vm
* Return proper error rather than integer in min_timestamp
@dutterbutter
Copy link
Contributor Author

@ansermino @austinabell @GregTheGreek changes made as requested

* Added Option to min_timestamp return rather than error
Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

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

:D looks like a good framework with what's available. Would be nice to have some sort of tests though so the logic and function signatures don't have to be assumed to be correct

@dutterbutter
Copy link
Contributor Author

dutterbutter commented Nov 22, 2019

:D looks like a good framework with what's available. Would be nice to have some sort of tests though so the logic and function signatures don't have to be assumed to be correct

Yeah tests will be added shortly after new fn is implemented and we have some agreement on where we want tests to live as per your slack message

blockchain/src/blocks/block.rs Outdated Show resolved Hide resolved
Copy link
Member

@ec2 ec2 left a comment

Choose a reason for hiding this comment

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

Remove extern crate. Other than that, its cosmetics, that are opinionated, so feel free to disregard those.

* Added blockheader comment
* Added vrfpi comment
* Removed error prefixes
* Moved and renamed fn under impl Tipset
@dutterbutter
Copy link
Contributor Author

@GregTheGreek @ec2 @ansermino changes made as requested

* Removed extern crate
* Moved the vfriproof type to top of file
Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

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

new commits look good

use cid::Cid;
use vm::address::Address;

/// BlockHeader defines header of a block in the filecoin blockchain
Copy link
Member

Choose a reason for hiding this comment

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

filecoin -> Filecoin

blockchain/src/blocks/block.rs Outdated Show resolved Hide resolved
/// MINER INFO
///
/// miner_address is the address of the miner actor that mined this block
miner_address: Address,
Copy link
Member

Choose a reason for hiding this comment

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

What's the rational of what needs to be public or private in this struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the above comments, only make the fields public that are currently being used (e.g. height, parents). Once further functionality has been added the remainder of the fields in this struct will become public.

Copy link
Member

@ec2 ec2 left a comment

Choose a reason for hiding this comment

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

Minor cosmetics stuffs

Copy link
Member

@ec2 ec2 left a comment

Choose a reason for hiding this comment

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

lgtm

@dutterbutter dutterbutter merged commit ae84675 into master Nov 25, 2019
@dutterbutter dutterbutter deleted the dustin/tipset-structures branch November 25, 2019 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Ticket Type Implement Basic Block and Header
5 participants