Commit e8565f4a authored by George Hotz's avatar George Hotz

the tx runs, but does nothing since GetCode returns nil

parent 1bc67228
...@@ -18,6 +18,7 @@ type extblock struct { ...@@ -18,6 +18,7 @@ type extblock struct {
*/ */
function getTransactionRlp(tx : any): Buffer { function getTransactionRlp(tx : any): Buffer {
let dat: any let dat: any
// TODO: there are also type 1 transactions
if (tx.type == "0x2") { if (tx.type == "0x2") {
let accesslist = tx.accessList.map((x : any) => [x.address, x.storageKeys]) let accesslist = tx.accessList.map((x : any) => [x.address, x.storageKeys])
// london // london
......
package state package state
import ( import (
"fmt"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -17,10 +18,16 @@ func (s *StateDB) AddAddressToAccessList(addr common.Address) { ...@@ -17,10 +18,16 @@ func (s *StateDB) AddAddressToAccessList(addr common.Address) {
// AddBalance adds amount to the account associated with addr. // AddBalance adds amount to the account associated with addr.
func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) { func (s *StateDB) AddBalance(addr common.Address, amount *big.Int) {
fmt.Println("AddBalance", addr, amount)
} }
// SubBalance subtracts amount from the account associated with addr. // SubBalance subtracts amount from the account associated with addr.
func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) { func (s *StateDB) SubBalance(addr common.Address, amount *big.Int) {
fmt.Println("SubBalance", addr, amount)
}
func (s *StateDB) AddLog(log *types.Log) {
fmt.Println("AddLog", log)
} }
// IntermediateRoot computes the current root hash of the state trie. // IntermediateRoot computes the current root hash of the state trie.
...@@ -30,10 +37,8 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash { ...@@ -30,10 +37,8 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
return common.HexToHash("0x0") return common.HexToHash("0x0")
} }
func (s *StateDB) AddLog(log *types.Log) {
}
func (s *StateDB) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log { func (s *StateDB) GetLogs(hash common.Hash, blockHash common.Hash) []*types.Log {
fmt.Println("GetLogs", hash, blockHash)
return nil return nil
} }
...@@ -91,45 +96,55 @@ func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common ...@@ -91,45 +96,55 @@ func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common
// GetBalance retrieves the balance from the given address or 0 if object not found // GetBalance retrieves the balance from the given address or 0 if object not found
func (s *StateDB) GetBalance(addr common.Address) *big.Int { func (s *StateDB) GetBalance(addr common.Address) *big.Int {
return nil fmt.Println("GetBalance", addr)
return big.NewInt(1e18)
} }
func (s *StateDB) GetCode(addr common.Address) []byte { func (s *StateDB) GetCode(addr common.Address) []byte {
fmt.Println("GetCode", addr)
return nil return nil
} }
func (s *StateDB) GetCodeSize(addr common.Address) int { func (s *StateDB) GetCodeSize(addr common.Address) int {
fmt.Println("GetCodeSize", addr)
return 0 return 0
} }
func (s *StateDB) GetCodeHash(addr common.Address) common.Hash { func (s *StateDB) GetCodeHash(addr common.Address) common.Hash {
fmt.Println("GetCodeHash", addr)
return common.HexToHash("0x0") return common.HexToHash("0x0")
} }
// GetCommittedState retrieves a value from the given account's committed storage trie. // GetCommittedState retrieves a value from the given account's committed storage trie.
func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash { func (s *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash {
fmt.Println("GetCommittedState", addr, hash)
return common.Hash{} return common.Hash{}
} }
// GetState retrieves a value from the given account's storage trie. // GetState retrieves a value from the given account's storage trie.
func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash { func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash {
fmt.Println("GetState", addr, hash)
return common.Hash{} return common.Hash{}
} }
func (s *StateDB) GetNonce(addr common.Address) uint64 { func (s *StateDB) GetNonce(addr common.Address) uint64 {
return 0 fmt.Println("GetNonce", addr)
return 2122
} }
// GetRefund returns the current value of the refund counter. // GetRefund returns the current value of the refund counter.
func (s *StateDB) GetRefund() uint64 { func (s *StateDB) GetRefund() uint64 {
fmt.Println("GetRefund")
return 0 return 0
} }
func (s *StateDB) Suicide(addr common.Address) bool { func (s *StateDB) Suicide(addr common.Address) bool {
fmt.Println("Suicide", addr)
return true return true
} }
func (s *StateDB) HasSuicided(addr common.Address) bool { func (s *StateDB) HasSuicided(addr common.Address) bool {
fmt.Println("HasSuicided", addr)
return false return false
} }
...@@ -141,12 +156,15 @@ func (s *StateDB) RevertToSnapshot(revid int) { ...@@ -141,12 +156,15 @@ func (s *StateDB) RevertToSnapshot(revid int) {
} }
func (s *StateDB) SetCode(addr common.Address, code []byte) { func (s *StateDB) SetCode(addr common.Address, code []byte) {
fmt.Println("SetCode", addr, code)
} }
func (s *StateDB) SetNonce(addr common.Address, nonce uint64) { func (s *StateDB) SetNonce(addr common.Address, nonce uint64) {
fmt.Println("SetNonce", addr, nonce)
} }
func (s *StateDB) SetState(addr common.Address, key, value common.Hash) { func (s *StateDB) SetState(addr common.Address, key, value common.Hash) {
fmt.Println("SetState", addr, key)
} }
// SlotInAccessList returns true if the given (address, slot)-tuple is in the access list. // SlotInAccessList returns true if the given (address, slot)-tuple is in the access list.
......
...@@ -82,6 +82,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg ...@@ -82,6 +82,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg) vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
// Iterate over and process the individual transactions // Iterate over and process the individual transactions
for i, tx := range block.Transactions() { for i, tx := range block.Transactions() {
fmt.Println(i, tx.Hash())
msg, err := tx.AsMessage(types.MakeSigner(p.config, header.Number), header.BaseFee) msg, err := tx.AsMessage(types.MakeSigner(p.config, header.Number), header.BaseFee)
if err != nil { if err != nil {
return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
......
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