Skip to content

Commit d736f49

Browse files
committed
Trigger key generation according to tx pointer
1 parent 1b73c2a commit d736f49

File tree

8 files changed

+313
-232
lines changed

8 files changed

+313
-232
lines changed

rolling-shutter/keyperimpl/gnosis/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ type Config struct {
3838
Shuttermint *kprconfig.ShuttermintConfig
3939
Metrics *metricsserver.MetricsConfig
4040

41-
GnosisContracts *GnosisContracts `shconfig:",required"`
41+
GnosisContracts *GnosisContracts `shconfig:",required"`
42+
EncryptedGasLimit uint64 `shconfig:",required"`
43+
MinGasPerTransaction uint64 `shconfig:",required"`
4244
}
4345

4446
type GnosisContracts struct {
@@ -63,6 +65,8 @@ func (c *Config) SetDefaultValues() error {
6365
KeyBroadcastContract: common.Address{},
6466
Sequencer: common.Address{},
6567
}
68+
c.EncryptedGasLimit = 1_000_000
69+
c.MinGasPerTransaction = 21_000
6670
return nil
6771
}
6872

rolling-shutter/keyperimpl/gnosis/database/gnosiskeyper.sqlc.gen.go

Lines changed: 82 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rolling-shutter/keyperimpl/gnosis/database/models.sqlc.gen.go

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rolling-shutter/keyperimpl/gnosis/database/sql/queries/gnosiskeyper.sql

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ INSERT INTO transaction_submitted_event (
1313
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
1414
ON CONFLICT DO NOTHING;
1515

16+
-- name: GetTransactionSubmittedEvents :many
17+
SELECT * FROM transaction_submitted_event
18+
WHERE eon = $1 AND index >= $2
19+
ORDER BY index ASC
20+
LIMIT $3;
21+
1622
-- name: SetTransactionSubmittedEventsSyncedUntil :exec
1723
INSERT INTO transaction_submitted_events_synced_until (block_number) VALUES ($1)
1824
ON CONFLICT (enforce_one_row) DO UPDATE
@@ -32,20 +38,17 @@ SELECT event_count FROM transaction_submitted_event_count
3238
WHERE eon = $1
3339
LIMIT 1;
3440

35-
-- name: GetLocalTxPointer :one
36-
SELECT local, local_block FROM tx_pointer LIMIT 1;
37-
38-
-- name: GetConsensusTxPointer :one
39-
SELECT consensus, consensus_block FROM tx_pointer LIMIT 1;
41+
-- name: GetTxPointer :one
42+
SELECT * FROM tx_pointer
43+
WHERE eon = $1;
4044

41-
-- name: UpdateLocalTxPointer :exec
42-
INSERT INTO tx_pointer (local, local_block)
43-
VALUES ($1, $2)
44-
ON CONFLICT (enforce_one_row) DO UPDATE
45-
SET local = $1, local_block = $2;
45+
-- name: InitTxPointer :exec
46+
INSERT INTO tx_pointer (eon, block, value)
47+
VALUES ($1, $2, 0)
48+
ON CONFLICT DO NOTHING;
4649

47-
-- name: UpdateConsensusTxPointer :exec
48-
INSERT INTO tx_pointer (consensus, consensus_block)
49-
VALUES ($1, $2)
50-
ON CONFLICT (enforce_one_row) DO UPDATE
51-
SET consensus = $1, consensus_block = $2;
50+
-- name: SetTxPointer :exec
51+
INSERT INTO tx_pointer (eon, block, value)
52+
VALUES ($1, $2, $3)
53+
ON CONFLICT (eon) DO UPDATE
54+
SET block = $2, value = $3;

rolling-shutter/keyperimpl/gnosis/database/sql/schemas/gnosiskeyper.sql

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
-- the schema. We'll use this to check we're using the right schema.
44

55
CREATE TABLE transaction_submitted_event (
6-
index bigint PRIMARY KEY CHECK (index >= 0),
6+
index bigint CHECK (index >= 0),
77
block_number bigint NOT NULL CHECK (block_number >= 0),
88
block_hash bytea NOT NULL,
99
tx_index bigint NOT NULL CHECK (tx_index >= 0),
1010
log_index bigint NOT NULL CHECK (log_index >= 0),
1111
eon bigint NOT NULL CHECK (eon >= 0),
1212
identity_prefix bytea NOT NULL,
1313
sender text NOT NULL,
14-
gas_limit bigint NOT NULL CHECK (gas_limit >= 0)
14+
gas_limit bigint NOT NULL CHECK (gas_limit >= 0),
15+
PRIMARY KEY (index, eon)
1516
);
1617

1718
CREATE TABLE transaction_submitted_events_synced_until(
@@ -24,17 +25,8 @@ CREATE TABLE transaction_submitted_event_count(
2425
event_count bigint NOT NULL DEFAULT 0 CHECK (event_count >= 0)
2526
);
2627

27-
-- tx_pointer stores what we know about the current value of the tx pointer. There are two
28-
-- sources that are stored independently: The keyper itself (local) and the other keypers
29-
-- (consensus). The local value is updated whenever the keyper sends decryption key shares for some
30-
-- transactions. The consensus value is updated when decryption keys are received from other
31-
-- keypers. The values can be NULL if the keyper has lost track (e.g. after a restart or if no
32-
-- messages have been received recently). Each value is annotated with the number of the block at
33-
-- whose end the tx_pointer is valid.
3428
CREATE TABLE tx_pointer(
35-
enforce_one_row bool PRIMARY KEY DEFAULT true,
36-
local bigint DEFAULT NULL,
37-
local_block bigint NOT NULL DEFAULT 0,
38-
consensus bigint DEFAULT NULL,
39-
consensus_block bigint NOT NULL DEFAULT 0
29+
eon bigint PRIMARY KEY,
30+
block bigint NOT NULL DEFAULT 0,
31+
value bigint NOT NULL DEFAULT 0
4032
);

0 commit comments

Comments
 (0)