Skip to content

Commit 472446b

Browse files
fix: improve leaf index validation
1 parent 1f1249a commit 472446b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

cartesi-rollups/contracts/src/Merkle.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ library Merkle {
142142
/// @dev See `MerkleConstants` for leaf size.
143143
function getHashOfLeafAtIndex(bytes calldata data, uint256 leafIndex) internal pure returns (bytes32) {
144144
uint256 start = leafIndex << MerkleConstants.LOG2_LEAF_SIZE;
145-
if (start < data.length) {
145+
if (start < data.length && (start >> MerkleConstants.LOG2_LEAF_SIZE) == leafIndex) {
146146
/// forge-lint: disable-next-line(asm-keccak256)
147147
return keccak256(abi.encode(bytes32(data[start:])));
148148
} else {

test/Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN <<EOF
88
set -eu
99
apt-get update && apt-get install -y --no-install-recommends curl ca-certificates git
1010
curl -L https://foundry.paradigm.xyz | bash
11-
~/.foundry/bin/foundryup --install stable
11+
~/.foundry/bin/foundryup --install v1.5.0
1212
install -Dm755 ~/.foundry/bin/* /usr/local/bin/
1313
EOF
1414
# cargo binstall (to install just)
@@ -34,6 +34,11 @@ RUN \
3434
xxd jq sqlite3; \
3535
rm -rf /var/cache/apt;
3636

37+
# install pnpm
38+
RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -
39+
ENV PNPM_HOME="/root/.local/share/pnpm"
40+
ENV PATH="$PNPM_HOME:$PATH"
41+
3742
# install foundry
3843
COPY --from=tools /usr/local/bin/forge /usr/local/bin/
3944
COPY --from=tools /usr/local/bin/cast /usr/local/bin/
@@ -81,7 +86,9 @@ RUN \
8186
--mount=type=cache,target=cartesi-rollups/contracts/cache,sharing=locked \
8287
--mount=type=cache,target=prt/contracts/out,sharing=locked \
8388
--mount=type=cache,target=prt/contracts/cache,sharing=locked \
84-
just -f test/programs/justfile build-programs
89+
just -f test/programs/justfile build-programs && \
90+
just -f test/programs/justfile build-honeypot-snapshot && \
91+
just -f cartesi-rollups/contracts/justfile build-devnet
8592

8693
# copy everything else
8794
COPY \
@@ -105,5 +112,4 @@ RUN \
105112
just build-rust-workspace; \
106113
cp target/debug/cartesi-rollups-prt-node .
107114

108-
# because of `--mount`, we need to do this.
109-
RUN mkdir -p target/debug && mv cartesi-rollups-prt-node target/debug/
115+
RUN mkdir -p target/debug && mv cartesi-rollups-prt-node target/debug/

0 commit comments

Comments
 (0)