Skip to content

Conversation

cyl19970726
Copy link

No description provided.

@cyl19970726 cyl19970726 requested a review from qizhou November 21, 2022 15:45
@cyl19970726
Copy link
Author

The remove operation consists of two steps.

  • First, replace the data corresponding to removeKvIdx selected by the operator with data of lastKvIdx
  • Second, set the data space of the original lastKvIdx to 0

Test

  • Tests are written in the contracts_test.go file.
  • I prepare three shards to test.
    • Shard Info : MaxKvEntries = 10; KVSize = 4 * 1024; chunksPerKv = 1; ChunkSize = 4 *1024
  • Test case cover:
    • put
      • put test: the operation of storing data will fill up all shards
    • update
      • update test : the operation of updating data will update all data stored in each shard
    • remove
      • remove test:
        • case 1: removeKvIdx is equal to lastKvIdx
        • case 2: removeKvIdx and lastKvIdx are in the same Shard
        • case 3: removeKvIdx and lastKvIdx are in the different Shard

evm.StateDB.SstorageWrite(caller, lastKvIdx.Uint64(), make([]byte, sstorage.ShardInfos[0].KVSize))
} else {
// Read the data corresponding to lastKvIdx
replaceData, _, _ := evm.StateDB.SstorageRead(caller, lastKvIdx.Uint64(), int(sstorage.ShardInfos[0].KVSize), common.Hash{})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the replaceData does not exist locally?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took an approach that only allows deletion of KV entries in the last shard

Copy link
Collaborator

@blockchaindevsh blockchaindevsh Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen in this case: the shard is still synchronizing, so the SstorageRead may be stale. If we move the last kv into a kv index past synchronizing, the stale data will be there forever. If we add verification logic when SstorageRead, we can't even guarantee the execution result is the same across nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants