-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary ======= This implements EIP-1234 which updates the difficulty calculation and the block reward for Constantinople. More details =========== Thus far we have been using Parity's chain config files to generate configuration for a chain. We update those files to include the values for Constantinople. In this change, however, Parity updates not only some values in the json configuration but also how they are stored. In particular, the block rewards and the bomb delay factor can now be a single value or json objects whose key is the block_number of the fork in question and the value is the thing looked for. So, for example, we could find this in a block_reward, ``` block_reward: { "0" => 300000000, "1700000" => 2000000 } ``` We make updates to our `Chain` module to account for this. Update ethereum_common_tests Run generate_state_tests We update the state tests with tests that are still failing and the passing percentages in the main README. This change also updates chains from parity: https://github.com/paritytech/parity-ethereum/tree/master/ethcore/res/ethereum
- Loading branch information
1 parent
a90ae7a
commit 4024c64
Showing
17 changed files
with
2,825 additions
and
2,630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,68 @@ | ||
defmodule Blockchain.ChainTest do | ||
use ExUnit.Case, async: true | ||
doctest Blockchain.Chain | ||
|
||
alias Blockchain.Chain | ||
|
||
describe "after_bomb_delays?/2" do | ||
test "checks if the block number is after any of the bomb delays were introduced" do | ||
byzantium_transition = 4_370_000 | ||
|
||
chain = Chain.load_chain(:foundation) | ||
|
||
assert Chain.after_bomb_delays?(chain, byzantium_transition) | ||
assert Chain.after_bomb_delays?(chain, byzantium_transition + 1) | ||
refute Chain.after_bomb_delays?(chain, byzantium_transition - 1) | ||
end | ||
end | ||
|
||
describe "bomb_delay_factor_for_block/2" do | ||
test "returns the bomb delay for the block number" do | ||
byzantium_transition = 4_370_000 | ||
|
||
chain = Chain.load_chain(:foundation) | ||
|
||
assert 3_000_000 == Chain.bomb_delay_factor_for_block(chain, byzantium_transition) | ||
assert 3_000_000 == Chain.bomb_delay_factor_for_block(chain, byzantium_transition + 1) | ||
end | ||
end | ||
|
||
describe "block_reward_for_block/2" do | ||
test "returns the block reward based on the block number" do | ||
byzantium_transition = 4_370_000 | ||
three_eth = 3_000_000_000_000_000_000 | ||
five_eth = 5_000_000_000_000_000_000 | ||
|
||
chain = Chain.load_chain(:foundation) | ||
|
||
assert three_eth == Chain.block_reward_for_block(chain, byzantium_transition) | ||
assert three_eth == Chain.block_reward_for_block(chain, byzantium_transition + 1) | ||
assert five_eth == Chain.block_reward_for_block(chain, 0) | ||
assert five_eth == Chain.block_reward_for_block(chain, 1) | ||
end | ||
end | ||
|
||
describe "after_homestead?/2" do | ||
test "checks whether or not a block number is after the homestead transition" do | ||
homestead_transition = 1_150_000 | ||
|
||
chain = Chain.load_chain(:foundation) | ||
|
||
assert Chain.after_homestead?(chain, homestead_transition) | ||
assert Chain.after_homestead?(chain, homestead_transition + 1) | ||
refute Chain.after_homestead?(chain, homestead_transition - 1) | ||
end | ||
end | ||
|
||
describe "after_byzantium?/2" do | ||
test "checks whether or not a block number is after the byzatium transition" do | ||
byzantium_transition = 4_370_000 | ||
|
||
chain = Chain.load_chain(:foundation) | ||
|
||
assert Chain.after_byzantium?(chain, byzantium_transition) | ||
assert Chain.after_byzantium?(chain, byzantium_transition + 1) | ||
refute Chain.after_byzantium?(chain, byzantium_transition - 1) | ||
end | ||
end | ||
end |
Oops, something went wrong.