mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
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>
This commit is contained in:
parent
89700cb2aa
commit
5847897b37
122 changed files with 2889 additions and 4100 deletions
|
@ -8,37 +8,37 @@ import shutil
|
|||
add_pragmas = [] #["allow-post-modification", "compute-asm-ltr"];
|
||||
|
||||
tests = [
|
||||
# note, that deployed version of elector,config and multisig differ since it is compilled with func-0.1.0.
|
||||
# Newer compillators optimize arithmetic and logic expression that can be calculated at the compile time
|
||||
["elector/elector-code.fc", 115226404411715505328583639896096915745686314074575650766750648324043316883483],
|
||||
["config/config-code.fc", 10913070768607625342121305745084703121685937915388357634624451844356456145601],
|
||||
["eth-bridge-multisig/multisig-code.fc", 101509909129354488841890823627011033360100627957439967918234053299675481277954],
|
||||
# note, that deployed version of elector,config and multisig differ since it is compilled with func-0.1.0.
|
||||
# Newer compillators optimize arithmetic and logic expression that can be calculated at the compile time
|
||||
["elector/elector-code.fc", 115226404411715505328583639896096915745686314074575650766750648324043316883483],
|
||||
["config/config-code.fc", 10913070768607625342121305745084703121685937915388357634624451844356456145601],
|
||||
["eth-bridge-multisig/multisig-code.fc", 101509909129354488841890823627011033360100627957439967918234053299675481277954],
|
||||
|
||||
["bsc-bridge-collector/votes-collector.fc", 62190447221288642706570413295807615918589884489514159926097051017036969900417],
|
||||
["uni-lock-wallet/uni-lockup-wallet.fc", 61959738324779104851267145467044677651344601417998258530238254441977103654381],
|
||||
["nft-collection/nft-collection-editable.fc", 45561997735512210616567774035540357815786262097548276229169737015839077731274],
|
||||
["dns-collection/nft-collection.fc", 107999822699841936063083742021519765435859194241091312445235370766165379261859],
|
||||
["bsc-bridge-collector/votes-collector.fc", 62190447221288642706570413295807615918589884489514159926097051017036969900417],
|
||||
["uni-lock-wallet/uni-lockup-wallet.fc", 61959738324779104851267145467044677651344601417998258530238254441977103654381],
|
||||
["nft-collection/nft-collection-editable.fc", 45561997735512210616567774035540357815786262097548276229169737015839077731274],
|
||||
["dns-collection/nft-collection.fc", 107999822699841936063083742021519765435859194241091312445235370766165379261859],
|
||||
|
||||
|
||||
# note, that deployed version of tele-nft-item differs since it is compilled with func-0.3.0.
|
||||
# After introducing of try/catch construction, c2 register is not always the default one.
|
||||
# Thus it is necessary to save it upon jumps, differences of deployed and below compilled is that
|
||||
# "c2 SAVE" is added to the beginning of recv_internal. It does not change behavior.
|
||||
["tele-nft-item/nft-item.fc", 69777543125381987786450436977742010705076866061362104025338034583422166453344],
|
||||
# note, that deployed version of tele-nft-item differs since it is compilled with func-0.3.0.
|
||||
# After introducing of try/catch construction, c2 register is not always the default one.
|
||||
# Thus it is necessary to save it upon jumps, differences of deployed and below compilled is that
|
||||
# "c2 SAVE" is added to the beginning of recv_internal. It does not change behavior.
|
||||
["tele-nft-item/nft-item.fc", 69777543125381987786450436977742010705076866061362104025338034583422166453344],
|
||||
|
||||
["storage/storage-contract.fc", 91377830060355733016937375216020277778264560226873154627574229667513068328151],
|
||||
["storage/storage-provider.fc", 13618336676213331164384407184540461509022654507176709588621016553953760588122],
|
||||
["nominator-pool/pool.fc", 69767057279163099864792356875696330339149706521019810113334238732928422055375],
|
||||
["jetton-minter/jetton-minter.fc", 9028309926287301331466371999814928201427184114165428257502393474125007156494],
|
||||
["gg-marketplace/nft-marketplace-v2.fc", 92199806964112524639740773542356508485601908152150843819273107618799016205930],
|
||||
["jetton-wallet/jetton-wallet.fc", 86251125787443633057458168028617933212663498001665054651523310772884328206542],
|
||||
["whales-nominators/nominators.fc", 8941364499854379927692172316865293429893094891593442801401542636695127885153],
|
||||
["storage/storage-contract.fc", 91377830060355733016937375216020277778264560226873154627574229667513068328151],
|
||||
["storage/storage-provider.fc", 13618336676213331164384407184540461509022654507176709588621016553953760588122],
|
||||
["nominator-pool/pool.fc", 69767057279163099864792356875696330339149706521019810113334238732928422055375],
|
||||
["jetton-minter/jetton-minter.fc", 9028309926287301331466371999814928201427184114165428257502393474125007156494],
|
||||
["gg-marketplace/nft-marketplace-v2.fc", 92199806964112524639740773542356508485601908152150843819273107618799016205930],
|
||||
["jetton-wallet/jetton-wallet.fc", 86251125787443633057458168028617933212663498001665054651523310772884328206542],
|
||||
["whales-nominators/nominators.fc", 8941364499854379927692172316865293429893094891593442801401542636695127885153],
|
||||
|
||||
|
||||
["tact-examples/treasure_Treasure.code.fc", 13962538639825790677138656603323869918938565499584297120566680287245364723897],
|
||||
["tact-examples/jetton_SampleJetton.code.fc", 94076762218493729104783735200107713211245710256802265203823917715299139499110],
|
||||
["tact-examples/jetton_JettonDefaultWallet.code.fc", 29421313492520031238091587108198906058157443241743283101866538036369069620563],
|
||||
["tact-examples/maps_MapTestContract.code.fc", 22556550222249123835909180266811414538971143565993192846012583552876721649744],
|
||||
["tact-examples/treasure_Treasure.code.fc", 13962538639825790677138656603323869918938565499584297120566680287245364723897],
|
||||
["tact-examples/jetton_SampleJetton.code.fc", 94076762218493729104783735200107713211245710256802265203823917715299139499110],
|
||||
["tact-examples/jetton_JettonDefaultWallet.code.fc", 29421313492520031238091587108198906058157443241743283101866538036369069620563],
|
||||
["tact-examples/maps_MapTestContract.code.fc", 22556550222249123835909180266811414538971143565993192846012583552876721649744],
|
||||
]
|
||||
|
||||
def getenv(name, default=None):
|
||||
|
@ -51,7 +51,6 @@ def getenv(name, default=None):
|
|||
|
||||
FUNC_EXECUTABLE = getenv("FUNC_EXECUTABLE", "func")
|
||||
FIFT_EXECUTABLE = getenv("FIFT_EXECUTABLE", "fift")
|
||||
FIFT_LIBS = getenv("FIFTPATH")
|
||||
TMP_DIR = tempfile.mkdtemp()
|
||||
|
||||
COMPILED_FIF = os.path.join(TMP_DIR, "compiled.fif")
|
||||
|
@ -63,49 +62,49 @@ class ExecutionError(Exception):
|
|||
pass
|
||||
|
||||
def pre_process_func(f):
|
||||
shutil.copyfile(f, f+"_backup")
|
||||
with open(f, "r") as src:
|
||||
sources = src.read()
|
||||
with open(f, "w") as src:
|
||||
for pragma in add_pragmas:
|
||||
src.write("#pragma %s;\n"%pragma)
|
||||
src.write(sources)
|
||||
shutil.copyfile(f, f+"_backup")
|
||||
with open(f, "r") as src:
|
||||
sources = src.read()
|
||||
with open(f, "w") as src:
|
||||
for pragma in add_pragmas:
|
||||
src.write("#pragma %s;\n"%pragma)
|
||||
src.write(sources)
|
||||
|
||||
def post_process_func(f):
|
||||
shutil.move(f+"_backup", f)
|
||||
shutil.move(f+"_backup", f)
|
||||
|
||||
def compile_func(f):
|
||||
res = None
|
||||
try:
|
||||
pre_process_func(f)
|
||||
if "storage-provider.fc" in f :
|
||||
# This contract requires building of storage-contract to include it as ref
|
||||
with open(f, "r") as src:
|
||||
sources = src.read()
|
||||
# This contract requires building of storage-contract to include it as ref
|
||||
with open(f, "r") as src:
|
||||
sources = src.read()
|
||||
COMPILED_ST_BOC = os.path.join(TMP_DIR, "storage-contract-code.boc")
|
||||
sources = sources.replace("storage-contract-code.boc", COMPILED_ST_BOC)
|
||||
with open(f, "w") as src:
|
||||
src.write(sources)
|
||||
COMPILED_ST_FIF = os.path.join(TMP_DIR, "storage-contract.fif")
|
||||
COMPILED_ST_BOC = os.path.join(TMP_DIR, "storage-contract-code.boc")
|
||||
sources = sources.replace("storage-contract-code.boc", COMPILED_ST_BOC)
|
||||
with open(f, "w") as src:
|
||||
src.write(sources)
|
||||
COMPILED_ST_FIF = os.path.join(TMP_DIR, "storage-contract.fif")
|
||||
COMPILED_ST_BOC = os.path.join(TMP_DIR, "storage-contract-code.boc")
|
||||
COMPILED_BUILD_BOC = os.path.join(TMP_DIR, "build-boc.fif")
|
||||
res = subprocess.run([FUNC_EXECUTABLE, "-o", COMPILED_ST_FIF, "-SPA", f.replace("storage-provider.fc","storage-contract.fc")], capture_output=False, timeout=10)
|
||||
with open(COMPILED_BUILD_BOC, "w") as scr:
|
||||
scr.write("\"%s\" include boc>B \"%s\" B>file "%(COMPILED_ST_FIF, COMPILED_ST_BOC))
|
||||
res = subprocess.run([FIFT_EXECUTABLE, COMPILED_BUILD_BOC ], capture_output=True, timeout=10)
|
||||
|
||||
|
||||
COMPILED_BUILD_BOC = os.path.join(TMP_DIR, "build-boc.fif")
|
||||
res = subprocess.run([FUNC_EXECUTABLE, "-o", COMPILED_ST_FIF, "-SPA", f.replace("storage-provider.fc","storage-contract.fc")], capture_output=False, timeout=10)
|
||||
with open(COMPILED_BUILD_BOC, "w") as scr:
|
||||
scr.write("\"%s\" include boc>B \"%s\" B>file "%(COMPILED_ST_FIF, COMPILED_ST_BOC))
|
||||
res = subprocess.run([FIFT_EXECUTABLE, COMPILED_BUILD_BOC ], capture_output=True, timeout=10)
|
||||
|
||||
|
||||
res = subprocess.run([FUNC_EXECUTABLE, "-o", COMPILED_FIF, "-SPA", f], capture_output=True, timeout=10)
|
||||
except Exception as e:
|
||||
post_process_func(f)
|
||||
raise e
|
||||
post_process_func(f)
|
||||
raise e
|
||||
else:
|
||||
post_process_func(f)
|
||||
post_process_func(f)
|
||||
if res.returncode != 0:
|
||||
raise ExecutionError(str(res.stderr, "utf-8"))
|
||||
|
||||
def run_runner():
|
||||
res = subprocess.run([FIFT_EXECUTABLE, "-I", FIFT_LIBS, RUNNER_FIF], capture_output=True, timeout=10)
|
||||
res = subprocess.run([FIFT_EXECUTABLE, RUNNER_FIF], capture_output=True, timeout=10)
|
||||
if res.returncode != 0:
|
||||
raise ExecutionError(str(res.stderr, "utf-8"))
|
||||
s = str(res.stdout, "utf-8")
|
||||
|
@ -138,16 +137,15 @@ for ti, t in enumerate(tests):
|
|||
try:
|
||||
func_out = run_runner()
|
||||
if func_out != th:
|
||||
raise ExecutionError("Error : expected '%d', found '%d'" % (th, func_out))
|
||||
raise ExecutionError("Error : expected '%d', found '%d'" % (th, func_out))
|
||||
success += 1
|
||||
except ExecutionError as e:
|
||||
print(e, file=sys.stderr)
|
||||
#print("Compiled:", file=sys.stderr)
|
||||
#with open(COMPILED_FIF, "r") as f:
|
||||
# print(f.read(), file=sys.stderr)
|
||||
#exit(2)
|
||||
print("Compiled:", file=sys.stderr)
|
||||
with open(COMPILED_FIF, "r") as f:
|
||||
print(f.read(), file=sys.stderr)
|
||||
exit(2)
|
||||
print(" OK ", file=sys.stderr)
|
||||
|
||||
print(get_version())
|
||||
print("Done: Success %d, Error: %d"%(success, len(tests)-success), file=sys.stderr)
|
||||
|
||||
print("Done: Success %d, Error: %d"%(success, len(tests)-success), file=sys.stderr)
|
|
@ -4,6 +4,7 @@ import subprocess
|
|||
import sys
|
||||
import tempfile
|
||||
|
||||
|
||||
def getenv(name, default=None):
|
||||
if name in os.environ:
|
||||
return os.environ[name]
|
||||
|
@ -12,10 +13,9 @@ def getenv(name, default=None):
|
|||
exit(1)
|
||||
return default
|
||||
|
||||
|
||||
FUNC_EXECUTABLE = getenv("FUNC_EXECUTABLE", "func")
|
||||
FIFT_EXECUTABLE = getenv("FIFT_EXECUTABLE", "fift")
|
||||
#FUNC_STDLIB = getenv("FUNC_STDLIB")
|
||||
FIFT_LIBS = getenv("FIFT_LIBS")
|
||||
TMP_DIR = tempfile.mkdtemp()
|
||||
COMPILED_FIF = os.path.join(TMP_DIR, "compiled.fif")
|
||||
RUNNER_FIF = os.path.join(TMP_DIR, "runner.fif")
|
||||
|
@ -25,22 +25,26 @@ if len(sys.argv) != 2:
|
|||
exit(1)
|
||||
TESTS_DIR = sys.argv[1]
|
||||
|
||||
|
||||
class ExecutionError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def compile_func(f):
|
||||
res = subprocess.run([FUNC_EXECUTABLE, "-o", COMPILED_FIF, "-SPA", f], capture_output=True, timeout=10)
|
||||
if res.returncode != 0:
|
||||
raise ExecutionError(str(res.stderr, "utf-8"))
|
||||
|
||||
|
||||
def run_runner():
|
||||
res = subprocess.run([FIFT_EXECUTABLE, "-I", FIFT_LIBS, RUNNER_FIF], capture_output=True, timeout=10)
|
||||
res = subprocess.run([FIFT_EXECUTABLE, RUNNER_FIF], capture_output=True, timeout=10)
|
||||
if res.returncode != 0:
|
||||
raise ExecutionError(str(res.stderr, "utf-8"))
|
||||
s = str(res.stdout, "utf-8")
|
||||
s = [x.strip() for x in s.split("\n")]
|
||||
return [x for x in s if x != ""]
|
||||
|
||||
|
||||
tests = [s for s in os.listdir(TESTS_DIR) if s.endswith(".fc")]
|
||||
tests.sort()
|
||||
print("Found", len(tests), "tests", file=sys.stderr)
|
||||
|
@ -68,18 +72,18 @@ for ti, tf in enumerate(tests):
|
|||
|
||||
# preprocess arithmetics in input
|
||||
for i in range(len(cases)):
|
||||
inputs = cases[i][1].split(" ")
|
||||
processed_inputs = ""
|
||||
for in_arg in inputs:
|
||||
if "x{" in in_arg:
|
||||
processed_inputs += in_arg
|
||||
continue
|
||||
# filter and execute
|
||||
# is it safe enough?
|
||||
filtered_in = "".join(filter(lambda x: x in "0x123456789()+-*/<>", in_arg))
|
||||
if(filtered_in):
|
||||
processed_inputs += str(eval(filtered_in)) + " ";
|
||||
cases[i][1] = processed_inputs.strip()
|
||||
inputs = cases[i][1].split(" ")
|
||||
processed_inputs = ""
|
||||
for in_arg in inputs:
|
||||
if "x{" in in_arg:
|
||||
processed_inputs += in_arg
|
||||
continue
|
||||
# filter and execute
|
||||
# is it safe enough?
|
||||
filtered_in = "".join(filter(lambda x: x in "0x123456789()+-*/<>", in_arg))
|
||||
if filtered_in:
|
||||
processed_inputs += str(eval(filtered_in)) + " "
|
||||
cases[i][1] = processed_inputs.strip()
|
||||
|
||||
with open(RUNNER_FIF, "w") as f:
|
||||
print("\"%s\" include <s constant code" % COMPILED_FIF, file=f)
|
||||
|
@ -103,4 +107,4 @@ for ti, tf in enumerate(tests):
|
|||
exit(2)
|
||||
print(" OK, %d cases" % len(cases), file=sys.stderr)
|
||||
|
||||
print("Done", file=sys.stderr)
|
||||
print("Done", file=sys.stderr)
|
Loading…
Add table
Add a link
Reference in a new issue