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

Add QBFT support #6

Merged
merged 5 commits into from
May 16, 2024
Merged
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
22 changes: 16 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Test
run: go test -v ./...
Expand All @@ -28,16 +31,23 @@ jobs:
with:
submodules: recursive

- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '20'

- name: Resolve dependencies
working-directory: e2e
run: npm install

- name: Run E2E test
- name: Launch QBFT network
working-directory: e2e
run: make network-qbft CONSENSUS_TYPE=qbft test network-down

- name: Launch IBFT 2.0 network
working-directory: e2e
run: make test
run: make network-ibft2 CONSENSUS_TYPE=ibft2 test network-down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ibft2-relay-prover
# besu-ibc-relay-prover

This repository provides a [yui-relayer](https://github.com/hyperledger-labs/yui-relayer) prover module for Hyperledger Besu's IBFT 2.0.
This repository provides a [yui-relayer](https://github.com/hyperledger-labs/yui-relayer) prover module for [the light client of Hyperledger Besu's QBFT and IBFT 2.0 consensus algorithms](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/main/contracts/clients/qbft/QBFTClient.sol).

You can find [an e2e demo between two HB chains using yui-relayer](./e2e/README.md).
15 changes: 9 additions & 6 deletions e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
HARDHAT ?= npx hardhat
RLY_BIN ?= ./build/yrly
CONSENSUS_TYPE ?= qbft

.PHONY: yrly
yrly:
Expand All @@ -11,9 +12,13 @@ deploy:
$(HARDHAT) --network chain0 deploy
$(HARDHAT) --network chain1 deploy

.PHONY: network
network:
docker compose up --wait -d
.PHONY: network-qbft
network-qbft:
docker compose up --wait -d qbft-testchain0 qbft-testchain1

.PHONY: network-ibft2
network-ibft2:
docker compose up --wait -d ibft2-testchain0 ibft2-testchain1

.PHONY: network-down
network-down:
Expand All @@ -22,7 +27,7 @@ network-down:
.PHONY: init
init:
./relayer/scripts/extract-abi.sh
RLY_BIN=$(RLY_BIN) ./relayer/scripts/init-rly
RLY_BIN=$(RLY_BIN) CONSENSUS_TYPE=$(CONSENSUS_TYPE) ./relayer/scripts/init-rly

.PHONY: handshake
handshake:
Expand All @@ -34,8 +39,6 @@ relay:

.PHONY: test
test: yrly
$(MAKE) network
sleep 3
$(MAKE) deploy
$(MAKE) init
$(MAKE) handshake
Expand Down
16 changes: 7 additions & 9 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ $ make test

The above commands execute the following in sequence:

1. Launch two HB chains (both chain uses IBFT 2.0 consensus)
- `make network`
2. Deploy IBC contracts from yui-ibc-solidity to the chains using hardhat
1. Launch two HB chains (both chain uses QBFT consensus)
- `make network-qbft`
2. Deploy the IBC contracts from yui-ibc-solidity to the chains using hardhat
- `make deploy`
3. Call `registerClient` and `bindPort` to configurate the `IBCHandler`'s state
- `make deploy`
4. Configurate yui-relayer setting with [./relayer/configs](./relayer/configs/)
3. Configurate yui-relayer setting with [./relayer/configs](./relayer/configs/)
- `make init`
5. Perform IBC handshake using yui-relayer
4. Perform IBC handshake using yui-relayer
- `make handshake`
6. Send a packet using [./scripts/sendPacket.js](./scripts/sendPacket.js) and relay it using yui-relayer
5. Send a packet using [./scripts/sendPacket.js](./scripts/sendPacket.js) and relay it using yui-relayer
- `make relay`
7. Shutdown two HB chains
6. Shutdown two HB chains
- `make network-down`
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hyperledger/besu:24.3
FROM hyperledger/besu:24.3.0

USER root

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"fe3b557e8fb62b89f4916b721be55ceb828dbd73": {
"privateKey": "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
"privateKey": "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"627306090abaB3A6e1400e9345bC60c78a8BEf57": {
"privateKey": "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
Expand All @@ -34,17 +34,17 @@
"a89f47c6b463f74d87572b058427da0a13ec5425": {
"privateKey": "e517af47112e4f501afb26e4f34eadc8b0ad8eadaf4962169fc04bc8ddbfe091",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
"balance": "90000000000000000000000"
},
"cBED645B1C1a6254f1149Df51d3591c6B3803007": {
"privateKey": "713071a0b7101f177ae9c9ab0412eb7e43812bd289650f8db63f3055f2bcb029",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
"balance": "90000000000000000000000"
},
"00731540cd6060991D6B9C57CE295998d9bC2faB": {
"privateKey": "043a3427c36481e3cce70f5e6738b5f4d1a7e87fa90aa833f4bf2d3d690d4919",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
"balance": "90000000000000000000000"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hyperledger/besu:24.3
FROM hyperledger/besu:24.3.0

USER root

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"fe3b557e8fb62b89f4916b721be55ceb828dbd73": {
"privateKey": "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
"privateKey": "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"627306090abaB3A6e1400e9345bC60c78a8BEf57": {
"privateKey": "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
Expand All @@ -34,17 +34,17 @@
"a89f47c6b463f74d87572b058427da0a13ec5425": {
"privateKey": "e517af47112e4f501afb26e4f34eadc8b0ad8eadaf4962169fc04bc8ddbfe091",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
"balance": "90000000000000000000000"
},
"cBED645B1C1a6254f1149Df51d3591c6B3803007": {
"privateKey": "713071a0b7101f177ae9c9ab0412eb7e43812bd289650f8db63f3055f2bcb029",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
"balance": "90000000000000000000000"
},
"00731540cd6060991D6B9C57CE295998d9bC2faB": {
"privateKey": "043a3427c36481e3cce70f5e6738b5f4d1a7e87fa90aa833f4bf2d3d690d4919",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "0xad78ebc5ac6200000"
"balance": "90000000000000000000000"
}
}
},
Expand Down
13 changes: 13 additions & 0 deletions e2e/chains/qbft/chain0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM hyperledger/besu:24.3.0

USER root

RUN mkdir -p /tmp/besu/data
WORKDIR /tmp/besu
ADD qbftConfigFile.json /tmp/besu/qbftConfigFile.json
RUN besu operator generate-blockchain-config --config-file=qbftConfigFile.json --to=networkFiles --private-key-file-name=key
RUN cp ./networkFiles/keys/*/* ./data/

EXPOSE 8545 8546 8547 30303
ENTRYPOINT [ "besu" ]
CMD ["--data-path", "./data", "--genesis-file", "./networkFiles/genesis.json", "--rpc-http-enabled", "--rpc-http-api", "ETH,NET,IBFT,QBFT,DEBUG", "--host-allowlist", "*", "--rpc-http-cors-origins", "all", "--revert-reason-enabled", "--min-gas-price", "0"]
57 changes: 57 additions & 0 deletions e2e/chains/qbft/chain0/qbftConfigFile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"genesis": {
"config": {
"chainId": 2018,
"muirglacierblock": 0,
"qbft": {
"blockperiodseconds": 1,
"epochlength": 30000,
"requesttimeoutseconds": 4
}
},
"nonce": "0x0",
"timestamp": "0x58ee40ba",
"gasLimit": "0x1fffffffffffff",
"difficulty": "0x1",
"mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"fe3b557e8fb62b89f4916b721be55ceb828dbd73": {
"privateKey": "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"627306090abaB3A6e1400e9345bC60c78a8BEf57": {
"privateKey": "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"f17f52151EbEF6C7334FAD080c5704D77216b732": {
"privateKey": "ae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"a89f47c6b463f74d87572b058427da0a13ec5425": {
"privateKey": "e517af47112e4f501afb26e4f34eadc8b0ad8eadaf4962169fc04bc8ddbfe091",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"cBED645B1C1a6254f1149Df51d3591c6B3803007": {
"privateKey": "713071a0b7101f177ae9c9ab0412eb7e43812bd289650f8db63f3055f2bcb029",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"00731540cd6060991D6B9C57CE295998d9bC2faB": {
"privateKey": "043a3427c36481e3cce70f5e6738b5f4d1a7e87fa90aa833f4bf2d3d690d4919",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
}
}
},
"blockchain": {
"nodes": {
"generate": true,
"count": 1
}
}
}
13 changes: 13 additions & 0 deletions e2e/chains/qbft/chain1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM hyperledger/besu:24.3.0

USER root

RUN mkdir -p /tmp/besu/data
WORKDIR /tmp/besu
ADD qbftConfigFile.json /tmp/besu/qbftConfigFile.json
RUN besu operator generate-blockchain-config --config-file=qbftConfigFile.json --to=networkFiles --private-key-file-name=key
RUN cp ./networkFiles/keys/*/* ./data/

EXPOSE 8545 8546 8547 30303
ENTRYPOINT [ "besu" ]
CMD ["--data-path", "./data", "--genesis-file", "./networkFiles/genesis.json", "--rpc-http-enabled", "--rpc-http-api", "ETH,NET,IBFT,QBFT,DEBUG", "--host-allowlist", "*", "--rpc-http-cors-origins", "all", "--revert-reason-enabled", "--min-gas-price", "0"]
57 changes: 57 additions & 0 deletions e2e/chains/qbft/chain1/qbftConfigFile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"genesis": {
"config": {
"chainId": 3018,
"muirglacierblock": 0,
"qbft": {
"blockperiodseconds": 1,
"epochlength": 30000,
"requesttimeoutseconds": 4
}
},
"nonce": "0x0",
"timestamp": "0x58ee40ba",
"gasLimit": "0x1fffffffffffff",
"difficulty": "0x1",
"mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"fe3b557e8fb62b89f4916b721be55ceb828dbd73": {
"privateKey": "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"627306090abaB3A6e1400e9345bC60c78a8BEf57": {
"privateKey": "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"f17f52151EbEF6C7334FAD080c5704D77216b732": {
"privateKey": "ae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"a89f47c6b463f74d87572b058427da0a13ec5425": {
"privateKey": "e517af47112e4f501afb26e4f34eadc8b0ad8eadaf4962169fc04bc8ddbfe091",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"cBED645B1C1a6254f1149Df51d3591c6B3803007": {
"privateKey": "713071a0b7101f177ae9c9ab0412eb7e43812bd289650f8db63f3055f2bcb029",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
},
"00731540cd6060991D6B9C57CE295998d9bC2faB": {
"privateKey": "043a3427c36481e3cce70f5e6738b5f4d1a7e87fa90aa833f4bf2d3d690d4919",
"comment": "private key and this comment are ignored. In a real chain, the private key should NOT be stored",
"balance": "90000000000000000000000"
}
}
},
"blockchain": {
"nodes": {
"generate": true,
"count": 1
}
}
}
41 changes: 41 additions & 0 deletions e2e/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
services:
ibft2-testchain0:
build: ./chains/ibft2/chain0
ports:
- 8545:8545
- 8546:8546
healthcheck:
test: [ "CMD-SHELL", "grep \"00000000:2161 00000000:0000 0A\" /proc/net/tcp || exit 1" ]
interval: 100ms
timeout: 1s
retries: 100
ibft2-testchain1:
build: ./chains/ibft2/chain1
ports:
- 8645:8545
- 8646:8546
healthcheck:
test: [ "CMD-SHELL", "grep \"00000000:2161 00000000:0000 0A\" /proc/net/tcp || exit 1" ]
interval: 100ms
timeout: 1s
retries: 100
qbft-testchain0:
build: ./chains/qbft/chain0
ports:
- 8545:8545
- 8546:8546
healthcheck:
test: [ "CMD-SHELL", "grep \"00000000:2161 00000000:0000 0A\" /proc/net/tcp || exit 1" ]
interval: 100ms
timeout: 1s
retries: 100
qbft-testchain1:
build: ./chains/qbft/chain1
ports:
- 8645:8545
- 8646:8546
healthcheck:
test: [ "CMD-SHELL", "grep \"00000000:2161 00000000:0000 0A\" /proc/net/tcp || exit 1" ]
interval: 100ms
timeout: 1s
retries: 100
2 changes: 1 addition & 1 deletion e2e/contracts/Dependencies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ import {
} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/04-channel/IBCChannelUpgrade.sol";
import {IIBCHandler} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/25-handler/IIBCHandler.sol";
import {OwnableIBCHandler} from "@hyperledger-labs/yui-ibc-solidity/contracts/core/25-handler/OwnableIBCHandler.sol";
import {IBFT2Client} from "@hyperledger-labs/yui-ibc-solidity/contracts/clients/IBFT2Client.sol";
import {QBFTClient} from "@hyperledger-labs/yui-ibc-solidity/contracts/clients/qbft/QBFTClient.sol";
import {IBCMockApp} from "@hyperledger-labs/yui-ibc-solidity/contracts/apps/mock/IBCMockApp.sol";
Loading
Loading