Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
27ca74a
WIP
konradkonrad Jul 11, 2025
8ff0e83
Experiment with more complex log data
konradkonrad Jul 11, 2025
75288a7
Add type definitions
konradkonrad Jul 11, 2025
08da22b
Initial test for TriggerDefinition
konradkonrad Jul 11, 2025
d9cde75
Fixes for condensed encoding
konradkonrad Jul 15, 2025
c3698a5
Enhance complex type matching
konradkonrad Jul 16, 2025
08dac78
Make spec human friendly
konradkonrad Jul 16, 2025
f42bd00
Add initial registry contract
konradkonrad Jul 16, 2025
4d7d27b
Start condensed encoding implementation [WIP]
konradkonrad Jul 17, 2025
3968454
Updated condensed spec
konradkonrad Jul 17, 2025
d701f2b
First take of EventTriggerDefinition UnmarshalBytes
konradkonrad Jul 17, 2025
38922a4
Debugging serdes
konradkonrad Jul 18, 2025
1751a52
Fixed UnmarshalBytes
konradkonrad Jul 18, 2025
8ca9446
WIP use special event trigger contract
konradkonrad Jul 20, 2025
28d7727
Add DB functions
konradkonrad Jul 21, 2025
79a50f2
Remove unused py module
konradkonrad Jul 21, 2025
ff92413
Implement syncing
jannikluhn Jul 30, 2025
e57f4b1
Restore RegistrySyncer
jannikluhn Jul 30, 2025
93ae1d6
Use MultiEventSyncer in keyper
jannikluhn Aug 4, 2025
e8a5b71
Refactor decryption triggering
jannikluhn Aug 4, 2025
5205854
Send decryption triggers for fired triggers
jannikluhn Aug 4, 2025
3c04cdb
Squashed docker setup
jannikluhn Aug 5, 2025
5377b6f
Fix test
jannikluhn Aug 13, 2025
7dbfee2
Remove EventSignature type
jannikluhn Aug 13, 2025
f3ab189
Add event trigger marshalling tests
jannikluhn Aug 13, 2025
5a93ce0
Simplify event trigger byte format
jannikluhn Aug 13, 2025
98c2aea
Fix endianness of topic pattern
jannikluhn Aug 13, 2025
683813d
Validate address and signatures are read in full
jannikluhn Aug 13, 2025
e499a4c
Use event trigger registry from contract repo
jannikluhn Aug 17, 2025
9dbdf10
Fix trigger definition marshalling
jannikluhn Aug 17, 2025
ea390ae
Fix event trigger filter test
jannikluhn Aug 17, 2025
9639457
Use helper contract from contracts repo
jannikluhn Aug 17, 2025
07b0eb5
Fix filter query generation
jannikluhn Aug 17, 2025
28c7417
Rename config contract parameter
jannikluhn Aug 17, 2025
719be4a
Fix trigger event query
jannikluhn Aug 17, 2025
e594171
Fix trigger processor event
jannikluhn Aug 17, 2025
fbd9d07
Mark trigger events as decrypted in middleware
jannikluhn Aug 17, 2025
2b616b8
Improve event trigger data structures
jannikluhn Aug 18, 2025
2c47b86
Tidy go.mod
jannikluhn Aug 19, 2025
6ff7b49
Improve logging
jannikluhn Aug 19, 2025
e1a73c6
Valiate TTL
jannikluhn Aug 19, 2025
cf29631
Only handle event based triggers if enabled
jannikluhn Aug 19, 2025
8141167
Cleanup newblock
jannikluhn Aug 19, 2025
6c7ae0a
Fix linting errors
jannikluhn Aug 19, 2025
d81c17d
Fix tests
jannikluhn Aug 19, 2025
38829b5
Handle context cancellations when sending triggers
jannikluhn Aug 19, 2025
d69ca8a
Use identity from db instead of recomputing
jannikluhn Aug 19, 2025
a7c41bc
Fix fired trigger rollback
jannikluhn Aug 19, 2025
b2e4d3c
Remove unused db query
jannikluhn Aug 21, 2025
a15c58b
Include eon in primary key
jannikluhn Aug 21, 2025
ac5c293
Simplify IsTopic check
jannikluhn Aug 21, 2025
6f53ac9
Return error instead of panicking in Match
jannikluhn Aug 21, 2025
c0aeb00
Fix primary key constraint checks
jannikluhn Sep 2, 2025
cb2294e
Add event trigger test scripts
jannikluhn Sep 2, 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
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
circleci 0.1.31425
golang 1.23.6
golang 1.24.5
golangci-lint 1.64.5
nodejs 18.17.0
postgres 14.2
Expand Down
1 change: 1 addition & 0 deletions docker-test-setup-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/data
5 changes: 5 additions & 0 deletions docker-test-setup-api/00-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

source ./common.sh

$DC --profile dev build
24 changes: 24 additions & 0 deletions docker-test-setup-api/01-init-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

source ./common.sh

mkdb() {
$DC exec -T db createdb -U postgres $1
$DC run -T --rm --no-deps $1 initdb --config /config/${1}.toml
}

$DC stop db
$DC rm -f db

${BB} rm -rf data/db

$DC up -d db
$DC run --rm --no-deps wait-for-db

for cmd in keyper-0 keyper-1 keyper-2; do
mkdb $cmd &
done

wait

$DC stop db
67 changes: 67 additions & 0 deletions docker-test-setup-api/02-init-chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

source ./common.sh

$DC stop blockchain
$DC rm -f blockchain
$DC stop chain-{0..2}-validator chain-seed
$DC rm -f chain-{0..2}-validator chain-seed

${BB} rm -rf data/chain-{0..2}-validator data/chain-seed
${BB} mkdir -p data/chain-{0..2}-validator/config data/chain-seed/config
${BB} chmod -R a+rwX data/chain-{0..2}-validator/config data/chain-seed/config
${BB} rm -rf data/deployments

# has blockchain as dependency
$DC up -d blockchain
sleep 5
$DC up deploy-contracts
$DC run --rm contract-scripts --broadcast --rpc-url http://blockchain:8545 ./script/DeployEventTriggerTestHelper.service.s.sol:DeployEventTriggerTestHelperScript

bash get-contracts.sh
# setup chain-seed
$DC run --rm --no-deps chain-seed init \
--root /chain \
--blocktime 1 \
--listen-address tcp://0.0.0.0:${TM_RPC_PORT} \
--role seed

seed_node=$(cat data/chain-seed/config/node_key.json.id)@chain-seed:${TM_P2P_PORT}

${BB} sed -i "/^moniker/c\moniker = \"chain-seed\"" data/chain-seed/config/config.toml

# configure validators and keypers 0-2
for num in {0..2}; do
validator_cmd=chain-$num-validator

$DC run --rm --no-deps ${validator_cmd} init \
--root /chain \
--genesis-keyper 0x440Dc6F164e9241F04d282215ceF2780cd0B755e \
--blocktime 1 \
--listen-address tcp://0.0.0.0:${TM_RPC_PORT} \
--role validator

validator_id=$(cat data/${validator_cmd}/config/node_key.json.id)
validator_node=${validator_id}@${validator_cmd}:${TM_P2P_PORT}
validator_config_path=data/${validator_cmd}/config/config.toml

# share genesis
if [ $num -eq 0 ]; then
for destination in data/chain-seed/config/ data/chain-{1..2}-validator/config/; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, this is a copy and past from elsewhere, but I think this could just be:

Suggested change
for destination in data/chain-seed/config/ data/chain-{1..2}-validator/config/; do
for destination in data/chain-seed/config/ data/chain-${num}-validator/config/; do

or it could be pulled out of the for num in {0..2}; do-loop and just be

for destination in data/chain-seed/config/ data/chain-{1..2}-validator/config/; do
  ${BB} cp -v data/chain-0-validator/config/genesis.json "${destination}"
done

${BB} cp -v data/chain-0-validator/config/genesis.json "${destination}"
done
fi

# set validator publickey for keyper
${BB} sed -i "/ValidatorPublicKey/c\ValidatorPublicKey = \"$(cat data/${validator_cmd}/config/priv_validator_pubkey.hex)\"" /config/keyper-${num}.toml

# set seed node for chain bootstrap
${BB} sed -i "/^seeds =/c\seeds = \"${seed_node}\"" "${validator_config_path}"
# fix external address for docker internal communication
${BB} sed -i "/^external_address =/c\external_address = \"${validator_cmd}:${TM_P2P_PORT}\"" "${validator_config_path}"
# give a nice name
${BB} sed -i "/^moniker/c\moniker = \"${validator_cmd}\"" "${validator_config_path}"

done

$DC stop -t 30
6 changes: 6 additions & 0 deletions docker-test-setup-api/03-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source ./common.sh

echo "Starting entire system"
$DC up -d
22 changes: 22 additions & 0 deletions docker-test-setup-api/04-addkeyperset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

source ./common.sh
source .env
set -e

CONTRACTS_JSON=$(jq '.transactions[]|(select(.function==null))|{(.contractName|tostring): .contractAddress}' data/deployments/Deploy.service.s.sol/31337/run-latest.json)

for s in $(echo ${CONTRACTS_JSON} | jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")| .[] "); do
export $s
done

# Get keyper addresses from node-deploy.json
export KEYPER_ADDRESSES=$(jq -r '.keypers[0] | join(",")' config/node-deploy.json)

echo "Submitting Add Keyper Set transaction"
export THRESHOLD=2
export KEYPERSETMANAGER_ADDRESS=${KeyperSetManager}
export KEYBROADCAST_ADDRESS=${KeyBroadcastContract}
export ACTIVATION_DELTA=10

$DC run --rm --no-deps add-keyper-set
11 changes: 11 additions & 0 deletions docker-test-setup-api/05-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

source ./common.sh

echo "Submitting bootstrap transaction"

$DC run --rm --no-deps --entrypoint /rolling-shutter chain-0-validator op-bootstrap fetch-keyperset \
--config /config/op-bootstrap.toml

$DC run --rm --no-deps --entrypoint /rolling-shutter chain-0-validator op-bootstrap \
--config /config/op-bootstrap.toml
34 changes: 34 additions & 0 deletions docker-test-setup-api/06-test-decryption.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

source ./common.sh
set -e

echo "Submitting identity registration transaction"

CONTRACTS_JSON=$(jq '.transactions[]|(select(.function==null))|{(.contractName|tostring): .contractAddress}' data/deployments/Deploy.service.s.sol/31337/run-latest.json)

for s in $(echo ${CONTRACTS_JSON} | jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")| .[] "); do
export $s
done

export TIMESTAMP=$(($(date +%s) + 50))
export IDENTITY_PREFIX=0x$(LC_ALL=C tr -dc 'a-f0-9' </dev/urandom | head -c64)
export REGISTRY_ADDRESS=${ShutterRegistry}
export EON=$($DC exec db psql -U postgres -d keyper-0 -t -c 'select max(eon) from eons;' | tr -d '[:space:]')
if [[ -z $EON ]]; then
echo "No eonId found in keyper-0 db. Did you run bootstrap?"
exit 1
fi

${DC} run --rm --no-deps register-identity
sleep 55

DECRYPTION_KEY_MSGS=$(${DC} logs keyper-0 | grep ${EON} | grep -c decryptionKey)
echo "DECRYPTION_KEY_MSGS: ${DECRYPTION_KEY_MSGS}"
if [[ $DECRYPTION_KEY_MSGS -gt 0 ]]; then
echo "Decryption successful with $DECRYPTION_KEY_MSGS / 3 nodes"
exit 0
else
echo "Decryption failed"
exit 1
fi
6 changes: 6 additions & 0 deletions docker-test-setup-api/90-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source ./common.sh

echo "Stopping entire system"
$DC down
16 changes: 16 additions & 0 deletions docker-test-setup-api/build-src/deploy_contracts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM alpine/git AS builder

ADD https://api.github.com/repos/shutter-network/contracts/git/refs/heads/event-trigger-registry /tmp/version.json
RUN git clone --branch=event-trigger-registry https://github.com/shutter-network/contracts /contracts
RUN cd /contracts && git submodule update --init --recursive

FROM --platform=linux/amd64 ghcr.io/foundry-rs/foundry AS runner
WORKDIR /contracts
COPY --from=builder --chown=foundry:foundry /contracts /contracts

RUN git config --global --add safe.directory /contracts

USER foundry
RUN forge install
RUN forge build
ENTRYPOINT ["forge", "script"]
6 changes: 6 additions & 0 deletions docker-test-setup-api/build-src/setup-blockchain/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# syntax=docker/dockerfile:1.4
FROM --platform=linux/amd64 ghcr.io/foundry-rs/foundry

WORKDIR /anvil

ENTRYPOINT anvil --host 0.0.0.0 -p 8545 -b 2 --dump-state /data/blockchain.json
11 changes: 11 additions & 0 deletions docker-test-setup-api/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
BB="docker run --rm -v $(pwd)/data:/data -v $(pwd)/config:/config -w / busybox"
TM_P2P_PORT=26656
TM_RPC_PORT=26657

if docker compose ls >/dev/null 2>&1; then
DC="docker compose"
else
DC=docker-compose
fi

set -xe
21 changes: 21 additions & 0 deletions docker-test-setup-api/config/bootstrap.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Peer identity: /p2p/12D3KooWJN7262vmnEQHkYG7VrZDwz9fMyJtHyvGp4XSenuUYfeJ
# Peer role: bootstrap

# whether to register handlers on the messages and log them
InstanceID = 0
ListenMessages = true

[P2P]
P2PKey = "CAESQKFtiMAqd2c8bQ/mfPStxViY970MNtWUVWdn44rUoQXAfv7ztSQ9nLeqliXrkuqKi3XUObyAfH+Py3eMbHFvIpM="
ListenAddresses = ["/ip4/0.0.0.0/tcp/23000"]
# Overwrite p2p boostrap nodes
CustomBootstrapAddresses = [
"/dns4/bootnode-0/tcp/23000/p2p/12D3KooWJN7262vmnEQHkYG7VrZDwz9fMyJtHyvGp4XSenuUYfeJ",
]
IsAccessNode = false
DiscoveryNamespace = "shutter-local"

[P2P.FloodSubDiscovery]
Enabled = false
Interval = 10
Topics = []
55 changes: 55 additions & 0 deletions docker-test-setup-api/config/keyper-0.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Peer identity: /p2p/12D3KooWQ8iKQe4iEfkTh3gdBtpxWsKwx3BwrA18km5rq3Zwt2QF
# Ethereum address: 0xCDD50A6F9B1439dc14c4f2A7eaF14dA1EF5A476c


InstanceID = 0
# If it's empty, we use the standard PG_ environment variables
DatabaseURL = "postgres://postgres@db:5432/keyper-0"
HTTPEnabled = false
HTTPListenAddress = ':3000'
MaxNumKeysPerMessage = 500

[P2P]
P2PKey = 'CAESQJ3NdZ6mRrDAW/Z59OKwcKdOCbZQ45z5o8K+tLHOL8Xw1LbawPZLk3mXNyiDyADcLk1bqYMe3uQ6T8xi65zkM0A='
ListenAddresses = ["/ip4/0.0.0.0/tcp/23000"]
# Overwrite p2p boostrap nodes
CustomBootstrapAddresses = [
"/dns4/bootnode-0/tcp/23000/p2p/12D3KooWJN7262vmnEQHkYG7VrZDwz9fMyJtHyvGp4XSenuUYfeJ",
]
DiscoveryNamespace = 'shutter-local'
# Optional, to be set to true if running an access node
IsAccessNode = false

[P2P.FloodSubDiscovery]
Enabled = false
Interval = 10
Topics = []

[Chain]
SyncStartBlockNumber = 0
SyncMonitorCheckInterval = 60

[Chain.Node]
PrivateKey = '82904d1c48d3a27d218408fc2db3e743f554a69b05b91d28c2897a9026ea47df'
# Contract source directory
DeploymentDir = '/deployments/localhost/'
# The layer 1 JSON RPC endpoint
EthereumURL = "ws://blockchain:8545/"

[Chain.Contracts]
KeyperSetManager = "0x5fbdb2315678afecb367f032d93f642f64180aa3"
ShutterRegistry = "0x0165878a594ca255338adfa4d48449f69242eb8f"
ShutterEventTriggerRegistry = "0xa513e6e4b8f2a923d98304ec87f64353c4d5c853"
KeyBroadcastContract = "0x5fc8d32690cc91d4c39d9d3abcbd16989f875707"

[Shuttermint]
ShuttermintURL = "http://chain-0-validator:26657"
ValidatorPublicKey = "f015590ac9416b1b51d81a5cdb3756c2a5194af42d376c7abc2fa833854cd0df"
EncryptionKey = '6bf7e6c8d6753d435f885f398f62f221a84f0ccb0c5e2a382290489441e16f77'
DKGPhaseLength = 8
DKGStartBlockDelta = 5

[Metrics]
Enabled = true
Host = "[::]"
Port = 9100
55 changes: 55 additions & 0 deletions docker-test-setup-api/config/keyper-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Peer identity: /p2p/12D3KooWGksg5G2oau6EgdJFLiQoKaMvzPJnTCuoPScZcmZRdkny
# Ethereum address: 0x539cF80D345d26525A47dB80De0fAb147D588fDa


InstanceID = 0
# If it's empty, we use the standard PG_ environment variables
DatabaseURL = "postgres://postgres@db:5432/keyper-1"
HTTPEnabled = false
HTTPListenAddress = ':3000'
MaxNumKeysPerMessage = 500

[P2P]
P2PKey = 'CAESQO+t2CR93jdMq/FDqZf2+KIY9kLhKA1rZY9WFherSqvZZxzY8W4y5hSBrW5u79SDCvbLcmo7kEwu6VsK0NjZnxY='
ListenAddresses = ["/ip4/0.0.0.0/tcp/23000"]
# Overwrite p2p boostrap nodes
CustomBootstrapAddresses = [
"/dns4/bootnode-0/tcp/23000/p2p/12D3KooWJN7262vmnEQHkYG7VrZDwz9fMyJtHyvGp4XSenuUYfeJ",
]
DiscoveryNamespace = 'shutter-local'
# Optional, to be set to true if running an access node
IsAccessNode = false

[P2P.FloodSubDiscovery]
Enabled = false
Interval = 10
Topics = []

[Chain]
SyncStartBlockNumber = 0
SyncMonitorCheckInterval = 60

[Chain.Node]
PrivateKey = '939babbad75cbcc42eef92496ce86ede989ba96918bbc6cc0efcc498f9cc0887'
# Contract source directory
DeploymentDir = '/deployments/localhost/'
# The layer 1 JSON RPC endpoint
EthereumURL = "ws://blockchain:8545/"

[Chain.Contracts]
KeyperSetManager = "0x5fbdb2315678afecb367f032d93f642f64180aa3"
ShutterRegistry = "0x0165878a594ca255338adfa4d48449f69242eb8f"
ShutterEventTriggerRegistry = "0xa513e6e4b8f2a923d98304ec87f64353c4d5c853"
KeyBroadcastContract = "0x5fc8d32690cc91d4c39d9d3abcbd16989f875707"

[Shuttermint]
ShuttermintURL = "http://chain-0-validator:26657"
ValidatorPublicKey = "2f2706f1e80406a7c9cba52ca917421b835f54820fa3fc90c5763fe84e1a4e89"
EncryptionKey = 'd10fcd3a9db97ecf80a41b5fb30bb91ea16bf6a8575e389912a335b19cc4b3b8'
DKGPhaseLength = 8
DKGStartBlockDelta = 5

[Metrics]
Enabled = true
Host = "[::]"
Port = 9100
Loading