Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor rollup-http-server based on libcmt #37

Closed
wants to merge 4 commits into from
Closed
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: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,7 @@ jobs:

- name: Test rollup-http-server and echo-dapp client
run: |
mkdir -p /opt/mock
make -C sys-utils/libcmt/ -j$(nproc) install-mock PREFIX=/opt/mock
cd rollup-http/rollup-http-server
USE_ROLLUP_BINDINGS_MOCK=1 cargo test -- --show-output --test-threads=1
CPATH="/opt/mock/include:$CPATH" RUSTFLAGS="-L /opt/mock/lib" cargo test -- --show-output --test-threads=1
100 changes: 52 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ apt-get install -y --no-install-recommends \
wget \
pkg-config \
dpkg-cross \
libclang-dev \
gcc-12-riscv64-linux-gnu \
g++-12-riscv64-linux-gnu

Expand All @@ -46,6 +47,8 @@ for tool in cpp g++ gcc gcc-ar gcc-nm gcc-ranlib gcov gcov-dump gcov-tool; do
update-alternatives --install /usr/bin/$tool $tool /usr/bin/$tool-12 12
done

ln -s gcc /usr/bin/cc

wget -O ${LINUX_HEADERS_FILEPATH} ${LINUX_HEADERS_URLPATH}
echo "7d0238324661a3850fe2e07e5c4485a94da5d5162dbb67def0f1541ed1dc3b45 ${LINUX_HEADERS_FILEPATH}" | sha256sum --check
apt-get install -y --no-install-recommends ${LINUX_HEADERS_FILEPATH}
Expand Down Expand Up @@ -76,58 +79,59 @@ RUN make -C ${BUILD_BASE}/tools/sys-utils/libcmt/ -j$(nproc) install install-moc
PREFIX=/usr/x86_64-linux-gnu TARGET_PREFIX=/usr/riscv64-linux-gnu
USER developer
RUN make -C ${BUILD_BASE}/tools/sys-utils/ -j$(nproc) all
ENV CPATH="/usr/riscv64-linux-gnu/include/:${CPATH}"

# build rust tools
# ------------------------------------------------------------------------------
FROM tools-env as rust-env
FROM c-builder as rust-env
ENV PATH="/home/developer/.cargo/bin:${PATH}"

USER developer

#RUN cd && \
# wget https://github.com/rust-lang/rustup/archive/refs/tags/1.26.0.tar.gz && \
# echo "6f20ff98f2f1dbde6886f8d133fe0d7aed24bc76c670ea1fca18eb33baadd808 1.26.0.tar.gz" | sha256sum --check && \
# tar -xzf 1.26.0.tar.gz && \
# bash rustup-1.26.0/rustup-init.sh \
# -y \
# --default-toolchain 1.74.0 \
# --profile minimal \
# --target riscv64gc-unknown-linux-gnu && \
# rm -rf rustup-1.26.0 1.26.0.tar.gz
#
#FROM rust-env as rust-builder
#COPY --chown=developer:developer rollup-http/rollup-init ${BUILD_BASE}/tools/rollup-http/rollup-init
#COPY --chown=developer:developer rollup-http/rollup-http-client ${BUILD_BASE}/tools/rollup-http/rollup-http-client
#COPY --chown=developer:developer rollup-http/.cargo ${BUILD_BASE}/tools/rollup-http/.cargo
#
## build rollup-http-server dependencies
#FROM rust-builder as http-server-dep-builder
#COPY --chown=developer:developer rollup-http/rollup-http-server/Cargo.toml rollup-http/rollup-http-server/Cargo.lock ${BUILD_BASE}/tools/rollup-http/rollup-http-server/
#RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && \
# mkdir src/ && \
# echo "fn main() {}" > src/main.rs && \
# echo "pub fn dummy() {}" > src/lib.rs && \
# cargo build --target riscv64gc-unknown-linux-gnu --release
#
## build rollup-http-server
#FROM http-server-dep-builder as http-server-builder
#COPY --chown=developer:developer rollup-http/rollup-http-server/build.rs ${BUILD_BASE}/tools/rollup-http/rollup-http-server/
#COPY --chown=developer:developer rollup-http/rollup-http-server/src ${BUILD_BASE}/tools/rollup-http/rollup-http-server/src
#RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && touch build.rs src/* && \
# cargo build --target riscv64gc-unknown-linux-gnu --release
#
## build echo-dapp dependencies
#FROM rust-builder as echo-dapp-dep-builder
#COPY --chown=developer:developer rollup-http/echo-dapp/Cargo.toml rollup-http/echo-dapp/Cargo.lock ${BUILD_BASE}/tools/rollup-http/echo-dapp/
#RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && \
# mkdir src/ && echo "fn main() {}" > src/main.rs && \
# cargo build --target riscv64gc-unknown-linux-gnu --release
#
## build echo-dapp
#FROM echo-dapp-dep-builder as echo-dapp-builder
#COPY --chown=developer:developer rollup-http/echo-dapp/src ${BUILD_BASE}/tools/rollup-http/echo-dapp/src
#RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && touch src/* && \
# cargo build --target riscv64gc-unknown-linux-gnu --release
RUN cd && \
wget https://github.com/rust-lang/rustup/archive/refs/tags/1.26.0.tar.gz && \
echo "6f20ff98f2f1dbde6886f8d133fe0d7aed24bc76c670ea1fca18eb33baadd808 1.26.0.tar.gz" | sha256sum --check && \
tar -xzf 1.26.0.tar.gz && \
bash rustup-1.26.0/rustup-init.sh \
-y \
--default-toolchain 1.74.0 \
--profile minimal \
--target riscv64gc-unknown-linux-gnu && \
rm -rf rustup-1.26.0 1.26.0.tar.gz

FROM rust-env as rust-builder
COPY --chown=developer:developer rollup-http/rollup-init ${BUILD_BASE}/tools/rollup-http/rollup-init
COPY --chown=developer:developer rollup-http/rollup-http-client ${BUILD_BASE}/tools/rollup-http/rollup-http-client
COPY --chown=developer:developer rollup-http/.cargo ${BUILD_BASE}/tools/rollup-http/.cargo

# build rollup-http-server dependencies
FROM rust-builder as http-server-dep-builder
COPY --chown=developer:developer rollup-http/rollup-http-server/Cargo.toml rollup-http/rollup-http-server/Cargo.lock ${BUILD_BASE}/tools/rollup-http/rollup-http-server/
RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && \
mkdir src/ && \
echo "fn main() {}" > src/main.rs && \
echo "pub fn dummy() {}" > src/lib.rs && \
cargo build --target riscv64gc-unknown-linux-gnu --release

# build rollup-http-server
FROM http-server-dep-builder as http-server-builder
COPY --chown=developer:developer rollup-http/rollup-http-server/build.rs ${BUILD_BASE}/tools/rollup-http/rollup-http-server/
COPY --chown=developer:developer rollup-http/rollup-http-server/src ${BUILD_BASE}/tools/rollup-http/rollup-http-server/src
RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && touch build.rs src/* && \
cargo build --target riscv64gc-unknown-linux-gnu --release

# build echo-dapp dependencies
FROM rust-builder as echo-dapp-dep-builder
COPY --chown=developer:developer rollup-http/echo-dapp/Cargo.toml rollup-http/echo-dapp/Cargo.lock ${BUILD_BASE}/tools/rollup-http/echo-dapp/
RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && \
mkdir src/ && echo "fn main() {}" > src/main.rs && \
cargo build --target riscv64gc-unknown-linux-gnu --release

# build echo-dapp
FROM echo-dapp-dep-builder as echo-dapp-builder
COPY --chown=developer:developer rollup-http/echo-dapp/src ${BUILD_BASE}/tools/rollup-http/echo-dapp/src
RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && touch src/* && \
cargo build --target riscv64gc-unknown-linux-gnu --release

# pack tools (deb)
# ------------------------------------------------------------------------------
Expand All @@ -151,8 +155,8 @@ COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/rollup/rollup ${STAGING_SBIN
COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/ioctl-echo-loop/ioctl-echo-loop ${STAGING_BIN}
COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/yield/yield ${STAGING_SBIN}
COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/misc/* ${STAGING_BIN}
#COPY --from=rust-builder ${BUILD_BASE}/tools/rollup-http/rollup-init/rollup-init ${STAGING_SBIN}
#COPY --from=http-server-builder ${BUILD_BASE}/tools/rollup-http/rollup-http-server/target/riscv64gc-unknown-linux-gnu/release/rollup-http-server ${STAGING_BIN}
#COPY --from=echo-dapp-builder ${BUILD_BASE}/tools/rollup-http/echo-dapp/target/riscv64gc-unknown-linux-gnu/release/echo-dapp ${STAGING_BIN}
COPY --from=rust-builder ${BUILD_BASE}/tools/rollup-http/rollup-init/rollup-init ${STAGING_SBIN}
COPY --from=http-server-builder ${BUILD_BASE}/tools/rollup-http/rollup-http-server/target/riscv64gc-unknown-linux-gnu/release/rollup-http-server ${STAGING_BIN}
COPY --from=echo-dapp-builder ${BUILD_BASE}/tools/rollup-http/echo-dapp/target/riscv64gc-unknown-linux-gnu/release/echo-dapp ${STAGING_BIN}

RUN dpkg-deb -Zxz --root-owner-group --build ${STAGING_BASE} ${BUILD_BASE}/${TOOLS_DEB}
2 changes: 1 addition & 1 deletion fs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RUN apt-get update && \
bash=5.1-6ubuntu1 \
psmisc=23.4-2build3 \
bc=1.07.1-3build1 \
curl=7.81.0-1ubuntu1.15 \
curl=7.81.0-1ubuntu1.16 \
device-tree-compiler=1.6.1-1 \
jq=1.6-2.1ubuntu3 \
lua5.4=5.4.4-1 \
Expand Down
1 change: 1 addition & 0 deletions rollup-http/echo-dapp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub async fn process_advance_request(
let voucher_payload = request.payload.clone();
let voucher = Voucher {
destination: request.metadata.msg_sender.clone(),
value: "0xdeadbeef".to_string(),
payload: voucher_payload,
};

Expand Down
4 changes: 2 additions & 2 deletions rollup-http/rollup-http-client/src/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct AdvanceMetadata {
pub msg_sender: String,
pub epoch_index: u64,
pub input_index: u64,
pub block_number: u64,
pub timestamp: u64,
pub block_timestamp: u64,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand All @@ -51,6 +50,7 @@ pub struct Notice {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Voucher {
pub destination: String,
pub value: String,
pub payload: String,
}

Expand Down
Loading
Loading