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

85-block-extra-data #88

Merged
merged 7 commits into from
Jul 12, 2017
Merged

85-block-extra-data #88

merged 7 commits into from
Jul 12, 2017

Conversation

david-julien
Copy link
Contributor

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 77.343% when pulling 5a45c27 on 85-block-extra-data into 0ce1330 on dev.

Copy link
Contributor

@chadlagore chadlagore left a comment

Choose a reason for hiding this comment

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

Interested in what the use case of the extra data is? I know there is some analogue in BTC. Also, why are we enforcing a block size now?

@@ -28,6 +27,9 @@ type BlockHeader struct {
Time uint32
// Nonce starts at 0 and increments by 1 for every hash when mining
Nonce uint64
// ExtraData is an extra field that can be filled with arbitrary data to
// be stored in the block
ExtraData []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

I know there is some analogue to this in bitcoin. Interested, why are we adding it to our chain?

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 was thinking its a standard blockchain feature, lets you store data for "eternity" and will potentially help us with future applications of our blockchain.

Copy link
Member

Choose a reason for hiding this comment

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

Should we make this an array to indicate that it should be size-limited? (can change later too).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what chad and i were talking about on slack, I think we decided to not limit any size for now. I made a ticket for it.


return buf
}

// Len returns the length in bytes of the BlockHeader.
func (bh *BlockHeader) Len() int {
l := 2*(32/8) + 64/8 + 2*HashLen
Copy link
Contributor

Choose a reason for hiding this comment

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

unsafe doesn't seem ideal, but isn't there some notion of sizeof in golang?https://stackoverflow.com/questions/26975738/how-to-get-memory-size-of-variable

Copy link
Contributor Author

@david-julien david-julien Jul 10, 2017

Choose a reason for hiding this comment

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

been looking in to this, unsafe.Sizeof causes some issues because in the ExtraData byte array, Sizeof returns the size of the slice descriptor, not the size of the memory referenced by the slice which is what we want as we are looking for the length when marshalled.

Statically setting the length here should be safe if we have tests that will fail once someone messes with it.

BlockHeaderLen = 2*(32/8) + 64/8 + 2*HashLen
// MaxBlockSize is the maximum size of a block in bytes when marshaled
// (about 250K).
MaxBlockSize = 1 << 18
Copy link
Contributor

@chadlagore chadlagore Jul 10, 2017

Choose a reason for hiding this comment

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

Block size is busy blowing the bitcoin universe up - are we sure we want to enforce it?

Did you guys discuss this on Saturday? I'm game if we're consciously making the decision.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bringing this to slack


valid, code := bc.ValidGenesisBlock(gb)

if valid {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use assert if we can? 😄

@david-julien david-julien changed the title ExtraData field added to block 85-block-extra-data Jul 11, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 76.587% when pulling 89c0706 on 85-block-extra-data into 0ce1330 on dev.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 76.587% when pulling 89c0706 on 85-block-extra-data into 0ce1330 on dev.

@@ -28,6 +27,9 @@ type BlockHeader struct {
Time uint32
// Nonce starts at 0 and increments by 1 for every hash when mining
Nonce uint64
// ExtraData is an extra field that can be filled with arbitrary data to
// be stored in the block
ExtraData []byte
Copy link
Member

Choose a reason for hiding this comment

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

Should we make this an array to indicate that it should be size-limited? (can change later too).

@@ -73,7 +73,7 @@ const (
BadGenesisBlockNumber
// BadGenesisTarget is returned when the genesis block's target is invalid.
BadGenesisTarget
// BadGenesisTime is returned when teh gensis block's time is invalid.
// BadGenesisTime is returned when the gensis block's time is invalid.
Copy link
Member

Choose a reason for hiding this comment

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

there's another typo here lol (gensis -> genesis)

Copy link
Member

Choose a reason for hiding this comment

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

Gensyscalls

Copy link
Member

@bfbachmann bfbachmann left a comment

Choose a reason for hiding this comment

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

Wow! Great work!

l += t.Len()
}
return l
return len(b.Marshal())
Copy link
Member

Choose a reason for hiding this comment

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

Nice

@@ -73,7 +73,7 @@ const (
BadGenesisBlockNumber
// BadGenesisTarget is returned when the genesis block's target is invalid.
BadGenesisTarget
// BadGenesisTime is returned when teh gensis block's time is invalid.
// BadGenesisTime is returned when the gensis block's time is invalid.
Copy link
Member

Choose a reason for hiding this comment

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

Gensyscalls

@@ -190,6 +190,7 @@ func ValidCloudBase(t *Transaction) (bool, CloudBaseTransactionCode) {

// ValidGenesisBlock checks whether a block is a valid genesis block.
func (bc *BlockChain) ValidGenesisBlock(gb *Block) (bool, GenesisBlockCode) {

Copy link
Member

Choose a reason for hiding this comment

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

This is my favorite line

if b == nil {
return false, NilBlock
}

// Check if the block is the genesis block
// Check if the block is the genesis block.
Copy link
Member

Choose a reason for hiding this comment

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

Good catch

@jordanschalm
Copy link
Member

@david-julien Does this build for you locally? I get:

app/worker.go:76: work.Miner undefined (type BlockWork has no field or method Miner)
app/worker.go:76: too many arguments in call to chain.AppendBlock
	have (*blockchain.Block, <T>)
	want (*blockchain.Block)

Maybe why Travis is failing

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 68.185% when pulling 14b93ad on 85-block-extra-data into 2fef206 on dev.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 68.703% when pulling eb76c5c on 85-block-extra-data into 2fef206 on dev.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 70.05% when pulling d4c1fc0 on 85-block-extra-data into 6788fe6 on dev.

@jordanschalm jordanschalm merged commit f4f8b68 into dev Jul 12, 2017
@jordanschalm jordanschalm deleted the 85-block-extra-data branch July 12, 2017 04:47
@david-julien david-julien mentioned this pull request Jul 14, 2017
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants