aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/geth/js.go2
-rw-r--r--cmd/geth/main.go2
-rw-r--r--core/vm/disasm.go21
-rw-r--r--miner/miner.go7
-rw-r--r--rpc/api.go29
-rw-r--r--rpc/args.go64
-rw-r--r--tests/vm/gh_test.go26
7 files changed, 88 insertions, 63 deletions
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index f99051a1e..342a80bd2 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -141,7 +141,7 @@ var net = web3.net;
utils.Fatalf("Error setting namespaces: %v", err)
}
- js.re.Eval(globalRegistrar + "registrar = new GlobalRegistrar(\"" + globalRegistrarAddr + "\");")
+ js.re.Eval(globalRegistrar + "registrar = GlobalRegistrar.at(\"" + globalRegistrarAddr + "\");")
}
var ds, _ = docserver.New("/")
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 6d345a18b..513b405ff 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -48,7 +48,7 @@ import _ "net/http/pprof"
const (
ClientIdentifier = "Geth"
- Version = "0.9.22"
+ Version = "0.9.23"
)
var (
diff --git a/core/vm/disasm.go b/core/vm/disasm.go
new file mode 100644
index 000000000..858ee684a
--- /dev/null
+++ b/core/vm/disasm.go
@@ -0,0 +1,21 @@
+package vm
+
+import "fmt"
+
+func Disasm(code []byte) []string {
+ var out []string
+ for pc := uint64(0); pc < uint64(len(code)); pc++ {
+ op := OpCode(code[pc])
+ out = append(out, op.String())
+
+ switch op {
+ case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32:
+ a := uint64(op) - uint64(PUSH1) + 1
+ out = append(out, fmt.Sprintf("0x%x", code[pc+1:pc+1+a]))
+
+ pc += a
+ }
+ }
+
+ return out
+}
diff --git a/miner/miner.go b/miner/miner.go
index c9427f302..20ca81648 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -45,6 +45,7 @@ func New(eth core.Backend, mux *event.TypeMux, pow pow.PoW) *Miner {
// and halt your mining operation for as long as the DOS continues.
func (self *Miner) update() {
events := self.mux.Subscribe(downloader.StartEvent{}, downloader.DoneEvent{}, downloader.FailedEvent{})
+out:
for ev := range events.Chan() {
switch ev.(type) {
case downloader.StartEvent:
@@ -62,9 +63,11 @@ func (self *Miner) update() {
if shouldStart {
self.Start(self.coinbase, self.threads)
}
+ // unsubscribe. we're only interested in this event once
+ events.Unsubscribe()
+ // stop immediately and ignore all further pending events
+ break out
}
- // unsubscribe. we're only interested in this event once
- events.Unsubscribe()
}
}
diff --git a/rpc/api.go b/rpc/api.go
index b6f6ac3f9..6b37acb03 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -6,6 +6,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
@@ -158,16 +159,16 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
v := api.xethAtStateNum(args.BlockNumber).CodeAtBytes(args.Address)
*reply = newHexData(v)
- // case "eth_sign":
- // args := new(NewSigArgs)
- // if err := json.Unmarshal(req.Params, &args); err != nil {
- // return err
- // }
- // v, err := api.xeth().Sign(args.From, args.Data, false)
- // if err != nil {
- // return err
- // }
- // *reply = v
+ case "eth_sign":
+ args := new(NewSigArgs)
+ if err := json.Unmarshal(req.Params, &args); err != nil {
+ return err
+ }
+ v, err := api.xeth().Sign(args.From, args.Data, false)
+ if err != nil {
+ return err
+ }
+ *reply = v
case "eth_sendTransaction", "eth_transact":
args := new(NewTxArgs)
@@ -344,7 +345,6 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return NewNotImplementedError(req.Method)
case "eth_compileSolidity":
-
solc, _ := api.xeth().Solc()
if solc == nil {
return NewNotAvailableError(req.Method, "solc (solidity compiler) not found")
@@ -562,6 +562,13 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
case "eth_hashrate":
*reply = newHexNum(api.xeth().HashRate())
+ case "ext_disasm":
+ args := new(SourceArgs)
+ if err := json.Unmarshal(req.Params, &args); err != nil {
+ return err
+ }
+
+ *reply = vm.Disasm(common.FromHex(args.Source))
// case "eth_register":
// // Placeholder for actual type
diff --git a/rpc/args.go b/rpc/args.go
index 27824f12c..686872a59 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -166,45 +166,45 @@ type NewTxArgs struct {
BlockNumber int64
}
-// type NewSigArgs struct {
-// From string
-// Data string
-// }
+type NewSigArgs struct {
+ From string
+ Data string
+}
-// func (args *NewSigArgs) UnmarshalJSON(b []byte) (err error) {
-// var obj []json.RawMessage
-// var ext struct {
-// From string
-// Data string
-// }
+func (args *NewSigArgs) UnmarshalJSON(b []byte) (err error) {
+ var obj []json.RawMessage
+ var ext struct {
+ From string
+ Data string
+ }
-// // Decode byte slice to array of RawMessages
-// if err := json.Unmarshal(b, &obj); err != nil {
-// return NewDecodeParamError(err.Error())
-// }
+ // Decode byte slice to array of RawMessages
+ if err := json.Unmarshal(b, &obj); err != nil {
+ return NewDecodeParamError(err.Error())
+ }
-// // Check for sufficient params
-// if len(obj) < 1 {
-// return NewInsufficientParamsError(len(obj), 1)
-// }
+ // Check for sufficient params
+ if len(obj) < 1 {
+ return NewInsufficientParamsError(len(obj), 1)
+ }
-// // Decode 0th RawMessage to temporary struct
-// if err := json.Unmarshal(obj[0], &ext); err != nil {
-// return NewDecodeParamError(err.Error())
-// }
+ // Decode 0th RawMessage to temporary struct
+ if err := json.Unmarshal(obj[0], &ext); err != nil {
+ return NewDecodeParamError(err.Error())
+ }
-// if len(ext.From) == 0 {
-// return NewValidationError("from", "is required")
-// }
+ if len(ext.From) == 0 {
+ return NewValidationError("from", "is required")
+ }
-// if len(ext.Data) == 0 {
-// return NewValidationError("data", "is required")
-// }
+ if len(ext.Data) == 0 {
+ return NewValidationError("data", "is required")
+ }
-// args.From = ext.From
-// args.Data = ext.Data
-// return nil
-// }
+ args.From = ext.From
+ args.Data = ext.Data
+ return nil
+}
func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
var obj []json.RawMessage
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go
index 68eb4cb45..2f76084d0 100644
--- a/tests/vm/gh_test.go
+++ b/tests/vm/gh_test.go
@@ -2,7 +2,6 @@ package vm
import (
"bytes"
- "io/ioutil"
"math/big"
"os"
"path/filepath"
@@ -373,21 +372,16 @@ func TestWallet(t *testing.T) {
RunVmTest(fn, t)
}
-func TestRandom(t *testing.T) {
- // TODO: fix JSON EOF bug and unskip
- t.Skip()
- fileNames := make([]string, 1024)
- fileInfos, err := ioutil.ReadDir("../files/StateTests/RandomTests")
- if err != nil {
- t.Errorf("Could not read StateTests/RandomTests dir: %v", err)
- return
- }
- for _, fileInfo := range fileInfos {
- fileNames = append(fileNames, fileInfo.Name())
+func TestStateTestsRandom(t *testing.T) {
+ fns, _ := filepath.Glob("../files/StateTests/RandomTests/*")
+ for _, fn := range fns {
+ RunVmTest(fn, t)
}
+}
- //for _, f := range fileNames {
- path := filepath.Join("../files/StateTests/RandomTests/", fileNames[0])
- RunVmTest(path, t)
- //}
+func TestVMRandom(t *testing.T) {
+ fns, _ := filepath.Glob("../files/VMTests/RandomTests/*")
+ for _, fn := range fns {
+ RunVmTest(fn, t)
+ }
}