Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor batch payer #639

Merged
merged 40 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
026427f
wip
Dec 13, 2022
f4a378e
use .value to get the enum memeber
Dec 15, 2022
d5f1279
Merge branch 'master' into refactor-batch-payer
Dec 16, 2022
5536fcd
style: code cleanup
Dec 16, 2022
1b7bbe5
fix: remove ipdp imports
Dec 16, 2022
29775b9
hack: comment out tests
Dec 16, 2022
110dd71
Merge branch 'master' into refactor-batch-payer
jdsika Dec 17, 2022
d111a31
fix API URL
jdsika Dec 17, 2022
8954222
remove newline
jdsika Dec 17, 2022
2b8607d
add newline
jdsika Dec 17, 2022
41213b2
apply black
jdsika Dec 17, 2022
fa53afb
Merge branch 'master' into refactor-batch-payer
Jan 4, 2023
3857745
Merge branch 'master' into refactor-batch-payer
jdsika Jan 4, 2023
d547d97
fix: update new gas limit
Jan 5, 2023
d081907
Merge branch 'refactor-batch-payer' of github.com:tezos-reward-distri…
Jan 5, 2023
b02f05c
test: reinstate previously broken tests
Jan 5, 2023
18fe4b6
fix: use correct tzkt url for api
Jan 5, 2023
8cf3cb1
test: remove broken test for now
Jan 5, 2023
ac0e14a
test: remove issue tests
Jan 5, 2023
f45482f
test: replacing calculate required fees
Jan 5, 2023
6c24d90
test: replacing calculate required fees
Jan 5, 2023
0d4c976
test: replacing calculate tx fees
Jan 5, 2023
3869aab
test: replacing tests
Jan 5, 2023
f8f7bba
tests: trying on 3.8
Jan 6, 2023
558e356
test: remove one option on calculate tx fees
Jan 6, 2023
91c2ad3
tests: use == instead of is
Jan 6, 2023
4bc8afb
test: remove ipdb
Jan 6, 2023
be504c3
tests:working tests
Jan 6, 2023
1d7b51a
style: put constants back for now
Jan 9, 2023
4fcaa10
fix: broken imports
Jan 9, 2023
03cad1d
tests: replace commented out text
Jan 9, 2023
3d254bd
Put comment at correct line
jdsika Jan 11, 2023
4767133
Update Gas Limit
jdsika Jan 11, 2023
851a8ee
test: replace commented out test
Jan 12, 2023
b908bde
Merge branch 'refactor-batch-payer' of github.com:tezos-reward-distri…
Jan 12, 2023
079e6c2
tests: remove incorrect assert
Jan 12, 2023
3ebbf77
style: cleanup pr
Jan 13, 2023
64b17f7
style: change requests
Jan 17, 2023
84b5009
fix: return from util correctly
Jan 19, 2023
13beb0a
style: update text for avoiding a simulated fail
Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fee.ini*
.python-version
lock
.coverage
.DS_Store

# State diagram outputs for sphinx documentation
config_cycle_state_diagram.png
Expand Down
17 changes: 17 additions & 0 deletions pymnt/cfg/tz1iZ9LkpAhN8X1L6RpBtfy3wxpEWzFrXz8j.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
baking_address: tz1iZ9LkpAhN8X1L6RpBtfy3wxpEWzFrXz8j
jdsika marked this conversation as resolved.
Show resolved Hide resolved
delegator_pays_ra_fee: true
delegator_pays_xfer_fee: true
founders_map: {}
min_delegation_amt: 0.0
owners_map: {}
pay_denunciation_rewards: true
payment_address: tz1eSZusm331X4GdvGsnaFjuiBpq8yHprdrf
plugins:
enabled: null
reactivate_zeroed: true
rewards_type: ideal
rules_map:
mindelegation: TOB
service_fee: 99
specials_map: {}
supporters_set: !!set {}
67 changes: 66 additions & 1 deletion src/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

# TzKT
TZKT_PUBLIC_API_URL = {
"MAINNET": "https://api.tzkt.io/v1",
"MAINNET": "https://api.{}.tzkt.io/v1".format(CURRENT_TESTNET.lower()),
CURRENT_TESTNET: "https://api.{}.tzkt.io/v1".format(CURRENT_TESTNET.lower()),
rvermootenct marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -118,9 +118,74 @@
GIGA_BYTE = 1e9
DISK_LIMIT_SIZE = 5 * GIGA_BYTE

PKH_LENGTH = 36

BUF_SIZE = 50


# General transaction parameters:
#
# This fee limit is set to allow payouts to ovens
# Other KT accounts with higher fee requirements will be skipped
# TODO: define set of known contract formats and make this fee for unknown contracts configurable
KT1_FEE_SAFETY_CHECK = False
jdsika marked this conversation as resolved.
Show resolved Hide resolved
FEE_LIMIT_CONTRACTS = 100000
ZERO_THRESHOLD = 1 # too less to payout in mutez
MAX_TX_PER_BLOCK_TZ = 550
MAX_TX_PER_BLOCK_KT = 25

# For simulation
# https://rpc.tzkt.io/mainnet/chains/main/blocks/head/context/constants
HARD_GAS_LIMIT_PER_OPERATION = 1040000
HARD_STORAGE_LIMIT_PER_OPERATION = 60000
COST_PER_BYTE = 250
MINIMUM_FEE_MUTEZ = 100
MUTEZ_PER_GAS_UNIT = 0.1
MUTEZ_PER_BYTE = 1

PKH_LENGTH = 36
SIGNATURE_BYTES_SIZE = 64
MAX_NUM_TRIALS_PER_BLOCK = 2
MAX_BLOCKS_TO_CHECK_AFTER_INJECTION = 5
MAX_BATCH_PAYMENT_ATTEMPTS = 3

COMM_DELEGATE_BALANCE = "/chains/main/blocks/{}/context/contracts/{}/balance"
COMM_PAYMENT_HEAD = "/chains/main/blocks/head~10"
COMM_HEAD = "/chains/main/blocks/head"
COMM_COUNTER = "/chains/main/blocks/head/context/contracts/{}/counter"
CONTENT = '{"kind":"transaction","source":"%SOURCE%","destination":"%DESTINATION%","fee":"%fee%","counter":"%COUNTER%","gas_limit":"%gas_limit%","storage_limit":"%storage_limit%","amount":"%AMOUNT%"}'
FORGE_JSON = '{"branch": "%BRANCH%","contents":[%CONTENT%]}'
RUNOPS_JSON = '{"branch": "%BRANCH%","contents":[%CONTENT%], "signature":"edsigtXomBKi5CTRf5cjATJWSyaRvhfYNHqSUGrn4SdbYRcGwQrUGjzEfQDTuqHhuA8b2d8NarZjz8TRf65WkpQmo423BtomS8Q"}'
PREAPPLY_JSON = '[{"protocol":"%PROTOCOL%","branch":"%BRANCH%","contents":[%CONTENT%],"signature":"%SIGNATURE%"}]'
JSON_WRAP = '{"operation": %JSON%,"chain_id":"%chain_id%"}'

COMM_RUNOPS = "/chains/main/blocks/head/helpers/scripts/run_operation"
COMM_FORGE = "/chains/main/blocks/head/helpers/forge/operations"
COMM_PREAPPLY = "/chains/main/blocks/head/helpers/preapply/operations"
COMM_INJECT = "/injection/operation"
COMM_WAIT = "/chains/main/blocks/%BLOCK_HASH%/operation_hashes"

# These values may change with protocol upgrades
TX_FEES = {
"TZ1_TO_ALLOCATED_TZ1": {
"FEE": 298,
"GAS_LIMIT": 1451,
"STORAGE_LIMIT": 0, # 65 mutez before
},
"TZ1_TO_NON_ALLOCATED_TZ1": {
"FEE": 397,
"GAS_LIMIT": 1421,
"STORAGE_LIMIT": 277,
"BURN_FEE": None, # 0.257 tez before
},
"TZ1_REVEAL": {
"FEE": 357,
"GAS_LIMIT": 1000,
"STORAGE_LIMIT": 0,
},
}


class DryRun(str, Enum):
SIGNER = "SIGNER"
NO_SIGNER = "NO_SIGNER"
Expand Down
23 changes: 15 additions & 8 deletions src/config/yaml_baking_conf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,23 @@ def validate_baking_address(self, conf_obj):
"Baking address must be a valid tz address."
)
else:
if not self.block_api.get_revelation(baking_address):
raise ConfigurationException(
"Baking address {} did not reveal key.".format(baking_address)
)
try:
if not self.block_api.get_revelation(baking_address):
raise ConfigurationException(
"Baking address {} did not reveal key.".format(
rvermootenct marked this conversation as resolved.
Show resolved Hide resolved
baking_address
)
)

if not self.block_api.get_delegatable(baking_address):
raise ConfigurationException(
"Baking address {} is not enabled for delegation".format(
baking_address
if not self.block_api.get_delegatable(baking_address):
raise ConfigurationException(
"Baking address {} is not enabled for delegation".format(
baking_address
)
)
except KeyError:
raise ConfigurationException(
"unable to use signer, do you have it running?"
)
else:
raise ConfigurationException(
Expand Down
1 change: 1 addition & 0 deletions src/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def onexclude(input):

try:
address_target = input.split(",")

address = address_target[0].strip()
target = address_target[1].strip()
AddressValidator("excluded address").validate(address)
Expand Down
Loading