Skip to content

Commit

Permalink
Merge pull request #5 from lsd-ucsc/py-eth-contract
Browse files Browse the repository at this point in the history
- Added EthContractHelper python script to help with contract deployment and function calls
- Added a Python script, GanachePubSubTests, to run tests with Ganache
  - This test covers
    - Deploy PubSubService contract
    - Deploy HelloWorldPublisher contract
    - Deploy HelloWorldSubscriber contract
    - Register HelloWorldPublisher -> PubSubService
    - Subscribe HelloWorldSubscriber -> HelloWorldPublisher
    - Publish HelloWorldPublisher -> HelloWorldSubscriber
- Code & repo cleaning
  • Loading branch information
zhenghaven authored Apr 23, 2023
2 parents 9270437 + b976b67 commit fbee95b
Show file tree
Hide file tree
Showing 15 changed files with 983 additions and 590 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
.idea
.deps
.debugger
.vscode

# python temporary files
__pycache__
*.pyc
*.pyo
*.pyd

artifacts/

Expand Down
46 changes: 25 additions & 21 deletions PubSub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ CONTRACTS := \
EventManager \
PubSubService

CHECKSUM_BIN := openssl sha256


all: $(addprefix ../build/$(MODULE_NAME)/,$(addsuffix .abi,$(CONTRACTS))) \
$(addprefix ../build/$(MODULE_NAME)/,$(addsuffix .bin,$(CONTRACTS))) \
Expand All @@ -14,36 +16,38 @@ all: $(addprefix ../build/$(MODULE_NAME)/,$(addsuffix .abi,$(CONTRACTS))) \


../build/$(MODULE_NAME)/%.bin: %.sol ../build/nodeenv.state
. ../build/nodeenv/bin/activate; \
solcjs --optimize --optimize-runs 200 \
--bin \
--include-path node_modules/ --base-path .. \
--output-dir ../build/$(MODULE_NAME)/ \
$< && \
mv ../build/$(MODULE_NAME)/$(MODULE_NAME)_$(basename $<)_sol_$(basename $<).bin \
../build/$(MODULE_NAME)/$(basename $<).bin && \
rm -f ../build/$(MODULE_NAME)/*_sol_*.bin; \
deactivate_node
( \
. ../build/nodeenv/bin/activate && \
solcjs --optimize --optimize-runs 200 \
--bin \
--include-path node_modules/ --base-path .. \
--output-dir ../build/$(MODULE_NAME)/ \
$< && \
mv ../build/$(MODULE_NAME)/$(MODULE_NAME)_$(basename $<)_sol_$(basename $<).bin \
../build/$(MODULE_NAME)/$(basename $<).bin && \
rm -f ../build/$(MODULE_NAME)/*_sol_*.bin \
)


../build/$(MODULE_NAME)/%.abi: %.sol ../build/nodeenv.state
. ../build/nodeenv/bin/activate; \
solcjs --optimize --optimize-runs 200 \
--abi \
--include-path node_modules/ --base-path .. \
--output-dir ../build/$(MODULE_NAME)/ \
$< && \
mv ../build/$(MODULE_NAME)/$(MODULE_NAME)_$(basename $<)_sol_$(basename $<).abi \
../build/$(MODULE_NAME)/$(basename $<).abi && \
rm -f ../build/$(MODULE_NAME)/*_sol_*.abi; \
deactivate_node
( \
. ../build/nodeenv/bin/activate && \
solcjs --optimize --optimize-runs 200 \
--abi \
--include-path node_modules/ --base-path .. \
--output-dir ../build/$(MODULE_NAME)/ \
$< && \
mv ../build/$(MODULE_NAME)/$(MODULE_NAME)_$(basename $<)_sol_$(basename $<).abi \
../build/$(MODULE_NAME)/$(basename $<).abi && \
rm -f ../build/$(MODULE_NAME)/*_sol_*.abi \
)


../build/$(MODULE_NAME)/checksums.txt: $(addprefix ../build/$(MODULE_NAME)/,$(addsuffix .abi,$(CONTRACTS))) \
$(addprefix ../build/$(MODULE_NAME)/,$(addsuffix .bin,$(CONTRACTS)))
( \
cd ../build/$(MODULE_NAME); \
sha256sum $(addsuffix .abi,$(CONTRACTS)) $(addsuffix .bin,$(CONTRACTS)) > checksums.txt; \
$(CHECKSUM_BIN) $(addsuffix .abi,$(CONTRACTS)) $(addsuffix .bin,$(CONTRACTS)) > checksums.txt; \
)


Expand Down
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,3 @@ Solidity code for the on-chain component of Decentagram project
- run `make` command under project's root directory, and the generated binary
files can be find under `build` directory
- The `solc` compiler version can be configured in `utils/nodeenv-requirements.txt`

# Ganache
## To start Ganache, create new keys, and add keys to keys directory:
```
ganache-cli -a 20 --network-id 1337 --wallet.accountKeysPath [path_to_decent_lib]/decent-pubsub-onchain/eth_accounts/keys.json
```
## Start Ganache with existing keys.json folder existing:
```
ganache-cli -d -a 20 --network-id 1337
```
### Notes
```
-d = deterministic (deterministic private keys for testing)
-a 20 = create 20 accounts
```
25 changes: 0 additions & 25 deletions code/go/throughput-eval/go.mod

This file was deleted.

144 changes: 0 additions & 144 deletions code/go/throughput-eval/go.sum

This file was deleted.

Loading

0 comments on commit fbee95b

Please sign in to comment.