Skip to content

Commit

Permalink
EDB: rename user to ten and grant full db permissions (#2045)
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel authored Sep 5, 2024
1 parent 6e135eb commit b2f1211
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
51 changes: 19 additions & 32 deletions go/enclave/storage/init/edgelessdb/001_init.sql
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
CREATE USER "obscuro" REQUIRE ISSUER "/CN=obscuroCA" SUBJECT "/CN=obscuroUser";
CREATE DATABASE obsdb;
CREATE USER "ten" REQUIRE ISSUER "/CN=tenCA" SUBJECT "/CN=tenUser";
CREATE DATABASE tendb;
GRANT ALL ON tendb.* TO ten;

create table if not exists obsdb.keyvalue
create table if not exists tendb.keyvalue
(
id INTEGER AUTO_INCREMENT,
ky varbinary(64) NOT NULL,
val mediumblob NOT NULL,
primary key (id),
INDEX USING HASH (ky)
);
GRANT ALL ON obsdb.keyvalue TO obscuro;

create table if not exists obsdb.config
create table if not exists tendb.config
(
ky varchar(64),
val mediumblob NOT NULL,
primary key (ky)
);
GRANT ALL ON obsdb.config TO obscuro;

insert into obsdb.config
insert into tendb.config
values ('CURRENT_SEQ', -1);

create table if not exists obsdb.attestation_key
create table if not exists tendb.attestation_key
(
party binary(20),
ky binary(33) NOT NULL
);
GRANT ALL ON obsdb.attestation_key TO obscuro;

create table if not exists obsdb.block
create table if not exists tendb.block
(
id INTEGER AUTO_INCREMENT,
hash binary(32) NOT NULL,
Expand All @@ -40,9 +38,8 @@ create table if not exists obsdb.block
INDEX (height),
INDEX USING HASH (hash)
);
GRANT ALL ON obsdb.block TO obscuro;

create table if not exists obsdb.l1_msg
create table if not exists tendb.l1_msg
(
id INTEGER AUTO_INCREMENT,
message varbinary(1024) NOT NULL,
Expand All @@ -51,9 +48,8 @@ create table if not exists obsdb.l1_msg
INDEX (block),
primary key (id)
);
GRANT ALL ON obsdb.l1_msg TO obscuro;

create table if not exists obsdb.rollup
create table if not exists tendb.rollup
(
id INTEGER AUTO_INCREMENT,
hash binary(32) NOT NULL,
Expand All @@ -66,9 +62,8 @@ create table if not exists obsdb.rollup
INDEX USING HASH (hash),
primary key (id)
);
GRANT ALL ON obsdb.rollup TO obscuro;

create table if not exists obsdb.batch
create table if not exists tendb.batch
(
sequence INTEGER,
converted_hash binary(32) NOT NULL,
Expand All @@ -86,9 +81,8 @@ create table if not exists obsdb.batch
INDEX (height),
INDEX (is_canonical, is_executed, height)
);
GRANT ALL ON obsdb.batch TO obscuro;

create table if not exists obsdb.tx
create table if not exists tendb.tx
(
id INTEGER AUTO_INCREMENT,
hash binary(32) NOT NULL,
Expand All @@ -101,9 +95,8 @@ create table if not exists obsdb.tx
INDEX (batch_height, idx),
primary key (id)
);
GRANT ALL ON obsdb.tx TO obscuro;

create table if not exists obsdb.receipt
create table if not exists tendb.receipt
(
id INTEGER AUTO_INCREMENT,
content mediumblob,
Expand All @@ -113,28 +106,25 @@ create table if not exists obsdb.receipt
INDEX (tx, batch),
primary key (id)
);
GRANT ALL ON obsdb.receipt TO obscuro;

create table if not exists obsdb.contract
create table if not exists tendb.contract
(
id INTEGER AUTO_INCREMENT,
address binary(20) NOT NULL,
owner int NOT NULL,
primary key (id),
INDEX USING HASH (address)
);
GRANT ALL ON obsdb.contract TO obscuro;

create table if not exists obsdb.externally_owned_account
create table if not exists tendb.externally_owned_account
(
id INTEGER AUTO_INCREMENT,
address binary(20) NOT NULL,
primary key (id),
INDEX USING HASH (address)
);
GRANT ALL ON obsdb.externally_owned_account TO obscuro;

create table if not exists obsdb.event_type
create table if not exists tendb.event_type
(
id INTEGER AUTO_INCREMENT,
contract int NOT NULL,
Expand All @@ -143,9 +133,8 @@ create table if not exists obsdb.event_type
primary key (id),
INDEX USING HASH (contract, event_sig)
);
GRANT ALL ON obsdb.event_type TO obscuro;

create table if not exists obsdb.event_topic
create table if not exists tendb.event_topic
(
id INTEGER AUTO_INCREMENT,
topic binary(32) NOT NULL,
Expand All @@ -154,9 +143,8 @@ create table if not exists obsdb.event_topic
INDEX USING HASH (topic),
INDEX (rel_address)
);
GRANT ALL ON obsdb.event_topic TO obscuro;

create table if not exists obsdb.event_log
create table if not exists tendb.event_log
(
id INTEGER AUTO_INCREMENT,
event_type INTEGER NOT NULL,
Expand All @@ -169,5 +157,4 @@ create table if not exists obsdb.event_log
primary key (id),
INDEX (receipt, event_type, topic1, topic2, topic3),
INDEX (event_type, topic1, topic2, topic3)
);
GRANT ALL ON obsdb.event_log TO obscuro;
);
8 changes: 4 additions & 4 deletions go/enclave/storage/init/edgelessdb/edgelessdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ const (
edbSignatureEndpoint = "/signature"

dataDir = "/data"
certIssuer = "obscuroCA"
certSubject = "obscuroUser"
certIssuer = "tenCA"
certSubject = "tenUser"
enclaveHostName = "enclave"

dbUser = "obscuro"
dbName = "obsdb"
dbUser = "ten"
dbName = "tendb"

// change this flag to true to debug issues with edgeless DB (and start EDB process with -e EDG_EDB_DEBUG=1
// this will give you:
Expand Down

0 comments on commit b2f1211

Please sign in to comment.