1c0e57d984
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
76 lines
2.1 KiB
Solidity
76 lines
2.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.24;
|
|
|
|
contract Memory {
|
|
/// @notice Expands memory to the specified size by writing a byte at that offset
|
|
/// @param memorySize The memory size in bytes to expand to
|
|
function expandMemory(uint64 memorySize) public pure returns (bool success) {
|
|
// Allocate memory by accessing a byte at the specified offset
|
|
// This will trigger memory expansion up to at least memorySize + 1
|
|
assembly {
|
|
// Store a single byte (0xFF) at the memory offset
|
|
// This forces the EVM to expand memory to accommodate this write
|
|
mstore8(memorySize, 0xFF)
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function testMemory() public {
|
|
uint256 value = 0xfe;
|
|
assembly {
|
|
mstore(0, value)
|
|
}
|
|
uint256 result = 123;
|
|
assembly {
|
|
result := mload(0)
|
|
}
|
|
require(result == value, "Memory test failed");
|
|
|
|
for (uint256 i = 0; i < 32; i++) {
|
|
assembly {
|
|
mstore8(i, value)
|
|
}
|
|
}
|
|
assembly {
|
|
result := mload(0)
|
|
}
|
|
require(result == 0xfefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe, "Memory test failed");
|
|
|
|
assembly {
|
|
result := msize()
|
|
}
|
|
require(result == 96, "Memory size test failed");
|
|
}
|
|
|
|
function testMsize(uint64 offset) public returns (uint64) {
|
|
assembly {
|
|
mstore(offset, 123)
|
|
}
|
|
uint256 value;
|
|
assembly {
|
|
value := msize()
|
|
}
|
|
return uint64(value);
|
|
}
|
|
|
|
function testMcopy(uint64 dstOffset, uint64 offset, uint64 size, uint64 value) public returns (uint64) {
|
|
assembly {
|
|
mstore(dstOffset, 0)
|
|
}
|
|
for (uint256 i = 0; i < size; i += 32) {
|
|
assembly {
|
|
mstore(add(offset, i), value)
|
|
}
|
|
}
|
|
assembly {
|
|
mcopy(dstOffset, offset, size)
|
|
}
|
|
uint256 result = 123;
|
|
assembly {
|
|
result := mload(dstOffset)
|
|
}
|
|
return uint64(result);
|
|
}
|
|
}
|