Skip to content

Commit d73259b

Browse files
authored
Merge branch 'dev' into bot
2 parents b47ab23 + f8aa2f3 commit d73259b

File tree

4 files changed

+56
-34
lines changed

4 files changed

+56
-34
lines changed

modules/utilities.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,21 @@ def check_adnl_connection(self):
365365
error = f'{{red}}Failed to check ADNL connection to local node: {response.get("message")}{{endc}}'
366366
return ok, error
367367

368+
def get_pool_data(self, args):
369+
try:
370+
pool_name = args[0]
371+
except:
372+
color_print("{red}Bad args. Usage:{endc} get_pool_data <pool-name | pool-addr>")
373+
return
374+
if self.ton.IsAddr(pool_name):
375+
pool_addr = pool_name
376+
else:
377+
pool = self.ton.GetLocalPool(pool_name)
378+
pool_addr = pool.addrB64
379+
pool_data = self.ton.GetPoolData(pool_addr)
380+
print(json.dumps(pool_data, indent=4))
381+
# end define
382+
368383
def add_console_commands(self, console):
369384
console.AddItem("vas", self.view_account_status, self.local.translate("vas_cmd"))
370385
console.AddItem("vah", self.view_account_history, self.local.translate("vah_cmd"))
@@ -380,3 +395,4 @@ def add_console_commands(self, console):
380395
console.AddItem("vl", self.print_validator_list, self.local.translate("vl_cmd"))
381396
console.AddItem("cl", self.print_complaints_list, self.local.translate("cl_cmd"))
382397

398+
console.AddItem("get_pool_data", self.get_pool_data, self.local.translate("get_pool_data_cmd"))

mytoncore/mytoncore.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ def CreateWallet(self, name, workchain=0, version="v1", **kwargs):
16241624
if os.path.isfile(wallet_path + ".pk") and "v3" not in version:
16251625
self.local.add_log("CreateWallet error: Wallet already exists: " + name, "warning")
16261626
else:
1627-
fift_args = self.get_new_wallet_fift_args(version, workchain=workchain,
1627+
fift_args = self.get_new_wallet_fift_args(version, workchain=workchain,
16281628
wallet_path=wallet_path, subwallet=subwallet)
16291629
result = self.fift.Run(fift_args)
16301630
if "Creating new" not in result:
@@ -1681,7 +1681,7 @@ def import_wallet_with_version(self, key, version, **kwargs):
16811681
wallet_path = self.walletsDir + wallet_name
16821682
with open(wallet_path + ".pk", 'wb') as file:
16831683
file.write(pk_bytes)
1684-
fift_args = self.get_new_wallet_fift_args(version, workchain=workchain,
1684+
fift_args = self.get_new_wallet_fift_args(version, workchain=workchain,
16851685
wallet_path=wallet_path, subwallet=subwallet)
16861686
result = self.fift.Run(fift_args)
16871687
if "Creating new" not in result:
@@ -2310,6 +2310,7 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
23102310
continue
23112311

23122312
exists = False
2313+
vload = None
23132314
for item in validators_load.values():
23142315
if 'fileName' not in item:
23152316
continue
@@ -2319,15 +2320,16 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
23192320
pseudohash = pubkey + str(election_id)
23202321
if pseudohash == complaint['pseudohash']:
23212322
exists = True
2322-
vid = item['id']
2323+
vload = item
23232324
break
23242325

23252326
if not exists:
23262327
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint info was not found, probably it's wrong", "info")
23272328
continue
23282329

2329-
if vid >= config32['mainValidators']:
2330-
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint created for non masterchain validator", "info")
2330+
if (vload["id"] >= config32['mainValidators'] and
2331+
vload["masterBlocksCreated"] + vload["workBlocksCreated"] > 0):
2332+
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint created for non masterchain validator that created more than zero blocks", "info")
23312333
continue
23322334

23332335
# check complaint fine value
@@ -2526,7 +2528,7 @@ def CheckValidators(self, start, end):
25262528
pseudohash = pubkey + str(electionId)
25272529
if pseudohash in valid_complaints or pseudohash in voted_complaints_pseudohashes: # do not create complaints that already created or voted by ourself
25282530
continue
2529-
if item['id'] >= config['mainValidators']: # do not create complaints for non-masterchain validators
2531+
if item['id'] >= config['mainValidators'] and item["masterBlocksCreated"] + item["workBlocksCreated"] > 0: # create complaints for non-masterchain validators only if they created 0 blocks
25302532
continue
25312533
# Create complaint
25322534
fileName = self.remove_proofs_from_complaint(fileName)

scripts/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def parse_args(answers: dict):
6666
if validator_mode == 'Nominator pool':
6767
validator_mode = 'nominator-pool'
6868
elif validator_mode == 'Single pool':
69-
validator_mode = 'single-pool'
69+
validator_mode = 'single-nominator'
7070
elif validator_mode == 'Liquid Staking':
7171
validator_mode = 'liquid-staking'
7272
res += f' -m {validator_mode}'

scripts/install.sh

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@ ton_node_version="master" # Default version
2020

2121

2222
show_help_and_exit() {
23-
echo 'Supported arguments:'
24-
echo ' -c PATH Provide custom config for toninstaller.sh'
25-
echo ' -t Disable telemetry'
26-
echo ' -i Ignore minimum requirements'
27-
echo ' -d Use pre-packaged dump. Reduces duration of initial synchronization.'
28-
echo ' -a Set MyTonCtrl git repo author'
29-
echo ' -r Set MyTonCtrl git repo'
30-
echo ' -b Set MyTonCtrl git repo branch'
31-
echo ' -m MODE Install MyTonCtrl with specified mode (validator or liteserver)'
32-
echo ' -n NETWORK Specify the network (mainnet or testnet)'
33-
echo ' -v VERSION Specify the ton node version (commit, branch, or tag)'
34-
echo ' -h Show this help'
35-
exit
23+
echo 'Supported arguments:'
24+
echo ' -c PATH Provide custom config for toninstaller.sh'
25+
echo ' -t Disable telemetry'
26+
echo ' -i Ignore minimum requirements'
27+
echo ' -d Use pre-packaged dump. Reduces duration of initial synchronization.'
28+
echo ' -a Set MyTonCtrl git repo author'
29+
echo ' -r Set MyTonCtrl git repo'
30+
echo ' -b Set MyTonCtrl git repo branch'
31+
echo ' -m MODE Install MyTonCtrl with specified mode (validator or liteserver)'
32+
echo ' -n NETWORK Specify the network (mainnet or testnet)'
33+
echo ' -v VERSION Specify the ton node version (commit, branch, or tag)'
34+
echo ' -u USER Specify the user to be used for MyTonCtrl installation'
35+
echo ' -h Show this help'
36+
exit
3637
}
3738

3839
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
@@ -47,7 +48,7 @@ dump=false
4748
cpu_required=16
4849
mem_required=64000000 # 64GB in KB
4950

50-
while getopts ":c:tida:r:b:m:n:v:h" flag; do
51+
while getopts ":c:tida:r:b:m:n:v:u:h" flag; do
5152
case "${flag}" in
5253
c) config=${OPTARG};;
5354
t) telemetry=false;;
@@ -59,10 +60,11 @@ while getopts ":c:tida:r:b:m:n:v:h" flag; do
5960
m) mode=${OPTARG};;
6061
n) network=${OPTARG};;
6162
v) ton_node_version=${OPTARG};;
63+
u) user=${OPTARG};;
6264
h) show_help_and_exit;;
6365
*)
6466
echo "Flag -${flag} is not recognized. Aborting"
65-
exit 1 ;;
67+
exit 1 ;;
6668
esac
6769
done
6870

@@ -90,8 +92,8 @@ memory=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
9092

9193
echo "This machine has ${cpus} CPUs and ${memory}KB of Memory"
9294
if [ "$ignore" = false ] && ([ "${cpus}" -lt "${cpu_required}" ] || [ "${memory}" -lt "${mem_required}" ]); then
93-
echo "Insufficient resources. Requires a minimum of "${cpu_required}" processors and "${mem_required}" RAM."
94-
exit 1
95+
echo "Insufficient resources. Requires a minimum of "${cpu_required}" processors and "${mem_required}" RAM."
96+
exit 1
9597
fi
9698

9799
echo -e "${COLOR}[2/5]${ENDC} Checking for required TON components"
@@ -100,9 +102,9 @@ BIN_DIR=/usr/bin
100102

101103
# create dirs for OSX
102104
if [[ "$OSTYPE" =~ darwin.* ]]; then
103-
SOURCES_DIR=/usr/local/src
104-
BIN_DIR=/usr/local/bin
105-
mkdir -p ${SOURCES_DIR}
105+
SOURCES_DIR=/usr/local/src
106+
BIN_DIR=/usr/local/bin
107+
mkdir -p ${SOURCES_DIR}
106108
fi
107109

108110
# check TON components
@@ -111,9 +113,9 @@ file2=${BIN_DIR}/ton/lite-client/lite-client
111113
file3=${BIN_DIR}/ton/validator-engine-console/validator-engine-console
112114

113115
if [ ! -f "${file1}" ] || [ ! -f "${file2}" ] || [ ! -f "${file3}" ]; then
114-
echo "TON does not exists, building"
115-
wget https://raw.githubusercontent.com/${author}/${repo}/${branch}/scripts/ton_installer.sh -O /tmp/ton_installer.sh
116-
bash /tmp/ton_installer.sh -c ${config} -v ${ton_node_version}
116+
echo "TON does not exists, building"
117+
wget https://raw.githubusercontent.com/${author}/${repo}/${branch}/scripts/ton_installer.sh -O /tmp/ton_installer.sh
118+
bash /tmp/ton_installer.sh -c ${config} -v ${ton_node_version}
117119
fi
118120

119121
# Cloning mytonctrl
@@ -134,10 +136,12 @@ pip3 install -U . # TODO: make installation from git directly
134136
echo -e "${COLOR}[4/5]${ENDC} Running mytoninstaller"
135137
# DEBUG
136138

137-
parent_name=$(ps -p $PPID -o comm=)
138-
user=$(whoami)
139-
if [ "$parent_name" = "sudo" ] || [ "$parent_name" = "su" ] || [ "$parent_name" = "python3" ]; then
140-
user=$(logname)
139+
if [ "${user}" = "" ]; then # no user
140+
parent_name=$(ps -p $PPID -o comm=)
141+
user=$(whoami)
142+
if [ "$parent_name" = "sudo" ] || [ "$parent_name" = "su" ] || [ "$parent_name" = "python3" ]; then
143+
user=$(logname)
144+
fi
141145
fi
142146
echo "User: $user"
143147
python3 -m mytoninstaller -u ${user} -t ${telemetry} --dump ${dump} -m ${mode}

0 commit comments

Comments
 (0)