Skip to content

Commit eab638d

Browse files
Recently audited contracts have been deployed to all supported network (#31)
* added explicit error for unauthorized reads * implemented check duplicate method in the base contract * check enclave identity duplicates * fmspc tcb duplicate check * duplicate check pckdao * duplicate check for pcs dao * new collateral issuance date must be strictly higher than the issuance date of existing collaterals * fixed incorrect enclave identity data fetcher * consistent behavior for granting and revoking dao write permission to storage * modified fmspc tcb timestamp attestation * defined external getter interface to fetch the collateral validity timestamp range * implemented getter in fmspc dao * timestamp attestation for all collaterals * moved _storeTcbInfoIssueEvaluation in FMSPC TCB DAO * added authority key identifier and subject key identifier getters for both X509 and X509 CRL helper libs * negative test case * included key identifiers in parsed struct * platform tcb event logs * emit logs via state-changes in the storage * Update FmspcTcbDao.sol * Update PckDao.sol * declare keyIdentifiers as dynamic bytes * fixed internal method to find extension values * removed keyIdentifier length check * length is still required to get the correct slice for subject key identifier * fixed _findExtensionValuePtr to break infinite loop * changes to CN parsing * fmspc tcb content hash * parsedIdentityString returns tcb string * enclave identity content hash * use internal methods to read attestation entry * updated ci build action * create2 * updated code commenting * appendix d: encode json obj as a whole, instead of individually by members * use _onFetchDataFromResolver() for collateral reads * fixes * asn1 decoder length check * asn1 length bytes should not be zero * asn1 decoder index out of bound check * do not use external calls to fetch data * stricter issuer ca check * do not store tcb evaluation twice * docs * conflict resolution isnt my strongest suit, both in code and irl * fmspc tcb merge conflict resolution * fixed enclaveiddao merge conflict resolution error * deployment scripts * updated Makefile to include contract verification * updated Makefile and README * chore: clean up and fmt * cleanup * chore: update * minor update on P256 util scripts * testnet deployment * readme formatting * world sepolia deployment * l2 mainnet deployment * fix: README World mainnet address typo * fuji deployment * polgon mainnet and bnb testnet deployment * eth mainnet and bsc mainnet deployment * updated readme * polygon amoy deployment * avax c mainnet deployment * hoodi deployment * updated readme --------- Co-authored-by: Maxim Evtush <154841002+maximevtush@users.noreply.github.com>
1 parent 352f4f6 commit eab638d

File tree

208 files changed

+13316
-7586
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+13316
-7586
lines changed

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# cast wallet address --keystore keystore/dcap_prod
2+
OWNER=
3+
4+
ETHERSCAN_API_KEY_OG=
5+
ETHERSCAN_API_KEY_BASE=
6+
ETHERSCAN_API_KEY_OPTIMISM=
7+
ETHERSCAN_API_KEY_ARBITRUM=
8+
ETHERSCAN_API_KEY_WORLDCHAIN=
9+
ETHERSCAN_API_KEY_BSC=
10+
ETHERSCAN_API_KEY_POLYGON=

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Foundry Build CI/CD
33
# Controls when the workflow will run
44
on:
55
push:
6-
branches: [main]
6+
branches: [main, development]
77
pull_request:
88
branches: [main]
99

.gitignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ broadcast/**/run-*.json
88
broadcast/**/dry-run/
99
!broadcast/**/*-latest.json
1010

11-
# Docs
12-
docs/
13-
1411
# Dotenv file
1512
.env
1613

17-
**/.DS_Store
14+
# Ignore development deployment files
15+
deployment/31337.json
1816

19-
**/node_modules/
17+
# Misc
18+
**/.DS_Store
19+
**/node_modules/
20+
**/keystore/
21+
**/.vscode

Makefile

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Configuration
2+
VERIFIER ?= etherscan
3+
VERIFIER_URL ?=
4+
WITH_STORAGE ?= true
5+
SIMULATED ?=
6+
KEYSTORE_PATH ?= keystore/dcap_prod
7+
PRIVATE_KEY ?=
8+
9+
# Required environment variables check
10+
check_env:
11+
ifdef RPC_URL
12+
$(eval CHAIN_ID := $(shell cast chain-id --rpc-url $(RPC_URL)))
13+
@echo "Chain ID: $(CHAIN_ID)"
14+
else
15+
$(error RPC_URL is not set)
16+
endif
17+
18+
# Get the Owner's Wallet Address
19+
get_owner:
20+
ifdef PRIVATE_KEY
21+
$(eval OWNER := $(shell cast wallet address --private-key $(PRIVATE_KEY)))
22+
else
23+
$(eval KEYSTORE_PASSWORD := $(shell read -s -p "Enter keystore password: " pwd; echo $$pwd))
24+
$(eval OWNER := $(shell cast wallet address --keystore $(KEYSTORE_PATH) --password $(KEYSTORE_PASSWORD) \
25+
|| (echo "Improper wallet configuration"; exit 1)))
26+
endif
27+
@echo "\nWallet Owner: $(OWNER)"
28+
29+
# Deployment targets
30+
deploy-helpers: check_env get_owner
31+
@echo "Deploying helper contracts..."
32+
@OWNER=$(OWNER) \
33+
forge script script/helper/DeployHelpers.s.sol:DeployHelpers \
34+
--rpc-url $(RPC_URL) \
35+
$(if $(PRIVATE_KEY), --private-key $(PRIVATE_KEY), \
36+
--keystore $(KEYSTORE_PATH) --password $(KEYSTORE_PASSWORD)) \
37+
$(if $(SIMULATED),, --broadcast) \
38+
$(if $(LEGACY), --legacy) \
39+
-vv
40+
@echo "Helper contracts deployed"
41+
42+
deploy-dao: check_env get_owner
43+
@echo "Deploying DAO contracts..."
44+
@if [ ! -f deployment/$(CHAIN_ID).json ]; then \
45+
echo "Helper addresses not found. Run deploy-helpers first"; \
46+
exit 1; \
47+
fi
48+
@OWNER=$(OWNER) \
49+
forge script script/automata/DeployAutomataDao.s.sol:DeployAutomataDao \
50+
--rpc-url $(RPC_URL) \
51+
$(if $(PRIVATE_KEY), --private-key $(PRIVATE_KEY), \
52+
--keystore $(KEYSTORE_PATH) --password $(KEYSTORE_PASSWORD)) \
53+
$(if $(SIMULATED),, --broadcast) \
54+
$(if $(LEGACY), --legacy) \
55+
-vv \
56+
--sig "deployAll(bool)" $(WITH_STORAGE)
57+
@echo "DAO contracts deployed"
58+
59+
deploy-all: deploy-helpers deploy-dao
60+
@echo "Deployment completed"
61+
62+
# Contract verification
63+
verify-helpers: check_env
64+
@echo "Verifying helper contracts..."
65+
@if [ ! -f deployment/$(CHAIN_ID).json ]; then \
66+
echo "Helper addresses not found. Deploy helpers first."; \
67+
exit 1; \
68+
fi
69+
@for contract in EnclaveIdentityHelper FmspcTcbHelper PCKHelper X509CRLHelper; do \
70+
addr=$$(jq -r ".$$contract" deployment/$(CHAIN_ID).json); \
71+
if [ "$$addr" != "null" ]; then \
72+
forge verify-contract \
73+
--rpc-url $(RPC_URL) \
74+
--verifier $(VERIFIER) \
75+
--watch \
76+
$(if $(VERIFIER_URL),--verifier-url $(VERIFIER_URL)) \
77+
$$addr \
78+
src/helpers/$$contract.sol:$$contract || true; \
79+
fi \
80+
done
81+
82+
verify-dao: check_env
83+
@echo "Verifying DAO contracts..."
84+
@if [ ! -f deployment/$(CHAIN_ID).json ]; then \
85+
echo "DAO addresses not found. Deploy DAOs first."; \
86+
exit 1; \
87+
fi
88+
@for contract in AutomataDaoStorage AutomataPcsDao AutomataPckDao AutomataEnclaveIdentityDao AutomataFmspcTcbDao; do \
89+
addr=$$(jq -r ".$$contract" deployment/$(CHAIN_ID).json); \
90+
if [ "$$addr" != "null" ]; then \
91+
if [ "$$contract" != "AutomataDaoStorage" ]; then \
92+
forge verify-contract \
93+
--rpc-url $(RPC_URL) \
94+
--verifier $(VERIFIER) \
95+
--watch \
96+
$(if $(VERIFIER_URL),--verifier-url $(VERIFIER_URL)) \
97+
$$addr \
98+
src/automata_pccs/$$contract.sol:$$contract || true; \
99+
else \
100+
forge verify-contract \
101+
--rpc-url $(RPC_URL) \
102+
--verifier $(VERIFIER) \
103+
--watch \
104+
$(if $(VERIFIER_URL),--verifier-url $(VERIFIER_URL)) \
105+
$$addr \
106+
src/automata_pccs/shared/AutomataDaoStorage.sol:AutomataDaoStorage || true; \
107+
fi \
108+
fi \
109+
done
110+
111+
verify-all: verify-helpers verify-dao
112+
@echo "Verification completed"
113+
114+
# Utility targets
115+
clean:
116+
forge clean
117+
118+
# Help target
119+
help:
120+
@echo "Available targets:"
121+
@echo " deploy-helpers Deploy helper contracts"
122+
@echo " deploy-dao Deploy DAO contracts"
123+
@echo " deploy-all Deploy all contracts"
124+
@echo " verify-helpers Verify helper contracts"
125+
@echo " verify-dao Verify DAO contracts"
126+
@echo " verify-all Verify all contracts"
127+
@echo " clean Remove build artifacts"
128+
@echo ""
129+
@echo "Wallet environment variables: (you only need to set one)"
130+
@echo " PRIVATE_KEY Private key for wallet"
131+
@echo " KEYSTORE_PATH Path to keystore directory"
132+
@echo ""
133+
@echo "Required environment variables:"
134+
@echo " RPC_URL RPC URL for the target network"
135+
@echo ""
136+
@echo "Optional environment variables:"
137+
@echo " VERIFIER Contract verifier (default: etherscan)"
138+
@echo " VERIFIER_URL Custom verifier API URL"
139+
@echo " ETHERSCAN_API_KEY API key for contract verification"
140+
@echo " WITH_STORAGE Deploy with storage (default: true)"
141+
@echo " SIMULATED Simulate deployment (default: false)"
142+
@echo ""
143+
@echo "Example usage:"
144+
@echo " make deploy-all RPC_URL=xxx"
145+
@echo " make verify-all RPC_URL=xxx ETHERSCAN_API_KEY=xxx"
146+
@echo " make deploy-dao PRIVATE_KEY=xxx RPC_URL=xxx SIMULATED=true"
147+
148+
.PHONY: check_env clean help deploy-% verify-%

0 commit comments

Comments
 (0)