diff options
author | yenlin.lai <yenlin.lai@cobinhood.com> | 2019-04-12 11:18:24 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-05-06 10:44:04 +0800 |
commit | 5b71bbd50a64d3b1576626d4cf0ca22569b57cf8 (patch) | |
tree | 50f3b391c6f5995225396a1a9379791c2b292a93 /core/vm/sqlvm/runtime | |
parent | c044cbc979abae7563344d6b047a6b0c616d7b7f (diff) | |
download | dexon-5b71bbd50a64d3b1576626d4cf0ca22569b57cf8.tar dexon-5b71bbd50a64d3b1576626d4cf0ca22569b57cf8.tar.gz dexon-5b71bbd50a64d3b1576626d4cf0ca22569b57cf8.tar.bz2 dexon-5b71bbd50a64d3b1576626d4cf0ca22569b57cf8.tar.lz dexon-5b71bbd50a64d3b1576626d4cf0ca22569b57cf8.tar.xz dexon-5b71bbd50a64d3b1576626d4cf0ca22569b57cf8.tar.zst dexon-5b71bbd50a64d3b1576626d4cf0ca22569b57cf8.zip |
sqlvm: common: refine StateDB/Storage
In the context of vm module, we usually access vm.StateDB interface
object instead of state.StateDB directly. Also, state.StateDB is usually
passed with pointer and used with pointer receiver. Implement the
similar behavior on Storage object.
Diffstat (limited to 'core/vm/sqlvm/runtime')
-rw-r--r-- | core/vm/sqlvm/runtime/instructions_test.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/core/vm/sqlvm/runtime/instructions_test.go b/core/vm/sqlvm/runtime/instructions_test.go index fe9f15994..7cf05c9f5 100644 --- a/core/vm/sqlvm/runtime/instructions_test.go +++ b/core/vm/sqlvm/runtime/instructions_test.go @@ -59,13 +59,12 @@ func createSchema(storage *common.Storage, raws []*raw) { ) } storage.Schema.SetupColumnOffset() - storage.Commit(false) } // setSlotDataInStateDB store data in StateDB, and // return corresponding slot hash and raw slice. func setSlotDataInStateDB(head dexCommon.Hash, addr dexCommon.Address, - storage common.Storage) ([]dexCommon.Hash, []*raw) { + storage *common.Storage) ([]dexCommon.Hash, []*raw) { hash := dexCommon.Hash{} var b []byte @@ -176,7 +175,6 @@ func setSlotDataInStateDB(head dexCommon.Hash, addr dexCommon.Address, ptr = crypto.Keccak256Hash(ptr.Bytes()) storage.SetState(addr, ptr, hash) - storage.Commit(false) return hData, raws } @@ -219,7 +217,7 @@ func (s *opLoadSuite) SetupTest() { s.ctx.Contract = vm.NewContract(vm.AccountRef(s.address), vm.AccountRef(s.address), new(big.Int), 0) s.slotHash, s.raws = setSlotDataInStateDB(s.headHash, s.address, s.ctx.Storage) - createSchema(&s.ctx.Storage, s.raws) + createSchema(s.ctx.Storage, s.raws) s.setColData("Table_B", 654321) } @@ -285,10 +283,10 @@ func (s *opLoadSuite) getOKCaseFields(raws []*raw) []uint8 { } func (s *opLoadSuite) getDecodeTestCases(headHash dexCommon.Hash, - address dexCommon.Address, storage common.Storage) []decodeTestCase { + address dexCommon.Address, storage *common.Storage) []decodeTestCase { slotHash, raws := setSlotDataInStateDB(headHash, address, storage) - createSchema(&storage, raws) + createSchema(storage, raws) testCases := make([]decodeTestCase, len(raws)) for i := range testCases { @@ -375,7 +373,7 @@ func newFieldsOperand(fields []uint8) *Operand { return o } -func (s *opLoadSuite) newStorage() common.Storage { +func (s *opLoadSuite) newStorage() *common.Storage { db := ethdb.NewMemDatabase() state, _ := state.New(dexCommon.Hash{}, state.NewDatabase(db)) storage := common.NewStorage(state) |