core, cmd/puppeth: implement constantinople fix, disable EIP-1283 (#18486)

This PR adds a new fork which disables EIP-1283. Internally it's called Petersburg,
but the genesis/config field is ConstantinopleFix.

The block numbers are:

    7280000 for Constantinople on Mainnet
    7280000 for ConstantinopleFix on Mainnet
    4939394 for ConstantinopleFix on Ropsten
    9999999 for ConstantinopleFix on Rinkeby (real number decided later)

This PR also defaults to using the same ConstantinopleFix number as whatever
Constantinople is set to. That is, it will default to mainnet behaviour if ConstantinopleFix
is not set.This means that for private networks which have already transitioned
to Constantinople, this PR will break the network unless ConstantinopleFix is
explicitly set!
This commit is contained in:
Martin Holst Swende
2019-01-24 11:36:30 +01:00
committed by Felix Lange
parent 9dc5d1a915
commit c7664b0636
11 changed files with 134 additions and 66 deletions

View File

@ -42,9 +42,22 @@ type RLPTest struct {
Out string
}
// FromHex returns the bytes represented by the hexadecimal string s.
// s may be prefixed with "0x".
// This is copy-pasted from bytes.go, which does not return the error
func FromHex(s string) ([]byte, error) {
if len(s) > 1 && (s[0:2] == "0x" || s[0:2] == "0X") {
s = s[2:]
}
if len(s)%2 == 1 {
s = "0" + s
}
return hex.DecodeString(s)
}
// Run executes the test.
func (t *RLPTest) Run() error {
outb, err := hex.DecodeString(t.Out)
outb, err := FromHex(t.Out)
if err != nil {
return fmt.Errorf("invalid hex in Out")
}