From b9894c1d0979b9f3e8428b1dc230f1ece106f676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 16 Feb 2015 16:27:11 +0100 Subject: Update JIT interface to ABI 0.2: code hash added to input data, gas counter passed as int64 --- vm/vm_jit.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/vm/vm_jit.go b/vm/vm_jit.go index 38cab57da..0fac31d07 100644 --- a/vm/vm_jit.go +++ b/vm/vm_jit.go @@ -50,6 +50,7 @@ type RuntimeData struct { timestamp int64 code *byte codeSize uint64 + codeHash i256 } func hash2llvm(h []byte) i256 { @@ -180,6 +181,7 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi self.data.timestamp = self.env.Time() self.data.code = getDataPtr(code) self.data.codeSize = uint64(len(code)) + self.data.codeHash = hash2llvm(crypto.Sha3(code)) // TODO: Get already computed hash? jit := C.evmjit_create() retCode := C.evmjit_run(jit, unsafe.Pointer(&self.data), unsafe.Pointer(self)) @@ -201,8 +203,8 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi state.Delete(me.Address()) } } - - C.evmjit_destroy(jit); + + C.evmjit_destroy(jit) return } @@ -278,7 +280,7 @@ func env_blockhash(_vm unsafe.Pointer, _number unsafe.Pointer, _result unsafe.Po } //export env_call -func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Pointer, _value unsafe.Pointer, inDataPtr unsafe.Pointer, inDataLen uint64, outDataPtr *byte, outDataLen uint64, _codeAddr unsafe.Pointer) bool { +func env_call(_vm unsafe.Pointer, _gas *int64, _receiveAddr unsafe.Pointer, _value unsafe.Pointer, inDataPtr unsafe.Pointer, inDataLen uint64, outDataPtr *byte, outDataLen uint64, _codeAddr unsafe.Pointer) bool { vm := (*JitVm)(_vm) //fmt.Printf("env_call (depth %d)\n", vm.Env().Depth()) @@ -297,8 +299,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point inData := C.GoBytes(inDataPtr, C.int(inDataLen)) outData := llvm2bytesRef(outDataPtr, outDataLen) codeAddr := llvm2hash((*i256)(_codeAddr)) - llvmGas := (*i256)(_gas) - gas := llvm2big(llvmGas) + gas := big.NewInt(*_gas) var out []byte var err error if bytes.Equal(codeAddr, receiveAddr) { @@ -306,7 +307,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point } else { out, err = vm.env.CallCode(vm.me, codeAddr, inData, gas, vm.price, value) } - *llvmGas = big2llvm(gas) + *_gas = gas.Int64() if err == nil { copy(outData, out) return true @@ -317,7 +318,7 @@ func env_call(_vm unsafe.Pointer, _gas unsafe.Pointer, _receiveAddr unsafe.Point } //export env_create -func env_create(_vm unsafe.Pointer, _gas unsafe.Pointer, _value unsafe.Pointer, initDataPtr unsafe.Pointer, initDataLen uint64, _result unsafe.Pointer) { +func env_create(_vm unsafe.Pointer, _gas *int64, _value unsafe.Pointer, initDataPtr unsafe.Pointer, initDataLen uint64, _result unsafe.Pointer) { vm := (*JitVm)(_vm) value := llvm2big((*i256)(_value)) @@ -325,9 +326,7 @@ func env_create(_vm unsafe.Pointer, _gas unsafe.Pointer, _value unsafe.Pointer, result := (*i256)(_result) *result = i256{} - llvmGas := (*i256)(_gas) - gas := llvm2big(llvmGas) - + gas := big.NewInt(*_gas) ret, suberr, ref := vm.env.Create(vm.me, nil, initData, gas, vm.price, value) if suberr == nil { dataGas := big.NewInt(int64(len(ret))) // TODO: Nto the best design. env.Create can do it, it has the reference to gas counter @@ -335,7 +334,7 @@ func env_create(_vm unsafe.Pointer, _gas unsafe.Pointer, _value unsafe.Pointer, gas.Sub(gas, dataGas) *result = hash2llvm(ref.Address()) } - *llvmGas = big2llvm(gas) + *_gas = gas.Int64() } //export env_log -- cgit v1.2.3 From 9c6d9dfc5c9fdd9aeb8f4d9926ed98008b849f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 2 Mar 2015 18:43:01 +0100 Subject: Add required block number --- vm/vm_jit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_jit.go b/vm/vm_jit.go index 0fac31d07..7cb9c75ec 100644 --- a/vm/vm_jit.go +++ b/vm/vm_jit.go @@ -357,7 +357,7 @@ func env_log(_vm unsafe.Pointer, dataPtr unsafe.Pointer, dataLen uint64, _topic1 topics = append(topics, llvm2hash((*i256)(_topic4))) } - vm.Env().AddLog(state.NewLog(vm.me.Address(), topics, data)) + vm.Env().AddLog(state.NewLog(vm.me.Address(), topics, data, vm.env.BlockNumber().Uint64())) } //export env_extcode -- cgit v1.2.3 From e72173dc43331e000c23ab693f6aee99fb86ed06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 3 Mar 2015 12:31:26 +0100 Subject: Fix JitVm build --- vm/vm_jit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/vm_jit.go b/vm/vm_jit.go index 7cb9c75ec..9d26957f0 100644 --- a/vm/vm_jit.go +++ b/vm/vm_jit.go @@ -199,7 +199,7 @@ func (self *JitVm) Run(me, caller ContextRef, code []byte, value, gas, price *bi receiverAddr := llvm2hashRef(bswap(&self.data.address)) receiver := state.GetOrNewStateObject(receiverAddr) balance := state.GetBalance(me.Address()) - receiver.AddAmount(balance) + receiver.AddBalance(balance) state.Delete(me.Address()) } } -- cgit v1.2.3 From a56243075a7527d65d14c4cf3480029feb0a1e3f Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 4 Mar 2015 10:51:17 +0100 Subject: removed double flag. Closes #421 --- cmd/ethereum/flags.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index fe848397c..a3004f503 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -134,7 +134,6 @@ func Init() { flag.StringVar(&BootNodes, "bootnodes", "", "space-separated node URLs for discovery bootstrap") flag.IntVar(&MaxPeer, "maxpeer", 30, "maximum desired peers") - flag.IntVar(&MinerThreads, "minerthreads", runtime.NumCPU(), "number of miner threads") flag.Parse() -- cgit v1.2.3