Skip to content

Commit

Permalink
Merge pull request #267 from hyperledger-labs/qbft
Browse files Browse the repository at this point in the history
QBFT support

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored May 16, 2024
2 parents d7122d1 + db97d54 commit fab89d7
Show file tree
Hide file tree
Showing 37 changed files with 1,939 additions and 1,818 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,14 @@ jobs:
- name: Resolve dependencies
run: npm install

- name: Setup chains for E2E test
run: make network-e2e
- name: Setup chains for E2E test (IBFT2)
run: make network-ibft2

- name: E2E test
run: make e2e-test
- name: E2E test (IBFT2)
run: make e2e-test network-down

- name: Setup chains for E2E test (QBFT)
run: make network-qbft

- name: E2E test (QBFT)
run: make e2e-test network-down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FORGE ?= forge
SOLC_VERSION ?= 0.8.24
ABIGEN ?= "docker run -v .:/workspace -w /workspace -it ethereum/client-go:alltools-v1.11.6 abigen"
DOCKER_COMPOSE ?= docker compose
E2E_TEST_COMPOSE_FILE ?= ./chains/docker-compose.yml
E2E_TEST_COMPOSE_FILE ?= ./chains/compose.yml
TEST_BROADCAST_LOG_DIR ?= ./broadcast/Deploy.s.sol
TEST_MNEMONIC ?= "math razor capable expose worth grape metal sunset metal sudden usage scheme"

Expand Down Expand Up @@ -69,9 +69,18 @@ abigen: build

######## E2E test ########

.PHONY: network-e2e
network-e2e:
$(DOCKER_COMPOSE) -f $(E2E_TEST_COMPOSE_FILE) up --detach --wait testchain0 testchain1
.PHONY: network-ibft2
network-ibft2:
$(DOCKER_COMPOSE) -f $(E2E_TEST_COMPOSE_FILE) up --detach --wait ibft2-testchain0 ibft2-testchain1
$(MAKE) deploy

.PHONY: network-qbft
network-qbft:
$(DOCKER_COMPOSE) -f $(E2E_TEST_COMPOSE_FILE) up --detach --wait qbft-testchain0 qbft-testchain1
$(MAKE) deploy

.PHONY: deploy
deploy:
TEST_MNEMONIC=$(TEST_MNEMONIC) $(FORGE) script --legacy --batch-size 5 --use solc:${SOLC_VERSION} --fork-url http://127.0.0.1:8645 --broadcast \
./tests/foundry/src/Deploy.s.sol
TEST_MNEMONIC=$(TEST_MNEMONIC) $(FORGE) script --legacy --batch-size 5 --use solc:${SOLC_VERSION} --fork-url http://127.0.0.1:8745 --broadcast \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You can deploy a Light Client that implements [the ILightClient interface](./con

Here are some such examples:
- [Tendermint ZK Light Client](https://github.com/datachainlab/tendermint-zk-ibc)
- [IBFT 2.0 Light Client](./contracts/clients/IBFT2Client.sol)
- [QBFT/IBFT2.0 Light Client](./contracts/clients/qbft/QBFTClient.sol)
- [LCP(TEE) Client](https://github.com/datachainlab/lcp-solidity)
- [Localhost Client](./contracts/clients/LocalhostClient.sol)

Expand Down
42 changes: 42 additions & 0 deletions chains/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
services:
ibft2-testchain0:
build: ./ibft2/chain0
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
ibft2-testchain1:
build: ./ibft2/chain1
ports:
- 8745:8545
- 8746: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: ./qbft/chain0
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-testchain1:
build: ./qbft/chain1
ports:
- 8745:8545
- 8746:8546
healthcheck:
test: [ "CMD-SHELL", "grep \"00000000:2161 00000000:0000 0A\" /proc/net/tcp || exit 1" ]
interval: 100ms
timeout: 1s
retries: 100
21 changes: 0 additions & 21 deletions chains/docker-compose.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hyperledger/besu:23.7.2
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:23.7.2
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 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 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 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 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
}
}
}
File renamed without changes.
Loading

0 comments on commit fab89d7

Please sign in to comment.