(╯°□°)╯︵ ┻━┻

This commit is contained in:
Jae Kwon
2015-04-17 17:39:50 -07:00
parent 2668b59631
commit b11ca1bbfc
12 changed files with 27 additions and 21 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ func GetStorage(address, key []byte) (*ctypes.ResponseGetStorage, error) {
storageRoot := account.StorageRoot
storageTree := state.LoadStorage(storageRoot)
_, value := storageTree.Get(RightPadWord256(key).Bytes())
_, value := storageTree.Get(LeftPadWord256(key).Bytes())
if value == nil {
return &ctypes.ResponseGetStorage{key, nil}, nil
}
+4 -5
View File
@@ -12,11 +12,11 @@ import (
func toVMAccount(acc *account.Account) *vm.Account {
return &vm.Account{
Address: RightPadWord256(acc.Address),
Address: LeftPadWord256(acc.Address),
Balance: acc.Balance,
Code: acc.Code, // This is crazy.
Nonce: uint64(acc.Sequence),
StorageRoot: RightPadWord256(acc.StorageRoot),
StorageRoot: LeftPadWord256(acc.StorageRoot),
Other: acc.PubKey,
}
}
@@ -26,7 +26,6 @@ func toVMAccount(acc *account.Account) *vm.Account {
// Run a contract's code on an isolated and unpersisted state
// Cannot be used to create new contracts
func Call(address, data []byte) (*ctypes.ResponseCall, error) {
st := consensusState.GetState() // performs a copy
cache := mempoolReactor.Mempool.GetCache()
outAcc := cache.GetAccount(address)
@@ -38,7 +37,7 @@ func Call(address, data []byte) (*ctypes.ResponseCall, error) {
txCache := state.NewTxCache(cache)
params := vm.Params{
BlockHeight: uint64(st.LastBlockHeight),
BlockHash: RightPadWord256(st.LastBlockHash),
BlockHash: LeftPadWord256(st.LastBlockHash),
BlockTime: st.LastBlockTime.Unix(),
GasLimit: 10000000,
}
@@ -63,7 +62,7 @@ func CallCode(code, data []byte) (*ctypes.ResponseCall, error) {
txCache := state.NewTxCache(cache)
params := vm.Params{
BlockHeight: uint64(st.LastBlockHeight),
BlockHash: RightPadWord256(st.LastBlockHash),
BlockHash: LeftPadWord256(st.LastBlockHash),
BlockTime: st.LastBlockTime.Unix(),
GasLimit: 10000000,
}
+1 -1
View File
@@ -288,7 +288,7 @@ func simpleContract() ([]byte, []byte, []byte) {
// the is the code we need to return the contractCode when the contract is initialized
lenCode := len(contractCode)
// push code to the stack
//code := append([]byte{byte(0x60 + lenCode - 1)}, LeftPadWord256(contractCode).Bytes()...)
//code := append([]byte{byte(0x60 + lenCode - 1)}, RightPadWord256(contractCode).Bytes()...)
code := append([]byte{0x7f}, RightPadWord256(contractCode).Bytes()...)
// store it in memory
code = append(code, []byte{0x60, 0x0, 0x52}...)
+2 -2
View File
@@ -119,8 +119,8 @@ func testGetStorage(t *testing.T, typ string) {
mempoolCount = 0
v := getStorage(t, typ, contractAddr, []byte{0x1})
got := RightPadWord256(v)
expected := RightPadWord256([]byte{0x5})
got := LeftPadWord256(v)
expected := LeftPadWord256([]byte{0x5})
if got.Compare(expected) != 0 {
t.Fatalf("Wrong storage value. Got %x, expected %x", got.Bytes(), expected.Bytes())
}