Skip to content

Commit

Permalink
Merge pull request #157 from everx-labs/0.75.0
Browse files Browse the repository at this point in the history
0.75.0
  • Loading branch information
IgorKoval authored Jul 1, 2024
2 parents ec2400c + 69488ef commit 7f26a06
Show file tree
Hide file tree
Showing 46 changed files with 2,351 additions and 1,214 deletions.
422 changes: 378 additions & 44 deletions API.md

Large diffs are not rendered by default.

664 changes: 211 additions & 453 deletions Cargo.lock

Large diffs are not rendered by default.

40 changes: 34 additions & 6 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
### 0.75.0 (2024-06-04)

Breaking changes:
* If the contract does not have constructor explicitly and does not have state variables with initialisation, then in `*.abi.json` file there is no `constructor` function and no `_constructorFlag` field. See [Deploy the contract with no constructor](API.md#deploy-the-contract-with-no-constructor) for more details.

Bugfixes:
* Peephole optimizer generated invalid code. See [issue #153](https://github.com/everx-labs/TVM-Solidity-Compiler/issues/153).
* Fixed segmentation fault that occurred in some cases of using incorrect types for `math.*` and some another functions.
* Fixed minor bugs in TypeChecker (using bad type for mapping value).

Compiler features:
* Supported `stateInit`option for [External function calls](./API.md#external-function-calls).
* Supported [math.mulmod()](./API.md#mathmulmod).
* Supported functions to work with `TvmSlice`'s:
* [\<TvmSlice\>.bitEmpty() and \<TvmSlice\>.refEmpty()](./API.md#tvmsliceempty-tvmslicebitempty-and-tvmslicerefempty)
* [\<TvmSlice\>.startsWith()](./API.md#tvmslicestartswith)
* [\<TvmSlice\>.startsWithOne()](./API.md#tvmslicestartswithone)
* Supported [operations on a pairing friendly BLS12-381 curve](./API.md#bls-namespace).
* Supported conversion string literals to `TvmSlice`, e.g. `TvmSlice s = "0189abef_";`.

Usability:
* Print function-candidates on compilation failure (for function overloading).

Optimizations:
* 14-bit numbers are used for function ids for private/internal functions for code optimizations instead of 32-bit.
32-bit numbers are still used for `onCodeUpgrade` functions for back compatibility.
* peephole optimizations.

### 0.74.0 (2024-04-11)

Breaking changes:
Expand Down Expand Up @@ -31,11 +59,11 @@ Other changes:
Update compiler frontend (from original version 0.8.17 to 0.8.24). Full changelog can be found [here](./compiler/Changelog.md).

Breaking changes:
* Supported [ABI 2.4](https://github.com/tonlabs/ever-abi/blob/master/CHANGELOG.md#version-240).
* Supported [ABI 2.4](https://github.com/everx-labs/ever-abi/blob/master/CHANGELOG.md#version-240).
* Deleted `tvm.insertPubkey()` function.
* Deleted `address.makeAddrNone()` function. Use [address.addrNone](./API.md#addressaddrnone).
* Default value for `address` type was `address(0)` but now it is [address.addrNone](./API.md#addressaddrnone).
* `byteN` in `*abi.json` file marked as `fixedbytesN`. See [ABI.md](https://github.com/tonlabs/ever-abi/blob/master/docs/ABI.md#fixedbytesn).
* `byteN` in `*abi.json` file marked as `fixedbytesN`. See [ABI.md](https://github.com/everx-labs/ever-abi/blob/master/docs/ABI.md#fixedbytesn).
* [abi.encodeStateInit()](./API.md#abiencodestateinit), [abi.encodeData()](./API.md#abiencodedata) functions and [Deploy via new](./API.md#deploy-via-new) generate contract's data in the new format. To deploy old contracts (with version < 0.72.0) from new ones (with version >= 0.72.0) use [abi.encodeOldDataInit()](./API.md#abiencodeolddatainit).
* [format()](API.md#format) no longer throws an exception if formatted value exceeds the specified width. E.g. `format("{:1d}", 10) == "10"` now is correct, no exception.
* Functions and constructions previously working with `uint128` value, now using `varUint16`:
Expand Down Expand Up @@ -81,7 +109,7 @@ Other changes:

### 0.72.0 (2023-10-31)

Use [sold](https://github.com/tonlabs/TVM-Solidity-Compiler/tree/master/sold) to compile contracts. If you used `solc`+`tvm_linker`, then use `solc`+[asm](https://github.com/tonlabs/ever-assembler). Generated `*.code` files have some another format.
Use [sold](https://github.com/everx-labs/TVM-Solidity-Compiler/tree/master/sold) to compile contracts. If you used `solc`+`tvm_linker`, then use `solc`+[asm](https://github.com/everx-labs/ever-assembler). Generated `*.code` files have some another format.

Breaking changes:
* The conversion for integer type is only allowed when there is at most one change in sign, width or type-category (`int`, `address`, `bytesNN`, etc.). To perform multiple changes, use multiple conversions. See [Solidity v0.8.0 Breaking Changes](https://docs.soliditylang.org/en/v0.8.17/080-breaking-changes.html#new-restrictions). For example, to convert `int8 x;` to `uint` you can use at least two ways: 1) `uint(uint8(x))`, 2) `uint(int(x))`.
Expand Down Expand Up @@ -268,10 +296,10 @@ Compiler features:

### 0.64.0 (2022-08-18)

Fixed build [sold](https://github.com/tonlabs/TVM-Solidity-Compiler/tree/master/sold) for Windows and macOS.
Fixed build [sold](https://github.com/everx-labs/TVM-Solidity-Compiler/tree/master/sold) for Windows and macOS.

Compiler features:
* Supported [ABI v2.3](https://github.com/tonlabs/ton-labs-abi/blob/master/docs/ABI_2.3_spec.md).
* Supported [ABI v2.3](https://github.com/everx-labs/ever-abi/blob/master/docs/ABI_2.3_spec.md).
* Supported try-catch (experimental feature).
* Supported type `variant`.

Expand Down Expand Up @@ -513,7 +541,7 @@ Compiler features:
* Added support of `bytes` to `bytesN` conversion.

Support ABI 2.1:
* Field `fields` appeared in abi file. You can parse state variable. See `tonos-cli decode account --help`.
* Field `fields` appeared in abi file. You can parse state variable. See `ever-cli decode account --help`.
* Supported `string` type in abi.

Bugfixes:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

# The TVM Solidity compiler

[![GitHub](https://img.shields.io/github/license/tonlabs/TVM-Solidity-Compiler?style=for-the-badge)](./LICENSE)
[![GitHub](https://img.shields.io/github/license/everx-labs/TVM-Solidity-Compiler?style=for-the-badge)](./LICENSE)
[![Everscale](https://custom-icon-badges.demolab.com/badge/-everscale-13173e?style=for-the-badge&logoColor=yellow&logo=everscale)](https://everscale.network/)


Port of the Solidity smart-contract [compiler](https://github.com/ethereum/solidity) generating TVM bytecode for TVM compatible blockchains (Everscale, Venom, Gosh, TON). Please refer to upstream README.md for information on the language itself.

## TVM Solidity API reference

[API documentation is here](https://github.com/tonlabs/TVM-Solidity-Compiler/blob/master/API.md)
[API documentation is here](https://github.com/everx-labs/TVM-Solidity-Compiler/blob/master/API.md)

## Build and Install

### Sold driver

We recommend using `sold` to compile smart-contracts. Documentation is available at [README.md](https://github.com/tonlabs/TVM-Solidity-Compiler/blob/master/sold/README.md).
We recommend using `sold` to compile smart-contracts. Documentation is available at [README.md](https://github.com/everx-labs/TVM-Solidity-Compiler/blob/master/sold/README.md).

### Building compiler

Expand All @@ -27,7 +27,7 @@ Original Instructions about how to build and install the Solidity compiler can b
#### Ubuntu Linux

```shell
git clone https://github.com/tonlabs/TVM-Solidity-Compiler
git clone https://github.com/everx-labs/TVM-Solidity-Compiler
cd TVM-Solidity-Compiler
sh ./compiler/scripts/install_deps.sh
mkdir build
Expand All @@ -42,7 +42,7 @@ Install Visual Studio Build Tools 2019, Git bash, cmake.
Run Developer PowerShell for VS 2019

```shell
git clone https://github.com/tonlabs/TVM-Solidity-Compiler
git clone https://github.com/everx-labs/TVM-Solidity-Compiler
cd TVM-Solidity-Compiler
compiler\scripts\install_deps.ps1
mkdir build
Expand All @@ -53,11 +53,11 @@ cmake --build . --config Release -- /m
## Links
* [Ever assembler and disassembler](https://github.com/tonlabs/ever-assembler)
* [Code samples](https://github.com/tonlabs/samples/tree/master/solidity) in TVM Solidity
* [tonos-cli](https://github.com/tonlabs/tonos-cli) command line interface for TVM compatible blockchains
* Example of usage `tonos-cli` for working (deploying, calling etc.) with TVM compatible blockchains can be found there: [Write smart contract in Solidity](https://docs.ton.dev/86757ecb2/p/950f8a-write-smart-contract-in-solidity)
* [Changelog](https://github.com/tonlabs/TVM-Solidity-Compiler/blob/master/Changelog_TON.md)
* [Ever assembler and disassembler](https://github.com/everx-labs/ever-assembler)
* [Code samples](https://github.com/everx-labs/samples/tree/master/solidity) in TVM Solidity
* [ever-cli](https://github.com/everx-labs/ever-cli) command line interface for TVM compatible blockchains
* Example of usage `ever-cli` for working (deploying, calling etc.) with TVM compatible blockchains can be found there: [Write smart contract in Solidity](https://docs.ton.dev/86757ecb2/p/950f8a-write-smart-contract-in-solidity)
* [Changelog](https://github.com/everx-labs/TVM-Solidity-Compiler/blob/master/Changelog_TON.md)
## License
[GNU GENERAL PUBLIC LICENSE Version 3](./LICENSE)
2 changes: 1 addition & 1 deletion compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include(EthPolicy)
eth_policy()

# project name and version should be set after cmake_policy CMP0048
set(PROJECT_VERSION "0.74.0")
set(PROJECT_VERSION "0.75.0")
# OSX target needed in order to support std::visit
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
Expand Down
17 changes: 12 additions & 5 deletions compiler/libsolidity/analysis/DeclarationTypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,27 @@ void DeclarationTypeChecker::endVisit(Optional const& _optional)
types.emplace_back(c->annotation().type);
}

if (comp.size() == 1) {
if (comp.size() == 1)
_optional.annotation().type = TypeProvider::optional(types.at(0));
} else {
else
_optional.annotation().type = TypeProvider::optional(TypeProvider::tuple(types));
}
}

void DeclarationTypeChecker::endVisit(TvmVector const& _tvmVector)
{
if (_tvmVector.annotation().type)
return;

TypeName const& type = _tvmVector.type();
_tvmVector.annotation().type = TypeProvider::tvmVector(type.annotation().type);
std::vector<ASTPointer<TypeName>> const& comp = _tvmVector.types();
std::vector<Type const*> types;
for (const ASTPointer<TypeName>& c : comp) {
types.emplace_back(c->annotation().type);
}

if (comp.size() == 1)
_tvmVector.annotation().type = TypeProvider::tvmVector(types.at(0));
else
_tvmVector.annotation().type = TypeProvider::tvmVector(TypeProvider::tuple(types));
}

void DeclarationTypeChecker::endVisit(TvmStack const& _tvmStack)
Expand Down
16 changes: 9 additions & 7 deletions compiler/libsolidity/analysis/GlobalContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ int magicVariableToID(std::string const& _name)
else if (_name == "blockhash") return -5;
else if (_name == "ecrecover") return -6;
else if (_name == "gasleft") return -7;
else if (_name == "format") return -105;
else if (_name == "keccak256") return -8;
else if (_name == "logtvm") return -102;
else if (_name == "math") return -103;
else if (_name == "rnd") return -105;
else if (_name == "gosh") return -107;
else if (_name == "msg") return -15;
else if (_name == "mulmod") return -16;
else if (_name == "now") return -17;
Expand All @@ -59,9 +54,7 @@ int magicVariableToID(std::string const& _name)
else if (_name == "selfdestruct") return -21;
else if (_name == "sha256") return -22;
else if (_name == "sha3") return -23;
else if (_name == "stoi") return -106;
else if (_name == "super") return -25;
else if (_name == "tvm") return -101;
else if (_name == "tx") return -26;
else if (_name == "type") return -27;
else if (_name == "this") return -28;
Expand All @@ -70,6 +63,14 @@ int magicVariableToID(std::string const& _name)
else if (_name == "valueToGas") return -61;
else if (_name == "bitSize") return -62;
else if (_name == "uBitSize") return -63;
else if (_name == "tvm") return -101;
else if (_name == "logtvm") return -102;
else if (_name == "math") return -103;
else if (_name == "format") return -104;
else if (_name == "rnd") return -105;
else if (_name == "stoi") return -106;
else if (_name == "gosh") return -107;
else if (_name == "bls") return -108;
else
solAssert(false, "Unknown magic variable: \"" + _name + "\".");
}
Expand Down Expand Up @@ -107,6 +108,7 @@ inline std::vector<std::shared_ptr<MagicVariableDeclaration const>> constructMag
FunctionType::Kind::Stoi,
StateMutability::Pure)
),
magicVarDecl("bls", TypeProvider::magic(MagicType::Kind::BLS)),
magicVarDecl("tvm", TypeProvider::magic(MagicType::Kind::TVM)),
magicVarDecl("tx", TypeProvider::magic(MagicType::Kind::Transaction)),
// Accepts a MagicType that can be any contract type or an Integer type and returns a
Expand Down
Loading

0 comments on commit 7f26a06

Please sign in to comment.