aboutsummaryrefslogtreecommitdiffstats
path: root/vm/address.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-10 03:27:57 +0800
committerobscuren <geffobscura@gmail.com>2014-12-10 03:27:57 +0800
commitacf4b5753fd473f048176a12c42e1b8209035b57 (patch)
treeed9b73ea5a69684e40cfdb546cf729cd29f88db5 /vm/address.go
parent76842b0df8b5605682362bd57fbd6eb315bcaf1f (diff)
downloaddexon-acf4b5753fd473f048176a12c42e1b8209035b57.tar.gz
dexon-acf4b5753fd473f048176a12c42e1b8209035b57.tar.zst
dexon-acf4b5753fd473f048176a12c42e1b8209035b57.zip
Core changes
* Code = '' if gas < len(D) * 5 * Sha3 gas 10 + 10 * len(D), rounding up 32 bytes * Sha256 gas 50 + 50 * len(D), rounding up 32 bytes * Ripmed gas 50 + 50 * len(D), rounding up 32 bytes * Accounts and value transfers no longer reverted
Diffstat (limited to 'vm/address.go')
-rw-r--r--vm/address.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/vm/address.go b/vm/address.go
index 06bd35f6b..be8921a3b 100644
--- a/vm/address.go
+++ b/vm/address.go
@@ -12,7 +12,7 @@ type Address interface {
}
type PrecompiledAddress struct {
- Gas *big.Int
+ Gas func(l int) *big.Int
fn func(in []byte) []byte
}
@@ -21,9 +21,19 @@ func (self PrecompiledAddress) Call(in []byte) []byte {
}
var Precompiled = map[uint64]*PrecompiledAddress{
- 1: &PrecompiledAddress{big.NewInt(500), ecrecoverFunc},
- 2: &PrecompiledAddress{big.NewInt(100), sha256Func},
- 3: &PrecompiledAddress{big.NewInt(100), ripemd160Func},
+ 1: &PrecompiledAddress{func(l int) *big.Int {
+ return GasEcrecover
+ }, ecrecoverFunc},
+ 2: &PrecompiledAddress{func(l int) *big.Int {
+ n := big.NewInt(int64(l+31)/32 + 1)
+ n.Mul(n, GasSha256)
+ return n
+ }, sha256Func},
+ 3: &PrecompiledAddress{func(l int) *big.Int {
+ n := big.NewInt(int64(l+31)/32 + 1)
+ n.Mul(n, GasRipemd)
+ return n
+ }, ripemd160Func},
}
func sha256Func(in []byte) []byte {