1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-12 19:22:37 +00:00
Commit graph

73 commits

Author SHA1 Message Date
SpyCheese
0fff1bd8c7 Fix loading library cell in contract code 2024-12-18 12:57:21 +03:00
SpyCheese
25b4c6794a
TVM instructions: SECP256K1_XONLY_PUBKEY_TWEAK_ADD, SETCONTCTRMANY(X) (#1404)
* TVM instructions: SECP256K1_XONLY_PUBKEY_TWEAK_ADD, SETCONTCTRMANY(X)

* Add tests for xonly_pubkey_tweak_add

* added secp256k1 as submodule, since we need extrakeys feature of secp256k1

* cleanup

* add ton_crypto_core secp256k1 dependency

* adjust Dockerfile, android and wasm builds

* adjust nix build

* test windows build with SECP256K1_ENABLE_MODULE_EXTRAKEYS

* test windows build with SECP256K1_ENABLE_MODULE_EXTRAKEYS

* adjust android build

* adjust emscripten build

* adjust emscripten build

* try macos-13

* emscripten build adjustments

* windows build adjustments

* final corrections

---------

Co-authored-by: neodix <neodix@ton.org>
2024-11-26 16:23:17 +03:00
tolk-vm
e2edadba92
[Tolk] v0.6 syntax: fun, import, var, types on the right, etc.
Lots of changes, actually. Most noticeable are:
- traditional //comments
- #include -> import
- a rule "import what you use"
- ~ found -> !found (for -1/0)
- null() -> null
- is_null?(v) -> v == null
- throw is a keyword
- catch with swapped arguments
- throw_if, throw_unless -> assert
- do until -> do while
- elseif -> else if
- drop ifnot, elseifnot
- drop rarely used operators

A testing framework also appears here. All tests existed earlier,
but due to significant syntax changes, their history is useless.
2024-11-02 03:44:13 +04:00
tolk-vm
f0e6470d0b
[Tolk] Rewrite lexer, spaces are not mandatory anymore
A new lexer is noticeably faster and memory efficient
(although splitting a file to tokens is negligible in a whole pipeline).

But the purpose of rewriting lexer was not just to speed up,
but to allow writing code without spaces:
`2+2` is now 4, not a valid identifier as earlier.

The variety of symbols allowed in identifier has greatly reduced
and is now similar to other languages.

SrcLocation became 8 bytes on stack everywhere.

Command-line flags were also reworked:
- the input for Tolk compiler is only a single file now, it's parsed, and parsing continues while new #include are resolved
- flags like -A -P and so on are no more needed, actually
2024-11-02 01:33:08 +04:00
tolk-vm
0bcc0b3c12
[Fift] Fix an issue of FunC/Tolk WASM which truncated long fif output
As it turned out, PSTRING() created a buffer of 128K.
If asm_code exceeded this buffer, it was truncated.
I've just dropped PSTRING() from there in favor of std::string.
2024-11-02 01:33:08 +04:00
birydrad
72020c04c4
celldb in-memory mode, stats for actors, perf counters, minor fix in rldp2 (#1164)
* getactorstats query for validator-engine-console

* celldb in-memory mode (--celldb-in-memory option)

* rldp2: bugfix - do not estimate speed while nothing is sent

* add simple ed25519 benchmark

* fix compilation errors of different platforms and move to c++20

* fix some warnings

* turn on TON_USE_ABSEIL for glibc 2.27 nix build

---------

Co-authored-by: birydrad <>
2024-09-23 17:34:37 +03:00
neodix42
679e6be294
Remove rocksdb usage from fift (#1064)
* add github action for macOS 14 (arm64, M1)

* add github action (portable) for macOS 14 (arm64, M1)

* rename macOS arm64 output artifact

* Update libsodium on windows

* Compile libsodium

* Update build-windows.bat

* use upgraded libsodium 1.0.20; use compiled static libsodium for Windows instead of precompiled;

* revert libsodium 1.0.20; use compiled static libsodium for Windows instead of precompiled;

* use upgraded libsodium 1.0.20; use compiled static libsodium for Windows instead of precompiled;

* fix libsodium version 1.0.19; use compiled static libsodium for Windows instead of precompiled;

* try 1.0.20 libsodium precompiled on github

* try 1.0.18 libsodium precompiled on github

* try windows build on win server 2019

* and use PlatformToolset=v142

* use cmake -G "Visual Studio 16 2019"

* fix path to msvc 2019 on github

* separate github windows build on win server 2019 and build on win server 2022

* Update assembly/native/build-windows-2019.bat

add retry mechanism

Co-authored-by: Dr. Awesome Doge <doge@ton.org>

* add test-emulator; disable test groovy pipeline

* trigger all gh actions

* fix win build

* call test-emulator

* remove usage of rocksdb in fift-lib

* put back some code for test-db

* fix test-emulator

* remove usage of db-path parameter in fift

* some func adjustments

* fix checkout of openssl in fift-func-wasm-build-ubuntu.sh

* typo

* improve wasm build script for quicker turn around

* remove sENVIRONMENT=web,worker for funcfiftlib. will be added later.

* remove sENVIRONMENT=web,worker for funcfiftlib. will be added later.

* remove sENVIRONMENT=web,worker for funcfiftlib. will be added later.

* minor adjustments

* remove -d option in fift; optimize fift-lib usage

* reduce tondb usage

---------

Co-authored-by: neodiX <neodix42@ton.org>
Co-authored-by: Dr. Awesome Doge <doge@ton.org>
Co-authored-by: ms <dungeon666master@protonmail.com>
2024-07-26 22:10:55 +03:00
SpyCheese
28f9a9b159
More verbose vm logs, fix parsing slice literals (#1076)
* More verbose VM logs

* Fix parsing slice literals in fift
2024-07-26 16:09:43 +03:00
neodix42
5186c4755c
Change fift path separator for FIFTPATH and -I argument (#1014)
* add github action for macOS 14 (arm64, M1)

* add github action (portable) for macOS 14 (arm64, M1)

* rename macOS arm64 output artifact

* Colon cannot be used as a path separator for FIFTPATH or -I argument in fift on Windows when absolute paths are used (e.g. C:\path\lib:C:\path\smartcont).
Suggestion to use @ as a new path separator on Windows.

---------

Co-authored-by: neodiX <neodix42@ton.org>
2024-06-07 18:50:11 +03:00
EmelyanenkoK
a11ffb1637
Add DUEPAYMENT and some others + small fixes of new opcodes (#881)
* Changes in TVM v6

* Rename some opcodes
* Add due payment to c7
* Add GETORIGINALFWDFEE, GETGASFEESIMPLE, GETFORWARDFEESIMPLE
* Bugfix in GETGASFEE

* Fix typo

---------

Co-authored-by: SpyCheese <mikle98@yandex.ru>
2024-01-29 16:38:42 +03:00
EmelyanenkoK
51d30e2f2b
Add TVM instructions for working with nonzero-level cells (#880)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
2024-01-26 18:24:39 +03:00
EmelyanenkoK
64b04e46d7
Cheap fee calculations (#878)
* TVM v6

* New tuple with unpacked config parameters in c7
* New instructions for calculating fees

* Change unpacked_config_tuple, fix typo

---------

Co-authored-by: SpyCheese <mikle98@yandex.ru>
2024-01-26 15:43:53 +03:00
SpyCheese
030ebaf772 Change GASCONSUMED opcode to f807 2023-11-03 15:25:58 +03:00
SpyCheese
5847897b37
Various changes in TVM, github builds and tests (#793)
* Bugfixes in TVM and node

* Upgrade to C++17

* Improve GitHub builds

* Fix existing tests and partially integrate them into builds

---------

Co-authored-by: neodiX42 <namlem@gmail.com>
Co-authored-by: EmelyanenkoK <emelyanenko.kirill@gmail.com>
2023-11-03 14:43:34 +03:00
EmelyanenkoK
9f93888cf4
TVM Upgrade (#686)
* New TVM instructions

* Remove PREVBLOCKS

* Separate target ton_crypto into TVM-related and -unrelared code

* Add fine for failed "send message"; rework SENDMSG

* Fix include

* Fix bugs, improve action fines

* Disable fines for special accounts

* Handle msg_balance_remaining.grams == null in transaction.cpp

* Bugfixes in SENDMSG

* Fix fee calculation in SENDMSG

* Fix CellStorageStat and transaction.cpp after merge

* SETBOUNCEONACTIONPHASEFAIL instruction

* ADDDIVMOD instructions

* RUNVM, RUNVMX instructions

* Changes in RUNVM

* Tests for adddiv and runvm

* HASHEXT instruction

* Improve opcode-timing

More iterations
Don't measure preliminary run
Remove logs and other excessive operations
Add "error" to output

* Increase RUNVM gas price

* Optimize HASHEXT, adjust gas price

* Add "bounce of action fail" flag to actions

* Stack operations with unlimited arguments

* Ristretto255 instructions

* Adjust gas consumption

* Optional fixed number of return values in RUNVM, fix exception handling

* Adjust gas consumption

* Simplify gas consumption logic

* Support of secp256k1 and sodium libraries in builds (#11)

* add support of secp256k1 library to the builds (linux, win)

* add support of secp256k1 library to the builds (linux, win)

* install secp256k1 via brew

* install libsodium via brew;
change sodium to upper case in FindSodium.cmake

* install libsodium via brew;
change sodium to upper case in FindSodium.cmake

* simplify FindSodium.cmake

* bug fixing

* bug fixing

* bug fixing

* add macro SODIUM_STATIC

* adjust build command for windows

* put back original FindSodium.cmake

* put back original FindSodium.cmake

* fix sodium unzipped path for windows;
add ninja

* fix sodium unzipped path for windows;
add ninja

* fix sodium unzipped path for windows;
add ninja

* Win32 github build for secp256k1

* x64 architecture github build for secp256k1

* fix sodium linking on linux

* enable docker buildx arm64 builds from forked repos

* enable docker buildx arm64 builds from forked repos

* enable docker buildx arm64 builds from forked repos

* adjust mac builds for secp2561k and sodium

* fix tonlib jni generation

* minor fix

* sync fixes across platforms

* add libsodium build script for android and precompiled static libraries

* build tonlib for android (fails)

* FindSodium uppercase

* remove system libsodium for android, use precompiled instead;
specify SECP256K1_INCLUDE_DIR fir mac 12.6

* uppercase sodium

* simplify FindSodium

* fix windows build sodium path;
use ninja for windows

* simplify sodium 2

* adjust windows sodium paths;
add paths to android jni

* add ninja build windows

* add ninja build windows

* add ninja build windows 2

* remove win ninja

* fix 1

* fix 2

* fix win 3

* fix linux compile 3

* fix jni 1

* fix jni 2 and mac

* fix jni 3

* fix jni 4

* fix jni 5

* fix mac 6

* fix mac 7 and jni paths

* fix jni 8

* rework sodium for android

* rework sodium for android

* rework sodium for android 2

* fixed sodium for android 2

* fixed sodium for android 3

* static secp256k1 for android

* add precompiled arm secp256k1

* add precompiled arm secp256k1

* build native-lib with secp256k1 x86-64 (non arm)

* update precompiled with NDK libsecp256k1.a

* update precompiled with NDK libsecp256k1.a

* update precompiled with NDK libsecp256k1.a

* refactor llvm-strip location

* refactor llvm-strip location

* add native-lib.so for armv7a, armv8a

* add native-lib.so for armv7a, armv8a

* test  armv7a, armv8a

* armv7a - fails linking on sodium, test -> armv8a

* works x86-64, armv7a - fails linking on sodium, armv8a - fails linking secp256k1 (incompatible with aarch64linux)

* update libpsec256k1, sodium static libs

* test x86 android native-lib

* test armv7 android native-lib

* test armv8 android native-lib

* x86_64 and arm64 android native-lib works

* x86_64 and arm64 android native-lib works

* x86_64 and arm64 android native-lib works

* test armv7 android native-lib

* test all android native-libs

* test all android native-libs

* test all android native-libs

* test all android native-libs - without SodiumAndroid

* test all android native-libs - with FindSodiumAndroid.cmake

* win, with Sodium via SODIUM_DIR

* win, with Sodium via SODIUM_DIR env

* win, with Sodium via SODIUM_DIR env

* win, with Sodium via SODIUM_DIR env and SODIUM_USE_STATIC_LIBS

* win, with Sodium via SODIUM_DIR, SODIUM_USE_STATIC_LIBS and SODIUM_INCLUDE_DIR

* android, with FindSodium

* android, with FindSodium with SODIUM_USE_STATIC_LIBS

* remove if not apple

* target_link_libraries(ton_crypto_core PUBLIC secp256k1)

* android SECP256K1_INCLUDE_DIRS

* android SECP256K1_INCLUDE_DIR

* add libsecp256k1.a/so pre-compiled with ubuntu 22 x86-64

* add libsecp256k1.a/so pre-compiled with ubuntu 22 x86-64

* sodium dirs

* sodium dirs

* sodium dirs

* remove NOT APPLE and SodiumAndroid

* add NOT APPLE and remove SodiumAndroid

* add NOT APPLE and remove SodiumAndroid

* remove build scripts for 18.04, reduce CMakeLists.txt

* remove build scripts for 18.04, reduce CMakeLists.txt

* Fix cas consumption during library load

* Fix fetch_config_params after merge

* Add all ADDDIVMOD ops to Asm.fif

* Save unpaid storage fee to due_payment

* Add "set prev blocks info" to emulator

* Adjusted builds  (#13)

* Update flake.nix

Add libsodium

* add libsecp256k1-dev and libsodium-dev into wasm build

* make back emulator a shared library;
put emulator to artifacts;
compile wasm artifacts with sodium and secp256k1.

* add secp256k1 to nix

* compile emulator statically with nix

* compile emulator statically with nix

* compile emulator lib statically with nix

* compile emulator lib statically with nix

* add libemulator to artifacts

* add shared libemulator library to artifacts

* minor release fix

* update set-output commands;
add recent_changelog.md

* releases fixes

* releases fixes, multiline

* releases fixes, multiline

* releases fixes, multiline

* put back multiline changelog

* put back multiline changelog

* ConfigParam 19 (global-id) and GLOBALID instruction

* Fix gas consumption in HASHEXT

* Add blst library

* Add bls instructions

* Allow passing long code to opcode-timing

* Add bls testcase

* More BLS instructions

* Fix tests, add bls tests

* Add more bls tests

* Improve some bls operations

* Adjust some BLS gas prices

* Adjust BLS gas prices

* Enable __BLST_PORTABLE__ flag only if PORTABLE flag is set

* Add tests for BLS_PAIRING

* GASCONSUMED instruction

* Fix compilation against docker with blst library; (#14)

* fix compilation against docker with blst library;
add precompiled libblst.a to android builds

* minor fix

* Adjust BLKSWX gas

* Fix comparison with NAN

* Allow arbitrary integers for scalars in ristretto multiplication, fix test

* Adjust nix builds according to PR 694 (#15)

* integrate and test PR-694

* integrate and test PR-694, test 2

* Add P256_CHKSIGN (secp256r1)

---------

Co-authored-by: SpyCheese <mikle98@yandex.ru>
Co-authored-by: neodiX42 <namlem@gmail.com>
2023-05-24 21:14:13 +03:00
SpyCheese
dad980ed09
Fix STSLICECONST, bump Asm.fif version to 0.4.4 (#700) 2023-05-15 16:35:23 +03:00
SpyCheese
5abfe2337e
Catchain improvements (#698)
* Fix "sgn" in fift; fix marking infinite loops as noterurn in func

* TON-P1-1: Remove unused catchain queries

* TON-P1-15: Avoid synchronization with self

* TON-P1-3, TON-P1-17: Disallow more than one candidate per src per round (to prevent flood), add checks to process_broadcast

* TON-P1-10: Fix fast/slow attempts

* TON-P1-14: Add named constants

* TON-P1-18, TON-P1-19: Alloc temporary memory in the same way as persistent memory

* TON-P1-20: Add comment to choose_blocks_to_approve

* TON-P1-16: Avoid creating two catchain blocks on need_new_block

* TON-P1-8: Add some validation to validator-engine parameters

* TON-P1-6: Don't allow sending the same block many times

Many requests for the same block are not unusual (however, there's no need to answer them all)

* TON-P1-2: Enable prohibiting dependencies from blamed nodes (2.7.5 in CatChain doc), fix processing blame proofs

* Best practices

bp-6: Fix incorrect warning
bp-7: Remove unused code
bp-8: Bring back PerfWarningTimer logging (only when no callback)
bp-9: Remove unnecessary condition
bp-11: Remove commented-out code
bp-13: Divide code in validator-session-state
Adherence to Specification: Fix typo
2023-05-10 12:57:57 +03:00
Ilyar
8d919a5db9
add missing VM opcode definition (#670) 2023-04-19 20:09:15 +03:00
EmelyanenkoK
e3af63e6c0
Fix PUSHSLICE for some unfortunate slice lengths 2023-04-04 18:26:02 +03:00
SpyCheese
4d5ded5761
Asm.fif improvements (#631) (#645)
* Asm.fif improvements (#631)

Add missing opcodes, CUSTOMOP, disallow 256 PUSHPOW256, recursive PROGRAM, require-asm-fif-version

* Fix nested PROGRAM, add test

* Simplify require-asm-fif-version

---------

Co-authored-by: EmelyanenkoK <emelyanenko.kirill@gmail.com>
2023-03-13 16:48:48 +03:00
EmelyanenkoK
865ebfce8d
Add namespaces to Fift (#641)
* Add fift-based disassembler

* Fift improvements: namespaces, hashmaps, flow controls

* Fift: add lib with better block structuring and more

* Minor changes in fift HashMap + tests (#643)

* Minor changes in fift HashMap

* Add tests for extended fift

---------

Co-authored-by: OmicronTau <omicron@ton.org>
Co-authored-by: Tolya <1449561+tolya-yanot@users.noreply.github.com>
Co-authored-by: SpyCheese <mikle98@yandex.ru>
2023-03-10 14:16:29 +03:00
SpyCheese
0578cb4a42
Fix typos, UBs and warnings (#625) 2023-02-28 12:06:09 +03:00
EmelyanenkoK
653c88aa9d
Add pragmas to funC for precise control of computation order (#589)
* FunC pragmas: allow-post-modification and compute-asm-ltr

* Warn if #pragma is enabled only in included files

* Add tests for new pragmas

* Add special ops for "allow-post-modification" only when needed

* Update FunC version to 0.4.1

* Allow empty inlines (#10)

Co-authored-by: SpyCheese <mikle98@yandex.ru>
2023-01-13 12:45:04 +03:00
EmelyanenkoK
b6d44bb02a
Revert "fix include paths parsing under Windows (#541)" (#557)
This reverts commit 4d09d04a42.
2022-12-15 17:12:29 +03:00
elderorb
4d09d04a42
fix include paths parsing under Windows (#541) 2022-12-15 14:55:11 +03:00
Andrey Tvorozhkov
c1f281d814
Add addr@+ / addr@ functions to parse addr from slice (#366)
Add addr@ to parse `addr_none$00` / `addr_extern$01` / `addr_std$10` / `addr_var$11` from slice.

Tests:

```
<b b{00} s, b> <s addr@  ."addr_none$00 parsed: " print-addr cr  // addr_none$00
<b b{01} s, 10 9 u, b{1101010101} s, b> <s addr@ ."addr_extern$01 parsed: " print-addr cr // addr_extern$01
<b b{10} s, b{1} s, 10 30 u, b{1111111111} s, -1 8 i, x{8000000000000000000000000000000000000000000000000000000000000000} s, b> <s addr@ ."addr_std$10 with Anycast parsed: " print-addr  cr // addr_std$10 with Anycast
<b b{10} s, b{0} s, -1 8 i, x{8000000000000000000000000000000000000000000000000000000000000000} s, b> <s addr@ ."addr_std$10 without Anycast parsed: " print-addr cr // addr_std$10 without Anycast
<b b{11} s, b{1} s, 10 30 u, b{1111111111} s, 256 9 u, -10 32 i, x{8000000000000000000000000000000000000000000000000000000000000000} s, b> <s addr@ ."addr_var$11 with Anycast parsed: " print-addr cr // addr_var$11
<b b{11} s, b{0} s, 256 9 u, -10 32 i, x{8000000000000000000000000000000000000000000000000000000000000000} s, b> <s addr@ ."addr_var$10 with Anycast parsed: " print-addr cr // addr_var$11
```
2022-08-15 18:35:27 +03:00
EmelyanenkoK
40cec56e28
A series of FunC improvements (#378)
* Don't use IFJMP/IFNOTJMP in inline functions

* Fix incorrect ifelse branch code generation 

https://github.com/ton-blockchain/ton/issues/374

* Make generate_code_all clearer

* Don't replace IFJMP with IF in inner blocks in inline functions

* Allow unbalance if/else by using RETALT

* Fix wrong PUSHCONT

* Bugfix in IF code generation for inline functions

* Fix unbalanced if/else

* Bugfix and improvements in code generation

* Fix analyzing while(0) in func

https://github.com/ton-blockchain/ton/issues/377

* FunC and Asm.fif: Fix inlining large functions

https://github.com/ton-blockchain/ton/issues/375

Co-authored-by: SpyCheese <mikle98@yandex.ru>
2022-08-04 14:48:19 +03:00
OmicronTau
0e47c6c8e0 Asm.fif typo in IFBITJMPs 2022-05-06 11:11:06 +03:00
akifoq
34590176eb Fix IF:<{ and IFNOT:<{ empty continuation case
The boolean value should be DROPped in the case the continuation is empty.
2022-05-06 11:06:48 +03:00
OmicronTau
703bcd6e32 Add tests and fixes for modpow2, muldivmod 2022-05-06 10:43:53 +03:00
Alex Melman
bab4c1637e Automatically integrates git build information into executables.
Usage:
func.exe -V
adnl-pong -V
validator-engine -V
and so on.
Result will be shown in the following format:
Func build information: [ Commit: d8b751d7a5, Date: 2021-02-27 14:34:41 +0200]
2021-02-27 14:34:43 +03:00
Alex Melman
41a3418b7b Adds command line parameter -V that shows build version to the binaries.
Build number controlled in top level CMakeLists.txt file via -DBUILD_VERSION variable.
Usage:
adnl-pong -V
validator-engine -V
and so on.
2021-02-27 14:34:41 +03:00
ton
f064b1047a pow-testgiver support 2020-07-06 17:07:20 +03:00
ton
4e2624459b integrating the existing state of TON Storage / TON Payments / CPS Fift development branches 2020-05-27 22:10:46 +04:00
ton
040df63c98 minor improvements and bugfixes 2020-05-07 10:35:23 +04:00
ton
eecf05ca59 bugfixes + tonlib update 2020-04-30 15:04:47 +04:00
ton
9f008b129f updated submodules, bugfixes
- added new fift/func code for validator complaint creation
- bugfixes in validator
- updates in tonlib
- new versions of rocksdb/abseil
- hardfork support
2020-04-27 16:01:46 +04:00
ton
be9c34c62d bugfixes 2020-04-10 23:06:01 +04:00
ton
9bff9285b8 bugfix in config sc + docs 2020-04-01 13:07:29 +04:00
ton
4b5dd4525e updated lite-client 2020-03-31 17:11:56 +04:00
ton
4dd5eea11f added support for config change proposals
- added some fift scripts for the config change proposal voting
- added validator-engine-console support for the config change proposal voting
- additional sanity checks in catchain
- unsafe slow catchain resync method
2020-03-30 17:20:45 +04:00
ton
a31f8d4424 bugfixed + crypto update
- compiles vs BoringSSL
- config proposal/vote fift code
- bugfixes in catchain
- other small fixes
2020-03-27 18:59:00 +04:00
ton
9f351fc29f emergency update 2020-03-24 03:32:16 +04:00
ton
ba76f1404e vm: bugfixes 2020-03-02 17:52:55 +04:00
ton
dd4ac0f440 vm bugfixes 2020-02-28 18:59:47 +04:00
ton
e27fb1e09c updated vm (breaking compatibility)
- updated vm
- new actor scheduler
- updated tonlib
- updated DNS smartcontract
2020-02-28 14:28:47 +04:00
ton
efd47af432 updated tonlib + fixes in vm 2020-02-20 19:56:18 +04:00
ton
28735ddc9e bugfixes 2020-02-17 14:18:59 +04:00
ton
a73d202ba2 updated func and tonlib 2020-02-15 20:03:17 +04:00
ton
493ae2410c rldp-http-proxy: use tonlib
- rldp-http-proxy used TONLib to resolve domains via DNS smartcontract
- updated tonlib
- bugfixes
2020-02-12 00:14:16 +04:00