Skip to content

Commit

Permalink
Mumbai & Nairobi Support (#667)
Browse files Browse the repository at this point in the history
* extend sunset date

* Fix: Adding new level in cycle calculation since Mumbai (#670)

* Fix: Adding new level in cycle calculation since Mumbai
* Move tests to appropriate folder
* Contributor: AndrewKishino, Effort=1h
* Reviewer: jdsika, Effort=0h

* Update src/Constants.py

Co-authored-by: Richard Ayotte <[email protected]>

* Exprimental: Nairobi support (#675)

* Nairobi fix #1

Payment to KT appears to fail due to:

  proto.017-PtNairob.gas_exhausted.operation

Adding "just a little bit more gas" to the KT1 calculation appears to be
fixing it.

* increase gas limit to manage updated costs for tz2/tz3

* add potential Oxford date

* fix gas in tests

* fix linter

* fix one more test wrt nairobi gas update

* fix black

---------

Co-authored-by: Andrew Kishino <[email protected]>
Co-authored-by: Richard Ayotte <[email protected]>
Co-authored-by: Nicolas Ochem <[email protected]>
  • Loading branch information
4 people authored Jul 31, 2023
1 parent cae79b4 commit dd3378b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
REQUIREMENTS_FILE_PATH = "requirements.txt"

# potentially the next upgrade
NEW_PROTOCOL_DATE = date(2023, 3, 29)
NEW_PROTOCOL_NAME = "Mumbai"
NEW_PROTOCOL_DATE = date(2023, 12, 31)
NEW_PROTOCOL_NAME = "Oxford"

LOCAL_HOST = "127.0.0.1"
EXIT_PAYMENT_TYPE = "exit"
Expand All @@ -35,6 +35,8 @@

FIRST_GRANADA_LEVEL = 1589249

FIRST_MUMBAI_LEVEL = 3268609

TEZOS_RPC_PORT = 8732

SIGNER_PORT = 6732
Expand Down
7 changes: 5 additions & 2 deletions src/api/block_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from Constants import FIRST_GRANADA_LEVEL
from Constants import FIRST_GRANADA_LEVEL, FIRST_MUMBAI_LEVEL

# TODO: we should check if we are on mainnet, or a testnet
# we could add a get_current_protocol() method and check against it
Expand All @@ -15,7 +15,10 @@ def get_current_cycle_and_level(self):
pass

def level_in_cycle(self, level):
if level >= FIRST_GRANADA_LEVEL:
if level >= FIRST_MUMBAI_LEVEL:
# Since protocol Mumbai
return (level - FIRST_MUMBAI_LEVEL) % self.nw["BLOCKS_PER_CYCLE"]
elif level >= FIRST_GRANADA_LEVEL:
# Since protocol Granada
return (level - FIRST_GRANADA_LEVEL) % self.nw["BLOCKS_PER_CYCLE"]
else:
Expand Down
17 changes: 10 additions & 7 deletions src/pay/batch_payer.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
TX_FEES = {
"TZ1_TO_ALLOCATED_TZ1": {
"FEE": 298,
"GAS_LIMIT": 1001,
"GAS_LIMIT": 1400,
"STORAGE_LIMIT": 0, # 65 mutez before
},
"TZ1_TO_NON_ALLOCATED_TZ1": {
Expand All @@ -92,7 +92,7 @@
},
"TZ1_REVEAL": {
"FEE": 357,
"GAS_LIMIT": 1000,
"GAS_LIMIT": 1400,
"STORAGE_LIMIT": 0,
},
}
Expand Down Expand Up @@ -471,11 +471,14 @@ def simulate_single_operation(self, payment_item, pymnt_amnt, branch, chain_id):
status = op["metadata"]["operation_result"]["status"]
if status == "applied":
# Calculate actual consumed gas amount
consumed_gas = calculate_consumed_gas(
consumed_milligas=op["metadata"]["operation_result"][
"consumed_milligas"
],
metadata=op["metadata"],
consumed_gas = (
calculate_consumed_gas(
consumed_milligas=op["metadata"]["operation_result"][
"consumed_milligas"
],
metadata=op["metadata"],
)
+ 100
)
# Calculate actual used storage
consumed_storage = calculate_consumed_storage(op["metadata"])
Expand Down
5 changes: 4 additions & 1 deletion src/rpc/rpc_reward_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,10 @@ def get_endorsing_rewards(self, level_of_last_block_in_cycle):
# If metadata is not available return zeros
return endorsing_rewards, lost_endorsing_rewards

if type(metadata) == list and "block_metadata_not_found" in metadata[0]:
if (
isinstance(list, type(metadata))
and "block_metadata_not_found" in metadata[0]
):
logger.warning("Block metadata not found!")
return endorsing_rewards, lost_endorsing_rewards

Expand Down
2 changes: 1 addition & 1 deletion tests/regression/test_attempt_single_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,5 @@ def test_attempt_single_batch_KT(sign, request_url, request_url_post):
)
assert status == PaymentStatus.DONE
assert operation_hash is None
assert reward_log.delegator_transaction_fee == 8994
assert reward_log.delegator_transaction_fee == 9004
assert opt_counter.counter == 4
5 changes: 3 additions & 2 deletions tests/regression/test_level_in_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ def get_current_cycle_and_level(self):


def test_levels_in_cycle():

# This test only works for blocks after granada because the network config
# map is based on current mainnet values

level_positions = [
[1589249, 0], # Granada activation level
[3000000, 1727],
[3268609, 0], # Mumbai activation level
[3333796, 16035],
]

block = DummyApiImpl()

for (level, pos) in level_positions:
for level, pos in level_positions:
assert block.level_in_cycle(level) == pos
4 changes: 2 additions & 2 deletions tests/regression/test_simulate_single_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def test_simulate_single_operation():
)
assert PaymentStatus.DONE == simulation_status
consumed_gas, tx_fee, storage = simulation_results
assert 150 == consumed_gas
assert 313.0 == default_fee + consumed_gas * MUTEZ_PER_GAS_UNIT
assert 250 == consumed_gas
assert 323.0 == default_fee + consumed_gas * MUTEZ_PER_GAS_UNIT
assert int == type(storage) # type of storage should be int
assert 24 == storage

Expand Down

0 comments on commit dd3378b

Please sign in to comment.