Skip to content

Add tests for uncle timestamps and refactor timestamp type #1711

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

Merged
merged 1 commit into from
Aug 25, 2015

Conversation

Gustav-Simonsson
Copy link

No description provided.

@robotally
Copy link

Vote Count Reviewers
👍 3 @fjl @karalabe @zelig
👎 0

Updated: Tue Aug 25 13:49:16 UTC 2015

@Gustav-Simonsson Gustav-Simonsson force-pushed the timestamp_big_int branch 3 times, most recently from 0659fb1 to df8688f Compare August 24, 2015 14:32
return &types.Header{
Root: state.Root(),
ParentHash: parent.Hash(),
Coinbase: parent.Coinbase(),
Difficulty: CalcDifficulty(time, parent.Time(), parent.Number(), parent.Difficulty()),
Difficulty: CalcDifficulty(time.Uint64(), new(big.Int).Sub(time, big.NewInt(10)).Uint64(), parent.Number(), parent.Difficulty()),
Copy link
Contributor

Choose a reason for hiding this comment

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

2nd arg why not parent.Time().Uint64()?

Copy link
Author

Choose a reason for hiding this comment

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

Some tests do not initialise parent in the first call to this function, and I wanted to avoid changing them just for this patch.

@zelig zelig added this to the 1.1.0 milestone Aug 24, 2015
if block.Time > uint64(time.Now().Unix()) {
return BlockFutureErr
if uncle {
if block.Time.Cmp(common.MaxBig) == 1 {
Copy link
Member

Choose a reason for hiding this comment

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

Although valid, comparing against 1 is a bit odd. Usually big int comparison is done as:

  • < 0 if the first is smaller
  • == 0 if they are equal
  • > 0 if the first one is greater

This scheme makes it a bit more visible as the comparison operator already "symbolizes" the actual result vs. having to interpret -1, or 1. It is used like that throughout the entire standard lib too, so better to stick with the canonical use.

Copy link
Author

Choose a reason for hiding this comment

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

@karalabe I'd wait with this since the comparisons for extra data, difficulty and gas uses the "odd" convention - better we change this everywhere in a follow-up PR so we avoid touching unrelated code in this patch.

Copy link
Member

Choose a reason for hiding this comment

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

Ok with me then, but it would be nice to update them at a certain point. :)

@zelig
Copy link
Contributor

zelig commented Aug 25, 2015

👍 modulo comments

@karalabe
Copy link
Member

👎 Until the immutability is fixed.

Also a question. The verify header does not check against negative values. Previously since we unmarshalled into an uint64, this was not an issue. Now however a timestamp big.Int may become negative. We should make sure that such cases are handled correctly.

@fjl
Copy link
Contributor

fjl commented Aug 25, 2015

@karalabe RLP cannot contain negative big ints.

@@ -301,13 +301,13 @@ func (b *Block) Number() *big.Int { return new(big.Int).Set(b.header.Number)
func (b *Block) GasLimit() *big.Int { return new(big.Int).Set(b.header.GasLimit) }
func (b *Block) GasUsed() *big.Int { return new(big.Int).Set(b.header.GasUsed) }
func (b *Block) Difficulty() *big.Int { return new(big.Int).Set(b.header.Difficulty) }
func (b *Block) Time() *big.Int { return new(big.Int).Set(b.header.Time) }
Copy link
Contributor

Choose a reason for hiding this comment

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

@Gustav-Simonsson please also update copyHeader

Copy link
Author

Choose a reason for hiding this comment

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

done

@karalabe
Copy link
Member

👍

1 similar comment
@fjl
Copy link
Contributor

fjl commented Aug 25, 2015

👍

fjl added a commit that referenced this pull request Aug 25, 2015
Add tests for uncle timestamps and refactor timestamp type
@fjl fjl merged commit abce099 into ethereum:develop Aug 25, 2015
@fjl fjl removed the review label Aug 25, 2015
Gustav-Simonsson pushed a commit to Gustav-Simonsson/go-ethereum that referenced this pull request Aug 25, 2015
Add tests for uncle timestamps and refactor timestamp type
(cherry picked from commit abce099)
Gustav-Simonsson pushed a commit to Gustav-Simonsson/go-ethereum that referenced this pull request Sep 2, 2015
Add tests for uncle timestamps and refactor timestamp type
(cherry picked from commit abce099)

(cherry picked from commit fd512fa)

Conflicts:
	core/vm/instructions.go
	core/vm/jit_test.go
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.

6 participants