Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BSC_CLUSTER_SIZE=5
SPC_CLUSTER_SIZE=5
CHAIN_ID=714
KEYPASS="0123456789"
INIT_HOLDER="0x04d63aBCd2b9b1baa327f2Dda0f873F197ccd186"
Expand All @@ -11,7 +11,7 @@ FullImmutabilityThreshold=2048
MinBlocksForBlobRequests=576
DefaultExtraReserveForBlobRequests=32
BreatheBlockInterval=1200
useLatestBscClient=false
useLatestSpcClient=false
EnableSentryNode=false
EnableFullNode=false
RegisterNodeID=false
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

.idea/
lib/
node_modules/
5 changes: 2 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[submodule "genesis"]
path = genesis
url = https://github.com/bnb-chain/bsc-genesis-contract.git
branch = master
ignore = dirty
url = https://github.com/simplechain-org/bsc-genesis-contract.git
branch = develop/v1.0.1
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# BSC Node Docker Image
FROM ubuntu:20.04

# Install dependencies
RUN apt-get update && apt-get install -y \
wget \
jq \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Create user
RUN useradd -m -s /bin/bash sipc2

# Set working directory
WORKDIR /home/sipc2

# Copy sipc2 binary and configuration
COPY bin/geth /usr/local/bin/geth
RUN chmod +x /usr/local/bin/geth

# Copy scripts
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

# Create data directory
RUN mkdir -p /home/sipc2/data

# Set ownership
RUN chown -R sipc2:sipc2 /home/sipc2

# Switch to sipc2 user
USER sipc2

# Expose ports
EXPOSE 8545 8546 30303

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8545 || exit 1

# Set entrypoint
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Deployment tools of BSC
# Deployment tools of SPC


## Installation
Expand Down Expand Up @@ -43,35 +43,35 @@ go build
5. Setup all nodes.
two different ways, choose as you like.
```bash
bash -x ./bsc_cluster.sh reset # will reset the cluster and start
# The 'vidx' parameter is optional. If provided, its value must be in the range [0, ${BSC_CLUSTER_SIZE}). If omitted, it affects all clusters.
bash -x ./bsc_cluster.sh stop [vidx] # Stops the cluster
bash -x ./bsc_cluster.sh start [vidx] # only start the cluster
bash -x ./bsc_cluster.sh restart [vidx] # start the cluster after stopping it
bash -x ./spc_cluster.sh reset # will reset the cluster and start
# The 'vidx' parameter is optional. If provided, its value must be in the range [0, ${SPC_CLUSTER_SIZE}). If omitted, it affects all clusters.
bash -x ./spc_cluster.sh stop [vidx] # Stops the cluster
bash -x ./spc_cluster.sh start [vidx] # only start the cluster
bash -x ./spc_cluster.sh restart [vidx] # start the cluster after stopping it
```

6. Setup a full node.
If you want to run a full node to test snap/full syncing, you can run:

> Attention: it relies on the validator cluster, so you should set up validators by `bsc_cluster.sh` firstly.
> Attention: it relies on the validator cluster, so you should set up validators by `spc_cluster.sh` firstly.

```bash
# start a full sync node0
bash +x ./bsc_fullnode.sh start 0 full
bash +x ./spc_fullnode.sh start 0 full
# start a snap sync node1
bash +x ./bsc_fullnode.sh start 1 snap
bash +x ./spc_fullnode.sh start 1 snap
# restart the snap sync node1
bash +x ./bsc_fullnode.sh restart 1 snap
bash +x ./spc_fullnode.sh restart 1 snap
# stop the snap sync node1
bash +x ./bsc_fullnode.sh stop 1 snap
bash +x ./spc_fullnode.sh stop 1 snap
# clean the snap sync node1
bash +x ./bsc_fullnode.sh clean 1 snap
bash +x ./spc_fullnode.sh clean 1 snap
# start a snap sync node as fast node
bash +x ./bsc_fullnode.sh start 2 snap "--tries-verify-mode none"
bash +x ./spc_fullnode.sh start 2 snap "--tries-verify-mode none"
# start a snap sync node with prune ancient
bash +x ./bsc_fullnode.sh start 3 snap "--pruneancient"
bash +x ./spc_fullnode.sh start 3 snap "--pruneancient"
# start pruneblock for a node
bash +x ./bsc_fullnode.sh pruneblock 3 snap
bash +x ./spc_fullnode.sh pruneblock 3 snap
```

You can see the logs in `.local/fullnode`.
Expand Down
5 changes: 3 additions & 2 deletions config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Eth]
NetworkId = 714
NetworkId = 1914
SyncMode = "full"
NoPruning = false
NoPrefetch = false
Expand Down Expand Up @@ -40,6 +40,7 @@ GlobalQueue = 1024
Lifetime = 10800000000000

[Node]
DataDir = "/data"
IPCPath = "geth.ipc"
HTTPHost = "0.0.0.0"
InsecureUnlockAllowed = true
Expand All @@ -66,7 +67,7 @@ WriteTimeout = 30000000000
IdleTimeout = 120000000000

[Node.LogConfig]
FilePath = "bsc.log"
FilePath = "spc.log"
TimeFormat = "01-02|15:04:05.000"
MaxBackups = 1000
MaxBytesSize = 10485760
Expand Down
18 changes: 12 additions & 6 deletions create-validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ var (
consensusKeyDir = flag.String("consensus-key-dir", "", "consensus keys dir")
voteKeyDir = flag.String("vote-key-dir", "", "vote keys dir")
passwordPath = flag.String("password-path", "", "password dir")
operatorKeyDir = flag.String("operator-key-dir", "", "operator keys dir")
)

func main() {
flag.Parse()

if *consensusKeyDir == "" {
panic("consensus-keys-dir is required")
}
Expand All @@ -43,6 +43,9 @@ func main() {
if *passwordPath == "" {
panic("password-path is required")
}
if *operatorKeyDir == "" {
*operatorKeyDir = *consensusKeyDir
}

client, err := ethclient.Dial(*rpcUrl)
if err != nil {
Expand All @@ -56,9 +59,12 @@ func main() {
password := string(bytes.TrimSpace(bz))

consensusKs := keystore.NewKeyStore(*consensusKeyDir+"/keystore", keystore.StandardScryptN, keystore.StandardScryptP)
operatorKs := keystore.NewKeyStore(*operatorKeyDir+"/keystore", keystore.StandardScryptN, keystore.StandardScryptP)
consensusAddr := consensusKs.Accounts()[0].Address
consensusAcc := accounts.Account{Address: consensusAddr}
err = consensusKs.Unlock(consensusAcc, password)

operatorAddr := operatorKs.Accounts()[0].Address
operatorAcc := accounts.Account{Address: operatorAddr}
err = operatorKs.Unlock(operatorAcc, password)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -94,7 +100,7 @@ func main() {
paddedChainIdBytes := make([]byte, 32)
copy(paddedChainIdBytes[32-len(chainId.Bytes()):], chainId.Bytes())

msgHash := crypto.Keccak256(append(consensusAddr.Bytes(), append(pubKey[:], paddedChainIdBytes...)...))
msgHash := crypto.Keccak256(append(operatorAddr.Bytes(), append(pubKey[:], paddedChainIdBytes...)...))
req := validatorpb.SignRequest{
PublicKey: pubKey[:],
SigningRoot: msgHash,
Expand All @@ -114,7 +120,7 @@ func main() {
panic(err)
}

nonce, err := client.PendingNonceAt(context.Background(), consensusAddr)
nonce, err := client.PendingNonceAt(context.Background(), operatorAddr)
if err != nil {
panic(err)
}
Expand All @@ -132,7 +138,7 @@ func main() {
Data: data,
})

signedTx, err := consensusKs.SignTx(consensusAcc, tx, chainId)
signedTx, err := operatorKs.SignTx(operatorAcc, tx, chainId)
if err != nil {
panic(err)
}
Expand Down
Loading