Remove code field from state diff output

this is the contract byte code, and it can still be obtained by querying
the db by the codeHash
This commit is contained in:
Elizabeth Engelman 2019-01-02 14:18:41 -06:00
parent 0dacc940fd
commit feaff9998f
6 changed files with 2 additions and 17 deletions

View File

@ -155,7 +155,6 @@ func (sdb *builder) buildDiffEventual(accounts map[common.Address]*state.Account
return nil, err return nil, err
} }
codeBytes, err := sdb.chainDB.Get(val.CodeHash)
codeHash := hexutil.Encode(val.CodeHash) codeHash := hexutil.Encode(val.CodeHash)
hexRoot := val.Root.Hex() hexRoot := val.Root.Hex()
nonce := DiffUint64{Value: &val.Nonce} nonce := DiffUint64{Value: &val.Nonce}
@ -165,7 +164,6 @@ func (sdb *builder) buildDiffEventual(accounts map[common.Address]*state.Account
Nonce: nonce, Nonce: nonce,
Balance: balance, Balance: balance,
CodeHash: codeHash, CodeHash: codeHash,
Code: codeBytes,
ContractRoot: contractRoot, ContractRoot: contractRoot,
Storage: storageDiffs, Storage: storageDiffs,
} }

View File

@ -113,7 +113,6 @@ func TestBuilder(t *testing.T) {
account1Addr: { account1Addr: {
Nonce: b.DiffUint64{Value: &nonce0}, Nonce: b.DiffUint64{Value: &nonce0},
Balance: b.DiffBigInt{Value: big.NewInt(balanceChange10000)}, Balance: b.DiffBigInt{Value: big.NewInt(balanceChange10000)},
Code: nil,
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
ContractRoot: b.DiffString{Value: &originalContractRoot}, ContractRoot: b.DiffString{Value: &originalContractRoot},
Storage: map[string]b.DiffString{}, Storage: map[string]b.DiffString{},
@ -121,7 +120,6 @@ func TestBuilder(t *testing.T) {
burnAddress: { burnAddress: {
Nonce: b.DiffUint64{Value: &nonce0}, Nonce: b.DiffUint64{Value: &nonce0},
Balance: b.DiffBigInt{Value: big.NewInt(miningReward)}, Balance: b.DiffBigInt{Value: big.NewInt(miningReward)},
Code: nil,
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
ContractRoot: b.DiffString{Value: &originalContractRoot}, ContractRoot: b.DiffString{Value: &originalContractRoot},
Storage: map[string]b.DiffString{}, Storage: map[string]b.DiffString{},
@ -156,7 +154,6 @@ func TestBuilder(t *testing.T) {
account2Addr: { account2Addr: {
Nonce: b.DiffUint64{Value: &nonce0}, Nonce: b.DiffUint64{Value: &nonce0},
Balance: b.DiffBigInt{Value: big.NewInt(balanceChange1000)}, Balance: b.DiffBigInt{Value: big.NewInt(balanceChange1000)},
Code: nil,
CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", CodeHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
ContractRoot: b.DiffString{Value: &originalContractRoot}, ContractRoot: b.DiffString{Value: &originalContractRoot},
Storage: map[string]b.DiffString{}, Storage: map[string]b.DiffString{},
@ -164,7 +161,6 @@ func TestBuilder(t *testing.T) {
contractAddr: { contractAddr: {
Nonce: b.DiffUint64{Value: &nonce1}, Nonce: b.DiffUint64{Value: &nonce1},
Balance: b.DiffBigInt{Value: big.NewInt(0)}, Balance: b.DiffBigInt{Value: big.NewInt(0)},
Code: []byte{96, 96, 96, 64, 82, 96, 0, 53, 124, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 144, 4, 128, 99, 96, 205, 38, 133, 20, 96, 65, 87, 128, 99, 193, 100, 49, 185, 20, 96, 107, 87, 96, 63, 86, 91, 0, 91, 96, 85, 96, 4, 128, 128, 53, 144, 96, 32, 1, 144, 145, 144, 80, 80, 96, 169, 86, 91, 96, 64, 81, 128, 130, 129, 82, 96, 32, 1, 145, 80, 80, 96, 64, 81, 128, 145, 3, 144, 243, 91, 96, 136, 96, 4, 128, 128, 53, 144, 96, 32, 1, 144, 145, 144, 128, 53, 144, 96, 32, 1, 144, 145, 144, 80, 80, 96, 138, 86, 91, 0, 91, 128, 96, 0, 96, 0, 80, 131, 96, 100, 129, 16, 21, 96, 2, 87, 144, 144, 1, 96, 0, 91, 80, 129, 144, 85, 80, 91, 80, 80, 86, 91, 96, 0, 96, 0, 96, 0, 80, 130, 96, 100, 129, 16, 21, 96, 2, 87, 144, 144, 1, 96, 0, 91, 80, 84, 144, 80, 96, 199, 86, 91, 145, 144, 80, 86},
CodeHash: "0x1c671ee4ae8abbacab7da59d6f8785cce8295eb086551ce7ac266a2e93666c0f", CodeHash: "0x1c671ee4ae8abbacab7da59d6f8785cce8295eb086551ce7ac266a2e93666c0f",
ContractRoot: b.DiffString{Value: &originalContractRoot}, ContractRoot: b.DiffString{Value: &originalContractRoot},
Storage: map[string]b.DiffString{}, Storage: map[string]b.DiffString{},

View File

@ -58,7 +58,6 @@ func (sd *StateDiff) Encode() ([]byte, error) {
type AccountDiffEventual struct { type AccountDiffEventual struct {
Nonce DiffUint64 `json:"nonce" gencodec:"required"` Nonce DiffUint64 `json:"nonce" gencodec:"required"`
Balance DiffBigInt `json:"balance" gencodec:"required"` Balance DiffBigInt `json:"balance" gencodec:"required"`
Code []byte `json:"code" gencodec:"required"`
CodeHash string `json:"codeHash" gencodec:"required"` CodeHash string `json:"codeHash" gencodec:"required"`
ContractRoot DiffString `json:"contractRoot" gencodec:"required"` ContractRoot DiffString `json:"contractRoot" gencodec:"required"`
Storage map[string]DiffString `json:"storage" gencodec:"required"` Storage map[string]DiffString `json:"storage" gencodec:"required"`

View File

@ -12,9 +12,8 @@ import (
var ( var (
Headers = []string{ Headers = []string{
"blockNumber", "blockHash", "accountAction", "blockNumber", "blockHash", "accountAction", "codeHash",
"code", "codeHash", "nonceValue", "nonceValue", "balanceValue", "contractRoot", "storageDiffPaths",
"balanceValue", "contractRoot", "storageDiffPaths",
} }
timeStampFormat = "20060102150405.00000" timeStampFormat = "20060102150405.00000"
@ -108,7 +107,6 @@ func formatAccountDiffEventual(accountDiff builder.AccountDiffEventual, sd build
strconv.FormatInt(sd.BlockNumber, 10), strconv.FormatInt(sd.BlockNumber, 10),
sd.BlockHash.String(), sd.BlockHash.String(),
accountAction, accountAction,
string(accountDiff.Code),
accountDiff.CodeHash, accountDiff.CodeHash,
strconv.FormatUint(*accountDiff.Nonce.Value, 10), strconv.FormatUint(*accountDiff.Nonce.Value, 10),
accountDiff.Balance.Value.String(), accountDiff.Balance.Value.String(),
@ -128,7 +126,6 @@ func formatAccountDiffIncremental(accountDiff builder.AccountDiffIncremental, sd
strconv.FormatInt(sd.BlockNumber, 10), strconv.FormatInt(sd.BlockNumber, 10),
sd.BlockHash.String(), sd.BlockHash.String(),
accountAction, accountAction,
"",
accountDiff.CodeHash, accountDiff.CodeHash,
strconv.FormatUint(*accountDiff.Nonce.Value, 10), strconv.FormatUint(*accountDiff.Nonce.Value, 10),
accountDiff.Balance.Value.String(), accountDiff.Balance.Value.String(),

View File

@ -29,7 +29,6 @@ var expectedCreatedAccountRow = []string{
strconv.FormatInt(testhelpers.BlockNumber, 10), strconv.FormatInt(testhelpers.BlockNumber, 10),
testhelpers.BlockHash, testhelpers.BlockHash,
"created", "created",
"created account code",
testhelpers.CodeHash, testhelpers.CodeHash,
strconv.FormatUint(testhelpers.NewNonceValue, 10), strconv.FormatUint(testhelpers.NewNonceValue, 10),
strconv.FormatInt(testhelpers.NewBalanceValue, 10), strconv.FormatInt(testhelpers.NewBalanceValue, 10),
@ -41,7 +40,6 @@ var expectedUpdatedAccountRow = []string{
strconv.FormatInt(testhelpers.BlockNumber, 10), strconv.FormatInt(testhelpers.BlockNumber, 10),
testhelpers.BlockHash, testhelpers.BlockHash,
"updated", "updated",
"",
testhelpers.CodeHash, testhelpers.CodeHash,
strconv.FormatUint(testhelpers.NewNonceValue, 10), strconv.FormatUint(testhelpers.NewNonceValue, 10),
strconv.FormatInt(testhelpers.NewBalanceValue, 10), strconv.FormatInt(testhelpers.NewBalanceValue, 10),
@ -53,7 +51,6 @@ var expectedDeletedAccountRow = []string{
strconv.FormatInt(testhelpers.BlockNumber, 10), strconv.FormatInt(testhelpers.BlockNumber, 10),
testhelpers.BlockHash, testhelpers.BlockHash,
"deleted", "deleted",
"deleted account code",
testhelpers.CodeHash, testhelpers.CodeHash,
strconv.FormatUint(testhelpers.NewNonceValue, 10), strconv.FormatUint(testhelpers.NewNonceValue, 10),
strconv.FormatInt(testhelpers.NewBalanceValue, 10), strconv.FormatInt(testhelpers.NewBalanceValue, 10),

View File

@ -25,7 +25,6 @@ var (
Nonce: builder.DiffUint64{Value: &NewNonceValue}, Nonce: builder.DiffUint64{Value: &NewNonceValue},
Balance: builder.DiffBigInt{Value: big.NewInt(NewBalanceValue)}, Balance: builder.DiffBigInt{Value: big.NewInt(NewBalanceValue)},
ContractRoot: builder.DiffString{Value: &ContractRoot}, ContractRoot: builder.DiffString{Value: &ContractRoot},
Code: []byte("created account code"),
CodeHash: CodeHash, CodeHash: CodeHash,
Storage: storage, Storage: storage,
}} }}
@ -42,7 +41,6 @@ var (
Nonce: builder.DiffUint64{Value: &NewNonceValue}, Nonce: builder.DiffUint64{Value: &NewNonceValue},
Balance: builder.DiffBigInt{Value: big.NewInt(NewBalanceValue)}, Balance: builder.DiffBigInt{Value: big.NewInt(NewBalanceValue)},
ContractRoot: builder.DiffString{Value: &ContractRoot}, ContractRoot: builder.DiffString{Value: &ContractRoot},
Code: []byte("deleted account code"),
CodeHash: CodeHash, CodeHash: CodeHash,
Storage: storage, Storage: storage,
}} }}