diff --git a/eth/backend.go b/eth/backend.go index e2b7fab1627cbb30fa782eab24558a9c3b2512f9..cba1b3939a2e893351090736c3d2da798b422979 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -45,6 +45,7 @@ import ( "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/nat" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/whisper" ) @@ -370,8 +371,8 @@ func New(config *Config) (*Ethereum, error) { eth.miner.SetGasPrice(config.GasPrice) extra := config.Name - if len(extra) > 1024 { - extra = extra[:1024] + if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { + extra = extra[:params.MaximumExtraDataSize.Uint64()] } eth.miner.SetExtra([]byte(extra)) diff --git a/params/protocol_params.go b/params/protocol_params.go index 5c34abe8cd3e686fc6dcce778d20f19735f58ab7..684e06b7ecee6b57dc14c4506d06b358d244d33e 100755 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -22,7 +22,7 @@ package params import "math/big" var ( - MaximumExtraDataSize = big.NewInt(1024) // Maximum size extra data may be after Genesis. + MaximumExtraDataSize = big.NewInt(32) // Maximum size extra data may be after Genesis. ExpByteGas = big.NewInt(10) // Times ceil(log256(exponent)) for the EXP instruction. SloadGas = big.NewInt(50) // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. CallValueTransferGas = big.NewInt(9000) // Paid for CALL when the value transfor is non-zero. @@ -32,7 +32,7 @@ var ( DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. QuadCoeffDiv = big.NewInt(512) // Divisor for the quadratic particle of the memory cost equation. GenesisDifficulty = big.NewInt(131072) // Difficulty of the Genesis block. - DurationLimit = big.NewInt(8) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. SstoreSetGas = big.NewInt(20000) // Once per SLOAD operation. LogDataGas = big.NewInt(8) // Per byte in a LOG* operation's data. CallStipend = big.NewInt(2300) // Free gas given at beginning of call. diff --git a/rpc/api/miner.go b/rpc/api/miner.go index 93507f54a11d02b6a7269696ec9e4bd752c482b9..12203ffe0712eb401aff8aa0bf57ef4a8ff658bf 100644 --- a/rpc/api/miner.go +++ b/rpc/api/miner.go @@ -17,9 +17,12 @@ package api import ( + "fmt" + "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc/codec" "github.com/ethereum/go-ethereum/rpc/shared" ) @@ -122,6 +125,11 @@ func (self *minerApi) SetExtra(req *shared.Request) (interface{}, error) { if err := self.codec.Decode(req.Params, &args); err != nil { return nil, err } + + if uint64(len(args.Data)) > params.MaximumExtraDataSize.Uint64()*2 { + return false, fmt.Errorf("extra datasize can be no longer than %v bytes", params.MaximumExtraDataSize) + } + self.ethereum.Miner().SetExtra([]byte(args.Data)) return true, nil }