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

Added support for V5 Smart Contracts on Arbitrum, Base, Fantom, Optimism and Polygon zkEVM #29

Merged
merged 37 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d45cdc3
Merge pull request #15 from LedgerHQ/master
GuilaneDen Nov 16, 2024
a622c3d
ci(LDG-585): update code base and ethereum-plugin-sdk
GuilaneDen Nov 17, 2024
817ad20
test(LDG-585): update ethereum and polygon snapshots
GuilaneDen Nov 17, 2024
71814ff
ci(LDG-585): adding flex and stax to the build
GuilaneDen Nov 17, 2024
ead11c1
ci(LDG-585): removed flex and stax to the build, cause icons missing
GuilaneDen Nov 17, 2024
e45d558
ci(LDG-585): removed glyphs gif
GuilaneDen Nov 17, 2024
7751844
test(LDG-585): updated test snapshots
GuilaneDen Nov 17, 2024
be40b0e
Merge pull request #18 from blooo-io/ci/LDG-585-update-ci-and-code-base
GuilaneDen Nov 25, 2024
8ff4740
feat(LDG-499): added ABIs and b2c.json for arbitrum, base, fantom, op…
GuilaneDen Nov 25, 2024
24f9b9c
test(LDG-499): added test for arbitrum (Nano S, SP, X)
GuilaneDen Nov 25, 2024
dc4008e
test(LDG-499): added test for base (Nano S, SP, X)
GuilaneDen Nov 25, 2024
502063c
test(LDG-499): added test for optimism (Nano S, SP, X)
GuilaneDen Nov 25, 2024
05ab82a
test(LDG-499): added test for polygon zkevm (Nano S, SP, X)
GuilaneDen Nov 25, 2024
5ca1d9a
feat: added icons
GuilaneDen Nov 27, 2024
2293022
feat: added stax and flex to the build
GuilaneDen Nov 27, 2024
c8bcc3e
feat: updated ABIs and b2c.json
GuilaneDen Nov 27, 2024
813607c
test: added test for all networks (Flex, Stax)
GuilaneDen Nov 27, 2024
6e6c13f
bumped version
GuilaneDen Nov 27, 2024
7c25f29
doc: added smart contract address to README file
GuilaneDen Nov 27, 2024
36b20ca
test: uncommented some tests
GuilaneDen Nov 27, 2024
4180b18
Merge pull request #19 from blooo-io/feat/LDG-499-integrate-new-networks
GuilaneDen Nov 28, 2024
93da4aa
fix: added tests and fuzzing
n4l5u0r Nov 29, 2024
be787d4
fix: removal unecessary code
n4l5u0r Nov 29, 2024
a9684cf
fix: lint issues
n4l5u0r Nov 29, 2024
83c4d0b
fix: linter issues
n4l5u0r Nov 29, 2024
3372fdc
fix: missing step
n4l5u0r Nov 29, 2024
2d8d0f3
fix: PIC macro definition
n4l5u0r Nov 30, 2024
f834972
fix: fuzzing
n4l5u0r Nov 30, 2024
98f9f92
fix: PIC Macro
n4l5u0r Nov 30, 2024
7508d8c
fix: adjusted fuzzing mocks
n4l5u0r Nov 30, 2024
402bca5
test: added new tests
n4l5u0r Nov 30, 2024
862056b
test: optimized execution
n4l5u0r Nov 30, 2024
e032fb2
test: adjustments
n4l5u0r Nov 30, 2024
e0518aa
Merge pull request #20 from blooo-io/ci/LDG-592-cicd-enhancement
n4l5u0r Nov 30, 2024
b64a991
Merge branch 'master' into develop
GuilaneDen Dec 5, 2024
3b6c8e4
Merge branch 'master' into develop
GuilaneDen Dec 5, 2024
16a62ba
Merge pull request #22 from blooo-io/develop
GuilaneDen Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ SortIncludes: false
SpaceAfterCStyleCast: true
AllowShortCaseLabelsOnASingleLine: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: None
BinPackArguments: false
BinPackParameters: false
---

14 changes: 14 additions & 0 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-lite:latest AS LITE_BUILDER

# Base image with clang toolchain
FROM gcr.io/oss-fuzz-base/base-builder:v1

# Copy the project's source code.
COPY . $SRC/app-plugin-paraswap
COPY --from=LITE_BUILDER /opt/nanox-secure-sdk $SRC/app-plugin-paraswap/BOLOS_SDK

# Working directory for build.sh
WORKDIR $SRC/app-plugin-paraswap

# Copy build.sh into $SRC dir.
COPY ./.clusterfuzzlite/build.sh $SRC/
9 changes: 9 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -eu

# build fuzzers

pushd fuzzing
cmake -DBOLOS_SDK=../BOLOS_SDK -Bbuild -H.
make -C build
mv ./build/fuzz "${OUT}"
popd
1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: c
41 changes: 41 additions & 0 deletions .github/workflows/cflite_cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ClusterFuzzLite cron tasks
on:
workflow_dispatch:
push:
branches:
- main # Use your actual default branch here.
schedule:
- cron: '0 13 * * 6' # At 01:00 PM, only on Saturday
permissions: read-all
jobs:
Fuzzing:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- mode: batch
sanitizer: address
- mode: batch
sanitizer: memory
- mode: prune
sanitizer: address
- mode: coverage
sanitizer: coverage
steps:
- name: Build Fuzzers (${{ matrix.mode }} - ${{ matrix.sanitizer }})
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
language: c # Change this to the language you are fuzzing.
sanitizer: ${{ matrix.sanitizer }}
- name: Run Fuzzers (${{ matrix.mode }} - ${{ matrix.sanitizer }})
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 300 # 5 minutes
mode: ${{ matrix.mode }}
sanitizer: ${{ matrix.sanitizer }}

43 changes: 43 additions & 0 deletions .github/workflows/cflite_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ClusterFuzzLite PR fuzzing
on:
pull_request:
paths:
- '**'
permissions: read-all
jobs:
PR:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.sanitizer }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
sanitizer: [address, undefined, memory] # Override this with the sanitizers you want.
steps:
- name: Build Fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
language: c # Change this to the language you are fuzzing.
github-token: ${{ secrets.GITHUB_TOKEN }}
sanitizer: ${{ matrix.sanitizer }}
# Optional but recommended: used to only run fuzzers that are affected
# by the PR.
# storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/OWNER/STORAGE-REPO-NAME.git
# storage-repo-branch: main # Optional. Defaults to "main"
# storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
- name: Run Fuzzers (${{ matrix.sanitizer }})
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 300 # 5 minutes
mode: 'code-change'
sanitizer: ${{ matrix.sanitizer }}
output-sarif: true
# Optional but recommended: used to download the corpus produced by
# batch fuzzing.
# storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/OWNER/STORAGE-REPO-NAME.git
# storage-repo-branch: main # Optional. Defaults to "main"
# storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
13 changes: 12 additions & 1 deletion .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
Expand All @@ -49,6 +51,10 @@ jobs:
name: "nanox"
- sdk: "$NANOSP_SDK"
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -85,6 +91,10 @@ jobs:
name: "nanox"
- sdk: "$NANOSP_SDK"
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"
- sdk: "$FLEX_SDK"
name: "flex"

runs-on: ubuntu-latest
container:
Expand All @@ -95,6 +105,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: LedgerHQ/app-ethereum
submodules: recursive
ref: ${{ ((github.base_ref || github.ref_name) == 'main' && 'master') || (github.base_ref || github.ref_name) }}

- name: Build
Expand Down Expand Up @@ -140,4 +151,4 @@ jobs:

- name: Run Zemu tests
run: |
cd tests && yarn test
cd tests && yarn test
17 changes: 4 additions & 13 deletions .github/workflows/lint-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,7 @@ on:

jobs:
job_lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Clone
uses: actions/checkout@v3

- name: Lint
uses: DoozyX/clang-format-lint-action@v0.15
with:
source: "./"
extensions: "h,c"
clangFormatVersion: 12.0.1
name: Check linting using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_lint.yml@v1
with:
source: "./src"
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ bin/
debug/
dep/
obj/
tests/elfs/plugin_nano*.elf
tests/elfs/*
build/

# Editors
.idea/
.vscode/

# Python
*.pyc[cod]
Expand All @@ -23,3 +24,6 @@ __pycache__/
tests/node_modules
tests/lib
tests/snapshots-tmp

# MacOS
.DS_Store
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "ethereum-plugin-sdk"]
path = ethereum-plugin-sdk
url = git@github.com:LedgerHQ/ethereum-plugin-sdk.git
url = https://github.com/LedgerHQ/ethereum-plugin-sdk.git
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ APPNAME = "Paraswap"

# Application version
APPVERSION_M = 2
APPVERSION_N = 1
APPVERSION_P = 1
APPVERSION_N = 2
APPVERSION_P = 0

include ethereum-plugin-sdk/standard_plugin.mk
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ Need more information about the interface, the architecture, or general stuff ab
Smart contracts covered by this plugin are:

| Network | Version | Smart Contract |
| --- | --- | --- |
| Ethereum | V4 | `0x1bd435f3c054b6e901b7b108a0ab7617c808677b` |
| Ethereum | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| BSC | V4 | `0x55a0e3b6579972055faa983482aceb4b251dcf15`|
| BSC | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| Polygon | V4 | `0x90249ed4d69d70e709ffcd8bee2c5a566f65dade`|
| Polygon | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| --- | --- | --- |
| Arbitrum | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| Base | V5 | `0x59c7c832e96d2568bea6db468c1aadcbbda08a52`|
| BSC | V4 | `0x55a0e3b6579972055faa983482aceb4b251dcf15`|
| BSC | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| Ethereum | V4 | `0x1bd435f3c054b6e901b7b108a0ab7617c808677b`|
| Ethereum | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| Fantom | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| Optimism | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| Polygon | V4 | `0x90249ed4d69d70e709ffcd8bee2c5a566f65dade`|
| Polygon | V5 | `0xdef171fe48cf0115b1d80b88dc8eab59176fee57`|
| Polygon ZK EVM | V5 | `0xb83b554730d29ce4cb55bb42206c3e2c03e4a40a`|



Expand Down
2 changes: 1 addition & 1 deletion ethereum-plugin-sdk
Submodule ethereum-plugin-sdk updated 37 files
+44 −0 .github/workflows/publish_doc_website.yml
+2 −0 .gitignore
+3 −2 README.md
+ docs/img/Ledger-logo-696.webp
+51 −0 docs/index.md
+4 −0 docs/requirements.txt
+57 −0 docs/technical_informations/diagram.md
+15 −0 docs/technical_informations/globals.md
+11 −0 docs/technical_informations/handlers/handle_finalize.md
+11 −0 docs/technical_informations/handlers/handle_init_contract.md
+11 −0 docs/technical_informations/handlers/handle_provide_parameter.md
+19 −0 docs/technical_informations/handlers/handle_provide_token.md
+11 −0 docs/technical_informations/handlers/handle_query_contract_id.md
+19 −0 docs/technical_informations/handlers/handle_query_contract_ui.md
+10 −0 docs/technical_informations/handlers/index.md
+3 −0 docs/technical_informations/index.md
+5 −0 docs/technical_informations/tx_content.md
+3 −0 docs/technical_informations/utils/common_utils.md
+3 −0 docs/technical_informations/utils/index.md
+3 −0 docs/technical_informations/utils/plugin_utils.md
+1 −0 docs/test_framework/ci.md
+1 −0 docs/test_framework/fuzzing.md
+9 −0 docs/test_framework/index.md
+1 −0 docs/test_framework/ragger.md
+ docs/walkthrough/img/uniswap.webp
+52 −0 docs/walkthrough/index.md
+75 −0 mkdocs.yml
+2 −3 src/asset_info.h
+9 −0 src/bip32_utils.h
+44 −12 src/common_utils.c
+212 −31 src/common_utils.h
+4 −2 src/eth_internals.h
+297 −57 src/eth_plugin_interface.h
+3 −10 src/main.c
+8 −5 src/plugin_utils.c
+81 −9 src/plugin_utils.h
+15 −3 src/tx_content.h
121 changes: 121 additions & 0 deletions fuzzing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
cmake_minimum_required(VERSION 3.10)

if(${CMAKE_VERSION} VERSION_LESS 3.10)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()

# project information
project(Fuzzer
VERSION 1.0
DESCRIPTION "Contract parser of Paraswap plugin app"
LANGUAGES C)

# guard against bad build-type strings
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

if (NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "Fuzzer needs to be built with Clang")
endif()

if (NOT DEFINED BOLOS_SDK)
message(FATAL_ERROR "BOLOS_SDK environment variable not found.")
endif()

# guard against in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
endif()

# specify C standard
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)

# compatible with ClusterFuzzLite
if (NOT DEFINED ENV{LIB_FUZZING_ENGINE})
set(COMPILATION_FLAGS_ "-fsanitize=fuzzer,address,undefined,signed-integer-overflow")
else()
set(COMPILATION_FLAGS_ "$ENV{LIB_FUZZING_ENGINE} $ENV{CFLAGS}")
endif()
string(REPLACE " " ";" COMPILATION_FLAGS ${COMPILATION_FLAGS_})

add_compile_options(-Wall -Wextra -g -pedantic)
# Just to limit compilation warnings of the plugin sources
add_compile_options(-Wno-implicit-function-declaration)
# Flag depending on the Build Type
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ggdb2 -O3")

set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../src")
set(ETH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ethereum-plugin-sdk")

add_compile_definitions(
APPNAME="Paraswap"
)

add_compile_definitions(
IO_HID_EP_LENGTH=64
HAVE_ECC
HAVE_ECC_WEIERSTRASS
HAVE_SECP_CURVES
HAVE_ECC_TWISTED_EDWARDS
HAVE_ED_CURVES
HAVE_ECDSA
HAVE_EDDSA
HAVE_HASH
HAVE_BLAKE2
HAVE_SHA224
HAVE_SHA256
HAVE_SHA3
HAVE_SHA512
)

include_directories(
${BOLOS_SDK}/include
${BOLOS_SDK}/lib_standard_app
${BOLOS_SDK}/lib_cxng/include
${BOLOS_SDK}/lib_cxng/src
${BOLOS_SDK}/target/nanox/include
${ETH_DIR}/src
${SRC_DIR}
)

# Take all source files from the application and the sdk
file(GLOB_RECURSE APPLICATION_SRC
# Take all plugin sources
${SRC_DIR}/*.c

# Take all sdk sources
${ETH_DIR}/src/*.c
)
# Filter out main.c from the SDK and the entire dbg folder
list(FILTER APPLICATION_SRC EXCLUDE REGEX "${ETH_DIR}/src/main|${SRC_DIR}/dbg/")

add_executable(fuzz
${APPLICATION_SRC}

# fuzzing specific files
fuzz_plugin.c
mocks.c

# sdk utils
${BOLOS_SDK}/src/ledger_assert.c
${BOLOS_SDK}/lib_standard_app/format.c

# cxng
${BOLOS_SDK}/lib_cxng/src/cx_hash.c
${BOLOS_SDK}/lib_cxng/src/cx_sha256.c
${BOLOS_SDK}/lib_cxng/src/cx_sha512.c
${BOLOS_SDK}/lib_cxng/src/cx_sha3.c
${BOLOS_SDK}/lib_cxng/src/cx_blake2b.c
${BOLOS_SDK}/lib_cxng/src/cx_utils.c
${BOLOS_SDK}/lib_cxng/src/cx_ram.c
)

target_compile_options(fuzz PUBLIC ${COMPILATION_FLAGS})
target_link_options(fuzz PUBLIC ${COMPILATION_FLAGS})

if (CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-gdwarf-4)
endif()
Loading
Loading