Add IsCallisto in config to keep the compatibility with go-ethereum

This commit is contained in:
Yohan Graterol 2017-11-30 23:51:37 -05:00
parent 6ed8fbfc4b
commit 6c1f21e405
5 changed files with 4767 additions and 17 deletions

View file

@ -463,7 +463,7 @@ func TestBindings(t *testing.T) {
if err != nil {
t.Fatalf("failed check for goimports symlink bug: %v", err)
}
if !strings.Contains(string(linkTestDeps), "go-ethereum") {
if !strings.Contains(string(linkTestDeps), "go-callisto") {
t.Skip("symlinked environment doesn't support bind (https://github.com/golang/go/issues/14845)")
}
// Create a temporary workspace for the test suite

View file

@ -10,11 +10,11 @@ fi
# Create fake Go workspace if it doesn't exist yet.
workspace="$PWD/build/_workspace"
root="$PWD"
ethdir="$workspace/src/github.com/ethereum"
if [ ! -L "$ethdir/go-ethereum" ]; then
ethdir="$workspace/src/github.com/EthereumCommonwealth"
if [ ! -L "$ethdir/go-callisto" ]; then
mkdir -p "$ethdir"
cd "$ethdir"
ln -s ../../../../../. go-ethereum
ln -s ../../../../../. go-callisto
cd "$root"
fi
@ -23,8 +23,8 @@ GOPATH="$workspace"
export GOPATH
# Run the command inside the workspace.
cd "$ethdir/go-ethereum"
PWD="$ethdir/go-ethereum"
cd "$ethdir/go-callisto"
PWD="$ethdir/go-callisto"
# Launch the arguments with the configured environment.
exec "$@"

View file

@ -37,8 +37,8 @@ import (
// Ethash proof-of-work protocol constants.
var (
callistoBlockReward, _ = new(big.Int).SetString("10000000000000000000", 10) // Block reward in wei for successfully mining a block
frontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
byzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
FrontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
ByzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
maxUncles = 2 // Maximum number of uncles allowed in a single block
)
@ -530,10 +530,16 @@ var (
// TODO (karalabe): Move the chain maker into this package and make this private!
func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
// Select the correct block reward based on chain progression
blockReward := callistoBlockReward
//if config.IsByzantium(header.Number) {
// blockReward = byzantiumBlockReward
//}
blockReward := FrontierBlockReward
if config.IsCallisto(header.Number) {
blockReward = callistoBlockReward
}
if config.IsByzantium(header.Number) {
blockReward = ByzantiumBlockReward
}
treasuryPercent := getTreasuryPercent(header)
reward := new(big.Int).Set(blockReward)
treasuryReward := new(big.Int)
@ -551,9 +557,13 @@ func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header
r.Div(blockReward, big32)
reward.Add(reward, r)
}
reward.Sub(reward, treasuryReward)
if config.IsCallisto(header.Number) {
reward.Sub(reward, treasuryReward)
state.AddBalance(common.HexToAddress("SET ADDRESS IN SETTINGS"), treasuryReward)
}
state.AddBalance(header.Coinbase, reward)
state.AddBalance(common.HexToAddress("SET ADDRESS IN SETTINGS"), treasuryReward)
}
// getTreasuryPercent computes the current block reward's percent will be for

View file

@ -82,16 +82,16 @@ var (
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil}
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil}
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Clique consensus.
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, &CliqueConfig{Period: 0, Epoch: 30000}}
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, &CliqueConfig{Period: 0, Epoch: 30000}}
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil}
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil}
TestRules = TestChainConfig.Rules(new(big.Int))
)
@ -117,6 +117,7 @@ type ChainConfig struct {
ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium)
CallistoBlock *big.Int `json:"byzantiumBlock,omitempty"`
// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`
@ -161,6 +162,7 @@ func (c *ChainConfig) String() string {
c.EIP155Block,
c.EIP158Block,
c.ByzantiumBlock,
c.CallistoBlock,
engine,
)
}
@ -191,6 +193,10 @@ func (c *ChainConfig) IsByzantium(num *big.Int) bool {
return isForked(c.ByzantiumBlock, num)
}
func (c *ChainConfig) IsCallisto(num *big.Int) bool {
return isForked(c.CallistoBlock, num)
}
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
//
// The returned GasTable's fields shouldn't, under any circumstances, be changed.

4734
test_result Normal file

File diff suppressed because it is too large Load diff