Skip to content

Commit

Permalink
core/vm, params: EIP160: EXP reprice
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Nov 13, 2016
1 parent 445feae commit 779ddb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
3 changes: 2 additions & 1 deletion core/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ func calculateGasAndSize(gasTable params.GasTable, env Environment, contract *Co

quadMemGas(mem, newMemSize, gas)
case EXP:
gas.Add(gas, new(big.Int).Mul(big.NewInt(int64(len(stack.data[stack.len()-2].Bytes()))), params.ExpByteGas))
expByteLen := int64((stack.data[stack.len()-2].BitLen() + 7) / 8)
gas.Add(gas, new(big.Int).Mul(big.NewInt(expByteLen), gasTable.ExpByte))
case SSTORE:
err := stack.require(2)
if err != nil {
Expand Down
12 changes: 4 additions & 8 deletions params/gas_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ type GasTable struct {
Calls *big.Int
Suicide *big.Int

Exp *big.Int
ExpOneByte *big.Int
Exp256 *big.Int
ExpByte *big.Int

// CreateBySuicide occurs when the
// refunded account is one that does
Expand All @@ -48,7 +46,7 @@ var (
SLoad: big.NewInt(50),
Calls: big.NewInt(40),
Suicide: big.NewInt(0),
Exp: big.NewInt(20),
ExpByte: big.NewInt(10),

// explicitly set to nil to indicate
// this rule does not apply to homestead.
Expand All @@ -66,7 +64,7 @@ var (
SLoad: big.NewInt(200),
Calls: big.NewInt(700),
Suicide: big.NewInt(5000),
Exp: big.NewInt(20),
ExpByte: big.NewInt(10),

CreateBySuicide: big.NewInt(25000),
}
Expand All @@ -78,9 +76,7 @@ var (
SLoad: big.NewInt(200),
Calls: big.NewInt(700),
Suicide: big.NewInt(5000),
Exp: big.NewInt(80),
ExpOneByte: big.NewInt(160),
Exp256: big.NewInt(2640),
ExpByte: big.NewInt(50),

CreateBySuicide: big.NewInt(25000),
}
Expand Down

0 comments on commit 779ddb1

Please sign in to comment.