Skip to content

Commit

Permalink
[skip audit]Pre release 1.0.1 (#873)
Browse files Browse the repository at this point in the history
* Separate bin_dir and work_dir

* Add docker diretory for build release images

* Bug fix for handling quota used error when Revert. (#870)
  • Loading branch information
leeyr338 authored and jerry-yu committed Oct 18, 2019
1 parent 0e91bcd commit 68a52fe
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 153 deletions.
14 changes: 8 additions & 6 deletions cita-executor/core/src/libexecutor/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ impl ExecutedBlock {
_ => Some(ReceiptError::Internal),
});

let tx_quota_used =
if receipt_error.is_some() && receipt_error != Some(ReceiptError::Internal) {
t.gas
} else {
ret.quota_used
};
let tx_quota_used = if receipt_error.is_some()
&& receipt_error != Some(ReceiptError::Internal)
&& receipt_error != Some(ReceiptError::Reverted)
{
t.gas
} else {
ret.quota_used
};

// Note: quota_used in Receipt is self.current_quota_used, this will be
// handled by get_rich_receipt() while getting a single transaction receipt.
Expand Down
32 changes: 32 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Docker image for CITA release

## Build image

Script is comming soon!

## Usage

### Using docker command

* Create a CITA chain config.

```shell
docker run -v `pwd`:/opt/cita-run cita/cita-release:1.0.0-secp256k1-sha3 cita create --super_admin "0x37d1c7449bfe76fe9c445e626da06265e9377601" --nodes "127.0.0.1:4000"
```

Tips: CITA image uses `/opt/cita-run` as its default work_dir, so you should mount `pwd` to it.

* Setup & run CITA

```shell
docker run -d -p 1337:1337 -v `pwd`:/opt/cita-run cita/cita-release:1.0.0-secp256k1-sha3 /bin/bash -c 'cita setup test-chain/0 && cita start test-chain/0 && sleep infinity'
```

Cool! Just two simple command, you have build a CITA blockchain in you computer.
Enjoy it!

### Using docker-compose

```shell
cd sample && docker-compose up
```
29 changes: 29 additions & 0 deletions docker/release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM cita/cita-run:ubuntu-18.04-20190829
LABEL maintainer="Cryptape Technologies <[email protected]>"

## Install CITA release here
ARG ENCRYPTION_ALG=secp256k1
ARG HASH_ALG=sha3
RUN mkdir -p /opt/cita

WORKDIR /opt/cita
COPY cita_${ENCRYPTION_ALG}_${HASH_ALG}.tar.gz .

# Keep tar package here for md5 test
RUN tar -xf cita_${ENCRYPTION_ALG}_${HASH_ALG}.tar.gz \
&& mv cita_${ENCRYPTION_ALG}_${HASH_ALG}/* /opt/cita \
&& rm -rf cita_${ENCRYPTION_ALG}_${HASH_ALG}

# Set CITA_HOME
ENV CITA_HOME=/opt/cita
# Set PATH to cita binary
ENV PATH=/opt/cita/bin:${PATH}
## End of install CITA release

COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh

WORKDIR /opt/cita-run

ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD ["cita", "bebop", "help"]
13 changes: 13 additions & 0 deletions docker/release/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [ "${USER_ID}" = "0" ] || [ "${USER_ID}" = "" ]; then
# Run with "root"
exec "$@"
else
# Add local user(name=user) use USER_ID
useradd --shell /bin/bash -u "${USER_ID}" -o -c "" -d /opt user
# Can use sudo without password
echo "user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers

exec /usr/sbin/gosu user "$@"
fi
73 changes: 73 additions & 0 deletions docker/sample/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
version: '3'

services:
config:
container_name: config
environment:
- USER_ID
- SUPER_ADMIN=0x4b5ae4567ad5d9fb92bc9afd6a657e6fa13a2523
- NODES_CONFIG=node0:4000, node1:4001
image: cita/cita-release:1.0.0-secp256k1-sha3
hostname: config
networks:
main:
aliases:
- config
volumes:
- ./:/opt/cita-run
command: |
bash -c '
echo "Create config files...";
cita create --super_admin "$$SUPER_ADMIN" --nodes "$$NODES_CONFIG";
echo "Done config"'
node0:
container_name: node0
depends_on:
- config
environment:
- USER_ID
image: cita/cita-release:1.0.0-secp256k1-sha3
hostname: node0
networks:
main:
aliases:
- node0
volumes:
- ./:/opt/cita-run
ports:
- "1337:1337"
command: |
bash -c '
while [[ ! -d /opt/cita-run/test-chain ]]; do sleep 1; done;
sleep 10;
cita setup test-chain/0;
cita start test-chain/0;
sleep infinity'
node1:
container_name: node1
depends_on:
- config
environment:
- USER_ID
image: cita/cita-release:1.0.0-secp256k1-sha3
hostname: node1
networks:
main:
aliases:
- node1
volumes:
- ./:/opt/cita-run
ports:
- "1338:1338"
command: |
bash -c '
while [[ ! -d /opt/cita-run/test-chain ]]; do sleep 1; done;
sleep 10;
cita setup test-chain/1;
cita start test-chain/1;
sleep infinity'
networks:
main:
Loading

0 comments on commit 68a52fe

Please sign in to comment.