Skip to content

Commit e787a2c

Browse files
authored
Merge pull request #8 from lsd-ucsc/solc-ver-0_8_20-n-bugfixes
- Updated compiler to `solc` v0.8.20, g++, linux version - Fixed the bug that `EventManager.notifySubscribers()` call will fail when there's no subscribers - Added gas cost evaluation on the `register` operation
2 parents b01d1bc + 2eaad56 commit e787a2c

15 files changed

+479
-1060
lines changed

.github/workflows/create-release.yaml

Lines changed: 118 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Create release
22

33
on:
44
push:
5-
branches: [ main ]
65
tags:
76
- "v*.*.*"
87
pull_request:
@@ -18,86 +17,102 @@ jobs:
1817
python-version: [ 3.11 ]
1918
node-version: [ 18.16.0 ]
2019

21-
solc-version: [ 0.8.19 ]
2220
ganache-version: [ 7.8.0 ]
2321

24-
opt-flags: [ "--optimize --optimize-runs 200" ]
22+
solc-version: [ v0.8.20 ]
23+
24+
env:
25+
SOLC_BIN: ${{ github.workspace }}/build/solc-static-linux
26+
SOLC_FLAGS: >-
27+
--optimize --optimize-runs 200
28+
--revert-strings strip
29+
--via-ir
30+
--overwrite
31+
--base-path ${{ github.workspace }}
32+
--output-dir ${{ github.workspace }}/build/
33+
SOLC_VER_CMD: >-
34+
${{ github.workspace }}/build/solc-static-linux
35+
--version | tail -n 1 | sed -e "s/^Version: //g"
36+
RELE_NOTE: ${{ github.workspace }}/build/release_note.md
2537

2638
name: A job to create a release
2739
steps:
2840
- name: Checkout
2941
uses: actions/checkout@v3
30-
31-
- name: Installing Node ${{ matrix.node-version }}
32-
uses: actions/setup-node@v3
3342
with:
34-
node-version: ${{ matrix.node-version }}
43+
submodules: recursive
3544

3645
- name: Installing Python ${{ matrix.python-version }}
3746
uses: actions/setup-python@v4
3847
with:
3948
python-version: ${{ matrix.python-version }}
4049

50+
- name: Installing Python packages
51+
run: |
52+
python3 -m pip install --requirement ${{ github.workspace }}/utils/gas_cost_eval_requirements.txt
53+
54+
- name: Installing Node ${{ matrix.node-version }}
55+
uses: actions/setup-node@v3
56+
with:
57+
node-version: ${{ matrix.node-version }}
58+
4159
- name: Installing NPM packages
4260
run: |
43-
npm install -g solc@${{ matrix.solc-version }}
4461
npm install -g ganache@${{ matrix.ganache-version }}
4562
46-
- name: Installing Python packages
63+
- name: Installing Solc compiler
4764
run: |
48-
python3 -m pip install --requirement ${{ github.workspace }}/utils/gas_cost_eval_requirements.txt
65+
mkdir -p ${{ github.workspace }}/build/
66+
curl -fsSL -o ${SOLC_BIN} \
67+
https://github.com/ethereum/solidity/releases/download/${{ matrix.solc-version }}/solc-static-linux
68+
chmod +x ${SOLC_BIN}
4969
5070
- name: Compiling contracts for PubSub/EventManager.sol
5171
run: |
52-
solcjs ${{ matrix.opt-flags }} --bin --include-path node_modules/ --base-path . --output-dir ./build/ ./PubSub/EventManager.sol
53-
solcjs ${{ matrix.opt-flags }} --abi --include-path node_modules/ --base-path . --output-dir ./build/ ./PubSub/EventManager.sol
54-
mv ./build/PubSub_EventManager_sol_EventManager.bin ./build/EventManager.bin
55-
mv ./build/PubSub_EventManager_sol_EventManager.abi ./build/EventManager.abi
72+
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/PubSub/EventManager.sol
73+
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/PubSub/EventManager.sol
5674
5775
- name: Compiling contracts for PubSub/PubSubService.sol
5876
run: |
59-
solcjs ${{ matrix.opt-flags }} --bin --include-path node_modules/ --base-path . --output-dir ./build/ ./PubSub/PubSubService.sol
60-
solcjs ${{ matrix.opt-flags }} --abi --include-path node_modules/ --base-path . --output-dir ./build/ ./PubSub/PubSubService.sol
61-
mv ./build/PubSub_PubSubService_sol_PubSubService.bin ./build/PubSubService.bin
62-
mv ./build/PubSub_PubSubService_sol_PubSubService.abi ./build/PubSubService.abi
77+
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/PubSub/PubSubService.sol
78+
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/PubSub/PubSubService.sol
6379
6480
- name: Compiling contracts for tests/HelloWorldSubscriber.sol
6581
run: |
66-
solcjs ${{ matrix.opt-flags }} --bin --include-path node_modules/ --base-path . --output-dir ./build/ ./tests/HelloWorldSubscriber.sol
67-
solcjs ${{ matrix.opt-flags }} --abi --include-path node_modules/ --base-path . --output-dir ./build/ ./tests/HelloWorldSubscriber.sol
68-
mv ./build/tests_HelloWorldSubscriber_sol_HelloWorldSubscriber.bin ./build/HelloWorldSubscriber.bin
69-
mv ./build/tests_HelloWorldSubscriber_sol_HelloWorldSubscriber.abi ./build/HelloWorldSubscriber.abi
82+
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/tests/HelloWorldSubscriber.sol
83+
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/tests/HelloWorldSubscriber.sol
7084
7185
- name: Compiling contracts for tests/HelloWorldPublisher.sol
7286
run: |
73-
solcjs ${{ matrix.opt-flags }} --bin --include-path node_modules/ --base-path . --output-dir ./build/ ./tests/HelloWorldPublisher.sol
74-
solcjs ${{ matrix.opt-flags }} --abi --include-path node_modules/ --base-path . --output-dir ./build/ ./tests/HelloWorldPublisher.sol
75-
mv ./build/tests_HelloWorldPublisher_sol_HelloWorldPublisher.bin ./build/HelloWorldPublisher.bin
76-
mv ./build/tests_HelloWorldPublisher_sol_HelloWorldPublisher.abi ./build/HelloWorldPublisher.abi
87+
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/tests/HelloWorldPublisher.sol
88+
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/tests/HelloWorldPublisher.sol
7789
7890
- name: Calculating checksums of the binary
91+
working-directory: ${{ github.workspace }}/build
7992
run: |
80-
sha256sum ./build/EventManager.bin >> ./build/checksums.txt
81-
sha256sum ./build/EventManager.abi >> ./build/checksums.txt
82-
sha256sum ./build/PubSubService.bin >> ./build/checksums.txt
83-
sha256sum ./build/PubSubService.abi >> ./build/checksums.txt
84-
sha256sum ./build/HelloWorldPublisher.bin >> ./build/checksums.txt
85-
sha256sum ./build/HelloWorldPublisher.abi >> ./build/checksums.txt
86-
sha256sum ./build/HelloWorldSubscriber.bin >> ./build/checksums.txt
87-
sha256sum ./build/HelloWorldSubscriber.abi >> ./build/checksums.txt
93+
sha256sum solc-static-linux >> checksums.txt
94+
sha256sum EventManager.bin >> checksums.txt
95+
sha256sum EventManager.abi >> checksums.txt
96+
sha256sum PubSubService.bin >> checksums.txt
97+
sha256sum PubSubService.abi >> checksums.txt
98+
sha256sum HelloWorldPublisher.bin >> checksums.txt
99+
sha256sum HelloWorldPublisher.abi >> checksums.txt
100+
sha256sum HelloWorldSubscriber.bin >> checksums.txt
101+
sha256sum HelloWorldSubscriber.abi >> checksums.txt
88102
89103
- name: Prepare binaries for gas cost evaluation
104+
working-directory: ${{ github.workspace }}/build
90105
run: |
91-
mkdir -p ./build/PubSub
92-
cp ./build/EventManager.bin ./build/PubSub/EventManager.bin
93-
cp ./build/EventManager.abi ./build/PubSub/EventManager.abi
94-
cp ./build/PubSubService.bin ./build/PubSub/PubSubService.bin
95-
cp ./build/PubSubService.abi ./build/PubSub/PubSubService.abi
96-
mkdir -p ./build/tests
97-
cp ./build/HelloWorldPublisher.bin ./build/tests/HelloWorldPublisher.bin
98-
cp ./build/HelloWorldPublisher.abi ./build/tests/HelloWorldPublisher.abi
99-
cp ./build/HelloWorldSubscriber.bin ./build/tests/HelloWorldSubscriber.bin
100-
cp ./build/HelloWorldSubscriber.abi ./build/tests/HelloWorldSubscriber.abi
106+
mkdir -p PubSub
107+
cp EventManager.bin PubSub/EventManager.bin
108+
cp EventManager.abi PubSub/EventManager.abi
109+
cp PubSubService.bin PubSub/PubSubService.bin
110+
cp PubSubService.abi PubSub/PubSubService.abi
111+
mkdir -p tests
112+
cp HelloWorldPublisher.bin tests/HelloWorldPublisher.bin
113+
cp HelloWorldPublisher.abi tests/HelloWorldPublisher.abi
114+
cp HelloWorldSubscriber.bin tests/HelloWorldSubscriber.bin
115+
cp HelloWorldSubscriber.abi tests/HelloWorldSubscriber.abi
101116
102117
- name: Run publish gas cost evaluation
103118
run: |
@@ -107,40 +122,59 @@ jobs:
107122
run: |
108123
python3 ${{ github.workspace }}/tests/GasCostEvalMultiPubs.py
109124
125+
- name: Run deployment gas cost evaluation
126+
run: |
127+
python3 ${{ github.workspace }}/tests/GasCostEvalDeploy.py
128+
110129
- name: Plot gas cost evaluation result figures
111130
run: |
112131
python3 ${{ github.workspace }}/tests/GasCostEvalPlot.py
113132
114133
- name: Generate release note
134+
working-directory: ${{ github.workspace }}/build
115135
run: |
116-
echo "# Release note" >> ./build/release_note.md
117-
echo "## Contracts" >> ./build/release_note.md
118-
echo "- PubSub/EventManager.sol" >> ./build/release_note.md
119-
echo "- PubSub/PubSubService.sol" >> ./build/release_note.md
120-
echo "- tests/HelloWorldPublisher.sol" >> ./build/release_note.md
121-
echo "- tests/HelloWorldSubscriber.sol" >> ./build/release_note.md
122-
echo "" >> ./build/release_note.md
123-
echo "## Build configurations" >> ./build/release_note.md
124-
echo "- OS: \`${{ matrix.os }}\`" >> ./build/release_note.md
125-
echo "- Node version: \`$(node --version)\`" >> ./build/release_note.md
126-
echo "- Solc version: \`$(solcjs --version)\`" >> ./build/release_note.md
127-
echo "- Optimizations: \`${{ matrix.opt-flags }}\`" >> ./build/release_note.md
128-
echo "" >> ./build/release_note.md
129-
echo "## Checksums" >> ./build/release_note.md
130-
echo "\`\`\`" >> ./build/release_note.md
131-
cat ./build/checksums.txt >> ./build/release_note.md
132-
echo "\`\`\`" >> ./build/release_note.md
133-
echo "" >> ./build/release_note.md
134-
echo "## Gas Cost Evaluations" >> ./build/release_note.md
135-
echo "### Gas Cost of Publishing Events" >> ./build/release_note.md
136-
echo "" >> ./build/release_note.md
137-
echo '!'"[publish_gas_cost](/../../blob/assets-gas-eval/assets/${{ github.ref_name }}-publish_gas_cost.svg)" >> ./build/release_note.md
138-
echo "" >> ./build/release_note.md
139-
echo "### Gas cost of Subscribing to Publishers" >> ./build/release_note.md
140-
echo "" >> ./build/release_note.md
141-
echo '!'"[subscribe_gas_cost](/../../blob/assets-gas-eval/assets/${{ github.ref_name }}-subscribe_gas_cost.svg)" >> ./build/release_note.md
142-
echo "" >> ./build/release_note.md
143-
echo "" >> ./build/release_note.md
136+
echo "# Release note" >> ${RELE_NOTE}
137+
echo "" >> ${RELE_NOTE}
138+
echo "## Contracts" >> ${RELE_NOTE}
139+
echo "- PubSub/EventManager.sol" >> ${RELE_NOTE}
140+
echo "- PubSub/PubSubService.sol" >> ${RELE_NOTE}
141+
echo "- tests/HelloWorldPublisher.sol" >> ${RELE_NOTE}
142+
echo "- tests/HelloWorldSubscriber.sol" >> ${RELE_NOTE}
143+
echo "" >> ${RELE_NOTE}
144+
echo "## Build configurations" >> ${RELE_NOTE}
145+
echo "- OS: \`${{ matrix.os }}\`" >> ${RELE_NOTE}
146+
echo "- Solc version: \`$(bash -c "${SOLC_VER_CMD}")\`" >> ${RELE_NOTE}
147+
echo "- Compiler Flags: \`${SOLC_FLAGS}\`" >> ${RELE_NOTE}
148+
echo "" >> ${RELE_NOTE}
149+
echo "## Checksums" >> ${RELE_NOTE}
150+
echo "\`\`\`" >> ${RELE_NOTE}
151+
cat checksums.txt >> ${RELE_NOTE}
152+
echo "\`\`\`" >> ${RELE_NOTE}
153+
echo "" >> ${RELE_NOTE}
154+
echo "## Gas Cost Evaluations" >> ${RELE_NOTE}
155+
echo "### Gas Cost of Publishing Events" >> ${RELE_NOTE}
156+
echo "" >> ${RELE_NOTE}
157+
echo '!'"[publish_gas_cost](/../../blob/assets-gas-eval/assets/${{ github.ref_name }}-publish_gas_cost.svg)" >> ${RELE_NOTE}
158+
echo "" >> ${RELE_NOTE}
159+
echo "### Gas Cost of Publisher Registeration" >> ${RELE_NOTE}
160+
echo "" >> ${RELE_NOTE}
161+
echo '!'"[register_gas_cost](/../../blob/assets-gas-eval/assets/${{ github.ref_name }}-register_gas_cost.svg)" >> ${RELE_NOTE}
162+
echo "" >> ${RELE_NOTE}
163+
echo "### Gas Cost of Subscribing to Publishers" >> ${RELE_NOTE}
164+
echo "" >> ${RELE_NOTE}
165+
echo '!'"[subscribe_gas_cost](/../../blob/assets-gas-eval/assets/${{ github.ref_name }}-subscribe_gas_cost.svg)" >> ${RELE_NOTE}
166+
echo "" >> ${RELE_NOTE}
167+
echo "### Gas Cost of Contract Deployment" >> ${RELE_NOTE}
168+
echo "\`\`\`json" >> ${RELE_NOTE}
169+
cat deploy_gas_cost.json >> ${RELE_NOTE}
170+
echo "" >> ${RELE_NOTE}
171+
echo "\`\`\`" >> ${RELE_NOTE}
172+
echo "" >> ${RELE_NOTE}
173+
echo "### Gas Cost Summary" >> ${RELE_NOTE}
174+
echo "" >> ${RELE_NOTE}
175+
echo '!'"[gas_cost](/../../blob/assets-gas-eval/assets/${{ github.ref_name }}-gas_cost.svg)" >> ${RELE_NOTE}
176+
echo "" >> ${RELE_NOTE}
177+
echo "" >> ${RELE_NOTE}
144178
145179
- name: Echo release note
146180
run: |
@@ -165,6 +199,9 @@ jobs:
165199
${{ github.workspace }}/build/publish_gas_cost.json
166200
${{ github.workspace }}/build/subscribe_gas_cost.svg
167201
${{ github.workspace }}/build/subscribe_gas_cost.json
202+
${{ github.workspace }}/build/register_gas_cost.svg
203+
${{ github.workspace }}/build/register_gas_cost.json
204+
${{ github.workspace }}/build/deploy_gas_cost.json
168205
${{ github.workspace }}/build/gas_cost.svg
169206
170207
- name: Store evaluation figures to assets branch
@@ -182,6 +219,11 @@ jobs:
182219
--path "assets/${{ github.ref_name }}-subscribe_gas_cost.svg" \
183220
--commit-msg "Uploaded file assets/${{ github.ref_name }}-subscribe_gas_cost.svg" \
184221
--file "${{ github.workspace }}/build/subscribe_gas_cost.svg"
222+
python3 ${{ github.workspace }}/utils/GitHubCreateFile.py \
223+
--branch assets-gas-eval \
224+
--path "assets/${{ github.ref_name }}-register_gas_cost.svg" \
225+
--commit-msg "Uploaded file assets/${{ github.ref_name }}-register_gas_cost.svg" \
226+
--file "${{ github.workspace }}/build/register_gas_cost.svg"
185227
python3 ${{ github.workspace }}/utils/GitHubCreateFile.py \
186228
--branch assets-gas-eval \
187229
--path "assets/${{ github.ref_name }}-gas_cost.svg" \
@@ -206,3 +248,7 @@ jobs:
206248
${{ github.workspace }}/build/publish_gas_cost.json
207249
${{ github.workspace }}/build/subscribe_gas_cost.svg
208250
${{ github.workspace }}/build/subscribe_gas_cost.json
251+
${{ github.workspace }}/build/register_gas_cost.svg
252+
${{ github.workspace }}/build/register_gas_cost.json
253+
${{ github.workspace }}/build/deploy_gas_cost.json
254+
${{ github.workspace }}/build/gas_cost.svg

.github/workflows/pubsub-solidity-unittesting.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,24 @@ on:
1616

1717
jobs:
1818
run_sol_contracts_job:
19-
runs-on: ubuntu-22.04
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ ubuntu-22.04 ]
23+
solc-version: [ 0.8.20 ]
24+
chain-fork: [ shanghai ]
25+
opt-runs: [ 200 ]
26+
2027
name: A job to run solidity unit tests on github actions CI
2128
steps:
2229
- name: Checkout
2330
uses: actions/checkout@v3
31+
2432
- name: Run Solidity Unit Testing Action
2533
uses: EthereumRemix/sol-test@v1.1
2634
with:
2735
test-path: 'tests/PubSub'
28-
compiler-version: '0.8.19'
36+
compiler-version: ${{ matrix.solc-version }}
2937
optimize: true
30-
optimizer-runs: 200
38+
optimizer-runs: ${{ matrix.opt-runs }}
39+
hard-fork: ${{ matrix.chain-fork }}

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "utils/PyEthHelper"]
2+
path = utils/PyEthHelper
3+
url = https://github.com/lsd-ucsc/PyEthHelper.git
4+
branch = main

Makefile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
NODEENV_CONFIG := ./utils/nodeenv.ini
2-
NODEENV_REQ := ./utils/nodeenv-requirements.txt
31
MODULES := \
42
PubSub \
53
tests
4+
SOLC_VERSION := v0.8.20
5+
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
6+
CURRENT_DIR := $(dir $(MKFILE_PATH))
7+
SOLC_BIN := $(CURRENT_DIR)/build/solc-static-linux
68

79

8-
all: build/nodeenv.state $(MODULES)
10+
all: $(SOLC_BIN) $(MODULES)
911

1012

11-
build/nodeenv.state: $(NODEENV_CONFIG) $(NODEENV_REQ)
12-
nodeenv --config=$(NODEENV_CONFIG) --requirements=$(NODEENV_REQ) build/nodeenv
13-
touch $@
13+
$(SOLC_BIN):
14+
mkdir -p $(dir $(SOLC_BIN)) && \
15+
curl -fsSL -o $(SOLC_BIN) \
16+
https://github.com/ethereum/solidity/releases/download/$(SOLC_VERSION)/solc-static-linux \
17+
&& \
18+
chmod +x $(SOLC_BIN)
19+
20+
21+
solc_bin: $(SOLC_BIN)
1422

1523

1624
$(MODULES):
@@ -22,7 +30,7 @@ $(addprefix clean_,$(MODULES)):
2230

2331

2432
clean: $(addprefix clean_,$(MODULES))
25-
rm -rf build/nodeenv build/nodeenv.state
33+
rm -rf $(SOLC_BIN)
2634

2735

28-
.PHONY: all clean $(MODULES) $(addprefix clean_,$(MODULES))
36+
.PHONY: all clean solc_bin $(MODULES) $(addprefix clean_,$(MODULES))

0 commit comments

Comments
 (0)