Remove StorageRoot from vm.Account

This commit is contained in:
Jae Kwon
2015-07-28 12:39:10 -07:00
parent 5230440141
commit 1a5bc9eeb2
5 changed files with 16 additions and 30 deletions

View File

@ -16,7 +16,6 @@ func toVMAccount(acc *acm.Account) *vm.Account {
Balance: acc.Balance,
Code: acc.Code, // This is crazy.
Nonce: int64(acc.Sequence),
StorageRoot: LeftPadWord256(acc.StorageRoot),
Other: acc.PubKey,
}
}

View File

@ -75,7 +75,6 @@ func (cache *TxCache) CreateAccount(creator *vm.Account) *vm.Account {
Balance: 0,
Code: nil,
Nonce: 0,
StorageRoot: Zero256,
Permissions: cache.GetAccount(ptypes.GlobalPermissionsAddress256).Permissions,
Other: nil,
}
@ -157,7 +156,6 @@ func toVMAccount(acc *acm.Account) *vm.Account {
Balance: acc.Balance,
Code: acc.Code, // This is crazy.
Nonce: int64(acc.Sequence),
StorageRoot: LeftPadWord256(acc.StorageRoot),
Permissions: acc.Permissions, // Copy
Other: acc.PubKey,
}
@ -170,19 +168,12 @@ func toStateAccount(acc *vm.Account) *acm.Account {
pubKey = nil
}
var storageRoot []byte
if acc.StorageRoot.IsZero() {
storageRoot = nil
} else {
storageRoot = acc.StorageRoot.Postfix(20)
}
return &acm.Account{
Address: acc.Address.Postfix(20),
PubKey: pubKey,
Balance: acc.Balance,
Code: acc.Code,
Sequence: int(acc.Nonce),
StorageRoot: storageRoot,
Permissions: acc.Permissions, // Copy
}
}

View File

@ -4,13 +4,11 @@ import (
"bytes"
"testing"
. "github.com/tendermint/tendermint/common"
"github.com/tendermint/tendermint/wire"
)
func TestStateToFromVMAccount(t *testing.T) {
acmAcc1, _ := RandAccount(true, 456)
acmAcc1.StorageRoot = RandBytes(20)
vmAcc := toVMAccount(acmAcc1)
acmAcc2 := toStateAccount(vmAcc)

View File

@ -40,7 +40,6 @@ func (fas *FakeAppState) CreateAccount(creator *Account) *Account {
Balance: 0,
Code: nil,
Nonce: 0,
StorageRoot: Zero256,
}
} else {
panic(Fmt("Invalid account addr: %X", addr))

View File

@ -14,7 +14,6 @@ type Account struct {
Balance int64
Code []byte
Nonce int64
StorageRoot Word256
Other interface{} // For holding all other data.
Permissions ptypes.AccountPermissions
@ -24,8 +23,8 @@ func (acc *Account) String() string {
if acc == nil {
return "nil-VMAccount"
}
return Fmt("VMAccount{%X B:%v C:%X N:%v S:%X}",
acc.Address, acc.Balance, acc.Code, acc.Nonce, acc.StorageRoot)
return Fmt("VMAccount{%X B:%v C:%X N:%v}",
acc.Address, acc.Balance, acc.Code, acc.Nonce)
}
// NOTE: This is serialized as an event from vm/vm.