forked from cerc-io/laconicd-deprecated
update from fork
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package importer
|
||||
|
||||
import (
|
||||
|
||||
@@ -2,13 +2,14 @@ local config = import 'default.jsonnet';
|
||||
|
||||
config {
|
||||
'ethermint_9000-1'+: {
|
||||
'app-config'+: {
|
||||
'minimum-gas-prices': '100000000000aphoton',
|
||||
},
|
||||
genesis+: {
|
||||
app_state+: {
|
||||
feemarket+: {
|
||||
params+: {
|
||||
no_base_fee: false,
|
||||
base_fee:: super.base_fee,
|
||||
initial_base_fee: super.base_fee,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
cmd: 'laconicd',
|
||||
'start-flags': '--trace',
|
||||
config: {
|
||||
<<<<<<< HEAD
|
||||
consensus: {
|
||||
// larger timeout for more stable mempool tests
|
||||
timeout_commit: '2s',
|
||||
},
|
||||
=======
|
||||
>>>>>>> v0.21.0
|
||||
mempool: {
|
||||
// use v1 mempool to enable tx prioritization
|
||||
version: 'v1',
|
||||
@@ -17,8 +20,8 @@
|
||||
'minimum-gas-prices': '0aphoton',
|
||||
'index-events': ['ethereum_tx.ethereumTxHash'],
|
||||
'json-rpc': {
|
||||
address: '0.0.0.0:{EVMRPC_PORT}',
|
||||
'ws-address': '0.0.0.0:{EVMRPC_PORT_WS}',
|
||||
address: '127.0.0.1:{EVMRPC_PORT}',
|
||||
'ws-address': '127.0.0.1:{EVMRPC_PORT_WS}',
|
||||
api: 'eth,net,web3,debug',
|
||||
'feehistory-cap': 100,
|
||||
'block-range-cap': 10000,
|
||||
|
||||
@@ -8,13 +8,18 @@ config {
|
||||
},
|
||||
},
|
||||
'app-config'+: {
|
||||
pruning: 'everything',
|
||||
'state-sync'+: {
|
||||
'snapshot-interval': 0,
|
||||
},
|
||||
'json-rpc'+: {
|
||||
'enable-indexer': true,
|
||||
},
|
||||
},
|
||||
genesis+: {
|
||||
app_state+: {
|
||||
feemarket+: {
|
||||
params+: {
|
||||
min_gas_multiplier: '0',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
local default = import 'default.jsonnet';
|
||||
|
||||
default {
|
||||
'ethermint_9000-1'+: {
|
||||
config+: {
|
||||
consensus+: {
|
||||
timeout_commit: '5s',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -8,5 +8,14 @@ config {
|
||||
'snapshot-interval': 0,
|
||||
},
|
||||
},
|
||||
genesis+: {
|
||||
app_state+: {
|
||||
feemarket+: {
|
||||
params+: {
|
||||
min_gas_multiplier: '0',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ local config = import 'default.jsonnet';
|
||||
|
||||
config {
|
||||
'ethermint_9000-1'+: {
|
||||
validators: super.validators + [{
|
||||
validators: super.validators[0:1] + [{
|
||||
name: 'fullnode',
|
||||
}],
|
||||
},
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
let
|
||||
pkgs = import ../../../nix { };
|
||||
fetchEthermint = rev: builtins.fetchTarball "https://github.com/evmos/ethermint/archive/${rev}.tar.gz";
|
||||
fetchEthermint = rev: builtins.fetchTarball "https://github.com/cerc-io/laconicd/archive/${rev}.tar.gz";
|
||||
released = pkgs.buildGo118Module rec {
|
||||
name = "laconicd";
|
||||
# the commit before https://github.com/evmos/ethermint/pull/943
|
||||
src = fetchEthermint "f21592ebfe74da7590eb42ed926dae970b2a9a3f";
|
||||
src = fetchEthermint "d29cdad6e667f6089dfecbedd36bb8d3a2a7d025";
|
||||
subPackages = [ "cmd/laconicd" ];
|
||||
vendorSha256 = "sha256-ABm5t6R/u2S6pThGrgdsqe8n3fH5tIWw7a57kxJPbYw=";
|
||||
vendorSha256 = "sha256-cQAol54b6hNzsA4Q3MP9mTqFWM1MvR5uMPrYpaoj3SY=";
|
||||
doCheck = false;
|
||||
};
|
||||
current = pkgs.callPackage ../../../. { };
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from .network import setup_custom_ethermint, setup_ethermint, setup_geth
|
||||
from .network import setup_ethermint, setup_geth
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@@ -11,42 +9,12 @@ def ethermint(tmp_path_factory):
|
||||
yield from setup_ethermint(path, 26650)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def ethermint_indexer(tmp_path_factory):
|
||||
path = tmp_path_factory.mktemp("indexer")
|
||||
yield from setup_custom_ethermint(
|
||||
path, 26660, Path(__file__).parent / "configs/enable-indexer.jsonnet"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def geth(tmp_path_factory):
|
||||
path = tmp_path_factory.mktemp("geth")
|
||||
yield from setup_geth(path, 8545)
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
scope="session", params=["ethermint", "geth", "ethermint-ws", "enable-indexer"]
|
||||
)
|
||||
def cluster(request, ethermint, ethermint_indexer, geth):
|
||||
"""
|
||||
run on both ethermint and geth
|
||||
"""
|
||||
provider = request.param
|
||||
if provider == "ethermint":
|
||||
yield ethermint
|
||||
elif provider == "geth":
|
||||
yield geth
|
||||
elif provider == "ethermint-ws":
|
||||
ethermint_ws = ethermint.copy()
|
||||
ethermint_ws.use_websocket()
|
||||
yield ethermint_ws
|
||||
elif provider == "enable-indexer":
|
||||
yield ethermint_indexer
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
scope="session", params=["ethermint", "ethermint-ws"]
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ from dateutil.parser import isoparse
|
||||
from pystarport.utils import build_cli_args_safe, interact
|
||||
|
||||
DEFAULT_GAS_PRICE = "5000000000000aphoton"
|
||||
DEFAULT_GAS = "250000"
|
||||
|
||||
|
||||
class ChainCommand:
|
||||
@@ -636,13 +637,14 @@ class CosmosCLI:
|
||||
)
|
||||
|
||||
def gov_propose(self, proposer, kind, proposal, **kwargs):
|
||||
method = "submit-proposal"
|
||||
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
|
||||
if kind == "software-upgrade":
|
||||
return json.loads(
|
||||
self.raw(
|
||||
"tx",
|
||||
"gov",
|
||||
"submit-proposal",
|
||||
method,
|
||||
kind,
|
||||
proposal["name"],
|
||||
"-y",
|
||||
@@ -664,7 +666,7 @@ class CosmosCLI:
|
||||
self.raw(
|
||||
"tx",
|
||||
"gov",
|
||||
"submit-proposal",
|
||||
method,
|
||||
kind,
|
||||
"-y",
|
||||
from_=proposer,
|
||||
@@ -685,7 +687,7 @@ class CosmosCLI:
|
||||
self.raw(
|
||||
"tx",
|
||||
"gov",
|
||||
"submit-proposal",
|
||||
method,
|
||||
kind,
|
||||
fp.name,
|
||||
"-y",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -68,8 +68,12 @@ class Geth:
|
||||
self.w3 = w3
|
||||
|
||||
|
||||
def setup_ethermint(path, base_port):
|
||||
cfg = Path(__file__).parent / "configs/default.jsonnet"
|
||||
def setup_ethermint(path, base_port, long_timeout_commit=False):
|
||||
cfg = Path(__file__).parent / (
|
||||
"configs/default.jsonnet"
|
||||
if long_timeout_commit
|
||||
else "configs/long_timeout_commit.jsonnet"
|
||||
)
|
||||
yield from setup_custom_ethermint(path, base_port, cfg)
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
def test_basic(cluster):
|
||||
w3 = cluster.w3
|
||||
assert w3.eth.chain_id == 9000
|
||||
@@ -0,0 +1,73 @@
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
|
||||
import pytest
|
||||
from web3 import Web3
|
||||
|
||||
from .network import setup_ethermint
|
||||
from .utils import ADDRS, send_transaction
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def custom_ethermint(tmp_path_factory):
|
||||
path = tmp_path_factory.mktemp("fee-history")
|
||||
yield from setup_ethermint(path, 26500, long_timeout_commit=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", params=["ethermint", "geth"])
|
||||
def cluster(request, custom_ethermint, geth):
|
||||
"""
|
||||
run on both ethermint and geth
|
||||
"""
|
||||
provider = request.param
|
||||
if provider == "ethermint":
|
||||
yield custom_ethermint
|
||||
elif provider == "geth":
|
||||
yield geth
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def test_basic(cluster):
|
||||
w3: Web3 = cluster.w3
|
||||
call = w3.provider.make_request
|
||||
tx = {"to": ADDRS["community"], "value": 10, "gasPrice": w3.eth.gas_price}
|
||||
send_transaction(w3, tx)
|
||||
size = 4
|
||||
# size of base fee + next fee
|
||||
max = size + 1
|
||||
# only 1 base fee + next fee
|
||||
min = 2
|
||||
method = "eth_feeHistory"
|
||||
field = "baseFeePerGas"
|
||||
percentiles = [100]
|
||||
height = w3.eth.block_number
|
||||
latest = dict(
|
||||
blocks=["latest", hex(height)],
|
||||
expect=max,
|
||||
)
|
||||
earliest = dict(
|
||||
blocks=["earliest", "0x0"],
|
||||
expect=min,
|
||||
)
|
||||
for tc in [latest, earliest]:
|
||||
res = []
|
||||
with ThreadPoolExecutor(len(tc["blocks"])) as exec:
|
||||
tasks = [
|
||||
exec.submit(call, method, [size, b, percentiles]) for b in tc["blocks"]
|
||||
]
|
||||
res = [future.result()["result"][field] for future in as_completed(tasks)]
|
||||
assert len(res) == len(tc["blocks"])
|
||||
assert res[0] == res[1]
|
||||
assert len(res[0]) == tc["expect"]
|
||||
|
||||
for x in range(max):
|
||||
i = x + 1
|
||||
fee_history = call(method, [size, hex(i), percentiles])
|
||||
# start to reduce diff on i <= size - min
|
||||
diff = size - min - i
|
||||
reduce = size - diff
|
||||
target = reduce if diff >= 0 else max
|
||||
res = fee_history["result"]
|
||||
assert len(res[field]) == target
|
||||
oldest = i + min - max
|
||||
assert res["oldestBlock"] == hex(oldest if oldest > 0 else 0)
|
||||
@@ -1,8 +1,11 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from eth_abi import abi
|
||||
from hexbytes import HexBytes
|
||||
from web3 import Web3
|
||||
|
||||
from .network import setup_custom_ethermint, setup_ethermint
|
||||
from .utils import (
|
||||
ADDRS,
|
||||
CONTRACTS,
|
||||
@@ -22,6 +25,86 @@ CHANGE_GREETING_TOPIC = Web3.keccak(text="ChangeGreeting(address,string)")
|
||||
TRANSFER_TOPIC = Web3.keccak(text="Transfer(address,address,uint256)")
|
||||
|
||||
|
||||
def test_get_logs_by_topic(cluster):
|
||||
w3: Web3 = cluster.w3
|
||||
|
||||
contract, _ = deploy_contract(w3, CONTRACTS["Greeter"])
|
||||
|
||||
topic = Web3.keccak(text="ChangeGreeting(address,string)")
|
||||
|
||||
# with tx
|
||||
tx = contract.functions.setGreeting("world").build_transaction()
|
||||
receipt = send_transaction(w3, tx)
|
||||
assert receipt.status == 1
|
||||
|
||||
# The getLogs method under the hood works as a filter
|
||||
# with the specified topics and a block range.
|
||||
# If the block range is not specified, it defaults
|
||||
# to fromBlock: "latest", toBlock: "latest".
|
||||
# Then, if we make a getLogs call within the same block that the tx
|
||||
# happened, we will get a log in the result. However, if we make the call
|
||||
# one or more blocks later, the result will be an empty array.
|
||||
logs = w3.eth.get_logs({"topics": [topic.hex()]})
|
||||
|
||||
assert len(logs) == 1
|
||||
assert logs[0]["address"] == contract.address
|
||||
|
||||
w3_wait_for_new_blocks(w3, 2)
|
||||
logs = w3.eth.get_logs({"topics": [topic.hex()]})
|
||||
assert len(logs) == 0
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def custom_ethermint(tmp_path_factory):
|
||||
path = tmp_path_factory.mktemp("filters")
|
||||
yield from setup_ethermint(path, 26200, long_timeout_commit=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def ethermint_indexer(tmp_path_factory):
|
||||
path = tmp_path_factory.mktemp("indexer")
|
||||
yield from setup_custom_ethermint(
|
||||
path, 26660, Path(__file__).parent / "configs/enable-indexer.jsonnet"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
scope="module", params=["ethermint", "geth", "ethermint-ws", "enable-indexer"]
|
||||
)
|
||||
def cluster(request, custom_ethermint, ethermint_indexer, geth):
|
||||
"""
|
||||
run on both ethermint and geth
|
||||
"""
|
||||
provider = request.param
|
||||
if provider == "ethermint":
|
||||
yield custom_ethermint
|
||||
elif provider == "geth":
|
||||
yield geth
|
||||
elif provider == "ethermint-ws":
|
||||
ethermint_ws = custom_ethermint.copy()
|
||||
ethermint_ws.use_websocket()
|
||||
yield ethermint_ws
|
||||
elif provider == "enable-indexer":
|
||||
yield ethermint_indexer
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def test_basic(cluster):
|
||||
w3 = cluster.w3
|
||||
assert w3.eth.chain_id == 9000
|
||||
|
||||
|
||||
# Smart contract names
|
||||
GREETER_CONTRACT = "Greeter"
|
||||
ERC20_CONTRACT = "TestERC20A"
|
||||
|
||||
# ChangeGreeting topic from Greeter contract calculated from event signature
|
||||
CHANGE_GREETING_TOPIC = Web3.keccak(text="ChangeGreeting(address,string)")
|
||||
# ERC-20 Transfer event topic
|
||||
TRANSFER_TOPIC = Web3.keccak(text="Transfer(address,address,uint256)")
|
||||
|
||||
|
||||
def test_get_logs_by_topic(cluster):
|
||||
w3: Web3 = cluster.w3
|
||||
|
||||
@@ -58,6 +141,7 @@ def test_pending_transaction_filter(cluster):
|
||||
# without tx
|
||||
assert flt.get_new_entries() == [] # GetFilterChanges
|
||||
|
||||
w3_wait_for_new_blocks(w3, 1, sleep=0.1)
|
||||
# with tx
|
||||
txhash = send_successful_transaction(w3)
|
||||
assert txhash in flt.get_new_entries()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import base64
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -13,6 +14,7 @@ from .utils import (
|
||||
decode_bech32,
|
||||
deploy_contract,
|
||||
supervisorctl,
|
||||
wait_for_block,
|
||||
wait_for_port,
|
||||
)
|
||||
|
||||
@@ -45,9 +47,6 @@ def grpc_eth_call(port: int, args: dict, chain_id=None, proposer_address=None):
|
||||
).json()
|
||||
|
||||
|
||||
@pytest.mark.skip(
|
||||
reason="undeterministic test - https://github.com/evmos/ethermint/issues/1530"
|
||||
)
|
||||
def test_grpc_mode(custom_ethermint):
|
||||
"""
|
||||
- restart a fullnode in grpc-only mode
|
||||
@@ -61,33 +60,43 @@ def test_grpc_mode(custom_ethermint):
|
||||
"to": contract.address,
|
||||
"data": contract.encodeABI(fn_name="currentChainID"),
|
||||
}
|
||||
api_port = ports.api_port(custom_ethermint.base_port(2))
|
||||
api_port = ports.api_port(custom_ethermint.base_port(1))
|
||||
# in normal mode, grpc query works even if we don't pass chain_id explicitly
|
||||
rsp = grpc_eth_call(api_port, msg)
|
||||
print(rsp)
|
||||
assert "code" not in rsp, str(rsp)
|
||||
assert 9000 == int.from_bytes(base64.b64decode(rsp["ret"].encode()), "big")
|
||||
|
||||
success = False
|
||||
max_retry = 3
|
||||
sleep = 1
|
||||
for i in range(max_retry):
|
||||
rsp = grpc_eth_call(api_port, msg)
|
||||
ret = rsp["ret"]
|
||||
valid = ret is not None
|
||||
if valid and 9000 == int.from_bytes(base64.b64decode(ret.encode()), "big"):
|
||||
success = True
|
||||
break
|
||||
time.sleep(sleep)
|
||||
assert success
|
||||
# wait 1 more block for both nodes to avoid node stopped before tnx get included
|
||||
for i in range(2):
|
||||
wait_for_block(custom_ethermint.cosmos_cli(i), 1)
|
||||
supervisorctl(
|
||||
custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node2"
|
||||
custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node1"
|
||||
)
|
||||
|
||||
# run grpc-only mode directly with existing chain state
|
||||
with (custom_ethermint.base_dir / "node2.log").open("w") as logfile:
|
||||
with (custom_ethermint.base_dir / "node1.log").open("a") as logfile:
|
||||
proc = subprocess.Popen(
|
||||
[
|
||||
"ethermintd",
|
||||
"start",
|
||||
"--grpc-only",
|
||||
"--home",
|
||||
custom_ethermint.base_dir / "node2",
|
||||
custom_ethermint.base_dir / "node1",
|
||||
],
|
||||
stdout=logfile,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
try:
|
||||
# wait for grpc and rest api ports
|
||||
grpc_port = ports.grpc_port(custom_ethermint.base_port(2))
|
||||
grpc_port = ports.grpc_port(custom_ethermint.base_port(1))
|
||||
wait_for_port(grpc_port)
|
||||
wait_for_port(api_port)
|
||||
|
||||
@@ -102,9 +111,8 @@ def test_grpc_mode(custom_ethermint):
|
||||
assert "validator does not exist" in rsp["message"]
|
||||
|
||||
# pass the first validator's consensus address to grpc query
|
||||
cons_addr = decode_bech32(
|
||||
custom_ethermint.cosmos_cli(0).consensus_address()
|
||||
)
|
||||
addr = custom_ethermint.cosmos_cli(0).consensus_address()
|
||||
cons_addr = decode_bech32(addr)
|
||||
|
||||
# should work with both chain_id and proposer_address set
|
||||
rsp = grpc_eth_call(
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
import sys
|
||||
|
||||
from .network import Ethermint
|
||||
import pytest
|
||||
|
||||
from .network import setup_ethermint
|
||||
from .utils import ADDRS, KEYS, eth_to_bech32, sign_transaction, wait_for_new_blocks
|
||||
|
||||
PRIORITY_REDUCTION = 1000000
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def custom_ethermint(tmp_path_factory):
|
||||
path = tmp_path_factory.mktemp("priority")
|
||||
yield from setup_ethermint(path, 26800, long_timeout_commit=True)
|
||||
|
||||
|
||||
def effective_gas_price(tx, base_fee):
|
||||
if "maxFeePerGas" in tx:
|
||||
# dynamic fee tx
|
||||
@@ -27,7 +35,7 @@ def tx_priority(tx, base_fee):
|
||||
return (tx["gasPrice"] - base_fee) // PRIORITY_REDUCTION
|
||||
|
||||
|
||||
def test_priority(ethermint: Ethermint):
|
||||
def test_priority(ethermint):
|
||||
"""
|
||||
test priorities of different tx types
|
||||
|
||||
@@ -112,7 +120,7 @@ def test_priority(ethermint: Ethermint):
|
||||
assert all(i1 > i2 for i1, i2 in zip(tx_indexes, tx_indexes[1:]))
|
||||
|
||||
|
||||
def test_native_tx_priority(ethermint: Ethermint):
|
||||
def test_native_tx_priority(ethermint):
|
||||
cli = ethermint.cosmos_cli()
|
||||
base_fee = cli.query_base_fee()
|
||||
print("base_fee", base_fee)
|
||||
|
||||
@@ -103,7 +103,7 @@ def test_pruned_node(pruned):
|
||||
exp_tx = AttributeDict(
|
||||
{
|
||||
"from": "0x57f96e6B86CdeFdB3d412547816a82E3E0EbF9D2",
|
||||
"gas": 51542,
|
||||
"gas": 51406,
|
||||
"input": (
|
||||
"0xa9059cbb000000000000000000000000378c50d9264c63f3f92b806d4ee56e"
|
||||
"9d86ffb3ec000000000000000000000000000000000000000000000000000000"
|
||||
|
||||
@@ -10,7 +10,7 @@ from .network import setup_custom_ethermint
|
||||
from .utils import supervisorctl, wait_for_block, wait_for_port
|
||||
|
||||
|
||||
def update_node2_cmd(path, cmd, i):
|
||||
def update_node_cmd(path, cmd, i):
|
||||
ini_path = path / SUPERVISOR_CONFIG_FILE
|
||||
ini = configparser.RawConfigParser()
|
||||
ini.read(ini_path)
|
||||
@@ -29,7 +29,7 @@ def update_node2_cmd(path, cmd, i):
|
||||
def post_init(broken_binary):
|
||||
def inner(path, base_port, config):
|
||||
chain_id = "ethermint_9000-1"
|
||||
update_node2_cmd(path / chain_id, broken_binary, 2)
|
||||
update_node_cmd(path / chain_id, broken_binary, 1)
|
||||
|
||||
return inner
|
||||
|
||||
@@ -66,33 +66,33 @@ def test_rollback(custom_ethermint):
|
||||
- use rollback command to rollback the db.
|
||||
- switch to correct binary should make the node syncing again.
|
||||
"""
|
||||
wait_for_port(ports.rpc_port(custom_ethermint.base_port(2)))
|
||||
target_port = ports.rpc_port(custom_ethermint.base_port(1))
|
||||
wait_for_port(target_port)
|
||||
|
||||
print("wait for node2 to sync the first 10 blocks")
|
||||
cli2 = custom_ethermint.cosmos_cli(2)
|
||||
wait_for_block(cli2, 10)
|
||||
print("wait for node1 to sync the first 10 blocks")
|
||||
cli1 = custom_ethermint.cosmos_cli(1)
|
||||
wait_for_block(cli1, 10)
|
||||
|
||||
print("wait for a few more blocks on the healthy nodes")
|
||||
cli = custom_ethermint.cosmos_cli(0)
|
||||
wait_for_block(cli, 13)
|
||||
cli0 = custom_ethermint.cosmos_cli(0)
|
||||
wait_for_block(cli0, 13)
|
||||
|
||||
# (app hash mismatch happens after the 10th block, detected in the 11th block)
|
||||
print("check node2 get stuck at block 10")
|
||||
assert cli2.block_height() == 10
|
||||
print("check node1 get stuck at block 10")
|
||||
assert cli1.block_height() == 10
|
||||
|
||||
print("stop node2")
|
||||
print("stop node1")
|
||||
supervisorctl(
|
||||
custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node2"
|
||||
custom_ethermint.base_dir / "../tasks.ini", "stop", "ethermint_9000-1-node1"
|
||||
)
|
||||
|
||||
print("do rollback on node2")
|
||||
cli2.rollback()
|
||||
print("do rollback on node1")
|
||||
cli1.rollback()
|
||||
|
||||
print("switch to normal binary")
|
||||
update_node2_cmd(custom_ethermint.base_dir, "ethermintd", 2)
|
||||
update_node_cmd(custom_ethermint.base_dir, "ethermintd", 1)
|
||||
supervisorctl(custom_ethermint.base_dir / "../tasks.ini", "update")
|
||||
wait_for_port(ports.rpc_port(custom_ethermint.base_port(2)))
|
||||
wait_for_port(target_port)
|
||||
|
||||
print("check node2 sync again")
|
||||
cli2 = custom_ethermint.cosmos_cli(2)
|
||||
wait_for_block(cli2, 15)
|
||||
print("check node1 sync again")
|
||||
wait_for_block(cli1, 15)
|
||||
|
||||
@@ -92,9 +92,12 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint):
|
||||
- check that queries on legacy blocks still works after upgrade.
|
||||
"""
|
||||
cli = custom_ethermint.cosmos_cli()
|
||||
<<<<<<< HEAD
|
||||
height = cli.block_height()
|
||||
target_height = height + 10
|
||||
print("upgrade height", target_height)
|
||||
=======
|
||||
>>>>>>> v0.21.0
|
||||
|
||||
w3 = custom_ethermint.w3
|
||||
contract, _ = deploy_contract(w3, CONTRACTS["TestERC20A"])
|
||||
@@ -104,6 +107,9 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint):
|
||||
old_erc20_balance = contract.caller.balanceOf(ADDRS["validator"])
|
||||
print("old values", old_height, old_balance, old_base_fee)
|
||||
|
||||
target_height = w3.eth.block_number + 10
|
||||
print("upgrade height", target_height)
|
||||
|
||||
plan_name = "integration-test-upgrade"
|
||||
rsp = cli.gov_propose(
|
||||
"community",
|
||||
@@ -120,7 +126,6 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint):
|
||||
|
||||
# get proposal_id
|
||||
ev = parse_events(rsp["logs"])["submit_proposal"]
|
||||
assert ev["proposal_type"] == "SoftwareUpgrade", rsp
|
||||
proposal_id = ev["proposal_id"]
|
||||
|
||||
rsp = cli.gov_vote("validator", proposal_id, "yes")
|
||||
|
||||
@@ -74,13 +74,12 @@ def w3_wait_for_new_blocks(w3, n, sleep=0.5):
|
||||
break
|
||||
|
||||
|
||||
def wait_for_new_blocks(cli, n):
|
||||
begin_height = int((cli.status())["SyncInfo"]["latest_block_height"])
|
||||
while True:
|
||||
time.sleep(0.5)
|
||||
def wait_for_new_blocks(cli, n, sleep=0.5):
|
||||
cur_height = begin_height = int((cli.status())["SyncInfo"]["latest_block_height"])
|
||||
while cur_height - begin_height < n:
|
||||
time.sleep(sleep)
|
||||
cur_height = int((cli.status())["SyncInfo"]["latest_block_height"])
|
||||
if cur_height - begin_height >= n:
|
||||
break
|
||||
return cur_height
|
||||
|
||||
|
||||
def wait_for_block(cli, height, timeout=240):
|
||||
|
||||
@@ -592,8 +592,8 @@ func TestEth_FeeHistory(t *testing.T) {
|
||||
baseFeePerGas := info["baseFeePerGas"].([]interface{})
|
||||
gasUsedRatio := info["gasUsedRatio"].([]interface{})
|
||||
|
||||
require.Equal(t, info["oldestBlock"].(string), "0x6")
|
||||
require.Equal(t, info["oldestBlock"].(string), "0x7")
|
||||
require.Equal(t, 4, len(gasUsedRatio))
|
||||
require.Equal(t, 4, len(baseFeePerGas))
|
||||
require.Equal(t, 5, len(baseFeePerGas))
|
||||
require.Equal(t, 4, len(reward))
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package rpc
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package tests
|
||||
|
||||
import (
|
||||
|
||||
@@ -38,8 +38,20 @@ laconicd init $MONIKER --chain-id $CHAINID
|
||||
# Set gas limit in genesis
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
|
||||
# Reduce the block time to 1s
|
||||
sed -i -e '/^timeout_commit =/ s/= .*/= "850ms"/' $HOME/.laconicd/config/config.toml
|
||||
# modified default configs
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/prometheus-retention-time = 0/prometheus-retention-time = 1000000000000/g' $HOME/.laconicd/config/app.toml
|
||||
sed -i '' 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
|
||||
sed -i '' 's/prometheus = false/prometheus = true/' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $HOME/.laconicd/config/config.toml
|
||||
else
|
||||
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/prometheus-retention-time = "0"/prometheus-retention-time = "1000000000000"/g' $HOME/.laconicd/config/app.toml
|
||||
sed -i 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
|
||||
sed -i 's/prometheus = false/prometheus = true/' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $HOME/.laconicd/config/config.toml
|
||||
fi
|
||||
|
||||
# Allocate genesis accounts (cosmos formatted addresses)
|
||||
laconicd add-genesis-account "$(laconicd keys show $VAL_KEY -a --keyring-backend test)" 1000000000000000000000aphoton,1000000000000000000stake --keyring-backend test
|
||||
|
||||
@@ -6996,9 +6996,9 @@ for-in@^1.0.2:
|
||||
integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=
|
||||
|
||||
foreach@^2.0.4, foreach@^2.0.5:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
|
||||
integrity sha1-C+4AUBiusmDQo6865ljdATbsG5k=
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.6.tgz#87bcc8a1a0e74000ff2bf9802110708cfb02eb6e"
|
||||
integrity sha512-k6GAGDyqLe9JaebCsFCoudPPWfihKu8pylYXRlqP1J7ms39iPoTtk2fviNglIeQEwdh0bQeKJ01ZPyuyQvKzwg==
|
||||
|
||||
forever-agent@~0.6.1:
|
||||
version "0.6.1"
|
||||
@@ -8709,14 +8709,7 @@ json-loader@^0.5.4:
|
||||
resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.7.tgz#dca14a70235ff82f0ac9a3abeb60d337a365185d"
|
||||
integrity sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==
|
||||
|
||||
json-pointer@^0.6.0:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/json-pointer/-/json-pointer-0.6.1.tgz#3c6caa6ac139e2599f5a1659d39852154015054d"
|
||||
integrity sha512-3OvjqKdCBvH41DLpV4iSt6v2XhZXV1bPB4OROuknvUXI7ZQNofieCPkmE26stEJ9zdQuvIxDHCuYhfgxFAAs+Q==
|
||||
dependencies:
|
||||
foreach "^2.0.4"
|
||||
|
||||
json-pointer@^0.6.1:
|
||||
json-pointer@^0.6.0, json-pointer@^0.6.1:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/json-pointer/-/json-pointer-0.6.2.tgz#f97bd7550be5e9ea901f8c9264c9d436a22a93cd"
|
||||
integrity sha512-vLWcKbOaXlO+jvRy4qNd+TI1QUPZzfJj1tpJ3vAXDych5XJf93ftpUKe5pKCrzyIIwgBJcOcCVRUfqQP25afBw==
|
||||
|
||||
Reference in New Issue
Block a user