forked from mirror/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.1 KiB
67 lines
1.1 KiB
10 years ago
|
package vm
|
||
10 years ago
|
|
||
|
import (
|
||
10 years ago
|
"math/big"
|
||
|
|
||
10 years ago
|
"github.com/ethereum/eth-go/ethlog"
|
||
|
"github.com/ethereum/eth-go/ethutil"
|
||
|
)
|
||
|
|
||
|
var vmlogger = ethlog.NewLogger("VM")
|
||
|
|
||
10 years ago
|
type Type int
|
||
|
|
||
|
const (
|
||
|
StandardVmTy Type = iota
|
||
|
DebugVmTy
|
||
|
|
||
|
MaxVmTy
|
||
|
)
|
||
|
|
||
10 years ago
|
var (
|
||
|
GasStep = big.NewInt(1)
|
||
|
GasSha = big.NewInt(20)
|
||
|
GasSLoad = big.NewInt(20)
|
||
|
GasSStore = big.NewInt(100)
|
||
|
GasBalance = big.NewInt(20)
|
||
|
GasCreate = big.NewInt(100)
|
||
|
GasCall = big.NewInt(20)
|
||
|
GasMemory = big.NewInt(1)
|
||
|
GasData = big.NewInt(5)
|
||
|
GasTx = big.NewInt(500)
|
||
|
|
||
|
Pow256 = ethutil.BigPow(2, 256)
|
||
|
|
||
|
LogTyPretty byte = 0x1
|
||
|
LogTyDiff byte = 0x2
|
||
10 years ago
|
|
||
10 years ago
|
U256 = ethutil.U256
|
||
|
S256 = ethutil.S256
|
||
10 years ago
|
)
|
||
10 years ago
|
|
||
|
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
|
||
|
}
|