Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "vendor/ctez"]
path = vendor/ctez
url = https://github.com/tezos-checker/ctez
branch = next_next
url = https://github.com/emturner/ctez
branch = next_next_checker_ref
[submodule "vendor/ligo"]
path = vendor/ligo
url = https://gitlab.com/ligolang/ligo.git
25 changes: 16 additions & 9 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -428,19 +428,21 @@ ligo:
# which does not exist in the git repo. This makes it nearly impossible to
# integrate with the earthly build here. Running the build scripts ourselves
# instead...
# Mostly copy-pasted from https://gitlab.com/ligolang/ligo/-/blob/0.34.0/Dockerfile
# Mostly copy-pasted from https://gitlab.com/ligolang/ligo/-/blob/0.43.0/Dockerfile
FROM alpine:3.12

RUN apk update && apk upgrade && apk --no-cache add \
build-base snappy-dev alpine-sdk wget \
build-base snappy-dev alpine-sdk \
bash ncurses-dev xz m4 git pkgconfig findutils rsync \
gmp-dev libev-dev libressl-dev linux-headers pcre-dev perl zlib-dev hidapi-dev \
libffi-dev \
cargo
cargo py3-pip
RUN pip3 install jsonschema

WORKDIR /ligo

RUN wget -O /usr/local/bin/opam https://github.com/ocaml/opam/releases/download/2.1.0/opam-2.1.0-x86_64-linux
RUN wget -O /usr/local/bin/opam \
https://github.com/ocaml/opam/releases/download/2.1.0/opam-2.1.0-x86_64-linux
RUN chmod u+x /usr/local/bin/opam
RUN opam init --disable-sandboxing --bare

Expand All @@ -462,7 +464,6 @@ ligo:
COPY /vendor/ligo/src /ligo/src
COPY /vendor/ligo/dune /ligo
COPY /vendor/ligo/dune-project /ligo/dune-project
# COPY /vendor/ligo/scripts/version.sh /ligo/scripts/version.sh
RUN LIGO_VERSION=checker opam exec -- dune build -p ligo --profile static

RUN cp /ligo/_build/install/default/bin/ligo /root/ligo
Expand Down Expand Up @@ -498,19 +499,25 @@ flextesa:

# Checkout flextesa
WORKDIR /root
ARG FLEXTESA_REV = "0d2c0c95e1d745416b191b399b760c98b440e0fd"
ARG FLEXTESA_REV = "0acbeec5e25491231f4976085c5b5f488bfda96f"
RUN git clone https://gitlab.com/tezos/flextesa.git && cd ./flextesa && git checkout "$FLEXTESA_REV"
WORKDIR /root/flextesa

# Create opam switch and install flextesa deps
ARG OCAML_VERSION = "4.13.1"
ENV OPAM_SWITCH="flextesa"
RUN opam init --disable-sandboxing --bare
RUN opam switch create "$OPAM_SWITCH" "$OCAML_VERSION"
RUN opam update --all
RUN opam switch create --deps-only "$OPAM_SWITCH" "$OCAML_VERSION"
RUN opam pin add -y tezai-base58-digest \
https://gitlab.com/oxheadalpha/tezai-base58-digest.git
RUN opam install -y --deps-only \
./tezai-base58-digest.opam ./tezai-tz1-crypto.opam \
./tezai-tz1-crypto.opam \
./flextesa.opam ./flextesa-cli.opam

# 1.0.2 release breaks flextesa build
RUN opam pin -y add dum 1.0.1

# Build flextesa
RUN eval $(opam env) && \
# Note: setting profile to `dune` to disable deprecation alerts as errors
Expand All @@ -521,7 +528,7 @@ flextesa:

# Fetch the tezos exes which are required by flextesa at runtime
ARG TARGETARCH
ARG OCTEZ_VERSION = "11.1.0"
ARG OCTEZ_VERSION = "12.4.0"
IF [ "$TARGETARCH" = "amd64" ]
ARG ARCH_PREFIX = "x86_64"
ELSE
Expand Down
39 changes: 9 additions & 30 deletions checker_tools/client/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from checker_tools.client.operations import inject

# Time between blocks for sandbox container
SANDBOX_TIME_BETWEEN_BLOCKS = "1,1"
SANDBOX_MINIMAL_BLOCK_DELAY = "1"
# Number of retries to use when awaiting new blocks
WAIT_OP_ATTEMPTS = 10
# Interval between retries when awaiting new blocks
Expand Down Expand Up @@ -233,59 +233,38 @@ def start_sandbox(name: str, port: int, wait_for_level=0):
print("Sandbox started!")
return client, teardownFun


# FIXME: Deprecated
def start_docker_sandbox(name: str, port: int):
docker_client = docker.from_env()
docker_container = docker_client.containers.run(
"tqtezos/flextesa:20210514",
command=["granabox", "start"],
environment={"block_time": SANDBOX_TIME_BETWEEN_BLOCKS},
ports={"20000/tcp": port},
name=name,
detach=True,
remove=True,
)

def teardownFun():
docker_container.kill()
docker_client.close()

return teardownFun


def start_local_sandbox(name: str, port: int):
# FIXME: Port selection for flextesa seems to be a bit flaky if port !=20_000.
alice_key = subprocess.check_output(["flextesa", "key-of-name", "alice"]).decode("utf-8")
bob_key = subprocess.check_output(["flextesa", "key-of-name", "bob"]).decode("utf-8")
alice_key = subprocess.check_output(["flextesa", "key", "alice"]).decode("utf-8")
bob_key = subprocess.check_output(["flextesa", "key", "bob"]).decode("utf-8")

tmpdir = tempfile.mkdtemp(prefix=name)

# below command is mainly from the 'granabox' script from flextesa docker
# below command is mainly from the 'tutorial-box' script from flextesa docker
# container.
args = [
"flextesa",
"mini-network",
"mini-net",
f"--root={tmpdir}",
f"--base-port={port}",
"--size=1",
"--set-history-mode=N000:archive",
f"--time-between-blocks=1,{SANDBOX_TIME_BETWEEN_BLOCKS}",
f"--time-b={SANDBOX_MINIMAL_BLOCK_DELAY}",
f"--add-bootstrap-account={alice_key}@2_000_000_000_000",
f"--add-bootstrap-account={bob_key}@2_000_000_000_000",
"--no-daemons-for=alice",
"--no-daemons-for=bob",
"--until-level=200_000_000",
"--protocol-hash=PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx",
"--protocol-kind=Hangzhou",
"--protocol-kind=Ithaca",
]

handle = subprocess.Popen(args)
handle = subprocess.Popen(args)#, stdin=subprocess.PIPE, text=True)

def teardownFun():
# send a keyboard interrupt and wait
print("Stopping sandbox process")
handle.send_signal(signal.SIGINT)
#handle.communicate(input="quit")
timeout = 20
print(f"Waiting up to {timeout}s for sandbox process to exit...")
handle.wait(timeout=20)
Expand Down
28 changes: 19 additions & 9 deletions checker_tools/client/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def await_operations(
)
# Note: This is only a *minimum* bound.
block_expected_starting_at = current_block_timestamp.timestamp() + int(
tz.shell.blocks[current_level].context.constants()["time_between_blocks"][0]
tz.shell.blocks[current_level].context.constants()["minimal_block_delay"][0]
)
sleep_for = max(1, block_expected_starting_at - datetime.utcnow().timestamp())
if sleep_for > MAX_BLOCK_TIME:
Expand Down Expand Up @@ -145,22 +145,32 @@ def inject(
Returns:
The confirmed operation group's metadata
"""
level = tz.shell.head.header()["level"]
op_hash = op_group.inject(min_confirmations=0)["hash"]
for attempt in range(1, N_ALLOWED_REORGS + 1):
reorg_attempt = 1
rpc_attempt = 1
while reorg_attempt <= N_ALLOWED_REORGS + 1 and rpc_attempt < 20:
try:
level = tz.shell.head.header()["level"]
op_hash = op_group.inject()["hash"]
all_confirmed, op_levels = await_operations(
tz,
[op_hash],
level,
max_blocks=max_wait_blocks,
min_confirmations=min_confirmations,
)
break
if not all_confirmed:
raise Exception(f"Operation {op_hash} was not confirmed.")
return _get_op_data(tz, op_hash, op_levels[op_hash])
except RpcError as e:
if rpc_attempt >= 20:
raise e
time.sleep(2)
rpc_attempt += 1
continue
except BlockchainReorg as e:
if attempt >= N_ALLOWED_REORGS:
if reorg_attempt >= N_ALLOWED_REORGS:
raise e
time.sleep(1)
if not all_confirmed:
raise Exception(f"Operation {op_hash} was not confirmed.")
return _get_op_data(tz, op_hash, op_levels[op_hash])
reorg_attempt += 1
rpc_attempt = 1
continue
Loading