aboutsummaryrefslogtreecommitdiffstats
path: root/ethvm/common.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-14 17:48:52 +0800
committerobscuren <geffobscura@gmail.com>2014-10-14 17:48:52 +0800
commitc5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28 (patch)
tree5588276a932ac88daaaf9ca1858106ba3ff007b1 /ethvm/common.go
parent2e894b668a2bde3eb83418cfd9128f3a571e0026 (diff)
downloaddexon-c5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28.tar
dexon-c5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28.tar.gz
dexon-c5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28.tar.bz2
dexon-c5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28.tar.lz
dexon-c5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28.tar.xz
dexon-c5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28.tar.zst
dexon-c5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28.zip
Refactored VM to two separate VMs; std & debug
Standard VM should be about 10x faster than the debug VM. Some error checking has been removed, all of the log statements and therefor quite some unnecessary if-statements.
Diffstat (limited to 'ethvm/common.go')
-rw-r--r--ethvm/common.go40
1 files changed, 39 insertions, 1 deletions
diff --git a/ethvm/common.go b/ethvm/common.go
index 5a3aec648..6854a5219 100644
--- a/ethvm/common.go
+++ b/ethvm/common.go
@@ -1,13 +1,23 @@
package ethvm
import (
+ "math/big"
+
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethutil"
- "math/big"
)
var vmlogger = ethlog.NewLogger("VM")
+type Type int
+
+const (
+ StandardVmTy Type = iota
+ DebugVmTy
+
+ MaxVmTy
+)
+
var (
GasStep = big.NewInt(1)
GasSha = big.NewInt(20)
@@ -24,4 +34,32 @@ var (
LogTyPretty byte = 0x1
LogTyDiff byte = 0x2
+
+ To256 = ethutil.To256
)
+
+const MaxCallDepth = 1024
+
+func calcMemSize(off, l *big.Int) *big.Int {
+ if l.Cmp(ethutil.Big0) == 0 {
+ return ethutil.Big0
+ }
+
+ return new(big.Int).Add(off, l)
+}
+
+// Simple helper
+func u256(n int64) *big.Int {
+ return big.NewInt(n)
+}
+
+// Mainly used for print variables and passing to Print*
+func toValue(val *big.Int) interface{} {
+ // Let's assume a string on right padded zero's
+ b := val.Bytes()
+ if b[0] != 0 && b[len(b)-1] == 0x0 && b[len(b)-2] == 0x0 {
+ return string(b)
+ }
+
+ return val
+}