@ -72,6 +72,7 @@ var (
FeeCollectEpoch : EpochTBD ,
LeaderRotationEpoch : EpochTBD ,
LeaderRotationBlocksCount : 64 ,
ValidatorCodeFixEpoch : EpochTBD ,
}
// TestnetChainConfig contains the chain parameters to run a node on the harmony test network.
@ -112,6 +113,7 @@ var (
LeaderRotationEpoch : EpochTBD ,
LeaderRotationBlocksCount : 64 ,
FeeCollectEpoch : EpochTBD ,
ValidatorCodeFixEpoch : EpochTBD ,
}
// PangaeaChainConfig contains the chain parameters for the Pangaea network.
// All features except for CrossLink are enabled at launch.
@ -152,6 +154,7 @@ var (
LeaderRotationEpoch : EpochTBD ,
LeaderRotationBlocksCount : 64 ,
FeeCollectEpoch : EpochTBD ,
ValidatorCodeFixEpoch : EpochTBD ,
}
// PartnerChainConfig contains the chain parameters for the Partner network.
@ -193,6 +196,7 @@ var (
FeeCollectEpoch : big . NewInt ( 574 ) ,
LeaderRotationEpoch : EpochTBD ,
LeaderRotationBlocksCount : 64 ,
ValidatorCodeFixEpoch : EpochTBD ,
}
// StressnetChainConfig contains the chain parameters for the Stress test network.
@ -234,6 +238,7 @@ var (
FeeCollectEpoch : EpochTBD ,
LeaderRotationEpoch : EpochTBD ,
LeaderRotationBlocksCount : 64 ,
ValidatorCodeFixEpoch : EpochTBD ,
}
// LocalnetChainConfig contains the chain parameters to run for local development.
@ -274,6 +279,7 @@ var (
LeaderRotationEpoch : EpochTBD ,
LeaderRotationBlocksCount : 5 ,
FeeCollectEpoch : big . NewInt ( 5 ) ,
ValidatorCodeFixEpoch : EpochTBD ,
}
// AllProtocolChanges ...
@ -316,6 +322,7 @@ var (
big . NewInt ( 1 ) , // LeaderRotationEpoch
64 , // LeaderRotationBlocksCount
big . NewInt ( 0 ) , // FeeCollectEpoch
big . NewInt ( 0 ) , // ValidatorCodeFixEpoch
}
// TestChainConfig ...
@ -358,6 +365,7 @@ var (
big . NewInt ( 1 ) , // LeaderRotationEpoch
64 , // LeaderRotationBlocksCount
big . NewInt ( 0 ) , // FeeCollectEpoch
big . NewInt ( 0 ) , // ValidatorCodeFixEpoch
}
// TestRules ...
@ -507,6 +515,13 @@ type ChainConfig struct {
// Then before FeeCollectEpoch, txn fees are burned.
// After FeeCollectEpoch, txn fees paid to FeeCollector account.
FeeCollectEpoch * big . Int
// ValidatorCodeFixEpoch is the first epoch that fixes the issue of validator code
// being available in Solidity. This is a temporary fix until we have a better
// solution.
// Contracts can check the (presence of) validator code by calling the following:
// extcodesize, extcodecopy and extcodehash.
ValidatorCodeFixEpoch * big . Int ` json:"validator-code-fix-epoch,omitempty" `
}
// String implements the fmt.Stringer interface.
@ -541,6 +556,8 @@ func (c *ChainConfig) mustValid() {
"must satisfy: StakingPrecompileEpoch >= PreStakingEpoch" )
require ( c . CrossShardXferPrecompileEpoch . Cmp ( c . CrossTxEpoch ) > 0 ,
"must satisfy: CrossShardXferPrecompileEpoch > CrossTxEpoch" )
require ( c . ValidatorCodeFixEpoch . Cmp ( c . EthCompatibleEpoch ) >= 0 ,
"must satisfy: ValidatorCodeFixEpoch >= EthCompatibleEpoch" )
}
// IsEIP155 returns whether epoch is either equal to the EIP155 fork epoch or greater.
@ -716,6 +733,10 @@ func (c *ChainConfig) IsFeeCollectEpoch(epoch *big.Int) bool {
return isForked ( c . FeeCollectEpoch , epoch )
}
func ( c * ChainConfig ) IsValidatorCodeFix ( epoch * big . Int ) bool {
return isForked ( c . ValidatorCodeFixEpoch , epoch )
}
// UpdateEthChainIDByShard update the ethChainID based on shard ID.
func UpdateEthChainIDByShard ( shardID uint32 ) {
once . Do ( func ( ) {
@ -773,6 +794,7 @@ type Rules struct {
IsStakingPrecompile , IsCrossShardXferPrecompile ,
// eip-155 chain id fix
IsChainIdFix bool
IsValidatorCodeFix bool
}
// Rules ensures c's ChainID is not nil.
@ -797,5 +819,6 @@ func (c *ChainConfig) Rules(epoch *big.Int) Rules {
IsStakingPrecompile : c . IsStakingPrecompile ( epoch ) ,
IsCrossShardXferPrecompile : c . IsCrossShardXferPrecompile ( epoch ) ,
IsChainIdFix : c . IsChainIdFix ( epoch ) ,
IsValidatorCodeFix : c . IsValidatorCodeFix ( epoch ) ,
}
}