Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shutter: decryption keys listener #13306

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
306752e
erigon-lib: move event notifier and observers to erigon-lib
taratorio Jan 2, 2025
08e99fb
shutter: add decryption keys listener
taratorio Jan 2, 2025
4c4d492
Merge branch 'main' of github.com:ledgerwatch/erigon into shutter-dec…
taratorio Jan 2, 2025
22eab44
register decryption key processor observer
taratorio Jan 2, 2025
d1b2189
eg with ctx
taratorio Jan 2, 2025
aa9c8e2
Merge branch 'main' of github.com:ledgerwatch/erigon into shutter-dec…
taratorio Jan 2, 2025
19aeee1
wip: set opts
taratorio Jan 2, 2025
95a9e19
set libp2p options
taratorio Jan 3, 2025
ba1733e
Merge branch 'main' of github.com:ledgerwatch/erigon into shutter-dec…
taratorio Jan 3, 2025
67ab927
tidy
taratorio Jan 3, 2025
e1f8503
tidy
taratorio Jan 3, 2025
29aef15
todo
taratorio Jan 3, 2025
04e5fda
add shutter.proto
taratorio Jan 3, 2025
9b1c731
fix makefile
taratorio Jan 3, 2025
97f97aa
Merge branch 'main' of github.com:ledgerwatch/erigon into shutter-dec…
taratorio Jan 3, 2025
97f5187
tidy
taratorio Jan 3, 2025
5b08a22
tidy
taratorio Jan 3, 2025
1489fb9
Merge branch 'main' of github.com:ledgerwatch/erigon into shutter-dec…
taratorio Jan 7, 2025
7242d70
add proto unmarshalling
taratorio Jan 7, 2025
160f0ec
add peer info loop for top
taratorio Jan 7, 2025
8aac990
wire initial decryption keys validator
taratorio Jan 7, 2025
9c40035
Merge branch 'main' of github.com:ledgerwatch/erigon into shutter-dec…
taratorio Jan 7, 2025
e53742a
tidy
taratorio Jan 7, 2025
f08931e
tidy
taratorio Jan 7, 2025
939d103
tidy
taratorio Jan 7, 2025
28143e8
Merge branch 'main' of github.com:ledgerwatch/erigon into shutter-dec…
taratorio Jan 8, 2025
2c28c1d
improve tests with decryption key message mock creation func
taratorio Jan 8, 2025
6988682
tidy
taratorio Jan 8, 2025
13bd2b8
add MaxNumKeysPerMessage validation
taratorio Jan 8, 2025
d7cef53
add more test cases for validator
taratorio Jan 8, 2025
92302f9
tidy
taratorio Jan 8, 2025
5098f85
tidy
taratorio Jan 8, 2025
e5932ce
use same node identity based on nodekey
taratorio Jan 8, 2025
3d55bf5
tidy
taratorio Jan 8, 2025
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
28 changes: 18 additions & 10 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1092,13 +1092,17 @@ var (
Usage: "Enable 'chaos monkey' to generate spontaneous network/consensus/etc failures. Use ONLY for testing",
Value: false,
}
ShutterEnabled = cli.BoolFlag{
ShutterEnabledFlag = cli.BoolFlag{
Name: "shutter",
Usage: "Enable the Shutter encrypted transactions mempool (defaults to false)",
}
ShutterKeyperBootnodes = cli.StringSliceFlag{
Name: "shutter.keyper.bootnodes",
Usage: "Use to override the default keyper bootnodes (defaults to using the bootnodes from the embedded config)",
ShutterP2pBootstrapNodesFlag = cli.StringSliceFlag{
Name: "shutter.p2p.bootstrap.nodes",
Usage: "Use to override the default p2p bootstrap nodes (defaults to using the values in the embedded config)",
}
ShutterP2pListenPortFlag = cli.UintFlag{
Name: "shutter.p2p.listen.port",
Usage: "Use to override the default p2p listen port (defaults to 23102)",
}
)

Expand Down Expand Up @@ -1583,18 +1587,22 @@ func setTxPool(ctx *cli.Context, dbDir string, fullCfg *ethconfig.Config) {
fullCfg.TxPool = cfg
}

func setShutter(ctx *cli.Context, chainName string, cfg *ethconfig.Config) {
if enabled := ctx.Bool(ShutterEnabled.Name); !enabled {
func setShutter(ctx *cli.Context, chainName string, nodeConfig *nodecfg.Config, ethConfig *ethconfig.Config) {
if enabled := ctx.Bool(ShutterEnabledFlag.Name); !enabled {
return
}

config := shutter.ConfigByChainName(chainName)
config.PrivateKey = nodeConfig.P2P.PrivateKey
// check for cli overrides
if ctx.IsSet(ShutterKeyperBootnodes.Name) {
config.KeyperBootnodes = ctx.StringSlice(ShutterKeyperBootnodes.Name)
if ctx.IsSet(ShutterP2pBootstrapNodesFlag.Name) {
config.BootstrapNodes = ctx.StringSlice(ShutterP2pBootstrapNodesFlag.Name)
}
if ctx.IsSet(ShutterP2pListenPortFlag.Name) {
config.ListenPort = ctx.Uint64(ShutterP2pListenPortFlag.Name)
}

cfg.Shutter = config
ethConfig.Shutter = config
}

func setEthash(ctx *cli.Context, datadir string, cfg *ethconfig.Config) {
Expand Down Expand Up @@ -1922,7 +1930,7 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
setGPO(ctx, &cfg.GPO)

setTxPool(ctx, nodeConfig.Dirs.TxPool, cfg)
setShutter(ctx, chain, cfg)
setShutter(ctx, chain, nodeConfig, cfg)

setEthash(ctx, nodeConfig.Dirs.DataDir, cfg)
setClique(ctx, &cfg.Clique, nodeConfig.Dirs.DataDir)
Expand Down
5 changes: 3 additions & 2 deletions turbo/cli/default_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ var DefaultFlags = []cli.Flag{

&utils.ChaosMonkeyFlag,

&utils.ShutterEnabled,
&utils.ShutterKeyperBootnodes,
&utils.ShutterEnabledFlag,
&utils.ShutterP2pBootstrapNodesFlag,
&utils.ShutterP2pListenPortFlag,
}
1 change: 1 addition & 0 deletions txnprovider/shutter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
37 changes: 37 additions & 0 deletions txnprovider/shutter/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
GOBINREL = build/bin
GOBIN = $(CURDIR)/$(GOBINREL)

OS = $(shell uname -s)
ARCH = $(shell uname -m)

ifeq ($(OS),Darwin)
PROTOC_OS := osx
ifeq ($(ARCH),arm64)
ARCH = aarch_64
endif
endif
ifeq ($(OS),Linux)
PROTOC_OS = linux
endif

PROTOC_INCLUDE = build/include/google
PROTO_DIR = $(CURDIR)/proto

$(GOBINREL):
mkdir -p "$(GOBIN)"

$(GOBINREL)/protoc: $(GOBINREL)
$(eval PROTOC_TMP := $(shell mktemp -d))
curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-$(PROTOC_OS)-$(ARCH).zip -o "$(PROTOC_TMP)/protoc.zip"
cd "$(PROTOC_TMP)" && unzip protoc.zip
cp "$(PROTOC_TMP)/bin/protoc" "$(GOBIN)"
mkdir -p "$(PROTOC_INCLUDE)"
cp -R "$(PROTOC_TMP)/include/google/" "$(PROTOC_INCLUDE)"
rm -rf "$(PROTOC_TMP)"

$(GOBINREL)/protoc-gen-go: $(GOBINREL)
go build -o "$(GOBIN)/protoc-gen-go" google.golang.org/protobuf/cmd/protoc-gen-go

.PHONY: proto
proto: $(GOBINREL)/protoc $(GOBINREL)/protoc-gen-go
PATH="$(GOBIN):$(PATH)" protoc -I=$(PROTO_DIR) --go_out=$(PROTO_DIR) $(PROTO_DIR)/shutter.proto
75 changes: 59 additions & 16 deletions txnprovider/shutter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,48 @@
package shutter

import (
"crypto/ecdsa"

"github.com/libp2p/go-libp2p/core/peer"
"github.com/multiformats/go-multiaddr"

"github.com/erigontech/erigon-lib/chain/networkname"
"github.com/erigontech/erigon/params"
)

type Config struct {
Enabled bool `json:"-"`
InstanceId uint64 `json:"instanceId"`
SequencerContractAddress string `json:"sequencerContractAddress"`
ValidatorRegistryContractAddress string `json:"validatorRegistryContractAddress"`
KeyBroadcastContractAddress string `json:"keyBroadcastContractAddress"`
KeyperSetManagerContractAddress string `json:"keyperSetManagerContractAddress"`
KeyperBootnodes []string `json:"keyperBootnodes"`
P2pConfig
Enabled bool
InstanceId uint64
SequencerContractAddress string
ValidatorRegistryContractAddress string
KeyBroadcastContractAddress string
KeyperSetManagerContractAddress string
MaxNumKeysPerMessage uint64
}

type P2pConfig struct {
PrivateKey *ecdsa.PrivateKey
ListenPort uint64
BootstrapNodes []string
}

func (c P2pConfig) BootstrapNodesAddrInfo() ([]peer.AddrInfo, error) {
addrInfos := make([]peer.AddrInfo, len(c.BootstrapNodes))
for i, node := range c.BootstrapNodes {
ma, err := multiaddr.NewMultiaddr(node)
if err != nil {
return nil, err
}

ai, err := peer.AddrInfoFromP2pAddr(ma)
if err != nil {
return nil, err
}

addrInfos[i] = *ai
}

return addrInfos, nil
}

func ConfigByChainName(chainName string) Config {
Expand All @@ -45,27 +75,40 @@ func ConfigByChainName(chainName string) Config {
var (
chiadoConfig = Config{
Enabled: true,
InstanceId: params.ChiadoChainConfig.ChainID.Uint64(),
InstanceId: 102_000,
SequencerContractAddress: "0x2aD8E2feB0ED5b2EC8e700edB725f120576994ed",
ValidatorRegistryContractAddress: "0xa9289A3Dd14FEBe10611119bE81E5d35eAaC3084",
KeyBroadcastContractAddress: "0x9D31865BEffcE842FBd36CDA587aDDA8bef804B7",
KeyperSetManagerContractAddress: "0xC4DE9FAf4ec882b33dA0162CBE628B0D8205D0c0",
KeyperBootnodes: []string{
"/ip4/167.99.177.227/tcp/23005/p2p/12D3KooWSdm5guPBdn8DSaBphVBzUUgPLg9sZLnazEUrcbtLy254",
"/ip4/159.89.15.119/tcp/23005/p2p/12D3KooWPP6bp2PJQR8rUvG1SD4qNH4WFrKve6DMgWThyKxwNbbH",
MaxNumKeysPerMessage: defaultMaxNumKeysPerMessage,
P2pConfig: P2pConfig{
ListenPort: defaultP2PListenPort,
BootstrapNodes: []string{
"/ip4/167.99.177.227/tcp/23005/p2p/12D3KooWSdm5guPBdn8DSaBphVBzUUgPLg9sZLnazEUrcbtLy254",
"/ip4/159.89.15.119/tcp/23005/p2p/12D3KooWPP6bp2PJQR8rUvG1SD4qNH4WFrKve6DMgWThyKxwNbbH",
},
},
}

gnosisConfig = Config{
Enabled: true,
InstanceId: params.GnosisChainConfig.ChainID.Uint64(),
InstanceId: 1_000,
SequencerContractAddress: "0xc5C4b277277A1A8401E0F039dfC49151bA64DC2E",
ValidatorRegistryContractAddress: "0xefCC23E71f6bA9B22C4D28F7588141d44496A6D6",
KeyBroadcastContractAddress: "0x626dB87f9a9aC47070016A50e802dd5974341301",
KeyperSetManagerContractAddress: "0x7C2337f9bFce19d8970661DA50dE8DD7d3D34abb",
KeyperBootnodes: []string{
"/ip4/167.99.177.227/tcp/23003/p2p/12D3KooWD35AESYCttDEi3J5WnQdTFuM5JNtmuXEb1x4eQ28gb1s",
"/ip4/159.89.15.119/tcp/23003/p2p/12D3KooWRzAhgPA16DiBQhiuYoasYzJaQSAbtc5i5FvgTi9ZDQtS",
MaxNumKeysPerMessage: defaultMaxNumKeysPerMessage,
P2pConfig: P2pConfig{
ListenPort: defaultP2PListenPort,
BootstrapNodes: []string{
"/ip4/167.99.177.227/tcp/23003/p2p/12D3KooWD35AESYCttDEi3J5WnQdTFuM5JNtmuXEb1x4eQ28gb1s",
"/ip4/159.89.15.119/tcp/23003/p2p/12D3KooWRzAhgPA16DiBQhiuYoasYzJaQSAbtc5i5FvgTi9ZDQtS",
},
},
}
)

const (
defaultP2PListenPort = 23_102
defaultMaxNumKeysPerMessage = 500
)
Loading