diff --git a/CHANGELOG.md b/CHANGELOG.md index bae761b..9cfa5e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,18 @@ This is a development pre-release. Supported `polkadot-sdk` rev: `2503.0.1` +## v0.3.0 + +This is a development pre-release. + +Supported `polkadot-sdk` rev: `2503.0.1` + +### Fixed + +- llvm-context: Bugfix the SAR YUL builtin translation. +- npm package: Bugfix the exports field defined in the `package.json`. + + ## v0.2.0 This is a development pre-release. diff --git a/crates/integration/contracts/SAR.sol b/crates/integration/contracts/SAR.sol new file mode 100644 index 0000000..33c88b8 --- /dev/null +++ b/crates/integration/contracts/SAR.sol @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8; + +/* runner.json +{ + "differential": true, + "actions": [ + { + "Instantiate": { + "code": { + "Solidity": { + "contract": "SAR" + } + } + } + } + ] +} +*/ + +contract SAR { + constructor() payable { + assert(sar(0x03, 0x01) == 0x01); + assert( + sar( + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, + 0x01 + ) == 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ); + assert( + sar( + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, + 0xff + ) == 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ); + assert( + sar( + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, + 0x100 + ) == 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ); + } + + function sar(uint256 a, uint256 b) public pure returns (uint256 c) { + assembly { + c := sar(b, a) + } + } +} diff --git a/crates/integration/src/tests.rs b/crates/integration/src/tests.rs index 1cede1a..bdb9b0f 100644 --- a/crates/integration/src/tests.rs +++ b/crates/integration/src/tests.rs @@ -60,6 +60,7 @@ test_spec!(mload, "MLoad", "MLoad.sol"); test_spec!(delegate_no_contract, "DelegateCaller", "DelegateCaller.sol"); test_spec!(function_type, "FunctionType", "FunctionType.sol"); test_spec!(layout_at, "LayoutAt", "LayoutAt.sol"); +test_spec!(shift_arithmetic_right, "SAR", "SAR.sol"); fn instantiate(path: &str, contract: &str) -> Vec { vec![Instantiate { diff --git a/crates/llvm-context/src/polkavm/evm/bitwise.rs b/crates/llvm-context/src/polkavm/evm/bitwise.rs index 0a02239..b4a0217 100644 --- a/crates/llvm-context/src/polkavm/evm/bitwise.rs +++ b/crates/llvm-context/src/polkavm/evm/bitwise.rs @@ -204,7 +204,7 @@ where &context.word_type().const_all_ones(), overflow_negative_block, ), - (&context.word_const(0), overflow_block), + (&context.word_const(0), overflow_positive_block), ]); Ok(result.as_basic_value()) }