diff --git a/contracts/EthStorageContract.sol b/contracts/EthStorageContract.sol index 9411322..9863aa8 100644 --- a/contracts/EthStorageContract.sol +++ b/contracts/EthStorageContract.sol @@ -5,31 +5,6 @@ import "./StorageContract.sol"; import "./Decoder.sol"; import "./BinaryRelated.sol"; -contract BlobHashGetterFactory { - constructor() payable { - bytes memory code = hex"6000354960005260206000F3"; - uint256 size = code.length; - assembly { - return(add(code, 0x020), size) - } - } -} - -// TODO: remove the library if solidity has direct support the new opcode -library BlobHashGetter { - function getBlobHash(address getter, uint256 idx) internal view returns (bytes32) { - bool success; - bytes32 blobHash; - assembly { - mstore(0x0, idx) - success := staticcall(gas(), getter, 0x0, 0x20, 0x0, 0x20) - blobHash := mload(0x0) - } - require(success, "failed to get blob hash"); - return blobHash; - } -} - contract EthStorageContract is StorageContract, Decoder { uint256 constant modulusBls = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001; uint256 constant ruBls = 0x564c0a11a0f704f4fc3e8acfe0f8245f0ad1347b378fbf96e206da11a5d36306; @@ -37,8 +12,6 @@ contract EthStorageContract is StorageContract, Decoder { uint256 constant modulusBn254 = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001; uint256 constant fieldElementsPerBlob = 0x1000; - address public hashGetter; - event PutBlob(uint256 indexed kvIdx, uint256 indexed kvSize, bytes32 indexed dataHash); function initialize( @@ -51,7 +24,6 @@ contract EthStorageContract is StorageContract, Decoder { uint256 _prepaidAmount ) public payable initializer { __init_storage(_config, _startTime, _storageCost, _dcfFactor, _nonceLimit, _treasury, _prepaidAmount); - hashGetter = address(new BlobHashGetterFactory()); } function modExp(uint256 _b, uint256 _e, uint256 _m) internal view returns (uint256 result) { @@ -205,7 +177,7 @@ contract EthStorageContract is StorageContract, Decoder { // Write a large value to KV store. If the KV pair exists, overrides it. Otherwise, will append the KV to the KV array. function putBlob(bytes32 key, uint256 blobIdx, uint256 length) public payable virtual { - bytes32 dataHash = BlobHashGetter.getBlobHash(hashGetter, blobIdx); + bytes32 dataHash = blobhash(blobIdx); uint256 kvIdx = _putInternal(key, dataHash, length); emit PutBlob(kvIdx, length, dataHash); diff --git a/hardhat.config.js b/hardhat.config.js index 2479a47..ceb4674 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -75,12 +75,13 @@ module.exports = { timeout: 120000, }, solidity: { - version: "0.8.20", + version: "0.8.24", settings: { optimizer: { enabled: true, runs: 200, }, + evmVersion: "cancun", }, }, };