diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-04-02 11:17:15 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-04-02 12:22:32 +0800 |
commit | c26c8d3a44cdd45994b6d99777d620565bab8f9c (patch) | |
tree | 6ab5a74981e9fb9f869f1ef884a375163b898113 | |
parent | 516ec28544e0f9c76e18d82742d3ae58cfb59cc1 (diff) | |
download | go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.gz go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.bz2 go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.lz go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.xz go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.zst go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.zip |
Read most protocol params from common/params.json
* Add params package with exported variables generated from
github.com/ethereum/common/blob/master/params.json
* Use params package variables in applicable places
* Add check for minimum gas limit in validation of block's gas limit
* Remove common/params.json from go-ethereum to avoid
outdated version of it
-rw-r--r-- | core/block_processor.go | 11 | ||||
-rw-r--r-- | core/chain_manager.go | 14 | ||||
-rw-r--r-- | core/execution.go | 3 | ||||
-rw-r--r-- | core/genesis.go | 8 | ||||
-rw-r--r-- | core/state_transition.go | 9 | ||||
-rw-r--r-- | core/vm/address.go | 15 | ||||
-rw-r--r-- | core/vm/common.go | 2 | ||||
-rw-r--r-- | core/vm/errors.go | 3 | ||||
-rw-r--r-- | core/vm/gas.go | 58 | ||||
-rw-r--r-- | core/vm/stack.go | 2 | ||||
-rw-r--r-- | core/vm/vm.go | 43 | ||||
-rw-r--r-- | core/vm/vm_jit.go | 4 | ||||
-rw-r--r-- | generators/default.json | 56 | ||||
-rw-r--r-- | generators/defaults.go | 7 | ||||
-rwxr-xr-x | params/protocol_params.go | 54 |
15 files changed, 126 insertions, 163 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index f7f0cd188..18667c449 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" "github.com/ethereum/go-ethereum/rlp" "gopkg.in/fatih/set.v0" @@ -252,7 +253,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big // an uncle or anything that isn't on the current block chain. // Validation validates easy over difficult (dagger takes longer time = difficult) func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error { - if len(block.Extra) > 1024 { + if big.NewInt(int64(len(block.Extra))).Cmp(params.MaximumExtraDataSize) == 1 { return fmt.Errorf("Block extra data too long (%d)", len(block.Extra)) } @@ -261,13 +262,11 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error { return fmt.Errorf("Difficulty check failed for block %v, %v", block.Difficulty, expd) } - // TODO: use use minGasLimit and gasLimitBoundDivisor from - // https://github.com/ethereum/common/blob/master/params.json - // block.gasLimit - parent.gasLimit <= parent.gasLimit / 1024 + // block.gasLimit - parent.gasLimit <= parent.gasLimit / GasLimitBoundDivisor a := new(big.Int).Sub(block.GasLimit, parent.GasLimit) a.Abs(a) - b := new(big.Int).Div(parent.GasLimit, big.NewInt(1024)) - if !(a.Cmp(b) < 0) { + b := new(big.Int).Div(parent.GasLimit, params.GasLimitBoundDivisor) + if !(a.Cmp(b) < 0) || (block.GasLimit.Cmp(params.MinGasLimit) == -1) { return fmt.Errorf("GasLimit check failed for block %v (%v > %v)", block.GasLimit, a, b) } diff --git a/core/chain_manager.go b/core/chain_manager.go index f0d3fd4cf..d97a94b06 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" ) @@ -32,18 +33,15 @@ type StateQuery interface { func CalcDifficulty(block, parent *types.Header) *big.Int { diff := new(big.Int) - diffBoundDiv := big.NewInt(2048) - min := big.NewInt(131072) - - adjust := new(big.Int).Div(parent.Difficulty, diffBoundDiv) - if (block.Time - parent.Time) < 8 { + adjust := new(big.Int).Div(parent.Difficulty, params.DifficultyBoundDivisor) + if big.NewInt(int64(block.Time)-int64(parent.Time)).Cmp(params.DurationLimit) < 0 { diff.Add(parent.Difficulty, adjust) } else { diff.Sub(parent.Difficulty, adjust) } - if diff.Cmp(min) < 0 { - return min + if diff.Cmp(params.MinimumDifficulty) < 0 { + return params.MinimumDifficulty } return diff @@ -76,7 +74,7 @@ func CalcGasLimit(parent, block *types.Block) *big.Int { result := new(big.Int).Add(previous, curInt) result.Div(result, big.NewInt(1024)) - return common.BigMax(GenesisGasLimit, result) + return common.BigMax(params.GenesisGasLimit, result) } type ChainManager struct { diff --git a/core/execution.go b/core/execution.go index 93fb03ecc..8134471d1 100644 --- a/core/execution.go +++ b/core/execution.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" ) type Execution struct { @@ -43,7 +44,7 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm. env := self.env evm := self.evm - if env.Depth() == vm.MaxCallDepth { + if env.Depth() > int(params.CallCreateDepth.Int64()) { caller.ReturnGas(self.Gas, self.price) return nil, vm.DepthError{} diff --git a/core/genesis.go b/core/genesis.go index 7958157a4..13656c40c 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -3,12 +3,12 @@ package core import ( "encoding/json" "fmt" - "math/big" "os" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" ) /* @@ -18,13 +18,11 @@ import ( var ZeroHash256 = make([]byte, 32) var ZeroHash160 = make([]byte, 20) var ZeroHash512 = make([]byte, 64) -var GenesisDiff = big.NewInt(131072) -var GenesisGasLimit = big.NewInt(3141592) func GenesisBlock(db common.Database) *types.Block { - genesis := types.NewBlock(common.Hash{}, common.Address{}, common.Hash{}, GenesisDiff, 42, "") + genesis := types.NewBlock(common.Hash{}, common.Address{}, common.Hash{}, params.GenesisDifficulty, 42, "") genesis.Header().Number = common.Big0 - genesis.Header().GasLimit = GenesisGasLimit + genesis.Header().GasLimit = params.GenesisGasLimit genesis.Header().GasUsed = common.Big0 genesis.Header().Time = 0 diff --git a/core/state_transition.go b/core/state_transition.go index 7616686db..1994cabf6 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" ) const tryJit = false @@ -178,7 +179,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er ) // Transaction gas - if err = self.UseGas(vm.GasTx); err != nil { + if err = self.UseGas(params.TxGas); err != nil { return nil, nil, InvalidTxError(err) } @@ -186,9 +187,9 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er dgas := new(big.Int) for _, byt := range self.data { if byt != 0 { - dgas.Add(dgas, vm.GasTxDataNonzeroByte) + dgas.Add(dgas, params.TxDataNonZeroGas) } else { - dgas.Add(dgas, vm.GasTxDataZeroByte) + dgas.Add(dgas, params.TxDataZeroGas) } } @@ -202,7 +203,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er ret, err, ref = vmenv.Create(sender, self.msg.Data(), self.gas, self.gasPrice, self.value) if err == nil { dataGas := big.NewInt(int64(len(ret))) - dataGas.Mul(dataGas, vm.GasCreateByte) + dataGas.Mul(dataGas, params.CreateDataGas) if err := self.UseGas(dataGas); err == nil { ref.SetCode(ret) } else { diff --git a/core/vm/address.go b/core/vm/address.go index 0b3a95dd0..df801863f 100644 --- a/core/vm/address.go +++ b/core/vm/address.go @@ -5,6 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" ) type Address interface { @@ -27,28 +28,28 @@ func PrecompiledContracts() map[string]*PrecompiledAccount { return map[string]*PrecompiledAccount{ // ECRECOVER string(common.LeftPadBytes([]byte{1}, 20)): &PrecompiledAccount{func(l int) *big.Int { - return GasEcrecover + return params.EcrecoverGas }, ecrecoverFunc}, // SHA256 string(common.LeftPadBytes([]byte{2}, 20)): &PrecompiledAccount{func(l int) *big.Int { n := big.NewInt(int64(l+31) / 32) - n.Mul(n, GasSha256Word) - return n.Add(n, GasSha256Base) + n.Mul(n, params.Sha256WordGas) + return n.Add(n, params.Sha256Gas) }, sha256Func}, // RIPEMD160 string(common.LeftPadBytes([]byte{3}, 20)): &PrecompiledAccount{func(l int) *big.Int { n := big.NewInt(int64(l+31) / 32) - n.Mul(n, GasRipemdWord) - return n.Add(n, GasRipemdBase) + n.Mul(n, params.Ripemd160WordGas) + return n.Add(n, params.Ripemd160Gas) }, ripemd160Func}, string(common.LeftPadBytes([]byte{4}, 20)): &PrecompiledAccount{func(l int) *big.Int { n := big.NewInt(int64(l+31) / 32) - n.Mul(n, GasIdentityWord) + n.Mul(n, params.IdentityWordGas) - return n.Add(n, GasIdentityBase) + return n.Add(n, params.IdentityGas) }, memCpy}, } } diff --git a/core/vm/common.go b/core/vm/common.go index 5ff4e05f2..0a93c3dd9 100644 --- a/core/vm/common.go +++ b/core/vm/common.go @@ -20,8 +20,6 @@ const ( JitVmTy MaxVmTy - MaxCallDepth = 1025 - LogTyPretty byte = 0x1 LogTyDiff byte = 0x2 ) diff --git a/core/vm/errors.go b/core/vm/errors.go index ab011bd62..fc3459de0 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + "github.com/ethereum/go-ethereum/params" "math/big" ) @@ -42,7 +43,7 @@ func IsStack(err error) bool { type DepthError struct{} func (self DepthError) Error() string { - return fmt.Sprintf("Max call depth exceeded (%d)", MaxCallDepth) + return fmt.Sprintf("Max call depth exceeded (%d)", params.CallCreateDepth) } func IsDepthErr(err error) bool { diff --git a/core/vm/gas.go b/core/vm/gas.go index 976333a78..f7abe63f8 100644 --- a/core/vm/gas.go +++ b/core/vm/gas.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + "github.com/ethereum/go-ethereum/params" "math/big" ) @@ -13,45 +14,10 @@ var ( GasSlowStep = big.NewInt(10) GasExtStep = big.NewInt(20) - GasStorageGet = big.NewInt(50) - GasStorageAdd = big.NewInt(20000) - GasStorageMod = big.NewInt(5000) - GasLogBase = big.NewInt(375) - GasLogTopic = big.NewInt(375) - GasLogByte = big.NewInt(8) - GasCreate = big.NewInt(32000) - GasCreateByte = big.NewInt(200) - GasCall = big.NewInt(40) - GasCallValueTransfer = big.NewInt(9000) - GasStipend = big.NewInt(2300) - GasCallNewAccount = big.NewInt(25000) - GasReturn = big.NewInt(0) - GasStop = big.NewInt(0) - GasJumpDest = big.NewInt(1) + GasReturn = big.NewInt(0) + GasStop = big.NewInt(0) - RefundStorage = big.NewInt(15000) - RefundSuicide = big.NewInt(24000) - - GasMemWord = big.NewInt(3) - GasQuadCoeffDenom = big.NewInt(512) - GasContractByte = big.NewInt(200) - GasTransaction = big.NewInt(21000) - GasTxDataNonzeroByte = big.NewInt(68) - GasTxDataZeroByte = big.NewInt(4) - GasTx = big.NewInt(21000) - GasExp = big.NewInt(10) - GasExpByte = big.NewInt(10) - - GasSha3Base = big.NewInt(30) - GasSha3Word = big.NewInt(6) - GasSha256Base = big.NewInt(60) - GasSha256Word = big.NewInt(12) - GasRipemdBase = big.NewInt(600) - GasRipemdWord = big.NewInt(12) - GasEcrecover = big.NewInt(3000) - GasIdentityBase = big.NewInt(15) - GasIdentityWord = big.NewInt(3) - GasCopyWord = big.NewInt(3) + GasContractByte = big.NewInt(200) ) func baseCheck(op OpCode, stack *stack, gas *big.Int) error { @@ -71,8 +37,8 @@ func baseCheck(op OpCode, stack *stack, gas *big.Int) error { return err } - if r.stackPush && len(stack.data)-r.stackPop+1 > 1024 { - return fmt.Errorf("stack limit reached (%d)", maxStack) + if r.stackPush && len(stack.data)-r.stackPop+1 > int(params.StackLimit.Int64()) { + return fmt.Errorf("stack limit reached (%d)", params.StackLimit.Int64()) } gas.Add(gas, r.gas) @@ -145,13 +111,13 @@ var _baseCheck = map[OpCode]req{ BALANCE: {1, GasExtStep, true}, EXTCODESIZE: {1, GasExtStep, true}, EXTCODECOPY: {4, GasExtStep, false}, - SLOAD: {1, GasStorageGet, true}, + SLOAD: {1, params.SloadGas, true}, SSTORE: {2, Zero, false}, - SHA3: {2, GasSha3Base, true}, - CREATE: {3, GasCreate, true}, - CALL: {7, GasCall, true}, - CALLCODE: {7, GasCall, true}, - JUMPDEST: {0, GasJumpDest, false}, + SHA3: {2, params.Sha3Gas, true}, + CREATE: {3, params.CreateGas, true}, + CALL: {7, params.CallGas, true}, + CALLCODE: {7, params.CallGas, true}, + JUMPDEST: {0, params.JumpdestGas, false}, SUICIDE: {1, Zero, false}, RETURN: {2, Zero, false}, PUSH1: {0, GasFastestStep, true}, diff --git a/core/vm/stack.go b/core/vm/stack.go index 168637708..bb232d0b9 100644 --- a/core/vm/stack.go +++ b/core/vm/stack.go @@ -5,8 +5,6 @@ import ( "math/big" ) -const maxStack = 1024 - func newStack() *stack { return &stack{} } diff --git a/core/vm/vm.go b/core/vm/vm.go index 59c64e8a3..6222ef8c2 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" ) type Vm struct { @@ -640,7 +641,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) { } else { // gas < len(ret) * CreateDataGas == NO_CODE dataGas := big.NewInt(int64(len(ret))) - dataGas.Mul(dataGas, GasCreateByte) + dataGas.Mul(dataGas, params.CreateDataGas) if context.UseGas(dataGas) { ref.SetCode(ret) } @@ -667,7 +668,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) { args := mem.Get(inOffset.Int64(), inSize.Int64()) if len(value.Bytes()) > 0 { - gas.Add(gas, GasStipend) + gas.Add(gas, params.CallStipend) } var ( @@ -759,13 +760,13 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo mSize, mStart := stack.data[stack.len()-2], stack.data[stack.len()-1] - gas.Add(gas, GasLogBase) - gas.Add(gas, new(big.Int).Mul(big.NewInt(int64(n)), GasLogTopic)) - gas.Add(gas, new(big.Int).Mul(mSize, GasLogByte)) + gas.Add(gas, params.LogGas) + gas.Add(gas, new(big.Int).Mul(big.NewInt(int64(n)), params.LogTopicGas)) + gas.Add(gas, new(big.Int).Mul(mSize, params.LogDataGas)) newMemSize = calcMemSize(mStart, mSize) case EXP: - gas.Add(gas, new(big.Int).Mul(big.NewInt(int64(len(stack.data[stack.len()-2].Bytes()))), GasExpByte)) + gas.Add(gas, new(big.Int).Mul(big.NewInt(int64(len(stack.data[stack.len()-2].Bytes()))), params.ExpByteGas)) case SSTORE: err := stack.require(2) if err != nil { @@ -777,19 +778,19 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo val := statedb.GetState(context.Address(), common.BigToHash(x)) if len(val) == 0 && len(y.Bytes()) > 0 { // 0 => non 0 - g = GasStorageAdd + g = params.SstoreSetGas } else if len(val) > 0 && len(y.Bytes()) == 0 { - statedb.Refund(self.env.Origin(), RefundStorage) + statedb.Refund(self.env.Origin(), params.SstoreRefundGas) - g = GasStorageMod + g = params.SstoreClearGas } else { // non 0 => non 0 (or 0 => 0) - g = GasStorageMod + g = params.SstoreClearGas } gas.Set(g) case SUICIDE: if !statedb.IsDeleted(context.Address()) { - statedb.Refund(self.env.Origin(), RefundSuicide) + statedb.Refund(self.env.Origin(), params.SuicideRefundGas) } case MLOAD: newMemSize = calcMemSize(stack.peek(), u256(32)) @@ -803,22 +804,22 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo newMemSize = calcMemSize(stack.peek(), stack.data[stack.len()-2]) words := toWordSize(stack.data[stack.len()-2]) - gas.Add(gas, words.Mul(words, GasSha3Word)) + gas.Add(gas, words.Mul(words, params.Sha3WordGas)) case CALLDATACOPY: newMemSize = calcMemSize(stack.peek(), stack.data[stack.len()-3]) words := toWordSize(stack.data[stack.len()-3]) - gas.Add(gas, words.Mul(words, GasCopyWord)) + gas.Add(gas, words.Mul(words, params.CopyGas)) case CODECOPY: newMemSize = calcMemSize(stack.peek(), stack.data[stack.len()-3]) words := toWordSize(stack.data[stack.len()-3]) - gas.Add(gas, words.Mul(words, GasCopyWord)) + gas.Add(gas, words.Mul(words, params.CopyGas)) case EXTCODECOPY: newMemSize = calcMemSize(stack.data[stack.len()-2], stack.data[stack.len()-4]) words := toWordSize(stack.data[stack.len()-4]) - gas.Add(gas, words.Mul(words, GasCopyWord)) + gas.Add(gas, words.Mul(words, params.CopyGas)) case CREATE: newMemSize = calcMemSize(stack.data[stack.len()-2], stack.data[stack.len()-3]) @@ -827,12 +828,12 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo if op == CALL { if self.env.State().GetStateObject(common.BigToAddress(stack.data[stack.len()-2])) == nil { - gas.Add(gas, GasCallNewAccount) + gas.Add(gas, params.CallNewAccountGas) } } if len(stack.data[stack.len()-3].Bytes()) > 0 { - gas.Add(gas, GasCallValueTransfer) + gas.Add(gas, params.CallValueTransferGas) } x := calcMemSize(stack.data[stack.len()-6], stack.data[stack.len()-7]) @@ -848,13 +849,13 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo if newMemSize.Cmp(u256(int64(mem.Len()))) > 0 { oldSize := toWordSize(big.NewInt(int64(mem.Len()))) pow := new(big.Int).Exp(oldSize, common.Big2, Zero) - linCoef := new(big.Int).Mul(oldSize, GasMemWord) - quadCoef := new(big.Int).Div(pow, GasQuadCoeffDenom) + linCoef := new(big.Int).Mul(oldSize, params.MemoryGas) + quadCoef := new(big.Int).Div(pow, params.QuadCoeffDiv) oldTotalFee := new(big.Int).Add(linCoef, quadCoef) pow.Exp(newMemSizeWords, common.Big2, Zero) - linCoef = new(big.Int).Mul(newMemSizeWords, GasMemWord) - quadCoef = new(big.Int).Div(pow, GasQuadCoeffDenom) + linCoef = new(big.Int).Mul(newMemSizeWords, params.MemoryGas) + quadCoef = new(big.Int).Div(pow, params.QuadCoeffDiv) newTotalFee := new(big.Int).Add(linCoef, quadCoef) fee := new(big.Int).Sub(newTotalFee, oldTotalFee) diff --git a/core/vm/vm_jit.go b/core/vm/vm_jit.go index 2b88d8620..991ade318 100644 --- a/core/vm/vm_jit.go +++ b/core/vm/vm_jit.go @@ -18,8 +18,8 @@ import ( "bytes" "errors" "fmt" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/crypto" "math/big" "unsafe" ) @@ -330,7 +330,7 @@ func env_create(_vm unsafe.Pointer, _gas *int64, _value unsafe.Pointer, initData ret, suberr, ref := vm.env.Create(vm.me, nil, initData, gas, vm.price, value) if suberr == nil { dataGas := big.NewInt(int64(len(ret))) // TODO: Nto the best design. env.Create can do it, it has the reference to gas counter - dataGas.Mul(dataGas, GasCreateByte) + dataGas.Mul(dataGas, params.CreateDataGas) gas.Sub(gas, dataGas) *result = hash2llvm(ref.Address()) } diff --git a/generators/default.json b/generators/default.json deleted file mode 100644 index 181a9dd54..000000000 --- a/generators/default.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, - "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, - "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, - "genesisDifficulty": { "v": 131072, "d": "Difficulty of the Genesis block." }, - "minimumDifficulty": { "v": 131072, "d": "The minimum that the difficulty may ever be." }, - "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, - "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, - "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, - "epochDuration": { "v": 30000, "d": "Duration between proof-of-work epochs." }, - "stackLimit": { "v": 1024, "d": "Maximum size of VM stack allowed." }, - - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, - "expGas": { "v": 10, "d": "Once per EXP instuction." }, - "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - - "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, - "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, - - "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, - "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, - "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, - "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, - "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - - "logGas": { "v": 375, "d": "Per LOG* operation." }, - "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, - "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - - "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - - "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, - "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, - "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, - "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - - "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, - "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - - "createDataGas": { "v": 200, "d": "" }, - "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, - "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, - "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - - "copyGas": { "v": 3, "d": "" }, - - "ecrecoverGas": { "v": 3000, "d": "" }, - "sha256Gas": { "v": 60, "d": "" }, - "sha256WordGas": { "v": 12, "d": "" }, - "ripemd160Gas": { "v": 600, "d": "" }, - "ripemd160WordGas": { "v": 120, "d": "" }, - "identityGas": { "v": 15, "d": "" }, - "identityWordGas": { "v": 3, "d": ""} -} diff --git a/generators/defaults.go b/generators/defaults.go index b0c71111c..41d46729c 100644 --- a/generators/defaults.go +++ b/generators/defaults.go @@ -35,13 +35,16 @@ func main() { m := make(map[string]setting) json.Unmarshal(content, &m) - filepath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "core", os.Args[2]) + filepath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "params", os.Args[2]) output, err := os.OpenFile(filepath, os.O_RDWR|os.O_CREATE, os.ModePerm /*0777*/) if err != nil { fatal("error opening file for writing %v\n", err) } - output.WriteString(`package core + output.WriteString(`// DO NOT EDIT!!! +// AUTOGENERATED FROM generators/defaults.go + +package params import "math/big" diff --git a/params/protocol_params.go b/params/protocol_params.go new file mode 100755 index 000000000..d0bc2f4ad --- /dev/null +++ b/params/protocol_params.go @@ -0,0 +1,54 @@ +// DO NOT EDIT!!! +// AUTOGENERATED FROM generators/defaults.go + +package params + +import "math/big" + +var ( + MaximumExtraDataSize = big.NewInt(1024) // 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. + CallNewAccountGas = big.NewInt(25000) // Paid for CALL when the destination address didn't exist prior. + TxGas = big.NewInt(21000) // Per transaction. NOTE: Not payable on data of calls between transactions. + TxDataZeroGas = big.NewInt(4) // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. + GenesisGasLimit = big.NewInt(3141592) // Gas limit of the Genesis block. + 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. + 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. + EcrecoverGas = big.NewInt(3000) // + Sha256WordGas = big.NewInt(12) // + MinGasLimit = big.NewInt(125000) // Minimum the gas limit may ever be. + Sha3Gas = big.NewInt(30) // Once per SHA3 operation. + Sha256Gas = big.NewInt(60) // + IdentityWordGas = big.NewInt(3) // + Sha3WordGas = big.NewInt(6) // Once per word of the SHA3 operation's data. + SstoreResetGas = big.NewInt(5000) // Once per SSTORE operation if the zeroness changes from zero. + SstoreClearGas = big.NewInt(5000) // Once per SSTORE operation if the zeroness doesn't change. + SstoreRefundGas = big.NewInt(15000) // Once per SSTORE operation if the zeroness changes to zero. + JumpdestGas = big.NewInt(1) // Refunded gas, once per SSTORE operation if the zeroness changes to zero. + IdentityGas = big.NewInt(15) // + GasLimitBoundDivisor = big.NewInt(1024) // The bound divisor of the gas limit, used in update calculations. + EpochDuration = big.NewInt(30000) // Duration between proof-of-work epochs. + CallGas = big.NewInt(40) // Once per CALL operation & message call transaction. + CreateDataGas = big.NewInt(200) // + Ripemd160Gas = big.NewInt(600) // + Ripemd160WordGas = big.NewInt(120) // + MinimumDifficulty = big.NewInt(131072) // The minimum that the difficulty may ever be. + CallCreateDepth = big.NewInt(1024) // Maximum depth of call/create stack. + ExpGas = big.NewInt(10) // Once per EXP instuction. + LogGas = big.NewInt(375) // Per LOG* operation. + CopyGas = big.NewInt(3) // + StackLimit = big.NewInt(1024) // Maximum size of VM stack allowed. + TierStepGas = big.NewInt(0) // Once per operation, for a selection of them. + LogTopicGas = big.NewInt(375) // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. + CreateGas = big.NewInt(32000) // Once per CREATE operation & contract-creation transaction. + SuicideRefundGas = big.NewInt(24000) // Refunded following a suicide operation. + MemoryGas = big.NewInt(3) // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. + TxDataNonZeroGas = big.NewInt(68) // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. +) |