Skip to content

Commit

Permalink
0.74.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKoval committed Apr 18, 2024
1 parent 82d8855 commit 2b58716
Show file tree
Hide file tree
Showing 75 changed files with 5,054 additions and 3,077 deletions.
782 changes: 483 additions & 299 deletions API.md

Large diffs are not rendered by default.

244 changes: 124 additions & 120 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 30 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
### 0.74.0 (2024-04-11)

Breaking changes:
* Now `int` is alias for `int257`, not for `int256`. That's why `*loadInt*` functions return `int257` and `*storeInt*` functions take `int257`.
* Deleted debots supporting.
* Now [vector](API.md#vectort) can contain at least 255 elements.

Bugfixes:
* Fixed minor bugs in TypeChecker.
* Fixed compilation fail when you have private and public functions with the same name in the contract.
* Fixed another minor bugs.

Compiler features:
* Supported [quiet arithmetic](./API.md#quiet-arithmetic).
* Supported [StringBuilder](./API.md#stringbuilder).
* Supported [int257](API.md#integers).
* Supported [\<vector(T)\>.last()](API.md#vectortlast).
* Supported [stack(T)](API.md#stackt).
* Supported unary operators (`++`, `--`, `-`, `delete` and `~`) for [varint and varuint](API.md#varint-and-varuint).
* Supported [Free function call via object](API.md#free-function-call-via-object).

Other changes:
* Renamed some types. Old types are available and marked as deprecated. Renaming:
* `varInt` -> `varint`
* `varUint` -> `varuint`
* `varIntM` -> `varintM`
* `varUintM` -> `varuintM`

### 0.73.0 (2024-02-12)

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

### 0.72.0 (2023-10-31)

Use [sold](https://github.com/tonlabs/TON-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/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.

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 @@ -240,7 +268,7 @@ Compiler features:

### 0.64.0 (2022-08-18)

Fixed build [sold](https://github.com/tonlabs/TON-Solidity-Compiler/tree/master/sold) for Windows and macOS.
Fixed build [sold](https://github.com/tonlabs/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).
Expand Down
16 changes: 8 additions & 8 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/TON-Solidity-Compiler?style=for-the-badge)](./LICENSE)
[![GitHub](https://img.shields.io/github/license/tonlabs/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/TON-Solidity-Compiler/blob/master/API.md)
[API documentation is here](https://github.com/tonlabs/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/TON-Solidity-Compiler/blob/master/sold/README.md).
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).

### Building compiler

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

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

```shell
git clone https://github.com/tonlabs/TON-Solidity-Compiler
cd TON-Solidity-Compiler
git clone https://github.com/tonlabs/TVM-Solidity-Compiler
cd TVM-Solidity-Compiler
compiler\scripts\install_deps.ps1
mkdir build
cd build
Expand All @@ -57,7 +57,7 @@ cmake --build . --config Release -- /m
* [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/TON-Solidity-Compiler/blob/master/Changelog_TON.md)
* [Changelog](https://github.com/tonlabs/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.73.0")
set(PROJECT_VERSION "0.74.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
43 changes: 39 additions & 4 deletions compiler/liblangutil/Token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,28 @@ void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _fi
"No elementary type " + std::string(TokenTraits::toString(_baseType)) + std::to_string(_first) + "."
);
}
else if (_baseType == Token::QUIntM || _baseType == Token::QIntM)
{
unsigned bitLength = _baseType == Token::QUIntM ? 256 : 257;
solAssert(_second == 0, "There should not be a second size argument to type " + std::string(TokenTraits::toString(_baseType)) + ".");
solAssert(
_first <= bitLength,
"No elementary type " + std::string(TokenTraits::toString(_baseType)) + std::to_string(_first) + "."
);
}
else if (_baseType == Token::QBool)
{
// all right
}
else if (_baseType == Token::UFixedMxN || _baseType == Token::FixedMxN)
{
solAssert(
_first >= 8 && _first <= 256 && _second <= 80,
"No elementary type " + std::string(TokenTraits::toString(_baseType)) + std::to_string(_first) + "x" + std::to_string(_second) + "."
);
}
else if (_baseType == Token::VarUintM || _baseType == Token::VarIntM)
else if (_baseType == Token::VarUintM || _baseType == Token::VarIntM ||
_baseType == Token::VaruintM || _baseType == Token::VarintM)
{
solAssert(_first == 16 || _first == 32, "");
}
Expand Down Expand Up @@ -193,12 +207,18 @@ std::tuple<Token, unsigned int, unsigned int> fromIdentifierOrKeyword(std::strin
int m = parseSize(positionM, positionX);
Token keyword = keywordByName(baseType);


if (keyword == Token::VarUint || keyword == Token::VarInt) {
if (keyword == Token::VarUint || keyword == Token::VarInt ||
keyword == Token::Varuint || keyword == Token::Varint) {
if (m == 16 || m == 32) {
if (keyword == Token::VarUint)
return std::make_tuple(Token::VarUintM, m, 0);
return std::make_tuple(Token::VarIntM, m, 0);
if (keyword == Token::Varuint)
return std::make_tuple(Token::VaruintM, m, 0);
if (keyword == Token::VarInt)
return std::make_tuple(Token::VarIntM, m, 0);
if (keyword == Token::Varint)
return std::make_tuple(Token::VarintM, m, 0);
solUnimplemented("");
}
}
else if (keyword == Token::Bytes)
Expand All @@ -217,6 +237,21 @@ std::tuple<Token, unsigned int, unsigned int> fromIdentifierOrKeyword(std::strin
return std::make_tuple(Token::IntM, m, 0);
}
}
else if (keyword == Token::QUInt || keyword == Token::QInt)
{
int bitLength = keyword == Token::QUInt ? 256 : 257;
if (0 < m && m <= bitLength && positionX == _literal.end())
{
if (keyword == Token::QUInt)
return std::make_tuple(Token::QUIntM, m, 0);
else
return std::make_tuple(Token::QIntM, m, 0);
}
}
else if (keyword == Token::QBool)
{
return std::make_tuple(Token::QBool, 0, 0);
}
else if (keyword == Token::UFixed || keyword == Token::Fixed)
{
if (
Expand Down
16 changes: 13 additions & 3 deletions compiler/liblangutil/Token.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ namespace solidity::langutil
K(Anonymous, "anonymous", 0) \
K(As, "as", 0) \
K(Assembly, "assembly", 0) \
K(Await, "await", 0) \
K(Break, "break", 0) \
K(Catch, "catch", 0) \
K(Constant, "constant", 0) \
Expand All @@ -157,7 +156,6 @@ namespace solidity::langutil
K(Emit, "emit", 0) \
K(Event, "event", 0) \
K(External, "external", 0) \
K(ExtMsg, "extMsg", 0) \
K(Fallback, "fallback", 0) \
K(onBounce, "onBounce", 0) \
K(For, "for", 0) \
Expand All @@ -180,6 +178,7 @@ namespace solidity::langutil
K(NoStorage, "nostorage", 0) \
K(Optional, "optional", 0) \
K(TvmVector, "vector", 0) \
K(TvmStack, "stack", 0) \
K(Override, "override", 0) \
K(Payable, "payable", 0) \
K(Public, "public", 0) \
Expand Down Expand Up @@ -239,26 +238,36 @@ namespace solidity::langutil
/* type keywords*/ \
K(Int, "int", 0) \
K(UInt, "uint", 0) \
K(QInt, "qint", 0) \
K(QUInt, "quint", 0) \
K(QBool, "qbool", 0) \
K(Bytes, "bytes", 0) \
K(String, "string", 0) \
K(Address, "address", 0) \
K(Bool, "bool", 0) \
K(TvmCell, "TvmCell", 0) \
K(TvmSlice, "TvmSlice", 0) \
K(TvmBuilder, "TvmBuilder", 0) \
K(StringBuilder, "StringBuilder", 0) \
K(Variant, "variant", 0) \
K(Fixed, "fixed", 0) \
K(UFixed, "ufixed", 0) \
T(IntM, "intM", 0) \
T(UIntM, "uintM", 0) \
T(QIntM, "qintM", 0) \
T(QUIntM, "quintM", 0) \
T(BytesM, "bytesM", 0) \
T(FixedMxN, "fixedMxN", 0) \
T(UFixedMxN, "ufixedMxN", 0) \
K(VarInt, "varInt", 0) \
K(Varint, "varint", 0) \
T(VarIntM, "varIntM", 0) \
T(VarintM, "varintM", 0) \
K(VarUint, "varUint", 0) \
K(coins, "coins", 0) \
K(Varuint, "varuint", 0) \
T(VarUintM, "varUintM", 0) \
T(VaruintM, "varuintM", 0) \
K(coins, "coins", 0) \
T(TypesEnd, nullptr, 0) /* used as type enum end marker */ \
\
/* Literals */ \
Expand Down Expand Up @@ -293,6 +302,7 @@ namespace solidity::langutil
K(Mutable, "mutable", 0) \
K(NullLiteral, "null", 0) \
K(EmptyMap, "emptyMap", 0) \
K(TVMNaN, "NaN", 0) \
K(Of, "of", 0) \
K(Partial, "partial", 0) \
K(Promise, "promise", 0) \
Expand Down
17 changes: 16 additions & 1 deletion compiler/libsolidity/analysis/DeclarationTypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,16 @@ void DeclarationTypeChecker::endVisit(TvmVector const& _tvmVector)
return;

TypeName const& type = _tvmVector.type();
_tvmVector.annotation().type = TypeProvider::tvmtuple(type.annotation().type);
_tvmVector.annotation().type = TypeProvider::tvmVector(type.annotation().type);
}

void DeclarationTypeChecker::endVisit(TvmStack const& _tvmStack)
{
if (_tvmStack.annotation().type)
return;

TypeName const& type = _tvmStack.type();
_tvmStack.annotation().type = TypeProvider::tvmStack(type.annotation().type);
}

void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
Expand Down Expand Up @@ -380,6 +389,12 @@ bool DeclarationTypeChecker::visit(UsingForDirective const& _usingFor)
for (ASTPointer<IdentifierPath> const& function: _usingFor.functionsOrLibrary())
if (auto functionDefinition = dynamic_cast<FunctionDefinition const*>(function->annotation().referencedDeclaration))
{
if (functionDefinition->isInlineAssembly())
m_errorReporter.typeError(
1167_error,
function->location(),
"Only file-level functions (not assembly) and library functions can be attached to a type in a \"using\" statement."
);
if (!functionDefinition->isFree() && !(
dynamic_cast<ContractDefinition const*>(functionDefinition->scope()) &&
dynamic_cast<ContractDefinition const*>(functionDefinition->scope())->isLibrary()
Expand Down
1 change: 1 addition & 0 deletions compiler/libsolidity/analysis/DeclarationTypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class DeclarationTypeChecker: private ASTConstVisitor
void endVisit(Mapping const& _mapping) override;
void endVisit(Optional const& _optional) override;
void endVisit(TvmVector const& _tvmVector) override;
void endVisit(TvmStack const& _tvmStack) override;
void endVisit(ArrayTypeName const& _typeName) override;
void endVisit(VariableDeclaration const& _variable) override;
bool visit(EnumDefinition const& _enum) override;
Expand Down
9 changes: 6 additions & 3 deletions compiler/libsolidity/analysis/SyntaxChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void SyntaxChecker::endVisit(SourceUnit const& _sourceUnit)
SemVerVersion recommendedVersion{std::string(VersionString)};
if (!recommendedVersion.isPrerelease())
errorString +=
" Consider adding \"pragma ever-solidity ^" +
" Consider adding \"pragma tvm-solidity ^" +
std::to_string(recommendedVersion.major()) +
std::string(".") +
std::to_string(recommendedVersion.minor()) +
Expand Down Expand Up @@ -141,7 +141,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
SemVerVersion recommendedVersion{std::string(VersionString)};
std::string errorString =
"It's deprecated."
" Consider adding \"pragma ever-solidity ^" +
" Consider adding \"pragma tvm-solidity ^" +
std::to_string(recommendedVersion.major()) +
std::string(".") +
std::to_string(recommendedVersion.minor()) +
Expand All @@ -151,7 +151,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
" to set a version of the compiler.";
m_errorReporter.warning(6413_error, _pragma.location(), errorString);
}
else if (_pragma.literals()[0] == "ever" || _pragma.literals()[0] == "ton") // ever-solidity
else if (_pragma.literals()[0] == "ever" || _pragma.literals()[0] == "ton" || _pragma.literals()[0] == "tvm")
{
if (m_versionPragma.has_value()) {
m_errorReporter.fatalTypeError(
Expand Down Expand Up @@ -480,6 +480,9 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
// Handled in experimental::SyntaxRestrictor instead.
return true;

if (!_function.isFree() && _function.isInlineAssembly())
m_errorReporter.fatalTypeError(7229_error, _function.location(), "Only free functions can be marked as \"assembly\".");

if (!_function.isFree() && !_function.isConstructor() && _function.noVisibilitySpecified())
{
std::string suggestedVisibility =
Expand Down
Loading

0 comments on commit 2b58716

Please sign in to comment.