Commit 9bf513e9 authored by Felix Lange's avatar Felix Lange

Merge ethereum/poc-9 into accounts-integration

Conflicts:
	cmd/utils/cmd.go
	cmd/utils/flags.go
	core/manager.go
	eth/backend.go
	rpc/http/server.go
	xeth/xeth.go
parents cd51860b 676a0de5
......@@ -11,6 +11,8 @@
.DS_Store
*/**/.DS_Store
.ethtest
*/**/*tx_database*
*/**/*dapps*
#*
.#*
......@@ -21,3 +23,5 @@
cmd/ethereum/ethereum
cmd/mist/mist
deploy/osx/Mist.app
deploy/osx/Mist\ Installer.dmg
......@@ -22,8 +22,8 @@
},
{
"ImportPath": "github.com/ethereum/ethash",
"Comment": "v17-63-gbca024b",
"Rev": "bca024b0b30d83ec6798a5d4fa8c5fc6f937009a"
"Comment": "v17-64-ga323708",
"Rev": "a323708b8c4d253b8567bf6c72727d1aec302225"
},
{
"ImportPath": "github.com/ethereum/serpent-go",
......
......@@ -11,7 +11,6 @@ import "C"
import (
"bytes"
"encoding/binary"
"fmt"
"io/ioutil"
"log"
"math/big"
......@@ -293,7 +292,6 @@ func (pow *Ethash) Verify(block pow.Block) bool {
}
func (pow *Ethash) verify(hash []byte, mixDigest []byte, difficulty *big.Int, blockNum uint64, nonce uint64) bool {
fmt.Printf("%x\n%d\n%x\n%x\n", hash, nonce, mixDigest, difficulty.Bytes())
// First check: make sure header, mixDigest, nonce are correct without hitting the DAG
// This is to prevent DOS attacks
chash := (*C.uint8_t)(unsafe.Pointer(&hash[0]))
......
mode: set
github.com/ethereum/go-ethereum/abi/abi.go:27.39,31.32 4 1
github.com/ethereum/go-ethereum/abi/abi.go:35.2,37.8 2 1
github.com/ethereum/go-ethereum/abi/abi.go:31.32,34.3 2 1
github.com/ethereum/go-ethereum/abi/abi.go:40.29,42.2 1 1
github.com/ethereum/go-ethereum/abi/abi.go:51.53,57.16 3 1
github.com/ethereum/go-ethereum/abi/abi.go:61.2,62.16 2 1
github.com/ethereum/go-ethereum/abi/abi.go:65.2,67.12 2 1
github.com/ethereum/go-ethereum/abi/abi.go:57.16,59.3 1 0
github.com/ethereum/go-ethereum/abi/abi.go:62.16,64.3 1 0
github.com/ethereum/go-ethereum/abi/abi.go:79.71,83.25 3 1
github.com/ethereum/go-ethereum/abi/abi.go:94.2,94.17 1 1
github.com/ethereum/go-ethereum/abi/abi.go:83.25,87.17 3 1
github.com/ethereum/go-ethereum/abi/abi.go:90.3,90.31 1 1
github.com/ethereum/go-ethereum/abi/abi.go:87.17,89.4 1 1
github.com/ethereum/go-ethereum/abi/abi.go:102.71,104.12 2 1
github.com/ethereum/go-ethereum/abi/abi.go:109.2,109.36 1 1
github.com/ethereum/go-ethereum/abi/abi.go:113.2,114.16 2 1
github.com/ethereum/go-ethereum/abi/abi.go:119.2,122.20 3 1
github.com/ethereum/go-ethereum/abi/abi.go:104.12,106.3 1 1
github.com/ethereum/go-ethereum/abi/abi.go:109.36,111.3 1 1
github.com/ethereum/go-ethereum/abi/abi.go:114.16,116.3 1 1
github.com/ethereum/go-ethereum/abi/abi.go:125.50,127.55 2 1
github.com/ethereum/go-ethereum/abi/abi.go:131.2,132.33 2 1
github.com/ethereum/go-ethereum/abi/abi.go:136.2,136.12 1 1
github.com/ethereum/go-ethereum/abi/abi.go:127.55,129.3 1 0
github.com/ethereum/go-ethereum/abi/abi.go:132.33,134.3 1 1
github.com/ethereum/go-ethereum/abi/abi.go:139.42,143.41 3 1
github.com/ethereum/go-ethereum/abi/abi.go:147.2,147.17 1 1
github.com/ethereum/go-ethereum/abi/abi.go:143.41,145.3 1 0
github.com/ethereum/go-ethereum/abi/numbers.go:39.30,41.2 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:43.30,46.32 3 1
github.com/ethereum/go-ethereum/abi/numbers.go:56.2,56.12 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:46.32,47.25 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:47.25,48.14 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:52.4,52.9 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:48.14,50.13 2 1
github.com/ethereum/go-ethereum/abi/numbers.go:59.30,61.2 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:63.29,65.2 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:67.51,68.36 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:91.2,91.12 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:69.2,70.19 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:75.2,76.19 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:81.2,83.19 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:70.19,72.4 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:72.4,74.4 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:76.19,78.4 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:78.4,80.4 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:83.19,85.4 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:85.4,87.4 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:94.37,95.18 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:101.2,101.14 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:96.2,97.14 1 1
github.com/ethereum/go-ethereum/abi/numbers.go:98.2,99.14 1 1
github.com/ethereum/go-ethereum/abi/type.go:32.46,35.16 2 1
github.com/ethereum/go-ethereum/abi/type.go:38.2,43.9 3 1
github.com/ethereum/go-ethereum/abi/type.go:55.2,56.16 2 1
github.com/ethereum/go-ethereum/abi/type.go:60.2,64.55 4 1
github.com/ethereum/go-ethereum/abi/type.go:69.2,69.13 1 1
github.com/ethereum/go-ethereum/abi/type.go:111.2,113.8 2 1
github.com/ethereum/go-ethereum/abi/type.go:35.16,37.3 1 0
github.com/ethereum/go-ethereum/abi/type.go:44.2,47.17 2 1
github.com/ethereum/go-ethereum/abi/type.go:48.2,50.12 2 1
github.com/ethereum/go-ethereum/abi/type.go:51.2,52.60 1 0
github.com/ethereum/go-ethereum/abi/type.go:56.16,58.3 1 0
github.com/ethereum/go-ethereum/abi/type.go:64.55,67.3 2 1
github.com/ethereum/go-ethereum/abi/type.go:69.13,72.16 3 1
github.com/ethereum/go-ethereum/abi/type.go:73.3,74.21 1 0
github.com/ethereum/go-ethereum/abi/type.go:75.3,76.22 1 1
github.com/ethereum/go-ethereum/abi/type.go:77.3,78.66 1 0
github.com/ethereum/go-ethereum/abi/type.go:80.3,81.16 1 1
github.com/ethereum/go-ethereum/abi/type.go:82.3,86.17 4 0
github.com/ethereum/go-ethereum/abi/type.go:87.3,91.18 4 1
github.com/ethereum/go-ethereum/abi/type.go:92.3,93.27 1 1
github.com/ethereum/go-ethereum/abi/type.go:94.3,95.30 1 0
github.com/ethereum/go-ethereum/abi/type.go:96.3,100.21 4 1
github.com/ethereum/go-ethereum/abi/type.go:101.3,104.17 3 1
github.com/ethereum/go-ethereum/abi/type.go:107.3,108.60 1 0
github.com/ethereum/go-ethereum/abi/type.go:104.17,106.5 1 1
github.com/ethereum/go-ethereum/abi/type.go:116.37,118.2 1 1
github.com/ethereum/go-ethereum/abi/type.go:126.51,128.36 2 1
github.com/ethereum/go-ethereum/abi/type.go:179.2,179.20 1 0
github.com/ethereum/go-ethereum/abi/type.go:129.2,130.23 1 1
github.com/ethereum/go-ethereum/abi/type.go:133.3,133.34 1 1
github.com/ethereum/go-ethereum/abi/type.go:134.2,135.23 1 1
github.com/ethereum/go-ethereum/abi/type.go:138.3,138.34 1 1
github.com/ethereum/go-ethereum/abi/type.go:139.2,142.49 1 1
github.com/ethereum/go-ethereum/abi/type.go:145.3,145.34 1 1
github.com/ethereum/go-ethereum/abi/type.go:146.2,147.42 1 1
github.com/ethereum/go-ethereum/abi/type.go:150.3,150.60 1 1
github.com/ethereum/go-ethereum/abi/type.go:151.2,152.42 1 1
github.com/ethereum/go-ethereum/abi/type.go:157.3,157.23 1 1
github.com/ethereum/go-ethereum/abi/type.go:162.3,162.78 1 1
github.com/ethereum/go-ethereum/abi/type.go:166.3,167.36 2 1
github.com/ethereum/go-ethereum/abi/type.go:170.3,170.21 1 1
github.com/ethereum/go-ethereum/abi/type.go:171.2,172.19 1 1
github.com/ethereum/go-ethereum/abi/type.go:130.23,132.4 1 0
github.com/ethereum/go-ethereum/abi/type.go:135.23,137.4 1 0
github.com/ethereum/go-ethereum/abi/type.go:142.49,144.4 1 1
github.com/ethereum/go-ethereum/abi/type.go:147.42,149.4 1 1
github.com/ethereum/go-ethereum/abi/type.go:152.42,154.4 1 1
github.com/ethereum/go-ethereum/abi/type.go:157.23,159.4 1 1
github.com/ethereum/go-ethereum/abi/type.go:162.78,164.4 1 0
github.com/ethereum/go-ethereum/abi/type.go:167.36,169.4 1 1
github.com/ethereum/go-ethereum/abi/type.go:172.19,174.4 1 1
github.com/ethereum/go-ethereum/abi/type.go:174.4,176.4 1 0
......@@ -33,7 +33,7 @@ var (
// timeout interval: max time allowed for peer without sending a block
blocksTimeout = 60 * time.Second
//
idleBestPeerTimeout = 60 * time.Second
idleBestPeerTimeout = 120 * time.Second
)
// config embedded in components, by default fall back to constants
......@@ -568,6 +568,7 @@ func (self *BlockPool) AddBlock(block *types.Block, peerId string) {
// sender.currentBlockC <- block
self.status.lock.Lock()
self.status.values.BlockHashes++
self.status.values.Blocks++
self.status.values.BlocksInPool++
self.status.lock.Unlock()
......
......@@ -41,7 +41,6 @@ type peer struct {
idleC chan bool
switchC chan bool
quit chan bool
bp *BlockPool
// timers for head section process
......@@ -360,6 +359,7 @@ func (self *peers) getPeer(id string) (p *peer, best bool) {
func (self *peer) handleSection(sec *section) {
self.lock.Lock()
defer self.lock.Unlock()
plog.DebugDetailf("HeadSection: <%s> (head: %s) head section received [%s]-[%s]", self.id, hex(self.currentBlockHash), sectionhex(self.headSection), sectionhex(sec))
self.headSection = sec
self.blockHashesRequestTimer = nil
......@@ -379,7 +379,7 @@ func (self *peer) handleSection(sec *section) {
self.idle = true
self.bp.wg.Done()
}
plog.DebugDetailf("HeadSection: <%s> head section [%s] created", self.id, sectionhex(sec))
plog.DebugDetailf("HeadSection: <%s> (head: %s) head section [%s] created", self.id, hex(self.currentBlockHash), sectionhex(sec))
self.suicideC = time.After(self.bp.Config.IdleBestPeerTimeout)
}
}
......@@ -408,7 +408,7 @@ func (self *peer) getCurrentBlock(currentBlock *types.Block) {
defer self.lock.Unlock()
self.currentBlock = currentBlock
self.parentHash = currentBlock.ParentHash()
plog.DebugDetailf("HeadSection: <%s> head block %s found (parent: [%s])... requesting hashes", self.id, hex(self.currentBlockHash), hex(self.parentHash))
plog.DebugDetailf("HeadSection: <%s> head block %s found (parent: %s)... requesting hashes", self.id, hex(self.currentBlockHash), hex(self.parentHash))
self.blockHashesRequestTimer = time.After(0)
self.blocksRequestTimer = nil
}
......@@ -418,13 +418,25 @@ func (self *peer) getBlockHashes() {
if self.bp.hasBlock(self.parentHash) {
plog.DebugDetailf("HeadSection: <%s> parent block %s found in blockchain", self.id, hex(self.parentHash))
err := self.bp.insertChain(types.Blocks([]*types.Block{self.currentBlock}))
if err != nil {
self.addError(ErrInvalidBlock, "%v", err)
self.bp.status.lock.Lock()
self.bp.status.badPeers[self.id]++
self.bp.status.lock.Unlock()
self.bp.status.values.BlocksInChain++
self.bp.status.values.BlocksInPool--
if err != nil {
self.addError(ErrInvalidBlock, "%v", err)
self.bp.status.badPeers[self.id]++
} else {
headKey := string(self.parentHash)
height := self.bp.status.chain[headKey] + 1
self.bp.status.chain[string(self.currentBlockHash)] = height
if height > self.bp.status.values.LongestChain {
self.bp.status.values.LongestChain = height
}
delete(self.bp.status.chain, headKey)
}
self.bp.status.lock.Unlock()
} else {
if parent := self.bp.get(self.parentHash); parent != nil {
if self.bp.get(self.currentBlockHash) == nil {
......@@ -450,7 +462,7 @@ func (self *peer) getBlockHashes() {
self.blockHashesRequestTimer = nil
if !self.idle {
self.idle = true
self.suicideC = time.After(self.bp.Config.IdleBestPeerTimeout)
self.suicideC = nil
self.bp.wg.Done()
}
}
......@@ -460,7 +472,6 @@ func (self *peer) run() {
self.lock.RLock()
switchC := self.switchC
currentBlockHash := self.currentBlockHash
self.lock.RUnlock()
self.blockHashesRequestTimer = nil
......@@ -468,7 +479,7 @@ func (self *peer) run() {
self.blocksRequestTimer = time.After(0)
self.suicideC = time.After(self.bp.Config.BlockHashesTimeout)
var quit chan bool
var quit <-chan time.Time
var ping = time.NewTicker(5 * time.Second)
......@@ -479,25 +490,16 @@ LOOP:
case <-ping.C:
plog.Debugf("HeadSection: <%s> section with head %s, idle: %v", self.id, hex(self.currentBlockHash), self.idle)
// idle timer started when process goes idle
case <-self.idleC:
if self.idle {
self.peerError(self.bp.peers.errors.New(ErrIdleTooLong, "timed out without providing new blocks...quitting", currentBlockHash))
self.bp.status.lock.Lock()
self.bp.status.badPeers[self.id]++
self.bp.status.lock.Unlock()
}
// signal from AddBlockHashes that head section for current best peer is created
// if sec == nil, it signals that chain info has updated (new block message)
case sec := <-self.headSectionC:
self.handleSection(sec)
// local var quit channel is linked to sections suicide channel so that
if sec == nil {
plog.Debugf("HeadSection: <%s> (headsection [%s], received: [%s]) quit channel set to nil, catchup happening", self.id, sectionhex(self.headSection), sectionhex(sec))
quit = nil
} else {
quit = sec.suicideC
plog.Debugf("HeadSection: <%s> (headsection [%s], received: [%s]) quit channel set to go off in IdleBestPeerTimeout", self.id, sectionhex(self.headSection), sectionhex(sec))
quit = time.After(self.bp.Config.IdleBestPeerTimeout)
}
// periodic check for block hashes or parent block/section
......@@ -514,7 +516,7 @@ LOOP:
// quitting on timeout
case <-self.suicideC:
self.peerError(self.bp.peers.errors.New(ErrInsufficientChainInfo, "timed out without providing block hashes or head block %x", currentBlockHash))
self.peerError(self.bp.peers.errors.New(ErrInsufficientChainInfo, "timed out without providing block hashes or head block (td: %v, head: %s)", self.td, hex(self.currentBlockHash)))
self.bp.status.lock.Lock()
self.bp.status.badPeers[self.id]++
......@@ -537,6 +539,12 @@ LOOP:
// quit
case <-quit:
self.peerError(self.bp.peers.errors.New(ErrIdleTooLong, "timed out without providing new blocks (td: %v, head: %s)...quitting", self.td, self.currentBlockHash))
self.bp.status.lock.Lock()
self.bp.status.badPeers[self.id]++
self.bp.status.lock.Unlock()
plog.Debugf("HeadSection: <%s> (headsection [%s]) quit channel closed : timed out without providing new blocks...quitting", self.id, sectionhex(self.headSection))
break LOOP
}
}
......
......@@ -125,11 +125,15 @@ func main() {
}
func memchain() *core.ChainManager {
db, err := ethdb.NewMemDatabase()
blockdb, err := ethdb.NewMemDatabase()
if err != nil {
utils.Fatalf("Could not create in-memory database: %v", err)
}
return core.NewChainManager(db, new(event.TypeMux))
statedb, err := ethdb.NewMemDatabase()
if err != nil {
utils.Fatalf("Could not create in-memory database: %v", err)
}
return core.NewChainManager(blockdb, statedb, new(event.TypeMux))
}
func loadBlocksFromTestFile(filePath string) (blocks types.Blocks, err error) {
......
......@@ -46,7 +46,7 @@ func execJsFile(ethereum *eth.Ethereum, filename string) {
if err != nil {
utils.Fatalf("%v", err)
}
re := javascript.NewJSRE(xeth.New(ethereum))
re := javascript.NewJSRE(xeth.New(ethereum, nil))
if _, err := re.Run(string(content)); err != nil {
utils.Fatalf("Javascript Error: %v", err)
}
......@@ -61,7 +61,7 @@ type repl struct {
}
func runREPL(ethereum *eth.Ethereum) {
xeth := xeth.New(ethereum)
xeth := xeth.New(ethereum, nil)
repl := &repl{
re: javascript.NewJSRE(xeth),
xeth: xeth,
......@@ -229,7 +229,7 @@ func (self *repl) dump(call otto.FunctionCall) otto.Value {
block = self.ethereum.ChainManager().CurrentBlock()
}
statedb := state.New(block.Root(), self.ethereum.Db())
statedb := state.New(block.Root(), self.ethereum.StateDb())
v, _ := self.re.Vm.ToValue(statedb.RawDump())
......
......@@ -40,7 +40,7 @@ import (
const (
ClientIdentifier = "Ethereum(G)"
Version = "0.8.6"
Version = "0.9.0"
)
var (
......@@ -121,7 +121,8 @@ runtime will execute the file and exit.
utils.RPCEnabledFlag,
utils.RPCListenAddrFlag,
utils.RPCPortFlag,
utils.VMTypeFlag,
utils.VMDebugFlag,
//utils.VMTypeFlag,
}
// missing:
......@@ -212,7 +213,7 @@ func importchain(ctx *cli.Context) {
if len(ctx.Args()) != 1 {
utils.Fatalf("This command requires an argument.")
}
chain, _ := utils.GetChain(ctx)
chain, _, _ := utils.GetChain(ctx)
start := time.Now()
err := utils.ImportChain(chain, ctx.Args().First())
if err != nil {
......@@ -223,7 +224,7 @@ func importchain(ctx *cli.Context) {
}
func dump(ctx *cli.Context) {
chain, db := utils.GetChain(ctx)
chain, _, stateDb := utils.GetChain(ctx)
for _, arg := range ctx.Args() {
var block *types.Block
if hashish(arg) {
......@@ -236,7 +237,7 @@ func dump(ctx *cli.Context) {
fmt.Println("{}")
utils.Fatalf("block not found")
} else {
statedb := state.New(block.Root(), db)
statedb := state.New(block.Root(), stateDb)
fmt.Printf("%s\n", statedb.Dump())
// fmt.Println(block)
}
......
......@@ -986,7 +986,7 @@ ApplicationWindow {
anchors.top: parent.top
anchors.topMargin: 30
font.pointSize: 12
text: "<h2>Mist (0.8.6)</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Viktor Trón<br>Felix Lange<br>Taylor Gerring<br>Daniel Nagy<br>Gustav Simonsson<br><h3>UX/UI</h3>Alex van de Sande<br>Fabian Vogelsteller"
text: "<h2>Mist (0.9.0)</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Viktor Trón<br>Felix Lange<br>Taylor Gerring<br>Daniel Nagy<br>Gustav Simonsson<br><h3>UX/UI</h3>Alex van de Sande<br>Fabian Vogelsteller"
}
}
......
......@@ -84,7 +84,7 @@ func (self *Gui) DumpState(hash, path string) {
return
}
stateDump = state.New(block.Root(), self.eth.Db()).Dump()
stateDump = state.New(block.Root(), self.eth.StateDb()).Dump()
}
file, err := os.OpenFile(path[7:], os.O_CREATE|os.O_RDWR, os.ModePerm)
......
/*
This file is part of go-ethereum
go-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @authors
* Jeffrey Wilcke <i@jev.io>
*/
package main
import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/xeth"
"github.com/obscuren/qml"
)
type AppContainer interface {
Create() error
Destroy()
Window() *qml.Window
Engine() *qml.Engine
NewBlock(*types.Block)
NewWatcher(chan bool)
Post(string, int)
}
type ExtApplication struct {
*xeth.XEth
eth core.Backend
events event.Subscription
watcherQuitChan chan bool
filters map[string]*core.Filter
container AppContainer
lib *UiLib
}
func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
return &ExtApplication{
XEth: xeth.New(lib.eth),
eth: lib.eth,
watcherQuitChan: make(chan bool),
filters: make(map[string]*core.Filter),
container: container,
lib: lib,
}
}
func (app *ExtApplication) run() {
// Set the "eth" api on to the containers context
context := app.container.Engine().Context()
context.SetVar("eth", app)
context.SetVar("ui", app.lib)
err := app.container.Create()
if err != nil {
guilogger.Errorln(err)
return
}
// Call the main loop
go app.mainLoop()
app.container.NewWatcher(app.watcherQuitChan)
win := app.container.Window()
win.Show()
win.Wait()
app.stop()
}
func (app *ExtApplication) stop() {
app.events.Unsubscribe()
// Kill the main loop
app.watcherQuitChan <- true
app.container.Destroy()
}
func (app *ExtApplication) mainLoop() {
for ev := range app.events.Chan() {
switch ev := ev.(type) {
case core.NewBlockEvent:
app.container.NewBlock(ev.Block)
/* TODO remove
case state.Messages:
for id, filter := range app.filters {
msgs := filter.FilterMessages(ev)
if len(msgs) > 0 {
app.container.Messages(msgs, id)
}
}
*/
}
}
}
......@@ -85,7 +85,7 @@ func NewWindow(ethereum *eth.Ethereum) *Gui {
panic(err)
}
xeth := xeth.New(ethereum)
xeth := xeth.New(ethereum, nil)
gui := &Gui{eth: ethereum,
txDb: db,
xeth: xeth,
......
......@@ -36,7 +36,7 @@ import (
const (
ClientIdentifier = "Mist"
Version = "0.8.6"
Version = "0.9.0"
)
var (
......
......@@ -58,7 +58,7 @@ type UiLib struct {
}
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
x := xeth.New(eth)
x := xeth.New(eth, nil)
lib := &UiLib{XEth: x, engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(x), filterCallbacks: make(map[int][]int)} //, filters: make(map[int]*xeth.JSFilter)}
lib.filterManager = filter.NewFilterManager(eth.EventMux())
go lib.filterManager.Start()
......@@ -91,24 +91,6 @@ func (self *UiLib) EvalJavascriptString(str string) string {
return fmt.Sprintf("%v", value)
}
func (ui *UiLib) OpenQml(path string) {
container := NewQmlApplication(path[7:], ui)
app := NewExtApplication(container, ui)
go app.run()
}
func (ui *UiLib) OpenHtml(path string) {
container := NewHtmlApplication(path, ui)
app := NewExtApplication(container, ui)
go app.run()
}
func (ui *UiLib) OpenBrowser() {
ui.OpenHtml("file://" + ui.AssetPath("ext/home.html"))
}
func (ui *UiLib) Muted(content string) {
component, err := ui.engine.LoadFile(ui.AssetPath("qml/muted.qml"))
if err != nil {
......
......@@ -145,7 +145,7 @@ func BlockDo(ethereum *eth.Ethereum, hash []byte) error {
parent := ethereum.ChainManager().GetBlock(block.ParentHash())
statedb := state.New(parent.Root(), ethereum.Db())
statedb := state.New(parent.Root(), ethereum.StateDb())
_, err := ethereum.BlockProcessor().TransitionState(statedb, parent, block, true)
if err != nil {
return err
......
......@@ -45,10 +45,16 @@ func NewApp(version, usage string) *cli.App {
var (
// General settings
/*
VMTypeFlag = cli.IntFlag{
Name: "vm",
Usage: "Virtual Machine type: 0 is standard VM, 1 is debug VM",
}
*/
VMDebugFlag = cli.BoolFlag{
Name: "vmdebug",
Usage: "Virtual Machine debug output",
}
DataDirFlag = cli.StringFlag{
Name: "datadir",
Usage: "Data directory to be used",
......@@ -161,6 +167,7 @@ func GetEthereum(clientID, version string, ctx *cli.Context) *eth.Ethereum {
LogFormat: ctx.GlobalString(LogFormatFlag.Name),
MinerThreads: ctx.GlobalInt(MinerThreadsFlag.Name),
AccountManager: GetAccountManager(ctx),
VmDebug: ctx.GlobalBool(VMDebugFlag.Name),
MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
Port: ctx.GlobalString(ListenPortFlag.Name),
NAT: GetNAT(ctx),
......@@ -175,13 +182,18 @@ func GetEthereum(clientID, version string, ctx *cli.Context) *eth.Ethereum {
return ethereum
}
func GetChain(ctx *cli.Context) (*core.ChainManager, ethutil.Database) {
func GetChain(ctx *cli.Context) (*core.ChainManager, ethutil.Database, ethutil.Database) {
dataDir := ctx.GlobalString(DataDirFlag.Name)
db, err := ethdb.NewLDBDatabase(path.Join(dataDir, "blockchain"))
blockDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "blockchain"))
if err != nil {
Fatalf("Could not open database: %v", err)
}
stateDb, err := ethdb.NewLDBDatabase(path.Join(dataDir, "state"))
if err != nil {
Fatalf("Could not open database: %v", err)
}
return core.NewChainManager(db, new(event.TypeMux)), db
return core.NewChainManager(blockDb, stateDb, new(event.TypeMux)), blockDb, stateDb
}
func GetAccountManager(ctx *cli.Context) *accounts.Manager {
......@@ -199,5 +211,5 @@ func StartRPC(eth *eth.Ethereum, ctx *cli.Context) {
if err != nil {
Fatalf("Can't listen on %s:%d: %v", addr, port, err)
}
go http.Serve(l, rpc.JSONRPC(xeth.New(eth), dataDir))
go http.Serve(l, rpc.JSONRPC(xeth.New(eth, nil), dataDir))
}
......@@ -6,14 +6,15 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/pow/ezp"
)
func proc() (*BlockProcessor, *ChainManager) {
db, _ := ethdb.NewMemDatabase()
var mux event.TypeMux
chainMan := NewChainManager(db, &mux)
return NewBlockProcessor(db, nil, chainMan, &mux), chainMan
chainMan := NewChainManager(db, db, &mux)
return NewBlockProcessor(db, ezp.New(), nil, chainMan, &mux), chainMan
}
func TestNumber(t *testing.T) {
......@@ -21,13 +22,13 @@ func TestNumber(t *testing.T) {
block1 := chain.NewBlock(nil)
block1.Header().Number = big.NewInt(3)
err := bp.ValidateBlock(block1, chain.Genesis())
err := bp.ValidateHeader(block1.Header(), chain.Genesis().Header())
if err != BlockNumberErr {
t.Errorf("expected block number error")
}
block1 = chain.NewBlock(nil)
err = bp.ValidateBlock(block1, chain.Genesis())
err = bp.ValidateHeader(block1.Header(), chain.Genesis().Header())
if err == BlockNumberErr {
t.Errorf("didn't expect block number error")
}
......
......@@ -108,7 +108,7 @@ func makeChain(bman *BlockProcessor, parent *types.Block, max int, db ethutil.Da
// Create a new chain manager starting from given block
// Effectively a fork factory
func newChainManager(block *types.Block, eventMux *event.TypeMux, db ethutil.Database) *ChainManager {
bc := &ChainManager{db: db, genesisBlock: GenesisBlock(db), eventMux: eventMux}
bc := &ChainManager{blockDb: db, stateDb: db, genesisBlock: GenesisBlock(db), eventMux: eventMux}
if block == nil {
bc.Reset()
} else {
......
......@@ -19,11 +19,6 @@ var (
jsonlogger = logger.NewJsonLogger()
)
type ChainEvent struct {
Block *types.Block
Td *big.Int
}
type StateQuery interface {
GetAccount(addr []byte) *state.StateObject
}
......@@ -66,7 +61,6 @@ func CalcGasLimit(parent, block *types.Block) *big.Int {
}
// ((1024-1) * parent.gasLimit + (gasUsed * 6 / 5)) / 1024
previous := new(big.Int).Mul(big.NewInt(1024-1), parent.GasLimit())
current := new(big.Rat).Mul(new(big.Rat).SetInt(parent.GasUsed()), big.NewRat(6, 5))
curInt := new(big.Int).Div(current.Num(), current.Denom())
......@@ -81,7 +75,8 @@ func CalcGasLimit(parent, block *types.Block) *big.Int {
type ChainManager struct {
//eth EthManager
db ethutil.Database
blockDb ethutil.Database
stateDb ethutil.Database
processor types.BlockProcessor
eventMux *event.TypeMux
genesisBlock *types.Block
......@@ -94,13 +89,16 @@ type ChainManager struct {
transState *state.StateDB
txState *state.StateDB
quit chan struct{}
}
func NewChainManager(db ethutil.Database, mux *event.TypeMux) *ChainManager {
bc := &ChainManager{db: db, genesisBlock: GenesisBlock(db), eventMux: mux}
func NewChainManager(blockDb, stateDb ethutil.Database, mux *event.TypeMux) *ChainManager {
bc := &ChainManager{blockDb: blockDb, stateDb: stateDb, genesisBlock: GenesisBlock(stateDb), eventMux: mux, quit: make(chan struct{})}
bc.setLastBlock()
bc.transState = bc.State().Copy()
bc.txState = bc.State().Copy()
go bc.update()
return bc
}
......@@ -138,7 +136,7 @@ func (self *ChainManager) SetProcessor(proc types.BlockProcessor) {
}
func (self *ChainManager) State() *state.StateDB {
return state.New(self.CurrentBlock().Root(), self.db)
return state.New(self.CurrentBlock().Root(), self.stateDb)
}
func (self *ChainManager) TransState() *state.StateDB {
......@@ -166,7 +164,7 @@ func (self *ChainManager) setTransState(statedb *state.StateDB) {
}
func (bc *ChainManager) setLastBlock() {
data, _ := bc.db.Get([]byte("LastBlock"))
data, _ := bc.blockDb.Get([]byte("LastBlock"))
if len(data) != 0 {
var block types.Block
rlp.Decode(bytes.NewReader(data), &block)
......@@ -174,7 +172,7 @@ func (bc *ChainManager) setLastBlock() {
bc.lastBlockHash = block.Hash()
// Set the last know difficulty (might be 0x0 as initial value, Genesis)
bc.td = ethutil.BigD(bc.db.LastKnownTD())
bc.td = ethutil.BigD(bc.blockDb.LastKnownTD())
} else {
bc.Reset()
}
......@@ -223,7 +221,7 @@ func (bc *ChainManager) Reset() {
defer bc.mu.Unlock()
for block := bc.currentBlock; block != nil; block = bc.GetBlock(block.Header().ParentHash) {
bc.db.Delete(block.Hash())
bc.blockDb.Delete(block.Hash())
}
// Prepare the genesis block
......@@ -239,7 +237,7 @@ func (bc *ChainManager) ResetWithGenesisBlock(gb *types.Block) {
defer bc.mu.Unlock()
for block := bc.currentBlock; block != nil; block = bc.GetBlock(block.Header().ParentHash) {
bc.db.Delete(block.Hash())
bc.blockDb.Delete(block.Hash())
}
// Prepare the genesis block
......@@ -265,14 +263,14 @@ func (self *ChainManager) Export() []byte {
func (bc *ChainManager) insert(block *types.Block) {
encodedBlock := ethutil.Encode(block)
bc.db.Put([]byte("LastBlock"), encodedBlock)
bc.blockDb.Put([]byte("LastBlock"), encodedBlock)
bc.currentBlock = block
bc.lastBlockHash = block.Hash()
}
func (bc *ChainManager) write(block *types.Block) {
encodedBlock := ethutil.Encode(block.RlpDataForStorage())
bc.db.Put(block.Hash(), encodedBlock)
bc.blockDb.Put(block.Hash(), encodedBlock)
}
// Accessors
......@@ -282,7 +280,7 @@ func (bc *ChainManager) Genesis() *types.Block {
// Block fetching methods
func (bc *ChainManager) HasBlock(hash []byte) bool {
data, _ := bc.db.Get(hash)
data, _ := bc.blockDb.Get(hash)
return len(data) != 0
}
......@@ -291,7 +289,6 @@ func (self *ChainManager) GetBlockHashesFromHash(hash []byte, max uint64) (chain
if block == nil {
return
}
// XXX Could be optimised by using a different database which only holds hashes (i.e., linked list)
for i := uint64(0); i < max; i++ {
parentHash := block.Header().ParentHash
......@@ -311,7 +308,7 @@ func (self *ChainManager) GetBlockHashesFromHash(hash []byte, max uint64) (chain
}
func (self *ChainManager) GetBlock(hash []byte) *types.Block {
data, _ := self.db.Get(hash)
data, _ := self.blockDb.Get(hash)
if len(data) == 0 {
return nil
}
......@@ -365,7 +362,7 @@ func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block {
}
func (bc *ChainManager) setTotalDifficulty(td *big.Int) {
bc.db.Put([]byte("LTD"), td.Bytes())
bc.blockDb.Put([]byte("LTD"), td.Bytes())
bc.td = td
}
......@@ -390,19 +387,24 @@ func (self *ChainManager) CalcTotalDiff(block *types.Block) (*big.Int, error) {
}
func (bc *ChainManager) Stop() {
if bc.CurrentBlock != nil {
chainlogger.Infoln("Stopped")
}
close(bc.quit)
}
func (self *ChainManager) InsertChain(chain types.Blocks) error {
println("insert chain start")
self.tsmu.Lock()
defer self.tsmu.Unlock()
type queueEvent struct {
queue []interface{}
canonicalCount int
sideCount int
splitCount int
}
defer println("insert chain end")
func (self *ChainManager) InsertChain(chain types.Blocks) error {
//self.tsmu.Lock()
//defer self.tsmu.Unlock()
for _, block := range chain {
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
var queue = make([]interface{}, len(chain))
var queueEvent = queueEvent{queue: queue}
for i, block := range chain {
// Call in to the block processor and check for errors. It's likely that if one block fails
// all others will fail too (unless a known block is returned).
td, err := self.processor.Process(block)
......@@ -419,7 +421,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
}
block.Td = td
var canonical, split bool
self.mu.Lock()
cblock := self.currentBlock
{
......@@ -431,41 +432,73 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
if td.Cmp(self.td) > 0 {
if block.Header().Number.Cmp(new(big.Int).Add(cblock.Header().Number, ethutil.Big1)) < 0 {
chainlogger.Infof("Split detected. New head #%v (%x) TD=%v, was #%v (%x) TD=%v\n", block.Header().Number, block.Hash()[:4], td, cblock.Header().Number, cblock.Hash()[:4], self.td)
split = true
queue[i] = ChainSplitEvent{block}
queueEvent.splitCount++
}
self.setTotalDifficulty(td)
self.insert(block)
canonical = true
}
}
self.mu.Unlock()
if canonical {
/*
jsonlogger.LogJson(&logger.EthChainNewHead{
BlockHash: ethutil.Bytes2Hex(block.Hash()),
BlockNumber: block.Number(),
ChainHeadHash: ethutil.Bytes2Hex(cblock.Hash()),
BlockPrevHash: ethutil.Bytes2Hex(block.ParentHash()),
})
*/
self.setTransState(state.New(block.Root(), self.db))
self.eventMux.Post(ChainEvent{block, td})
self.setTransState(state.New(block.Root(), self.stateDb))
queue[i] = ChainEvent{block}
queueEvent.canonicalCount++
} else {
//self.eventMux.
queue[i] = ChainSideEvent{block}
queueEvent.sideCount++
}
if split {
self.setTxState(state.New(block.Root(), self.db))
self.eventMux.Post(ChainSplitEvent{block})
}
self.mu.Unlock()
}
// XXX put this in a goroutine?
go self.eventMux.Post(queueEvent)
return nil
}
func (self *ChainManager) update() {
events := self.eventMux.Subscribe(queueEvent{})
out:
for {
select {
case ev := <-events.Chan():
switch ev := ev.(type) {
case queueEvent:
for i, event := range ev.queue {
switch event := event.(type) {
case ChainEvent:
// We need some control over the mining operation. Acquiring locks and waiting for the miner to create new block takes too long
// and in most cases isn't even necessary.
if i == ev.canonicalCount {
self.eventMux.Post(ChainHeadEvent{event.Block})
}
case ChainSplitEvent:
// On chain splits we need to reset the transaction state. We can't be sure whether the actual
// state of the accounts are still valid.
if i == ev.splitCount {
self.setTxState(state.New(event.Block.Root(), self.stateDb))
}
}
self.eventMux.Post(event)
}
}
case <-self.quit:
break out
}
}
}
// Satisfy state query interface
func (self *ChainManager) GetAccount(addr []byte) *state.StateObject {
return self.State().GetAccount(addr)
......
......@@ -257,9 +257,9 @@ func TestChainInsertions(t *testing.T) {
}
var eventMux event.TypeMux
chainMan := NewChainManager(db, &eventMux)
chainMan := NewChainManager(db, db, &eventMux)
txPool := NewTxPool(&eventMux)
blockMan := NewBlockProcessor(db, txPool, chainMan, &eventMux)
blockMan := NewBlockProcessor(db, nil, txPool, chainMan, &eventMux)
chainMan.SetProcessor(blockMan)
const max = 2
......@@ -303,9 +303,9 @@ func TestChainMultipleInsertions(t *testing.T) {
}
}
var eventMux event.TypeMux
chainMan := NewChainManager(db, &eventMux)
chainMan := NewChainManager(db, db, &eventMux)
txPool := NewTxPool(&eventMux)
blockMan := NewBlockProcessor(db, txPool, chainMan, &eventMux)
blockMan := NewBlockProcessor(db, nil, txPool, chainMan, &eventMux)
chainMan.SetProcessor(blockMan)
done := make(chan bool, max)
for i, chain := range chains {
......@@ -332,7 +332,7 @@ func TestGetAncestors(t *testing.T) {
db, _ := ethdb.NewMemDatabase()
var eventMux event.TypeMux
chainMan := NewChainManager(db, &eventMux)
chainMan := NewChainManager(db, db, &eventMux)
chain, err := loadChain("valid1", t)
if err != nil {
fmt.Println(err)
......
......@@ -146,3 +146,19 @@ func IsKnownBlockErr(e error) bool {
_, ok := e.(*KnownBlockError)
return ok
}
type ValueTransferError struct {
message string
}
func ValueTransferErr(str string, v ...interface{}) *ValueTransferError {
return &ValueTransferError{fmt.Sprintf(str, v...)}
}
func (self *ValueTransferError) Error() string {
return self.message
}
func IsValueTransferErr(e error) bool {
_, ok := e.(*ValueTransferError)
return ok
}
......@@ -16,3 +16,13 @@ type NewMinedBlockEvent struct{ Block *types.Block }
// ChainSplit is posted when a new head is detected
type ChainSplitEvent struct{ Block *types.Block }
type ChainEvent struct{ Block *types.Block }
type ChainSideEvent struct{ Block *types.Block }
type ChainHeadEvent struct{ Block *types.Block }
// Mining operation events
type StartMining struct{}
type TopMining struct{}
package core
import (
"fmt"
"math/big"
"time"
......@@ -26,7 +25,10 @@ func (self *Execution) Addr() []byte {
func (self *Execution) Call(codeAddr []byte, caller vm.ContextRef) ([]byte, error) {
// Retrieve the executing code
code := self.env.State().GetCode(codeAddr)
var code []byte
if self.env.State().GetStateObject(codeAddr) != nil {
code = self.env.State().GetCode(codeAddr)
}
return self.exec(code, codeAddr, caller)
}
......@@ -55,7 +57,7 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ContextRef) (ret
caller.ReturnGas(self.Gas, self.price)
return nil, fmt.Errorf("insufficient funds to transfer value. Req %v, has %v", self.value, from.Balance())
return nil, ValueTransferErr("insufficient funds to transfer value. Req %v, has %v", self.value, from.Balance())
}
snapshot := env.State().Copy()
......
......@@ -13,6 +13,7 @@ type Backend interface {
PeerCount() int
IsListening() bool
Peers() []*p2p.Peer
Db() ethutil.Database
BlockDb() ethutil.Database
StateDb() ethutil.Database
EventMux() *event.TypeMux
}
......@@ -184,7 +184,7 @@ func (self *StateTransition) TransitionState() (ret []byte, err error) {
}
}
if err = self.UseGas(big.NewInt(dgas)); err != nil {
return
return nil, InvalidTxError(err)
}
//stateCopy := self.env.State().Copy()
......@@ -230,9 +230,15 @@ func (self *StateTransition) TransitionState() (ret []byte, err error) {
*/
}
if err != nil && IsValueTransferErr(err) {
return nil, InvalidTxError(err)
}
/*
if err != nil {
self.UseGas(self.gas)
}
*/
return
}
......
......@@ -20,6 +20,7 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/vm"
"github.com/ethereum/go-ethereum/whisper"
)
......@@ -41,6 +42,7 @@ type Config struct {
LogFile string
LogLevel int
LogFormat string
VmDebug bool
MaxPeers int
Port string
......@@ -106,7 +108,8 @@ type Ethereum struct {
shutdownChan chan bool
// DB interface
db ethutil.Database
blockDb ethutil.Database
stateDb ethutil.Database
//*** SERVICES ***
// State manager for processing new blocks and managing the over all states
......@@ -133,25 +136,30 @@ func New(config *Config) (*Ethereum, error) {
// Boostrap database
ethlogger := logger.New(config.DataDir, config.LogFile, config.LogLevel, config.LogFormat)
db, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "blockchain"))
blockDb, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "blockchain"))
if err != nil {
return nil, err
}
stateDb, err := ethdb.NewLDBDatabase(path.Join(config.DataDir, "state"))
if err != nil {
return nil, err
}
// Perform database sanity checks
d, _ := db.Get([]byte("ProtocolVersion"))
d, _ := blockDb.Get([]byte("ProtocolVersion"))
protov := ethutil.NewValue(d).Uint()
if protov != ProtocolVersion && protov != 0 {
path := path.Join(config.DataDir, "blockchain")
return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, ProtocolVersion, path)
}
saveProtocolVersion(db)
saveProtocolVersion(blockDb)
//ethutil.Config.Db = db
eth := &Ethereum{
shutdownChan: make(chan bool),
db: db,
blockDb: blockDb,
stateDb: stateDb,
eventMux: &event.TypeMux{},
logger: ethlogger,
accountManager: config.AccountManager,
......@@ -163,10 +171,10 @@ func New(config *Config) (*Ethereum, error) {
return nil, fmt.Errorf("no coinbase: %v", err)
}
eth.chainManager = core.NewChainManager(db, eth.EventMux())
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
pow := ethash.New(eth.chainManager)
eth.txPool = core.NewTxPool(eth.EventMux())
eth.blockProcessor = core.NewBlockProcessor(db, pow, eth.txPool, eth.chainManager, eth.EventMux())
eth.blockProcessor = core.NewBlockProcessor(stateDb, pow, eth.txPool, eth.chainManager, eth.EventMux())
eth.chainManager.SetProcessor(eth.blockProcessor)
eth.whisper = whisper.New()
eth.miner = miner.New(cb, eth, pow, config.MinerThreads)
......@@ -198,6 +206,8 @@ func New(config *Config) (*Ethereum, error) {
eth.net.ListenAddr = ":" + config.Port
}
vm.Debug = config.VmDebug
return eth, nil
}
......@@ -210,7 +220,8 @@ func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
func (s *Ethereum) BlockPool() *blockpool.BlockPool { return s.blockPool }
func (s *Ethereum) Whisper() *whisper.Whisper { return s.whisper }
func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
func (s *Ethereum) Db() ethutil.Database { return s.db }
func (s *Ethereum) BlockDb() ethutil.Database { return s.blockDb }
func (s *Ethereum) StateDb() ethutil.Database { return s.stateDb }
func (s *Ethereum) Miner() *miner.Miner { return s.miner }
func (s *Ethereum) IsListening() bool { return true } // Always listening
func (s *Ethereum) PeerCount() int { return s.net.PeerCount() }
......@@ -260,7 +271,8 @@ func (self *Ethereum) SuggestPeer(nodeURL string) error {
func (s *Ethereum) Stop() {
// Close the database
defer s.db.Close()
defer s.blockDb.Close()
defer s.stateDb.Close()
s.txSub.Unsubscribe() // quits txBroadcastLoop
s.blockSub.Unsubscribe() // quits blockBroadcastLoop
......
......@@ -253,10 +253,9 @@ func (self *ethProtocol) handle() error {
case NewBlockMsg:
var request newBlockMsgData
if err := msg.Decode(&request); err != nil {
return self.protoError(ErrDecode, "msg %v: %v", msg, err)
return self.protoError(ErrDecode, "%v: %v", msg, err)
}
hash := request.Block.Hash()
fmt.Printf("received block: %x\n", hash)
_, chainHead, _ := self.chainManager.Status()
jsonlogger.LogJson(&logger.EthChainReceivedNewBlock{
......
......@@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/errs"
"github.com/ethereum/go-ethereum/ethutil"
ethlogger "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
)
......
package natspec
import (
"github.com/obscuren/otto"
"io/ioutil"
)
type NatSpec struct {
jsvm *otto.Otto
}
func NewNATSpec(transaction string) (self *NatSpec, err error) {
self = new(NatSpec)
self.jsvm = otto.New()
code, err := ioutil.ReadFile("natspec.js")
if err != nil {
return
}
_, err = self.jsvm.Run(string(code))
if err != nil {
return
}
_, err = self.jsvm.Run("var natspec = require('natspec');")
if err != nil {
return
}
self.jsvm.Run("var transaction = " + transaction + ";")
return
}
func (self *NatSpec) SetDescription(desc string) (err error) {
_, err = self.jsvm.Run("var expression = \"" + desc + "\";")
return
}
func (self *NatSpec) SetABI(abi string) (err error) {
_, err = self.jsvm.Run("var abi = " + abi + ";")
return
}
func (self *NatSpec) SetMethod(method string) (err error) {
_, err = self.jsvm.Run("var method = '" + method + "';")
return
}
func (self *NatSpec) Parse() string {
self.jsvm.Run("var call = {method: method,abi: abi,transaction: transaction};")
value, err := self.jsvm.Run("natspec.evaluateExpression(expression, call);")
if err != nil {
return err.Error()
}
return value.String()
}
This diff is collapsed.
package natspec
import (
"testing"
)
func TestNotice(t *testing.T) {
ns, err := NewNATSpec(`
{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "0x8521742d3f456bd237e312d6e30724960f72517a",
"data": "0xc6888fa1000000000000000000000000000000000000000000000000000000000000007a"
}],
"id": 6
}
`)
if err != nil {
t.Errorf("NewNATSpec error %v", err)
}
ns.SetABI(`
[{
"name": "multiply",
"constant": false,
"type": "function",
"inputs": [{
"name": "a",
"type": "uint256"
}],
"outputs": [{
"name": "d",
"type": "uint256"
}]
}]
`)
ns.SetDescription("Will multiply `a` by 7 and return `a * 7`.")
ns.SetMethod("multiply")
notice := ns.Parse()
expected := "Will multiply 122 by 7 and return 854."
if notice != expected {
t.Errorf("incorrect notice. expected %v, got %v", expected, notice)
} else {
t.Logf("returned notice \"%v\"", notice)
}
}
......@@ -3,6 +3,7 @@ package miner
import (
"math/big"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/pow"
......@@ -44,6 +45,8 @@ func (self *Miner) Mining() bool {
func (self *Miner) Start() {
self.mining = true
self.pow.(*ethash.Ethash).UpdateDAG()
self.worker.start()
self.worker.commitNewWork()
......@@ -53,6 +56,8 @@ func (self *Miner) Stop() {
self.mining = false
self.worker.stop()
//self.pow.(*ethash.Ethash).Stop()
}
func (self *Miner) HashRate() int64 {
......
......@@ -30,7 +30,7 @@ type environment struct {
}
func env(block *types.Block, eth core.Backend) *environment {
state := state.New(block.Root(), eth.Db())
state := state.New(block.Root(), eth.StateDb())
env := &environment{
totalUsedGas: new(big.Int),
state: state,
......@@ -116,7 +116,7 @@ func (self *worker) register(agent Agent) {
}
func (self *worker) update() {
events := self.mux.Subscribe(core.ChainEvent{}, core.NewMinedBlockEvent{})
events := self.mux.Subscribe(core.ChainHeadEvent{}, core.NewMinedBlockEvent{})
timer := time.NewTicker(2 * time.Second)
......@@ -125,7 +125,7 @@ out:
select {
case event := <-events.Chan():
switch ev := event.(type) {
case core.ChainEvent:
case core.ChainHeadEvent:
if self.current.block != ev.Block {
self.commitNewWork()
}
......
......@@ -9,7 +9,6 @@ For each request type, define the following:
package rpc
import (
"fmt"
"math/big"
"path"
"strings"
......@@ -24,7 +23,6 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event/filter"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/ui"
"github.com/ethereum/go-ethereum/xeth"
)
......@@ -84,7 +82,7 @@ func (self *EthereumApi) setStateByBlockNumber(num int64) {
block = chain.GetBlockByNumber(uint64(num))
if block != nil {
self.useState(state.New(block.Root(), self.xeth().Backend().Db()))
self.useState(state.New(block.Root(), self.xeth().Backend().StateDb()))
} else {
self.useState(chain.State())
}
......@@ -702,14 +700,3 @@ func (self *EthereumApi) useState(statedb *state.StateDB) {
self.eth = self.eth.UseState(statedb)
}
func t(f ui.Frontend) {
// Call the password dialog
ret, err := f.Call("PasswordDialog")
if err != nil {
fmt.Println(err)
}
// Get the first argument
t, _ := ret.Get(0)
fmt.Println("return:", t)
}
......@@ -9,10 +9,14 @@ import (
var rpchttplogger = logger.NewLogger("RPC-HTTP")
const (
jsonrpcver = "2.0"
maxSizeReqLength = 1024 * 1024 // 1MB
)
// JSONRPC returns a handler that implements the Ethereum JSON-RPC API.
func JSONRPC(pipe *xeth.XEth, dataDir string) http.Handler {
var json JsonWrapper
const jsonrpcver = "2.0"
api := NewEthereumApi(pipe, dataDir)
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
......@@ -20,6 +24,12 @@ func JSONRPC(pipe *xeth.XEth, dataDir string) http.Handler {
rpchttplogger.DebugDetailln("Handling request")
if req.ContentLength > maxSizeReqLength {
jsonerr := &RpcErrorObject{-32700, "Error: Request too large"}
json.Send(w, &RpcErrorResponse{JsonRpc: jsonrpcver, ID: nil, Error: jsonerr})
return
}
reqParsed, reqerr := json.ParseRequestBody(req)
if reqerr != nil {
jsonerr := &RpcErrorObject{-32700, "Error: Could not parse request"}
......
......@@ -111,7 +111,7 @@ func NewStateObjectFromBytes(address, data []byte, db ethutil.Database) *StateOb
func (self *StateObject) MarkForDeletion() {
self.remove = true
self.dirty = true
statelogger.DebugDetailf("%x: #%d %v (deletion)\n", self.Address(), self.nonce, self.balance)
statelogger.Debugf("%x: #%d %v X\n", self.Address(), self.nonce, self.balance)
}
func (c *StateObject) getAddr(addr []byte) *ethutil.Value {
......
......@@ -121,6 +121,7 @@ func (self *StateDB) Delete(addr []byte) bool {
stateObject := self.GetOrNewStateObject(addr)
if stateObject != nil {
stateObject.MarkForDeletion()
stateObject.balance = new(big.Int)
return true
}
......@@ -128,6 +129,14 @@ func (self *StateDB) Delete(addr []byte) bool {
return false
}
func (self *StateDB) IsDeleted(addr []byte) bool {
stateObject := self.GetStateObject(addr)
if stateObject != nil {
return stateObject.remove
}
return false
}
//
// Setting, updating & deleting state object methods
//
......
{
"genesis_rlp_hex": "f9012ef90129a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a07e204dc9cfb7acdf062ff0b8052f7fcb0b7e6593754773967932ce458d134af3a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080830f4240808080a004994f67dc55b09e814ab7ffc8df3686b4afb2bb53e60eae97ef043fe03fb829c0c0",
"genesis_state_root": "7e204dc9cfb7acdf062ff0b8052f7fcb0b7e6593754773967932ce458d134af3",
"genesis_hash": "32d9162f861a01bc8274e70b3cdb9d688fd7d8566f2f8c25cf1a882f244081c4"
"genesis_rlp_hex": "f90219f90214a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09178d0f23c965d81f0834a4c72c6253ce6830f4022b1359aaebfc1ecba442d4ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080830f4240808080a00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000088000000000000002ac0c0",
"genesis_state_root": "9178d0f23c965d81f0834a4c72c6253ce6830f4022b1359aaebfc1ecba442d4e",
"genesis_hash": "b5d6d8402156c5c1dfadaa4b87c676b5bcadb17ef9bc8e939606daaa0d35f55d"
}
{
"minDifficulty" : {
"blocks" : [
{
"blockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0000000000000000000000000000000000000000",
"difficulty" : "131072",
"extraData" : "0x",
"gasLimit" : "99902343",
"gasUsed" : "21000",
"hash" : "89cbb1c4aed1dd11118dd30537a050f60e3c3ab2a75f931377ae5b8e4ce01556",
"mixHash" : "10d3a79253db9e4307bd3f2f714b375f5aeb1a353e8faf2c275e4d45d3d9d49c",
"nonce" : "482c8d8082a0f5ec",
"number" : "1",
"parentHash" : "0ef7e09a5afada6e6c62f9aa2816b4880877f5cf3f061d316d441bcf4a781c5e",
"receiptTrie" : "eeceeeb4567b38e5b86275e3a36ac4ff55b9764b427714426710c3631a29011a",
"seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "0178d4488f358061cbf1a6086fa270e4a7d6ce54a26947eb84a5157251090124",
"timestamp" : "1425891408",
"transactionsTrie" : "2117c9060f6d15db2f509a1c764cc4797dfeeb96ac0dbb7b51b042b050948fec",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"rlp" : "0xf90284f9021ba00ef7e09a5afada6e6c62f9aa2816b4880877f5cf3f061d316d441bcf4a781c5ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a00178d4488f358061cbf1a6086fa270e4a7d6ce54a26947eb84a5157251090124a02117c9060f6d15db2f509a1c764cc4797dfeeb96ac0dbb7b51b042b050948feca0eeceeeb4567b38e5b86275e3a36ac4ff55b9764b427714426710c3631a29011ab901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000018405f463878252088454fd605080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a010d3a79253db9e4307bd3f2f714b375f5aeb1a353e8faf2c275e4d45d3d9d49c88482c8d8082a0f5ecf863f86180018404c4b43294095e7baea6a6c7c4c2dfeb977efac326af552d870a801ca01e4e724272d9bc78a982f20019a4bea0818427ab75bc39f0a8581055303dab2fa0e1e08de6b6e62a368e174cf426ce7f6df2f593d453adb890de00efc63a8c582dc0",
"transactions" : [
{
"data" : "0x",
"gasLimit" : "80000050",
"gasPrice" : "1",
"nonce" : "0",
"r" : "0x1e4e724272d9bc78a982f20019a4bea0818427ab75bc39f0a8581055303dab2f",
"s" : "0xe1e08de6b6e62a368e174cf426ce7f6df2f593d453adb890de00efc63a8c582d",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"v" : "28",
"value" : "10"
}
],
"uncleHeaders" : [
]
},
{
"blockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0000000000000000000000000000000000000000",
"difficulty" : "131136",
"extraData" : "0x",
"gasLimit" : "99804806",
"gasUsed" : "21000",
"hash" : "a45bc709aa7c382c5cc9576cbf86865ce44eb5cb6da35a82e2de402a36be0985",
"mixHash" : "2addc2ca0f0cd2ab8dc29a17fb18afa35fb0a20e6ce0b91fe6058a002d5f86dc",
"nonce" : "72ac24eff4c0b511",
"number" : "2",
"parentHash" : "89cbb1c4aed1dd11118dd30537a050f60e3c3ab2a75f931377ae5b8e4ce01556",
"receiptTrie" : "9f4d63754d02ccfa9a28d8a5795c462827a14370f01ec43925c95cd172b32672",
"seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "9c6c6cdb405d0d1435cf5fba044c72eed942c2764fb11062a17349b819f87252",
"timestamp" : "1425891413",
"transactionsTrie" : "d7d5752b4ce98cb3e69da2f7af9a8ecfff1d1e002e9226f6b4262a5ff06e3a2d",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"rlp" : "0xf90283f9021ba089cbb1c4aed1dd11118dd30537a050f60e3c3ab2a75f931377ae5b8e4ce01556a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09c6c6cdb405d0d1435cf5fba044c72eed942c2764fb11062a17349b819f87252a0d7d5752b4ce98cb3e69da2f7af9a8ecfff1d1e002e9226f6b4262a5ff06e3a2da09f4d63754d02ccfa9a28d8a5795c462827a14370f01ec43925c95cd172b32672b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020040028405f2e6868252088454fd605580a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a02addc2ca0f0cd2ab8dc29a17fb18afa35fb0a20e6ce0b91fe6058a002d5f86dc8872ac24eff4c0b511f862f8600180837a120094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ca0e0265f78919277dddb484cd94f045b3c27b46360b4e278f1d50da9dc723fef4aa057c4916c08d212aa2a55321ec415e7b76fb58fde702b4b2e7d393e1883488500c0",
"transactions" : [
{
"data" : "0x",
"gasLimit" : "8000000",
"gasPrice" : "0",
"nonce" : "1",
"r" : "0xe0265f78919277dddb484cd94f045b3c27b46360b4e278f1d50da9dc723fef4a",
"s" : "0x57c4916c08d212aa2a55321ec415e7b76fb58fde702b4b2e7d393e1883488500",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"v" : "28",
"value" : "10"
}
],
"uncleHeaders" : [
]
}
],
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "131072",
"extraData" : "0x42",
"gasLimit" : "100000000",
"gasUsed" : "0",
"hash" : "0ef7e09a5afada6e6c62f9aa2816b4880877f5cf3f061d316d441bcf4a781c5e",
"mixHash" : "e2d79d3ba9c6f60140f847f0b708585ab95143ee278799954bb4b72ad697d5da",
"nonce" : "259eb77837632668",
"number" : "0",
"parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "7dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1",
"timestamp" : "1422494849",
"transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000000000000",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"ForkBlockTransactionFee5" : {
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "10000",
"extraData" : "42",
"gasLimit" : "10000000000000000000000",
"gasUsed" : "0",
"nonce" : "5c4b5a259003f5717d9fb6bedf298fbb4e07e1eaef1cfe747e4a54932fac2d5c",
"number" : "0",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "5a4dfc958aba3034471698fe05df217e24637181edabff9259bbc826f0424ac4",
"timestamp" : "0x54c98c81",
"transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000000000",
"nonce" : "0",
"code" : "",
"storage": {}
}
},
"rlp" : "0xf9019af90133a01027db44289ca8ee6531aa143f57dbd9c14cc6330fb2d255fed1c47b77be10e5a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a022fab51fe44db728d2c8caa2018ad4581688305471fea3d57aa8cbab5501ad2fa088d9a9f6cbc82e9c4b5712cbe9784f61ab95ed7de920bdbe786aa7dea3aaae3aa06e87d93a708dbd3e74a92a8bdf163d2712d173cd6cd25ff8ca07d73cc387b324b84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000822707018a021d925a518843937000058454f0dccf80a006c3abf5074d88d97e9cb1270b8bfccf78bb8717c06c5094aef3ee049485171ff861f85f80018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b64801ca012b0439b2d0a4dda01f1d3150a6b82472656dbedcc2b0ecf9d8eaa838486d6fea03feed6ee8b7746219694fbbbd4b9d97020bb4484b2a05cd1f13559eb49297e91c0"
},
"ForkBlockValueNotInTransactionCost" : {
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "10000",
"extraData" : "42",
"gasLimit" : "10000000000000000000000",
"gasUsed" : "0",
"nonce" : "d499a99249cb29fcec16ea199034f5ee514fd7ef175a9c5df15e8b52ffd5dd70",
"number" : "0",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "5a4dfc958aba3034471698fe05df217e24637181edabff9259bbc826f0424ac4",
"timestamp" : "0x54c98c81",
"transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000000000",
"nonce" : "0",
"code" : "",
"storage": {}
}
},
"rlp" : "0xf9019cf90135a061d539f8f80e058754d06518a523175f12df9de06cb0b5634d988c0769fdbfaba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a069fd3f94d654a84e1160cb4864c41e9811250225355a7d5ccefe6d4f4eae9c0da042544006026776e4a36626cfe686c0a1ebf974660bb20b15e6c7e853f5055fa7a014d66747ae958fc4a9baf9684e67c135f8fb98bb5db3bdffef1f795fc8f0eb2fb84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000822707018a021d925a5188439370008201f48454f0e47b80a074d42816c7a2daeed1d7c6bcbfa2e8fb1053357622e3c3ce1c2913c1a61e9677f861f85f80018207d094b94f5374fce5edbc8e2a8697c15331677e6ebf0b64801ba04c5dbdafda364e28209857554030787414dcbf67861f727af3704ec9c616fa96a00dbb8979c53534d163f788eb28864f1a2b3ae746e015b414e1c0eed5f9ef0756c0"
},
"ForkBlockCreatedContractsStartWith1000eth" : {
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "10000",
"extraData" : "42",
"gasLimit" : "10000000000000000000000",
"gasUsed" : "0",
"nonce" : "61d3037528d7dcd86166936d27b6b5335f66bee76ab04a1b18a21712b7cd2daf",
"number" : "0",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "5a4dfc958aba3034471698fe05df217e24637181edabff9259bbc826f0424ac4",
"timestamp" : "0x54c98c81",
"transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "10000000000",
"nonce" : "0",
"code" : "",
"storage": {}
}
},
"rlp" : "0xf90188f90135a000080f45353c77c06ceda8a1e532f342f553f0b12bf72cedac418faa2e8f95dea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0feb1c35a6fb17928f8df46556de8c69f274c298a7f402cc2292a2ed4722529ffa01f48e009e7ca22aa905aa0b20b22aea7db1356c6fd377b04e73096cd065367f8a013473ade795b967f4d44485c1e13ed71bd2e5033d29ab9654ad4060d4d31c178b84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000822707018a021d925a5188439370008201f48454f0e60380a09ab495bd9cafdb1c78a51e8db07dc8246fa7400489660c715305ee174def2021f84df84b80018207d08080801ba0757204fb437aded3bad4e618c317824c28c0ea0b5a8a4decc91dc1599030234fa01ad3cdfff76ffecd8c2dec28d03abf77f23f7f6663a7188d15078c140bb000b5c0"
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"first": {
"nonce": "000000000000002a",
"mixhash": "86d46c9a313b096d66609ef84a334d6c3376d3a5e13b18aa5c666094ae04a1eb",
"header": "f90213a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a09178d0f23c965d81f0834a4c72c6253ce6830f4022b1359aaebfc1ecba442d4ea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082080080830f4240808080a00000000000000000000000000000000000000000000000000000000000000000a086d46c9a313b096d66609ef84a334d6c3376d3a5e13b18aa5c666094ae04a1eb88000000000000002a",
"seed": "0000000000000000000000000000000000000000000000000000000000000000",
"result": "a91eb868c6262d5456a696bd59cf67191ca7578c04dc72f40c5ece41fb1c3f9f",
"cache_size": 1048384,
"full_size": 1073739904,
"header_hash": "f71b596d43b462f63552a6d73a525dc777f172de3e9a023c8a85d3271144038b",
"cache_hash": "86a62f39bc1def6c35b54babdca953425392827c1992538c145bad931c546494"
}
}
......@@ -13,21 +13,28 @@
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"balance" : "1000000000000000010",
"code" : "0x600040600055600540600155600440600255",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "28500",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "71490",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"postStateRoot" : "5991795a1f45b319ba9eeaad2a016d05b8e7bcde1386113f5630d27d427641a4",
"postStateRoot" : "4782016164122fd5f724151b5248a3c6397a8024176248a83f1ab06dd15fd335",
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
......@@ -44,10 +51,9 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "8500",
"gasLimit" : "28500",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
......@@ -69,21 +75,28 @@
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"balance" : "1000000000000000010",
"code" : "0x60014060005560024060015561010040600255",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "28500",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "71490",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"postStateRoot" : "38895b1dec6e4e94204eebf737fb4669be2c81c17200ac87c8ad015a9c905258",
"postStateRoot" : "4180bf3804d44990168f5b3de8f3d061c3c0b6dc3f8f42f895c77cd98de5735b",
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
......@@ -100,10 +113,9 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "8500",
"gasLimit" : "28500",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
......@@ -125,21 +137,28 @@
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"balance" : "1000000000000000010",
"code" : "0x600040600055610101406001557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40600255",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "28500",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "71490",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"postStateRoot" : "cffd7c0b521c88a02d0c5329d2639d2ac6e8547d738c8f39ed2d5e0e93555f2f",
"postStateRoot" : "0ad00ad494cd7ceedc6b27be63573f7c8831f8e5bcca798b0bcafeea53806c03",
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
......@@ -156,10 +175,9 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "8500",
"gasLimit" : "28500",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
......
......@@ -13,21 +13,29 @@
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"balance" : "1000000000000100000",
"code" : "0x6001600101600055",
"nonce" : "0",
"storage" : {
"0x" : "0x02"
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "41012",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "999999999999858988",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
}
},
"postStateRoot" : "4b4b7a0d58a2388c0e6b3b048c3c27edd6febc6f04171167ed15a77ab2e60b16",
"postStateRoot" : "17454a767e5f04461256f3812ffca930443c04a47d05ce3f38940c4a14b8c479",
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
......@@ -44,10 +52,9 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "10000",
"gasLimit" : "400000",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
......
This diff is collapsed.
This diff is collapsed.
......@@ -51,7 +51,6 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "17592320524892",
......@@ -114,7 +113,6 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "37791080412587",
......
This diff is collapsed.
This diff is collapsed.
......@@ -142,7 +142,6 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "465224",
......
This diff is collapsed.
This diff is collapsed.
......@@ -30,7 +30,6 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639435",
......@@ -55,19 +54,26 @@
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"balance" : "1000000000000000010",
"code" : "0x7b601080600c6000396000f200600035541560095700602035600035556000526000600060006000601773aaaaaaaaace5edbc8e2a8697c15331677e6ebf0b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecf1",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000",
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "22850",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "77140",
"code" : "0x",
"nonce" : "1",
"storage" : {
}
},
"aaaaaaaaace5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"code" : "0x600160015532600255",
......@@ -76,7 +82,7 @@
}
}
},
"postStateRoot" : "45a2a0c2ccdbef34e6b9c9514025624c7de68630fb4b654abcc0c25052fea8e0",
"postStateRoot" : "942d1aa0569204aa9cef7c5cc98d75c3a19c04575dfa6033170e578b383200b4",
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
......@@ -86,7 +92,7 @@
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000",
"balance" : "100000",
"code" : "0x",
"nonce" : "0",
"storage" : {
......@@ -100,10 +106,9 @@
}
}
},
"preStateRoot" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"transaction" : {
"data" : "",
"gasLimit" : "850",
"gasLimit" : "22850",
"gasPrice" : "1",
"nonce" : "0",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
......
......@@ -26,5 +26,19 @@
},
"root": "0xa7c787bf470808896308c215e22c7a580a0087bb6db6e8695fb4759537283a83",
"hexEncoded": true
},
"test3": {
"in": {
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":
"0xf84c01880de0b6b3a7614bc3a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"0x095e7baea6a6c7c4c2dfeb977efac326af552d87":
"0xf84880840132b3a0a065fee2fffd7a68488cf7ef79f35f7979133172ac5727b5e0cf322953d13de492a06e5d8fec8b6b9bf41c3fb9b61696d5c87b66f6daa98d5f02ba9361b0c6916467",
"0x0000000000000000000000000000000000000001":
"0xf8448080a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba":
"0xf8478083012d9da056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
},
"root": "0x40b37be88a49e2c08b8d33fcb03a0676ffd0481df54dfebd3512b8ec54f40cad",
"hexEncoded": true
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -75,14 +75,18 @@ type VmTest struct {
}
func RunVmTest(p string, t *testing.T) {
tests := make(map[string]VmTest)
helper.CreateFileTests(t, p, &tests)
for name, test := range tests {
/*
vm.Debug = true
helper.Logger.SetLogLevel(4)
if name != "CallEcrecover0_overlappingInputOutput" {
if name != "refund_CallToSuicideTwice" {
continue
}
*/
db, _ := ethdb.NewMemDatabase()
statedb := state.New(nil, db)
for addr, account := range test.Pre {
......
This diff is collapsed.
......@@ -9,6 +9,9 @@ import (
var vmlogger = logger.NewLogger("VM")
// Global Debug flag indicating Debug VM (full logging)
var Debug bool
type Type byte
const (
......
This diff is collapsed.
......@@ -26,7 +26,7 @@ func (self *State) SafeGet(addr string) *Object {
func (self *State) safeGet(addr string) *state.StateObject {
object := self.state.GetStateObject(fromHex(addr))
if object == nil {
object = state.NewStateObject(fromHex(addr), self.xeth.eth.Db())
object = state.NewStateObject(fromHex(addr), self.xeth.eth.StateDb())
}
return object
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment