Implemented LOG. Closes #159

This commit is contained in:
obscuren
2014-10-27 11:44:16 +01:00
parent 6623500c6b
commit 272d58662c
15 changed files with 81 additions and 11 deletions
+6
View File
@@ -237,6 +237,12 @@ func (self *StateTransition) TransitionState() (err error) {
}
msg.Output = ret
} else {
// Add default LOG
// PUSH1 1 CALLER ADD LOG1
addr := ethutil.BigD(sender.Address())
addr.Add(addr, ethutil.Big1)
tx.addLog(vm.Log{sender.Address(), []*big.Int{addr}, nil})
}
}
+7
View File
@@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/ethcrypto"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/vm"
"github.com/obscuren/secp256k1-go"
)
@@ -28,6 +29,8 @@ type Transaction struct {
v byte
r, s []byte
logs []vm.Log
// Indicates whether this tx is a contract creation transaction
contractCreation bool
}
@@ -54,6 +57,10 @@ func NewTransactionFromValue(val *ethutil.Value) *Transaction {
return tx
}
func (self *Transaction) addLog(log vm.Log) {
self.logs = append(self.logs, log)
}
func (self *Transaction) GasValue() *big.Int {
return new(big.Int).Mul(self.Gas, self.GasPrice)
}
+2 -2
View File
@@ -18,7 +18,7 @@ const (
MOD = 0x06
SMOD = 0x07
EXP = 0x08
NEG = 0x09
BNOT = 0x09
LT = 0x0a
GT = 0x0b
SLT = 0x0c
@@ -166,7 +166,7 @@ var opCodeToString = map[OpCode]string{
MOD: "MOD",
SMOD: "SMOD",
EXP: "EXP",
NEG: "NEG",
BNOT: "BNOT",
LT: "LT",
GT: "GT",
SLT: "SLT",
+3
View File
@@ -31,6 +31,9 @@ func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
func (self *VMEnv) Value() *big.Int { return self.tx.Value }
func (self *VMEnv) State() *ethstate.State { return self.state }
func (self *VMEnv) GasLimit() *big.Int { return self.block.GasLimit }
func (self *VMEnv) AddLog(log vm.Log) {
self.tx.addLog(log)
}
func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error {
return vm.Transfer(from, to, amount)
}