From 272d58662c885ab1cef8930e96fb832ae5377d96 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 27 Oct 2014 11:44:16 +0100 Subject: Implemented LOG. Closes #159 --- ethchain/state_transition.go | 6 ++++++ ethchain/transaction.go | 7 +++++++ ethchain/types.go | 4 ++-- ethchain/vm_env.go | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) (limited to 'ethchain') diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go index 1274915d5..542b7be13 100644 --- a/ethchain/state_transition.go +++ b/ethchain/state_transition.go @@ -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}) } } diff --git a/ethchain/transaction.go b/ethchain/transaction.go index c78c27ed6..b0743097d 100644 --- a/ethchain/transaction.go +++ b/ethchain/transaction.go @@ -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) } diff --git a/ethchain/types.go b/ethchain/types.go index 29084c749..d0e7fcfb0 100644 --- a/ethchain/types.go +++ b/ethchain/types.go @@ -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", diff --git a/ethchain/vm_env.go b/ethchain/vm_env.go index 6dda27c6f..4dc96e8b1 100644 --- a/ethchain/vm_env.go +++ b/ethchain/vm_env.go @@ -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) } -- cgit