From 354af19dd2cd252817f55ab1b85cbc968e6a34f3 Mon Sep 17 00:00:00 2001 From: YoshihitoAso Date: Fri, 15 Mar 2024 17:59:25 +0900 Subject: [PATCH 1/2] Payload timeout test load module --- local-network/general/Dockerfile | 2 +- local-network/validator/Dockerfile | 2 +- loop.py | 53 ++++++++++++++++++++++++++++++ tests/config.py | 2 +- tests/contracts/Loop.sol | 31 +++++++++++++++++ tests/loop_deploy.py | 32 ++++++++++++++++++ 6 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 loop.py create mode 100644 tests/contracts/Loop.sol create mode 100644 tests/loop_deploy.py diff --git a/local-network/general/Dockerfile b/local-network/general/Dockerfile index 420fd8d..5274e7b 100644 --- a/local-network/general/Dockerfile +++ b/local-network/general/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout v2.3.0_beta1 + git checkout feature/#40 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/local-network/validator/Dockerfile b/local-network/validator/Dockerfile index 675326c..d9bd757 100644 --- a/local-network/validator/Dockerfile +++ b/local-network/validator/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout v2.3.0_beta1 + git checkout feature/#40 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/loop.py b/loop.py new file mode 100644 index 0000000..a720eed --- /dev/null +++ b/loop.py @@ -0,0 +1,53 @@ +""" +Copyright BOOSTRY Co., Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. + +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +""" + +import secrets + +from eth_utils import keccak, to_checksum_address +from coincurve import PublicKey +from web3 import Web3 +from web3.middleware import geth_poa_middleware + +from tests.config import WEB3_HTTP_PROVIDER, CHAIN_ID, DEPLOYED_CONTRACT_ADDRESS +from tests.util import ContractUtils + +contract = ContractUtils.get_contract(DEPLOYED_CONTRACT_ADDRESS) +web3 = Web3(Web3.HTTPProvider(WEB3_HTTP_PROVIDER)) +web3.middleware_onion.inject(geth_poa_middleware, layer=0) +web3.strict_bytes_type_checking = False + + +for i in range(1000): + private_key = keccak(secrets.token_bytes(32)) + public_key = PublicKey.from_valid_secret(private_key).format(compressed=False)[1:] + addr = to_checksum_address(keccak(public_key)[-20:]) + nonce = web3.eth.get_transaction_count(addr) + tx = contract.functions.loop10000().build_transaction( + transaction={ + "chainId": CHAIN_ID, + "from": addr, + "gas": 100000000, + "gasPrice": 0, + "nonce": nonce + } + ) + signed_tx = web3.eth.account.sign_transaction( + transaction_dict=tx, private_key=private_key + ) + tx_hash = web3.eth.send_raw_transaction(signed_tx.rawTransaction.hex()) diff --git a/tests/config.py b/tests/config.py index 59ee375..c1d960d 100644 --- a/tests/config.py +++ b/tests/config.py @@ -22,7 +22,7 @@ # Used common ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" CONTRACT_PATH = f"{os.path.dirname(__file__)}/contracts" -CONTRACT_NAME = "E2ETest" +CONTRACT_NAME = os.environ.get("CONTRACT_NAME") or "E2ETest" ACCOUNT_NAME = "test_user" ACCOUNT_PASSWORD = "password" diff --git a/tests/contracts/Loop.sol b/tests/contracts/Loop.sol new file mode 100644 index 0000000..08ad6b4 --- /dev/null +++ b/tests/contracts/Loop.sol @@ -0,0 +1,31 @@ +/** +* Copyright BOOSTRY Co., Ltd. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* +* You may obtain a copy of the License at +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +* See the License for the specific language governing permissions and +* limitations under the License. +* +* SPDX-License-Identifier: Apache-2.0 +*/ + +pragma solidity ^0.8.0; + +/// @title Loop 10000 +contract Loop { + + constructor() {} + + /// loop 10000 + function loop10000() public { + for (uint256 i = 0; i < 10000; i++) {} + } +} \ No newline at end of file diff --git a/tests/loop_deploy.py b/tests/loop_deploy.py new file mode 100644 index 0000000..79d48aa --- /dev/null +++ b/tests/loop_deploy.py @@ -0,0 +1,32 @@ +""" +Copyright BOOSTRY Co., Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. + +You may obtain a copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +""" + +import os +import sys + +path = os.path.join(os.path.dirname(__file__), "../") +sys.path.append(path) + +from tests.util import ContractUtils + +# Deploy +args = [] +contract_address, _, _ = ContractUtils.deploy_contract(args) + +print(f"DEPLOYED_CONTRACT_ADDRESS={contract_address}") From e3529ced5f4879f8bd2ebb4cd91f5cc19073d0e6 Mon Sep 17 00:00:00 2001 From: YoshihitoAso Date: Fri, 15 Mar 2024 20:43:41 +0900 Subject: [PATCH 2/2] v2.3.0 beta2 --- ibet-for-fin-network/general/Dockerfile | 2 +- ibet-for-fin-network/validator/Dockerfile | 2 +- ibet-network/general/Dockerfile | 2 +- ibet-network/validator/Dockerfile | 2 +- local-network/docker-compose.yml | 10 +++++----- local-network/general/Dockerfile | 2 +- local-network/validator/Dockerfile | 2 +- test-network/general/Dockerfile | 2 +- test-network/validator/Dockerfile | 2 +- loop.py => tests/loop.py | 0 10 files changed, 13 insertions(+), 13 deletions(-) rename loop.py => tests/loop.py (100%) diff --git a/ibet-for-fin-network/general/Dockerfile b/ibet-for-fin-network/general/Dockerfile index 420fd8d..1e1409e 100644 --- a/ibet-for-fin-network/general/Dockerfile +++ b/ibet-for-fin-network/general/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout v2.3.0_beta1 + git checkout v2.3.0_beta2 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/ibet-for-fin-network/validator/Dockerfile b/ibet-for-fin-network/validator/Dockerfile index 4059e68..726e044 100644 --- a/ibet-for-fin-network/validator/Dockerfile +++ b/ibet-for-fin-network/validator/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout v2.3.0_beta1 + git checkout v2.3.0_beta2 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/ibet-network/general/Dockerfile b/ibet-network/general/Dockerfile index 420fd8d..1e1409e 100644 --- a/ibet-network/general/Dockerfile +++ b/ibet-network/general/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout v2.3.0_beta1 + git checkout v2.3.0_beta2 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/ibet-network/validator/Dockerfile b/ibet-network/validator/Dockerfile index 4059e68..726e044 100644 --- a/ibet-network/validator/Dockerfile +++ b/ibet-network/validator/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout v2.3.0_beta1 + git checkout v2.3.0_beta2 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/local-network/docker-compose.yml b/local-network/docker-compose.yml index 8fd1a7f..da906dd 100644 --- a/local-network/docker-compose.yml +++ b/local-network/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: validator-0: hostname: validator-0 - image: ghcr.io/boostryjp/ibet-localnet/validator:v2.3.0_beta1 + image: ghcr.io/boostryjp/ibet-localnet/validator:v2.3.0_beta2 volumes: - /home/ubuntu/quorum_data/v0:/eth environment: @@ -24,7 +24,7 @@ services: restart: always validator-1: hostname: validator-1 - image: ghcr.io/boostryjp/ibet-localnet/validator:v2.3.0_beta1 + image: ghcr.io/boostryjp/ibet-localnet/validator:v2.3.0_beta2 volumes: - /home/ubuntu/quorum_data/v1:/eth environment: @@ -46,7 +46,7 @@ services: restart: always validator-2: hostname: validator-2 - image: ghcr.io/boostryjp/ibet-localnet/validator:v2.3.0_beta1 + image: ghcr.io/boostryjp/ibet-localnet/validator:v2.3.0_beta2 volumes: - /home/ubuntu/quorum_data/v2:/eth environment: @@ -68,7 +68,7 @@ services: restart: always validator-3: hostname: validator-3 - image: ghcr.io/boostryjp/ibet-localnet/validator:v2.3.0_beta1 + image: ghcr.io/boostryjp/ibet-localnet/validator:v2.3.0_beta2 volumes: - /home/ubuntu/quorum_data/v3:/eth environment: @@ -90,7 +90,7 @@ services: restart: always general-0: hostname: general-0 - image: ghcr.io/boostryjp/ibet-localnet/general:v2.3.0_beta1 + image: ghcr.io/boostryjp/ibet-localnet/general:v2.3.0_beta2 volumes: - /home/ubuntu/quorum_data/g0:/eth environment: diff --git a/local-network/general/Dockerfile b/local-network/general/Dockerfile index 5274e7b..1e1409e 100644 --- a/local-network/general/Dockerfile +++ b/local-network/general/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout feature/#40 + git checkout v2.3.0_beta2 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/local-network/validator/Dockerfile b/local-network/validator/Dockerfile index d9bd757..cec7c9b 100644 --- a/local-network/validator/Dockerfile +++ b/local-network/validator/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout feature/#40 + git checkout v2.3.0_beta2 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/test-network/general/Dockerfile b/test-network/general/Dockerfile index 420fd8d..1e1409e 100644 --- a/test-network/general/Dockerfile +++ b/test-network/general/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout v2.3.0_beta1 + git checkout v2.3.0_beta2 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/test-network/validator/Dockerfile b/test-network/validator/Dockerfile index 4059e68..726e044 100644 --- a/test-network/validator/Dockerfile +++ b/test-network/validator/Dockerfile @@ -7,7 +7,7 @@ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN git clone https://github.com/BoostryJP/quorum.git && \ cd quorum/ && \ - git checkout v2.3.0_beta1 + git checkout v2.3.0_beta2 RUN cd quorum/ && \ make geth bootnode && \ mv build/bin/geth /usr/local/bin && \ diff --git a/loop.py b/tests/loop.py similarity index 100% rename from loop.py rename to tests/loop.py