diff --git a/HISTORY.md b/HISTORY.md index 8041ab0249..fae951dc9f 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,10 @@ # Release History - open AEA +## 1.56.0 (2024-09-17) + +Plugins: +- Fixes the pricing logic. #756 + ## 1.55.0 (2024-08-05) Plugins: diff --git a/SECURITY.md b/SECURITY.md index bf60f02e55..f6bdbdcd66 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -8,8 +8,8 @@ The following table shows which versions of `open-aea` are currently being suppo | Version | Supported | |------------| ------------------ | -| `1.55.x` | :white_check_mark: | -| `< 1.55.0` | :x: | +| `1.56.x` | :white_check_mark: | +| `< 1.56.0` | :x: | ## Reporting a Vulnerability diff --git a/aea/__version__.py b/aea/__version__.py index ce6acb7162..e957ee052d 100644 --- a/aea/__version__.py +++ b/aea/__version__.py @@ -23,7 +23,7 @@ __title__ = "open-aea" __description__ = "Open Autonomous Economic Agent framework (without vendor lock-in)" __url__ = "https://github.com/valory-xyz/open-aea.git" -__version__ = "1.55.0" +__version__ = "1.56.0" __author__ = "Valory AG" __license__ = "Apache-2.0" __copyright__ = "2021 Valory AG, 2019 Fetch.AI Limited" diff --git a/aea/skills/scaffold/skill.yaml b/aea/skills/scaffold/skill.yaml index 4efa966a48..62e5a551e5 100644 --- a/aea/skills/scaffold/skill.yaml +++ b/aea/skills/scaffold/skill.yaml @@ -32,3 +32,4 @@ models: class_name: MyModel dependencies: {} is_abstract: false +customs: [] diff --git a/deploy-image/Dockerfile b/deploy-image/Dockerfile index 9a35619ff7..d7d9419002 100644 --- a/deploy-image/Dockerfile +++ b/deploy-image/Dockerfile @@ -16,7 +16,7 @@ RUN apk add --no-cache go # aea installation RUN pip install --upgrade pip -RUN pip install --upgrade --force-reinstall open-aea[all]==1.55.0 "open-aea-cli-ipfs<2.0.0,>=1.55.0" +RUN pip install --upgrade --force-reinstall open-aea[all]==1.56.0 "open-aea-cli-ipfs<2.0.0,>=1.56.0" # directories and aea cli config WORKDIR /home/agents diff --git a/deploy-image/README.md b/deploy-image/README.md index 217b0875ae..e29591e91a 100644 --- a/deploy-image/README.md +++ b/deploy-image/README.md @@ -11,7 +11,7 @@ The example uses the `fetchai/my_first_aea` project. You will likely want to mod Install subversion, then download the example directory to your local working directory ``` bash -svn checkout https://github.com/valory-xyz/open-aea/tags/v1.55.0/packages packages +svn checkout https://github.com/valory-xyz/open-aea/tags/v1.56.0/packages packages ``` ### Modify scripts diff --git a/develop-image/docker-env.sh b/develop-image/docker-env.sh index e1947d146f..bfdeb67aa7 100755 --- a/develop-image/docker-env.sh +++ b/develop-image/docker-env.sh @@ -1,7 +1,7 @@ #!/bin/bash # Swap the following lines if you want to work with 'latest' -DOCKER_IMAGE_TAG=valory/open-aea-develop:1.55.0 +DOCKER_IMAGE_TAG=valory/open-aea-develop:1.56.0 # DOCKER_IMAGE_TAG=valory/open-aea-develop:latest DOCKER_BUILD_CONTEXT_DIR=.. diff --git a/docs/api/plugins/aea_ledger_ethereum/ethereum.md b/docs/api/plugins/aea_ledger_ethereum/ethereum.md index ab2a481665..8fd337e974 100644 --- a/docs/api/plugins/aea_ledger_ethereum/ethereum.md +++ b/docs/api/plugins/aea_ledger_ethereum/ethereum.md @@ -47,7 +47,8 @@ Round WEI to equivalent GWEI #### get`_`base`_`fee`_`multiplier ```python -def get_base_fee_multiplier(base_fee_gwei: int) -> float +def get_base_fee_multiplier( + base_fee_gwei: Union[int, decimal.Decimal]) -> float ``` Returns multiplier value. @@ -58,9 +59,9 @@ Returns multiplier value. ```python def estimate_priority_fee( - web3_object: Web3, base_fee_gwei: int, block_number: int, - priority_fee_estimation_trigger: int, default_priority_fee: int, - fee_history_blocks: int, fee_history_percentile: int, + web3_object: Web3, block_number: int, + default_priority_fee: Optional[int], fee_history_blocks: int, + fee_history_percentile: int, priority_fee_increase_boundary: int) -> Optional[int] ``` @@ -73,7 +74,7 @@ Estimate priority fee from base fee. ```python def get_gas_price_strategy_eip1559( max_gas_fast: int, fee_history_blocks: int, fee_history_percentile: int, - priority_fee_estimation_trigger: int, default_priority_fee: int, + default_priority_fee: Optional[int], fallback_estimate: Dict[str, Optional[int]], priority_fee_increase_boundary: int ) -> Callable[[Web3, TxParams], Dict[str, Wei]] diff --git a/docs/package_list.md b/docs/package_list.md index 0a061e1b17..873d6302f7 100644 --- a/docs/package_list.md +++ b/docs/package_list.md @@ -14,7 +14,7 @@ | contract/fetchai/erc1155/0.22.0 | `bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4` | | connection/fetchai/gym/0.19.0 | `bafybeicqqvl4tt3qbulnkoffciagmfd6p3hxxi3i2mrrqtnbycv757pn6y` | | connection/fetchai/stub/0.21.0 | `bafybeibybboiwgklfiqpkkcw6rwj65s5jalzfzf6mh6fstxdlt6habzwvy` | -| connection/valory/ledger/0.19.0 | `bafybeihynkdraqthjtv74qk3nc5r2xubniqx2hhzpxn7bd4qmlf7q4wruq` | +| connection/valory/ledger/0.19.0 | `bafybeibigvowo52dw3tqwmxkdxtq52qzm6iqw752gpzpi23kgej4k3sum4` | | connection/valory/http_server/0.22.0 | `bafybeihpgu56ovmq4npazdbh6y6ru5i7zuv6wvdglpxavsckyih56smu7m` | | connection/valory/p2p_libp2p/0.1.0 | `bafybeic2u7azbwjny2nhaltqnbohlvysx3x6ectzbege7sxwrbzcz4lcma` | | connection/valory/p2p_libp2p_client/0.1.0 | `bafybeid3xg5k2ol5adflqloy75ibgljmol6xsvzvezebsg7oudxeeolz7e` | @@ -26,12 +26,12 @@ | skill/fetchai/error_test_skill/0.1.0 | `bafybeihsbtlpe7h6fsvoxban5rilkmwviwkokul5cqym6atoolirontiyu` | | skill/fetchai/gym/0.20.0 | `bafybeie7y2fsxfuhsqxqcaluo5exskmrm5q3a6e2hfcskcuvzvxjjhijh4` | | skill/fetchai/http_echo/0.20.0 | `bafybeicfiri2juaqh3azeit3z3rf44kgxdo6oj4lgxjgvnowq6m7j47qrm` | -| skill/fetchai/erc1155_client/0.28.0 | `bafybeihwk56assrj5xpu5dvyyajw7dgnk65eq2n3idd5pinxp5vortd6wi` | -| skill/fetchai/erc1155_deploy/0.30.0 | `bafybeiewhczeyrrml6shrd5dr556uwqt54aiwrol2fyqtx2n4ymgfbc6mu` | +| skill/fetchai/erc1155_client/0.28.0 | `bafybeigeoxvo3dabzbhjphu2n32wn5bomhv7b6ge6ogcte7qa6h42rwn5a` | +| skill/fetchai/erc1155_deploy/0.30.0 | `bafybeialn4tcp4vs7nousugfjpin5r37vhd2qcmphi3fs7ob66kcwb5gu4` | | skill/fetchai/error/0.17.0 | `bafybeicboomvykqhel3otyv4qg5t3hzpo6kmn5bk4ljluithhuieu7flsm` | | skill/fetchai/fipa_dummy_buyer/0.2.0 | `bafybeidgso7lo5ay44mbxsp3lxilrgeek3ye44e6wus2ayq6kyxfvc3vjm` | -| skill/fetchai/generic_buyer/0.26.0 | `bafybeif5q4xb45m5l2h6pikgqdieko4iojna5mou7byub5voajcxwxruo4` | -| skill/fetchai/generic_seller/0.27.0 | `bafybeie3dhsbasxhtkvpakxml6eyccqqpmog3kynyrl5khyrnw6hjjpdj4` | +| skill/fetchai/generic_buyer/0.26.0 | `bafybeienntvkd7blbbc4p624dop7tz4iejtpi36somhohbi4tmxd63ksr4` | +| skill/fetchai/generic_seller/0.27.0 | `bafybeid4y4p2xlnkezvtzhgwfdzrowhul34md64shf3jv5nskpggskc3fm` | | skill/fetchai/task_test_skill/0.1.0 | `bafybeidv77u2xl52mnxakwvh7fuh46aiwfpteyof4eaptfd4agoi6cdble` | | agent/fetchai/error_test/0.1.0 | `bafybeiecm675ndzbh35jkejtxn4ughoutztltjhgwzfbp57okabedjmnpq` | | agent/fetchai/gym_aea/0.25.0 | `bafybeibzn3qomqmkaksgpd3gn6aijffvvw7rojswhoytiovohuc737fvfm` | diff --git a/docs/upgrading.md b/docs/upgrading.md index 01627f1a66..7db49a5509 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -9,6 +9,13 @@ Below we describe the additional manual steps required to upgrade between differ ### Upgrade guide +## `v1.55.0` to `v1.56.0` + +- The `priority_fee_estimation_trigger` has been removed from the `eip1559` configuration of the ledger. +- The `default_priority_fee` is now optional. + If it is set to `None`, dynamic pricing will be applied. + Otherwise, the specified value will be used. + ## `v1.54.0` to `v1.55.0` - No backwards incompatible changes diff --git a/examples/tac_deploy/Dockerfile b/examples/tac_deploy/Dockerfile index 7767268a2e..1115b88cd9 100644 --- a/examples/tac_deploy/Dockerfile +++ b/examples/tac_deploy/Dockerfile @@ -19,7 +19,7 @@ RUN apk add --no-cache go # aea installation RUN python -m pip install --upgrade pip -RUN pip install --upgrade --force-reinstall open-aea[all]==1.55.0 +RUN pip install --upgrade --force-reinstall open-aea[all]==1.56.0 # directories and aea cli config COPY /.aea /home/.aea diff --git a/packages/fetchai/skills/erc1155_client/skill.yaml b/packages/fetchai/skills/erc1155_client/skill.yaml index 8acef4c775..d84dd05e49 100644 --- a/packages/fetchai/skills/erc1155_client/skill.yaml +++ b/packages/fetchai/skills/erc1155_client/skill.yaml @@ -21,7 +21,7 @@ fingerprint: tests/test_strategy.py: bafybeicbxie3v6vue3gcnru6vsvggcgy3shxwrldis5gppizbuhooslcqa fingerprint_ignore_patterns: [] connections: -- valory/ledger:0.19.0:bafybeihynkdraqthjtv74qk3nc5r2xubniqx2hhzpxn7bd4qmlf7q4wruq +- valory/ledger:0.19.0:bafybeigntoericenpzvwejqfuc3kqzo2pscs76qoygg5dbj6f4zxusru5e contracts: - fetchai/erc1155:0.22.0:bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4 protocols: diff --git a/packages/fetchai/skills/erc1155_deploy/skill.yaml b/packages/fetchai/skills/erc1155_deploy/skill.yaml index cc216289aa..f56dc80199 100644 --- a/packages/fetchai/skills/erc1155_deploy/skill.yaml +++ b/packages/fetchai/skills/erc1155_deploy/skill.yaml @@ -21,7 +21,7 @@ fingerprint: tests/test_strategy.py: bafybeigxtw2j2c7vl6xhdwos62jbtmx62xfgdyadptm5eewmkesmcooyea fingerprint_ignore_patterns: [] connections: -- valory/ledger:0.19.0:bafybeihynkdraqthjtv74qk3nc5r2xubniqx2hhzpxn7bd4qmlf7q4wruq +- valory/ledger:0.19.0:bafybeigntoericenpzvwejqfuc3kqzo2pscs76qoygg5dbj6f4zxusru5e contracts: - fetchai/erc1155:0.22.0:bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4 protocols: diff --git a/packages/fetchai/skills/generic_buyer/skill.yaml b/packages/fetchai/skills/generic_buyer/skill.yaml index e3afca86a3..25fae0f272 100644 --- a/packages/fetchai/skills/generic_buyer/skill.yaml +++ b/packages/fetchai/skills/generic_buyer/skill.yaml @@ -19,7 +19,7 @@ fingerprint: tests/test_models.py: bafybeibh72j3n72yseqvmpppucpu5wtidf6ebxbxkfnmrnlh4zv5y5apei fingerprint_ignore_patterns: [] connections: -- valory/ledger:0.19.0:bafybeihynkdraqthjtv74qk3nc5r2xubniqx2hhzpxn7bd4qmlf7q4wruq +- valory/ledger:0.19.0:bafybeigntoericenpzvwejqfuc3kqzo2pscs76qoygg5dbj6f4zxusru5e contracts: [] protocols: - fetchai/default:1.0.0:bafybeihdvtmnz7fzy7kwi3wlo6rfl27f6q3g5entplgvq7y23i3v5uoz24 diff --git a/packages/fetchai/skills/generic_seller/skill.yaml b/packages/fetchai/skills/generic_seller/skill.yaml index 145836c628..9defb353fa 100644 --- a/packages/fetchai/skills/generic_seller/skill.yaml +++ b/packages/fetchai/skills/generic_seller/skill.yaml @@ -20,7 +20,7 @@ fingerprint: tests/test_models.py: bafybeihabrc22zqssit3fmqhxptosy6qz6mx65ukhf5iayvirfv42xrhoq fingerprint_ignore_patterns: [] connections: -- valory/ledger:0.19.0:bafybeihynkdraqthjtv74qk3nc5r2xubniqx2hhzpxn7bd4qmlf7q4wruq +- valory/ledger:0.19.0:bafybeigntoericenpzvwejqfuc3kqzo2pscs76qoygg5dbj6f4zxusru5e contracts: [] protocols: - fetchai/default:1.0.0:bafybeihdvtmnz7fzy7kwi3wlo6rfl27f6q3g5entplgvq7y23i3v5uoz24 diff --git a/packages/packages.json b/packages/packages.json index d02b9a7bf4..1ca693b94f 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -14,7 +14,7 @@ "contract/fetchai/erc1155/0.22.0": "bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4", "connection/fetchai/gym/0.19.0": "bafybeicqqvl4tt3qbulnkoffciagmfd6p3hxxi3i2mrrqtnbycv757pn6y", "connection/fetchai/stub/0.21.0": "bafybeibybboiwgklfiqpkkcw6rwj65s5jalzfzf6mh6fstxdlt6habzwvy", - "connection/valory/ledger/0.19.0": "bafybeihynkdraqthjtv74qk3nc5r2xubniqx2hhzpxn7bd4qmlf7q4wruq", + "connection/valory/ledger/0.19.0": "bafybeigntoericenpzvwejqfuc3kqzo2pscs76qoygg5dbj6f4zxusru5e", "connection/valory/http_server/0.22.0": "bafybeihpgu56ovmq4npazdbh6y6ru5i7zuv6wvdglpxavsckyih56smu7m", "connection/valory/p2p_libp2p/0.1.0": "bafybeic2u7azbwjny2nhaltqnbohlvysx3x6ectzbege7sxwrbzcz4lcma", "connection/valory/p2p_libp2p_client/0.1.0": "bafybeid3xg5k2ol5adflqloy75ibgljmol6xsvzvezebsg7oudxeeolz7e", @@ -26,12 +26,12 @@ "skill/fetchai/error_test_skill/0.1.0": "bafybeihsbtlpe7h6fsvoxban5rilkmwviwkokul5cqym6atoolirontiyu", "skill/fetchai/gym/0.20.0": "bafybeie7y2fsxfuhsqxqcaluo5exskmrm5q3a6e2hfcskcuvzvxjjhijh4", "skill/fetchai/http_echo/0.20.0": "bafybeicfiri2juaqh3azeit3z3rf44kgxdo6oj4lgxjgvnowq6m7j47qrm", - "skill/fetchai/erc1155_client/0.28.0": "bafybeihwk56assrj5xpu5dvyyajw7dgnk65eq2n3idd5pinxp5vortd6wi", - "skill/fetchai/erc1155_deploy/0.30.0": "bafybeiewhczeyrrml6shrd5dr556uwqt54aiwrol2fyqtx2n4ymgfbc6mu", + "skill/fetchai/erc1155_client/0.28.0": "bafybeih7q6b2lcqcbh7rln3mgcnbtzlw7cpzjl23znnz6jj74cc4noahvq", + "skill/fetchai/erc1155_deploy/0.30.0": "bafybeigoarj6k2czdhhfqzry5w5jn2ux7chszem37zxiqy3232jr2mxs64", "skill/fetchai/error/0.17.0": "bafybeicboomvykqhel3otyv4qg5t3hzpo6kmn5bk4ljluithhuieu7flsm", "skill/fetchai/fipa_dummy_buyer/0.2.0": "bafybeidgso7lo5ay44mbxsp3lxilrgeek3ye44e6wus2ayq6kyxfvc3vjm", - "skill/fetchai/generic_buyer/0.26.0": "bafybeif5q4xb45m5l2h6pikgqdieko4iojna5mou7byub5voajcxwxruo4", - "skill/fetchai/generic_seller/0.27.0": "bafybeie3dhsbasxhtkvpakxml6eyccqqpmog3kynyrl5khyrnw6hjjpdj4", + "skill/fetchai/generic_buyer/0.26.0": "bafybeihzzcbki3p5l4nt5spbddx6nzbejv7b6nruhycwaxfrstjwmrfucq", + "skill/fetchai/generic_seller/0.27.0": "bafybeig3ffbcefeandebzepxabztob5sdkumydzla52k7pvztmjfegwflq", "skill/fetchai/task_test_skill/0.1.0": "bafybeidv77u2xl52mnxakwvh7fuh46aiwfpteyof4eaptfd4agoi6cdble", "agent/fetchai/error_test/0.1.0": "bafybeiecm675ndzbh35jkejtxn4ughoutztltjhgwzfbp57okabedjmnpq", "agent/fetchai/gym_aea/0.25.0": "bafybeibzn3qomqmkaksgpd3gn6aijffvvw7rojswhoytiovohuc737fvfm", diff --git a/packages/valory/connections/ledger/connection.yaml b/packages/valory/connections/ledger/connection.yaml index 4e6177994f..b269e899e9 100644 --- a/packages/valory/connections/ledger/connection.yaml +++ b/packages/valory/connections/ledger/connection.yaml @@ -16,7 +16,7 @@ fingerprint: tests/conftest.py: bafybeid7vo7e2m76ey5beeadtbxywxx5ukefd5slwbc362rwmhht6i45ou tests/test_contract_dispatcher.py: bafybeiag5lnpc7h25w23ash4hk4cowxsy5buxgpr474l3tfewnhf56eqyq tests/test_ledger.py: bafybeigcedfr3yv3jse3xwrerrgwbelgb56uhgrvdus527d3daekh6dx4m - tests/test_ledger_api.py: bafybeifw5smawex5m2fm6rt4kmunc22kpabalmshh45qb3xnuap33sfgyi + tests/test_ledger_api.py: bafybeihlwfzfffyr3gcrwa74g2ctoeymv76ahnxbxyal3xikgb7ftvpnl4 fingerprint_ignore_patterns: [] connections: [] protocols: @@ -37,8 +37,7 @@ config: max_gas_fast: 1500 fee_history_blocks: 10 fee_history_percentile: 5 - priority_fee_estimation_trigger: 100 - default_priority_fee: 3 + default_priority_fee: null fallback_estimate: maxFeePerGas: 20000000000 maxPriorityFeePerGas: 3000000000 diff --git a/packages/valory/connections/ledger/tests/test_ledger_api.py b/packages/valory/connections/ledger/tests/test_ledger_api.py index c7b85f2dfd..d0864f9eba 100644 --- a/packages/valory/connections/ledger/tests/test_ledger_api.py +++ b/packages/valory/connections/ledger/tests/test_ledger_api.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2021-2023 Valory AG +# Copyright 2021-2024 Valory AG # Copyright 2018-2019 Fetch.AI Limited # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,9 @@ DEFAULT_GANACHE_CHAIN_ID, ganache, ) +from eth_typing import BlockNumber from web3.eth import Eth +from web3.types import FeeHistory, Wei from aea.common import Address from aea.configurations.data_types import PublicId @@ -85,7 +87,7 @@ ], ) # TODO: uncomment gas station strategy config after the gasstation API start -gas_strategies = pytest.mark.parametrize( +gas_strategies_parametrization = pytest.mark.parametrize( "gas_strategies", [ {"gas_price_strategy": None}, @@ -98,6 +100,66 @@ ], ) +fee_history_mock = patch("web3.eth.Eth.fee_history") + +fee_history_parametrization = pytest.mark.parametrize( + "fee_history", + ( + FeeHistory( + baseFeePerGas=[Wei(0)], + gasUsedRatio=[0], + oldestBlock=BlockNumber(0), + reward=[[Wei(0)]], + ), + FeeHistory( + baseFeePerGas=[ + Wei(int("0x180b5d502", 16)), + Wei(int("0x18f9534de", 16)), + Wei(int("0x18367e3a6", 16)), + Wei(int("0x17e4519ed", 16)), + Wei(int("0x179eb57e1", 16)), + Wei(int("0x178ac8e88", 16)), + Wei(int("0x177434776", 16)), + Wei(int("0x17b4c8c2d", 16)), + Wei(int("0x173695e84", 16)), + Wei(int("0x1706c1f66", 16)), + Wei(int("0x155600bc6", 16)), + ], + gasUsedRatio=[ + 0.6546364333333333, + 0.37810266666666664, + 0.44697146666666665, + 0.4544759666666667, + 0.48681983333333334, + 0.4850136666666667, + 0.5430227, + 0.4168211333333333, + 0.46780666666666665, + 0.206346, + ], + oldestBlock=BlockNumber(int("0x13cd298", 16)), + reward=[ + [Wei(int("0xf4240", 16))], + [Wei(int("0xf4240", 16))], + [Wei(int("0xf4240", 16))], + [Wei(int("0x0", 16))], + [Wei(int("0xf4240", 16))], + [Wei(int("0xf4240", 16))], + [Wei(int("0xf4240", 16))], + [Wei(int("0x124f80", 16))], + [Wei(int("0x919f8", 16))], + [Wei(int("0xf4240", 16))], + ], + ), + FeeHistory( + baseFeePerGas=[], + gasUsedRatio=[], + oldestBlock=BlockNumber(0), + reward=[], + ), + ), +) + class LedgerApiDialogues(BaseLedgerApiDialogues): """The dialogues class keeps track of all ledger_api dialogues.""" @@ -220,17 +282,23 @@ async def test_get_state( ) assert actual_block == expected_block + @fee_history_mock @pytest.mark.asyncio - @gas_strategies + @gas_strategies_parametrization + @fee_history_parametrization async def test_get_raw_transaction( self, + fee_history_mock_: Mock, gas_strategies: Dict, + fee_history: FeeHistory, ledger_apis_connection: Connection, update_default_ethereum_ledger_api: None, ) -> None: """Test get raw transaction with Ethereum APIs.""" import aea # noqa # to load registries + fee_history_mock_.return_value = fee_history + crypto1 = make_crypto( EthereumCrypto.identifier, private_key_path=ETHEREUM_PRIVATE_KEY_PATH ) @@ -281,12 +349,19 @@ async def test_get_raw_transaction( assert isinstance(response_message.raw_transaction, RawTransaction) assert response_message.raw_transaction.ledger_id == request.terms.ledger_id + @fee_history_mock @pytest.mark.asyncio - @gas_strategies + @gas_strategies_parametrization + @fee_history_parametrization async def test_send_signed_transaction_ethereum( - self, gas_strategies: Dict, ledger_apis_connection: LedgerConnection + self, + fee_history_mock_: Mock, + gas_strategies: Dict, + fee_history: FeeHistory, + ledger_apis_connection: LedgerConnection, ) -> None: """Test send signed transaction with Ethereum APIs.""" + fee_history_mock_.return_value = fee_history ledger_api_dialogues = LedgerApiDialogues(SOME_SKILL_ID) crypto1 = make_crypto( diff --git a/plugins/aea-cli-benchmark/setup.py b/plugins/aea-cli-benchmark/setup.py index bddecacb62..2d5db9a970 100755 --- a/plugins/aea-cli-benchmark/setup.py +++ b/plugins/aea-cli-benchmark/setup.py @@ -26,7 +26,7 @@ setup( name="open-aea-cli-benchmark", - version="1.55.0", + version="1.56.0", author="Valory AG", license="Apache-2.0", description="CLI extension for AEA framework benchmarking.", diff --git a/plugins/aea-cli-ipfs/setup.py b/plugins/aea-cli-ipfs/setup.py index e030a5a1db..c10a8b9d66 100755 --- a/plugins/aea-cli-ipfs/setup.py +++ b/plugins/aea-cli-ipfs/setup.py @@ -28,7 +28,7 @@ setup( name="open-aea-cli-ipfs", - version="1.55.0", + version="1.56.0", author="Valory AG", license="Apache-2.0", description="CLI extension for open AEA framework wrapping IPFS functionality.", diff --git a/plugins/aea-ledger-cosmos/setup.py b/plugins/aea-ledger-cosmos/setup.py index 5457b3d726..13cabf5616 100644 --- a/plugins/aea-ledger-cosmos/setup.py +++ b/plugins/aea-ledger-cosmos/setup.py @@ -26,7 +26,7 @@ setup( name="open-aea-ledger-cosmos", - version="1.55.0", + version="1.56.0", author="Valory AG", license="Apache-2.0", description="Python package wrapping the public and private key cryptography and ledger api of Cosmos.", diff --git a/plugins/aea-ledger-ethereum-flashbots/setup.py b/plugins/aea-ledger-ethereum-flashbots/setup.py index e85cfa8e30..56cfb5337f 100644 --- a/plugins/aea-ledger-ethereum-flashbots/setup.py +++ b/plugins/aea-ledger-ethereum-flashbots/setup.py @@ -25,7 +25,7 @@ setup( name="open-aea-ledger-ethereum-flashbots", - version="1.55.0", + version="1.56.0", author="Valory AG", license="Apache-2.0", description="Python package extending the default open-aea ethereum ledger plugin to add support for flashbots.", @@ -41,7 +41,7 @@ }, python_requires=">=3.9,<4.0", install_requires=[ - "open-aea-ledger-ethereum~=1.55.0", + "open-aea-ledger-ethereum~=1.56.0", "open-aea-flashbots==1.4.0", ], tests_require=["pytest"], diff --git a/plugins/aea-ledger-ethereum-hwi/setup.py b/plugins/aea-ledger-ethereum-hwi/setup.py index 72c4c7c4d8..caf43e1c47 100644 --- a/plugins/aea-ledger-ethereum-hwi/setup.py +++ b/plugins/aea-ledger-ethereum-hwi/setup.py @@ -25,7 +25,7 @@ setup( name="open-aea-ledger-ethereum-hwi", - version="1.55.0", + version="1.56.0", author="Valory AG", license="Apache-2.0", description="Python package wrapping the public and private key cryptography and support for hardware wallet interactions.", @@ -42,7 +42,7 @@ "web3>=6.0.0,<7", "ipfshttpclient==0.8.0a2", "eth-account>=0.8.0,<0.9.0", - "open-aea-ledger-ethereum~=1.55.0", + "open-aea-ledger-ethereum~=1.56.0", "ledgerwallet==0.1.3", "protobuf<4.25.0,>=4.21.6", "construct<=2.10.61", diff --git a/plugins/aea-ledger-ethereum/aea_ledger_ethereum/ethereum.py b/plugins/aea-ledger-ethereum/aea_ledger_ethereum/ethereum.py index 8220125cc2..098830436a 100644 --- a/plugins/aea-ledger-ethereum/aea_ledger_ethereum/ethereum.py +++ b/plugins/aea-ledger-ethereum/aea_ledger_ethereum/ethereum.py @@ -27,6 +27,7 @@ import math import threading import warnings +from collections import defaultdict from copy import deepcopy from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, cast @@ -89,16 +90,13 @@ # Which percentile of effective priority fees to include FEE_HISTORY_PERCENTILE = 5 -# Which base fee to trigger priority fee estimation at (GWEI) -PRIORITY_FEE_ESTIMATION_TRIGGER = 100 - # Returned if above trigger is not met (GWEI) -DEFAULT_PRIORITY_FEE = 3 +DEFAULT_PRIORITY_FEE = None # In case something goes wrong fall back to this estimate FALLBACK_ESTIMATE = { "maxFeePerGas": to_wei(20, "gwei"), - "maxPriorityFeePerGas": to_wei(DEFAULT_PRIORITY_FEE, "gwei"), + "maxPriorityFeePerGas": to_wei(3, "gwei"), } PRIORITY_FEE_INCREASE_BOUNDARY = 200 # percentage @@ -107,7 +105,6 @@ "max_gas_fast": MAX_GAS_FAST, "fee_history_blocks": FEE_HISTORY_BLOCKS, "fee_history_percentile": FEE_HISTORY_PERCENTILE, - "priority_fee_estimation_trigger": PRIORITY_FEE_ESTIMATION_TRIGGER, "default_priority_fee": DEFAULT_PRIORITY_FEE, "fallback_estimate": FALLBACK_ESTIMATE, "priority_fee_increase_boundary": PRIORITY_FEE_INCREASE_BOUNDARY, @@ -129,6 +126,8 @@ EIP1559_POLYGON: DEFAULT_EIP1559_STRATEGY_POLYGON, } +BASE_FEE_MULTIPLIER = defaultdict(lambda: 1.2, {40: 2.0, 100: 1.6, 200: 1.4}) + # The tip increase is the minimum required of 10%. TIP_INCREASE = 1.1 @@ -149,32 +148,26 @@ def round_to_whole_gwei(number: Type[int]) -> Wei: return cast(Wei, to_wei(rounded, "gwei")) -def get_base_fee_multiplier(base_fee_gwei: int) -> float: +def get_base_fee_multiplier(base_fee_gwei: Union[int, decimal.Decimal]) -> float: """Returns multiplier value.""" - - if base_fee_gwei <= 40: # pylint: disable=no-else-return - return 2.0 - elif base_fee_gwei <= 100: # pylint: disable=no-else-return - return 1.6 - elif base_fee_gwei <= 200: # pylint: disable=no-else-return - return 1.4 - else: # pylint: disable=no-else-return - return 1.2 + valid_fees = {fee for fee in BASE_FEE_MULTIPLIER if base_fee_gwei <= fee} + # add negative fee in case the valid fees set is empty, to trigger the default value + if not valid_fees: + valid_fees.add(-1) + return BASE_FEE_MULTIPLIER[min(valid_fees)] def estimate_priority_fee( web3_object: Web3, - base_fee_gwei: int, block_number: int, - priority_fee_estimation_trigger: int, - default_priority_fee: int, + default_priority_fee: Optional[int], fee_history_blocks: int, fee_history_percentile: int, priority_fee_increase_boundary: int, ) -> Optional[int]: """Estimate priority fee from base fee.""" - if base_fee_gwei < priority_fee_estimation_trigger: + if default_priority_fee is not None: return default_priority_fee fee_history = web3_object.eth.fee_history( @@ -189,7 +182,7 @@ def estimate_priority_fee( # Calculate percentage increases from between ordered list of fees percentage_increases = [ - ((j - i) / i) * 100 for i, j in zip(rewards[:-1], rewards[1:]) + ((j - i) / i) * 100 if i != 0 else 0 for i, j in zip(rewards[:-1], rewards[1:]) ] highest_increase = max(*percentage_increases) highest_increase_index = percentage_increases.index(highest_increase) @@ -210,8 +203,7 @@ def get_gas_price_strategy_eip1559( max_gas_fast: int, fee_history_blocks: int, fee_history_percentile: int, - priority_fee_estimation_trigger: int, - default_priority_fee: int, + default_priority_fee: Optional[int], fallback_estimate: Dict[str, Optional[int]], priority_fee_increase_boundary: int, ) -> Callable[[Web3, TxParams], Dict[str, Wei]]: @@ -239,9 +231,7 @@ def eip1559_price_strategy( estimated_priority_fee = estimate_priority_fee( web3, - cast(int, base_fee_gwei), block_number, - priority_fee_estimation_trigger=priority_fee_estimation_trigger, default_priority_fee=default_priority_fee, fee_history_blocks=fee_history_blocks, fee_history_percentile=fee_history_percentile, @@ -255,9 +245,12 @@ def eip1559_price_strategy( return fallback_estimate max_priority_fee_per_gas = max( - estimated_priority_fee, to_wei(default_priority_fee, "gwei") + estimated_priority_fee, + to_wei(default_priority_fee, "gwei") + if default_priority_fee is not None + else -1, ) - multiplier = get_base_fee_multiplier(cast(int, base_fee_gwei)) + multiplier = get_base_fee_multiplier(base_fee_gwei) potential_max_fee = base_fee * multiplier max_fee_per_gas = ( @@ -1327,7 +1320,7 @@ def _try_get_revert_reason(self, tx: TxData, **_kwargs: Any) -> str: self.api.eth.call(replay_tx, tx["blockNumber"] - 1) except ContractLogicError as e: # execution reverted exception - return str(e) + return e.message except HTTPError as e: # http exception raise e diff --git a/plugins/aea-ledger-ethereum/setup.py b/plugins/aea-ledger-ethereum/setup.py index ac17a4e35c..29e6467559 100644 --- a/plugins/aea-ledger-ethereum/setup.py +++ b/plugins/aea-ledger-ethereum/setup.py @@ -26,7 +26,7 @@ setup( name="open-aea-ledger-ethereum", - version="1.55.0", + version="1.56.0", author="Valory AG", license="Apache-2.0", description="Python package wrapping the public and private key cryptography and ledger api of Ethereum.", diff --git a/plugins/aea-ledger-ethereum/tests/test_ethereum.py b/plugins/aea-ledger-ethereum/tests/test_ethereum.py index ae69abfa0c..df3aa9aa0e 100644 --- a/plugins/aea-ledger-ethereum/tests/test_ethereum.py +++ b/plugins/aea-ledger-ethereum/tests/test_ethereum.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2021-2023 Valory AG +# Copyright 2021-2024 Valory AG # Copyright 2018-2019 Fetch.AI Limited # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -56,11 +56,13 @@ get_base_fee_multiplier, get_gas_price_strategy_eip1559_polygon, ) +from eth_typing import BlockNumber from requests import HTTPError from web3 import Web3 from web3._utils.request import _session_cache as session_cache from web3.datastructures import AttributeDict from web3.exceptions import ContractLogicError +from web3.types import FeeHistory, Wei from aea.common import JSONLike from aea.crypto.helpers import DecryptError, KeyIsIncorrect @@ -876,6 +878,15 @@ def test_revert_reason( assert transaction_receipt["revert_reason"] == "test revert reason" +@mock.patch( + "web3.eth.Eth.fee_history", + return_value=FeeHistory( + baseFeePerGas=[Wei(0)], + gasUsedRatio=[0], + oldestBlock=BlockNumber(0), + reward=[[Wei(0)]], + ), +) @pytest.mark.parametrize( "strategy", ( @@ -885,6 +896,7 @@ def test_revert_reason( ), ) def test_try_get_gas_pricing( + _fee_history_mock: Mock, strategy: Dict[str, Union[str, Tuple[str, ...]]], ethereum_testnet_config: dict, ganache: Generator, @@ -899,7 +911,7 @@ def test_try_get_gas_pricing( gas_price[param] > 0 and isinstance(gas_price[param], int) for param in strategy["params"] ) - expteced_reprice = { + expected_reprice = { param: math.ceil(value * TIP_INCREASE) for param, value in gas_price.items() } @@ -911,7 +923,7 @@ def test_try_get_gas_pricing( gas_reprice[param] > 0 and isinstance(gas_reprice[param], int) for param in strategy["params"] ) - assert gas_reprice == expteced_reprice, "The repricing was performed incorrectly!" + assert gas_reprice == expected_reprice, "The repricing was performed incorrectly!" @pytest.mark.parametrize( @@ -1024,12 +1036,15 @@ def test_estimate_priority_fee() -> None: # return none on no rewards web3_mock = Mock() web3_mock.eth.fee_history = Mock(return_value={"reward": []}) - assert estimate_priority_fee(web3_mock, 1, 1, 1, 1, 11, 1, 1) is None + assert estimate_priority_fee(web3_mock, 1, None, 11, 1, 1) is None # If we have big increase in value, we could be considering "outliers" in our estimate # Skip the low elements and take a new median web3_mock.eth.fee_history = Mock(return_value={"reward": [[1], [10], [10000]]}) - assert estimate_priority_fee(web3_mock, 1, 1, 1, 1, 11, 1, 1) == 10000 + assert estimate_priority_fee(web3_mock, 1, None, 11, 1, 1) == 10000 + + # test the default priority fee + assert estimate_priority_fee(web3_mock, 1, 20, 11, 1, 1) == 20 def test_try_get_revert_reason_http_error_propagated(ethereum_testnet_config) -> None: diff --git a/plugins/aea-ledger-fetchai/setup.py b/plugins/aea-ledger-fetchai/setup.py index c5d8d40a4d..8ae6529a7b 100644 --- a/plugins/aea-ledger-fetchai/setup.py +++ b/plugins/aea-ledger-fetchai/setup.py @@ -31,7 +31,7 @@ setup( name="open-aea-ledger-fetchai", - version="1.55.0", + version="1.56.0", author="Valory AG", license="Apache-2.0", description="Python package wrapping the public and private key cryptography and ledger API of Fetch.AI.", @@ -44,7 +44,7 @@ "test_tools/data/*", ] }, - install_requires=["open-aea-ledger-cosmos~=1.55.0"], + install_requires=["open-aea-ledger-cosmos~=1.56.0"], tests_require=["pytest"], entry_points={ "aea.cryptos": ["fetchai = aea_ledger_fetchai:FetchAICrypto"], diff --git a/plugins/aea-ledger-solana/setup.py b/plugins/aea-ledger-solana/setup.py index f3e2e90022..fddebccfe9 100644 --- a/plugins/aea-ledger-solana/setup.py +++ b/plugins/aea-ledger-solana/setup.py @@ -25,7 +25,7 @@ setup( name="open-aea-ledger-solana", - version="1.55.0", + version="1.56.0", author="dassy23", license="Apache-2.0", description="Python package wrapping the public and private key cryptography and ledger api of solana.", diff --git a/scripts/install.ps1 b/scripts/install.ps1 index eea55beb6d..bc0a12a361 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -34,7 +34,7 @@ function instal_choco_golang_gcc { } function install_aea { echo "Install aea" - $output=pip install open-aea[all]==1.55.0 --force --no-cache-dir 2>&1 |out-string; + $output=pip install open-aea[all]==1.56.0 --force --no-cache-dir 2>&1 |out-string; if ($LastExitCode -ne 0) { echo $output echo "AEA install failed!" diff --git a/scripts/install.sh b/scripts/install.sh index 374567fc1a..c45218f45b 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -42,7 +42,7 @@ function is_python_version_ok() { function install_aea (){ echo "Install AEA" - output=$(pip3 install --user open-aea[all]==1.55.0 --force --no-cache-dir) + output=$(pip3 install --user open-aea[all]==1.56.0 --force --no-cache-dir) if [[ $? -ne 0 ]]; then echo "$output" diff --git a/skaffold.yaml b/skaffold.yaml index 7ed445554f..9701aa5eca 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -5,7 +5,7 @@ metadata: build: tagPolicy: envTemplate: - template: "1.55.0" + template: "1.56.0" artifacts: - image: valory/open-aea-develop docker: @@ -24,7 +24,7 @@ profiles: build: tagPolicy: envTemplate: - template: "1.55.0" + template: "1.56.0" artifacts: - image: valory/open-aea-docs docker: diff --git a/tests/data/dummy_aea/aea-config.yaml b/tests/data/dummy_aea/aea-config.yaml index 9e24b4a41d..dc7921184d 100644 --- a/tests/data/dummy_aea/aea-config.yaml +++ b/tests/data/dummy_aea/aea-config.yaml @@ -57,6 +57,7 @@ connection_private_key_paths: fetchai: fetchai_private_key.txt default_routing: {} dependencies: {} +customs: [] --- public_id: dummy_author/test_skill:0.1.0 type: skill diff --git a/user-image/Dockerfile b/user-image/Dockerfile index d22ca49202..ba8ea23b6a 100644 --- a/user-image/Dockerfile +++ b/user-image/Dockerfile @@ -7,7 +7,7 @@ ENV LANG C.UTF-8 RUN apt update && apt install -y python3.11-dev python3-pip -y && apt autoremove && apt autoclean RUN pip3 install --upgrade pip -RUN pip3 install "open-aea[all]==1.55.0" open-aea-cli-ipfs==1.55.0 +RUN pip3 install "open-aea[all]==1.56.0" open-aea-cli-ipfs==1.56.0 COPY user-image/openssl.cnf /etc/ssl diff --git a/user-image/docker-env.sh b/user-image/docker-env.sh index 9f0eadf7a0..038faebb41 100644 --- a/user-image/docker-env.sh +++ b/user-image/docker-env.sh @@ -1,7 +1,7 @@ #!/bin/bash # Swap the following lines if you want to work with 'latest' -DOCKER_IMAGE_TAG=valory/open-aea-user:1.55.0 +DOCKER_IMAGE_TAG=valory/open-aea-user:1.56.0 # DOCKER_IMAGE_TAG=valory/open-aea-user:latest DOCKER_BUILD_CONTEXT_DIR=..