aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/evm.go10
-rw-r--r--core/genesis.go2
-rw-r--r--core/state/journal.go2
-rw-r--r--core/state/state_object.go32
-rw-r--r--core/state/statedb.go57
-rw-r--r--core/vm/instructions.go6
-rw-r--r--core/vm/interface.go2
-rw-r--r--core/vm/jump_table.go12
-rw-r--r--core/vm/opcodes.go22
9 files changed, 69 insertions, 76 deletions
diff --git a/core/evm.go b/core/evm.go
index 74891d7..78f36e0 100644
--- a/core/evm.go
+++ b/core/evm.go
@@ -23,7 +23,7 @@ import (
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/core/vm"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/log"
+ //"github.com/ethereum/go-ethereum/log"
)
// ChainContext supports retrieving headers and consensus parameters from the
@@ -105,14 +105,6 @@ func CanTransferMC(db vm.StateDB, addr common.Address, to common.Address, coinID
if coinID == nil {
return 0
}
- if !db.IsMultiCoin(addr) {
- err := db.EnableMultiCoin(addr)
- log.Debug("try to enable MC", "addr", addr.Hex(), "err", err)
- }
- if !(db.IsMultiCoin(addr) && db.IsMultiCoin(to)) {
- // incompatible
- return -1
- }
if db.GetBalanceMultiCoin(addr, *coinID).Cmp(amount) >= 0 {
return 0
}
diff --git a/core/genesis.go b/core/genesis.go
index e48f411..9b96480 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -268,7 +268,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
statedb.SetState(addr, key, value)
}
if account.MCBalance != nil {
- statedb.ForceEnableMultiCoin(addr)
+ //statedb.ForceEnableMultiCoin(addr)
for coinID, value := range account.MCBalance {
statedb.AddBalanceMultiCoin(addr, coinID, value)
}
diff --git a/core/state/journal.go b/core/state/journal.go
index 0cc556b..be27493 100644
--- a/core/state/journal.go
+++ b/core/state/journal.go
@@ -185,7 +185,7 @@ func (ch balanceChange) dirtied() *common.Address {
}
func (ch multiCoinEnable) revert(s *StateDB) {
- s.getStateObject(*ch.account).data.IsMultiCoin = false
+ //s.getStateObject(*ch.account).data.IsMultiCoin = false
}
func (ch multiCoinEnable) dirtied() *common.Address {
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 2893f80..9772859 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -438,9 +438,9 @@ func (s *stateObject) setBalance(amount *big.Int) {
s.data.Balance = amount
}
-func (s *stateObject) enableMultiCoin() {
- s.data.IsMultiCoin = true
-}
+//func (s *stateObject) enableMultiCoin() {
+// s.data.IsMultiCoin = true
+//}
// Return the gas back to the origin. Used by the Virtual machine or Closures
func (s *stateObject) ReturnGas(gas *big.Int) {}
@@ -538,9 +538,9 @@ func (s *stateObject) Balance() *big.Int {
return s.data.Balance
}
-func IsMultiCoinKey(key common.Hash) bool {
- return key[0]&0x01 == 0x01
-}
+//func IsMultiCoinKey(key common.Hash) bool {
+// return key[0]&0x01 == 0x01
+//}
func NormalizeCoinID(coinID *common.Hash) {
coinID[0] |= 0x01
@@ -555,16 +555,16 @@ func (s *stateObject) BalanceMultiCoin(coinID common.Hash, db Database) *big.Int
return s.GetState(db, coinID).Big()
}
-func (s *stateObject) EnableMultiCoin() bool {
- if s.data.IsMultiCoin {
- return false
- }
- s.db.journal.append(multiCoinEnable{
- account: &s.address,
- })
- s.enableMultiCoin()
- return true
-}
+//func (s *stateObject) EnableMultiCoin() bool {
+// if s.data.IsMultiCoin {
+// return false
+// }
+// s.db.journal.append(multiCoinEnable{
+// account: &s.address,
+// })
+// s.enableMultiCoin()
+// return true
+//}
func (s *stateObject) IsMultiCoin() bool {
return s.data.IsMultiCoin
diff --git a/core/state/statedb.go b/core/state/statedb.go
index dbf0870..c4d926d 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -267,29 +267,30 @@ func (self *StateDB) GetBalanceMultiCoin(addr common.Address, coinID common.Hash
return common.Big0
}
-func (self *StateDB) EnableMultiCoin(addr common.Address) error {
- stateObject := self.GetOrNewStateObject(addr)
- if stateObject.data.Root != emptyRoot && stateObject.data.Root != zeroRoot {
- return errors.New(fmt.Sprintf("not a fresh account: %s", stateObject.data.Root.Hex()))
- }
- if !stateObject.EnableMultiCoin() {
- return errors.New("multi-coin mode already enabled")
- }
- log.Debug(fmt.Sprintf("enabled MC for %s", addr.Hex()))
- return nil
-}
-
-func (self *StateDB) ForceEnableMultiCoin(addr common.Address) {
- stateObject := self.GetOrNewStateObject(addr)
- stateObject.EnableMultiCoin()
-}
+//func (self *StateDB) EnableMultiCoin(addr common.Address) error {
+// stateObject := self.GetOrNewStateObject(addr)
+// if stateObject.data.Root != emptyRoot && stateObject.data.Root != zeroRoot {
+// return errors.New(fmt.Sprintf("not a fresh account: %s", stateObject.data.Root.Hex()))
+// }
+// if !stateObject.EnableMultiCoin() {
+// return errors.New("multi-coin mode already enabled")
+// }
+// log.Debug(fmt.Sprintf("enabled MC for %s", addr.Hex()))
+// return nil
+//}
+//
+//func (self *StateDB) ForceEnableMultiCoin(addr common.Address) {
+// stateObject := self.GetOrNewStateObject(addr)
+// stateObject.EnableMultiCoin()
+//}
func (self *StateDB) IsMultiCoin(addr common.Address) bool {
- stateObject := self.getStateObject(addr)
- if stateObject != nil {
- return stateObject.IsMultiCoin()
- }
- return false
+ return true
+ //stateObject := self.getStateObject(addr)
+ //if stateObject != nil {
+ // return stateObject.IsMultiCoin()
+ //}
+ //return false
}
func (s *StateDB) GetNonce(addr common.Address) uint64 {
@@ -339,6 +340,10 @@ func (s *StateDB) GetCodeHash(addr common.Address) common.Hash {
func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash {
stateObject := s.getStateObject(addr)
if stateObject != nil {
+ // NOTE: last-minute fix: just universally enable MC
+ //if stateObject.data.IsMultiCoin {
+ NormalizeStateKey(&hash)
+ //}
return stateObject.GetState(s.db, hash)
}
return common.Hash{}
@@ -425,9 +430,6 @@ func (s *StateDB) SetBalance(addr common.Address, amount *big.Int) {
// AddBalance adds amount to the account associated with addr.
func (s *StateDB) AddBalanceMultiCoin(addr common.Address, coinID common.Hash, amount *big.Int) {
- if !s.IsMultiCoin(addr) {
- s.EnableMultiCoin(addr)
- }
stateObject := s.GetOrNewStateObject(addr)
if stateObject != nil {
stateObject.AddBalanceMultiCoin(coinID, amount, s.db)
@@ -467,9 +469,10 @@ func (s *StateDB) SetState(addr common.Address, key, value common.Hash) (res err
res = nil
stateObject := s.GetOrNewStateObject(addr)
if stateObject != nil {
- if stateObject.data.IsMultiCoin {
- NormalizeStateKey(&key)
- }
+ // NOTE: last-minute fix: just universally enable MC
+ //if stateObject.data.IsMultiCoin {
+ NormalizeStateKey(&key)
+ //}
stateObject.SetState(s.db, key, value)
}
return
diff --git a/core/vm/instructions.go b/core/vm/instructions.go
index abfa2aa..e1eb25e 100644
--- a/core/vm/instructions.go
+++ b/core/vm/instructions.go
@@ -881,9 +881,9 @@ func opSuicide(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([
return nil, nil
}
-func opEMC(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
- return nil, interpreter.evm.StateDB.EnableMultiCoin(callContext.contract.Address())
-}
+//func opEMC(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
+// return nil, interpreter.evm.StateDB.EnableMultiCoin(callContext.contract.Address())
+//}
// following functions are used by the instruction jump table
diff --git a/core/vm/interface.go b/core/vm/interface.go
index 4f95423..05faac1 100644
--- a/core/vm/interface.go
+++ b/core/vm/interface.go
@@ -34,8 +34,6 @@ type StateDB interface {
SubBalanceMultiCoin(common.Address, common.Hash, *big.Int)
AddBalanceMultiCoin(common.Address, common.Hash, *big.Int)
GetBalanceMultiCoin(common.Address, common.Hash) *big.Int
- EnableMultiCoin(common.Address) error
- IsMultiCoin(common.Address) bool
GetNonce(common.Address) uint64
SetNonce(common.Address, uint64)
diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go
index 7e3e354..9b538d4 100644
--- a/core/vm/jump_table.go
+++ b/core/vm/jump_table.go
@@ -558,12 +558,12 @@ func newFrontierInstructionSet() JumpTable {
minStack: minStack(0, 0),
maxStack: maxStack(0, 0),
},
- EMC: {
- execute: opEMC,
- constantGas: params.EMCGas,
- minStack: minStack(0, 0),
- maxStack: maxStack(0, 0),
- },
+ //EMC: {
+ // execute: opEMC,
+ // constantGas: params.EMCGas,
+ // minStack: minStack(0, 0),
+ // maxStack: maxStack(0, 0),
+ //},
PUSH1: {
execute: opPush1,
constantGas: GasFastestStep,
diff --git a/core/vm/opcodes.go b/core/vm/opcodes.go
index 99688b1..c5097f8 100644
--- a/core/vm/opcodes.go
+++ b/core/vm/opcodes.go
@@ -210,8 +210,8 @@ const (
const (
BALANCEMC = 0xcd
- EMC = 0xce
- CALLEX = 0xcf
+ //EMC = 0xce
+ CALLEX = 0xcf
)
// 0xf0 range - closures.
@@ -385,9 +385,9 @@ var opCodeToString = map[OpCode]string{
LOG4: "LOG4",
// 0xf0 range.
- CREATE: "CREATE",
- CALL: "CALL",
- EMC: "EMC",
+ CREATE: "CREATE",
+ CALL: "CALL",
+ //EMC: "EMC",
CALLEX: "CALLEX",
RETURN: "RETURN",
CALLCODE: "CALLCODE",
@@ -553,12 +553,12 @@ var stringToOp = map[string]OpCode{
"CREATE": CREATE,
"CREATE2": CREATE2,
"CALL": CALL,
- "EMC": EMC,
- "CALLEX": CALLEX,
- "RETURN": RETURN,
- "CALLCODE": CALLCODE,
- "REVERT": REVERT,
- "SELFDESTRUCT": SELFDESTRUCT,
+ //"EMC": EMC,
+ "CALLEX": CALLEX,
+ "RETURN": RETURN,
+ "CALLCODE": CALLCODE,
+ "REVERT": REVERT,
+ "SELFDESTRUCT": SELFDESTRUCT,
}
// StringToOp finds the opcode whose name is stored in `str`.