From cce45cc010746f59eb461458bdeb3e33f71faf2b Mon Sep 17 00:00:00 2001 From: cyl19970726 <15258378443@163.com> Date: Mon, 27 Feb 2023 18:30:44 +0800 Subject: [PATCH] support out-of-order upload chunks && add initcode_prefixLen --- .../database/EthStorage/LargeStorageManagerV2.sol | 13 +++++++------ .../v3/database/EthStorage/StorageHelperV2.sol | 1 + contracts/v3/database/ethstorage.sol | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/contracts/v3/database/EthStorage/LargeStorageManagerV2.sol b/contracts/v3/database/EthStorage/LargeStorageManagerV2.sol index 8896343..52aea97 100644 --- a/contracts/v3/database/EthStorage/LargeStorageManagerV2.sol +++ b/contracts/v3/database/EthStorage/LargeStorageManagerV2.sol @@ -22,12 +22,13 @@ contract LargeStorageManagerV2 { function _preparePut(bytes32 key, uint256 chunkId) private { bytes32 metadata = keyToMetadata[key][chunkId]; - if (metadata == bytes32(0)) { - require( - chunkId == 0 || keyToMetadata[key][chunkId - 1] != bytes32(0x0), - "must replace or append" - ); - } + // Remove the following code to support out-of-order upload chunks + // if (metadata == bytes32(0)) { + // require( + // chunkId == 0 || keyToMetadata[key][chunkId - 1] != bytes32(0x0), + // "must replace or append" + // ); + // } if (!metadata.isInSlot()) { address addr = metadata.bytes32ToAddr(); diff --git a/contracts/v3/database/EthStorage/StorageHelperV2.sol b/contracts/v3/database/EthStorage/StorageHelperV2.sol index f638e7c..448c315 100644 --- a/contracts/v3/database/EthStorage/StorageHelperV2.sol +++ b/contracts/v3/database/EthStorage/StorageHelperV2.sol @@ -5,6 +5,7 @@ import "./Memory.sol"; import "./StorageSlotFactory.sol"; library StorageHelperV2 { + uint256 public constant STORAGE_SLOT_CODE_V2_PREFIX_LEN = 280; // StorageSlotSelfDestructableV2 compiled via solc 0.8.7 optimized 200 bytes internal constant STORAGE_SLOT_CODE_V2 = hex"6080604052348015600f57600080fd5b506004361060285760003560e01c80632b68b9c614602d575b600080fd5b60336035565b005b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161460965760405162461bcd60e51b81526020600482015260036024820152624e464f60e81b604482015260640160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316fffea2646970667358221220154417754813d1989858c876ab2ded2ba1aa380679fff7a4c8faea076ba020e664736f6c63430008070033"; diff --git a/contracts/v3/database/ethstorage.sol b/contracts/v3/database/ethstorage.sol index 1456ce6..7a80126 100644 --- a/contracts/v3/database/ethstorage.sol +++ b/contracts/v3/database/ethstorage.sol @@ -57,7 +57,7 @@ contract ethstorage is LargeStorageManagerV2, database { bytes memory path, uint256 chunkId, bytes calldata data - ) external payable { + ) external payable override{ _putChunkFromCalldata( keccak256(bytes.concat(repoName, "/", path)), chunkId,