Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
8fc3049
Initial migration work
peterbroadhurst Feb 8, 2022
0431c35
Merge branch 'main' of github.com:hyperledger/firefly into identityv2
peterbroadhurst Feb 8, 2022
07d8b89
More work on migrations
peterbroadhurst Feb 8, 2022
233cc94
Merge branch 'main' of github.com:hyperledger/firefly into identityv2
peterbroadhurst Feb 14, 2022
8ba8944
Updated migrations an initial typedefs
peterbroadhurst Feb 14, 2022
deed601
Merge branch 'main' of github.com:hyperledger/firefly into identityv2
peterbroadhurst Feb 14, 2022
dacb4bd
Merge branch 'main' of github.com:hyperledger/firefly into identityv2
peterbroadhurst Feb 15, 2022
77d0f19
Add identity SQL table
peterbroadhurst Feb 15, 2022
6616a4b
Verifier DTO
peterbroadhurst Feb 15, 2022
bcb739b
Interim commit
peterbroadhurst Feb 15, 2022
d3c568d
Identity manager lookup functions implemented
peterbroadhurst Feb 17, 2022
74ac994
Add message references to identity object/tables
peterbroadhurst Feb 17, 2022
aa948e8
Update identity object for claims/verifications
peterbroadhurst Feb 18, 2022
6418856
Add chain verification function for identities
peterbroadhurst Feb 18, 2022
ca88c9d
Interface impl for Definitions
peterbroadhurst Feb 18, 2022
73e9981
Commit before find/replace
peterbroadhurst Feb 19, 2022
bdda63e
Broadcast migrated
peterbroadhurst Feb 19, 2022
eac3554
Progress on networkmap
peterbroadhurst Feb 19, 2022
cbbeae4
Network map registration
peterbroadhurst Feb 21, 2022
94c8cc4
Add generic identity query support
peterbroadhurst Feb 21, 2022
a5c3bbb
Merge with main
peterbroadhurst Feb 21, 2022
3b87b55
Handle new identity structure for root check
peterbroadhurst Feb 21, 2022
34616f5
Identity profile update
peterbroadhurst Feb 22, 2022
59dde9b
Clean up DX interface - no need for separate ID
peterbroadhurst Feb 22, 2022
769187b
Updates to private messaging
peterbroadhurst Feb 22, 2022
2d90e68
Progress on Pm
peterbroadhurst Feb 22, 2022
38de541
UT complete on private messaging
peterbroadhurst Feb 22, 2022
9c68ec7
Move to single copy of IsRootOrgBroadcast logic in IM
peterbroadhurst Feb 22, 2022
a0002fc
Intermediate commit with events migration
peterbroadhurst Feb 23, 2022
07f4486
Up to definitions
peterbroadhurst Feb 23, 2022
2444848
Move various utilities to common identitymanager pkg
peterbroadhurst Feb 23, 2022
b7d0b30
Update Definitions interface to allow pending confirms to be checked
peterbroadhurst Feb 24, 2022
7378617
Events coverage
peterbroadhurst Feb 24, 2022
7857b1f
Remove IsRootOrgBroadcast as no longer required
peterbroadhurst Feb 24, 2022
4db351f
Verification then claim custom identity test
peterbroadhurst Feb 24, 2022
2e5f9ea
Verification claim tests with custom identities
peterbroadhurst Feb 24, 2022
4f22609
Merge branch 'main' of github.com:hyperledger/firefly into identityv2
peterbroadhurst Feb 24, 2022
f0f6082
Deprecated org/node tests
peterbroadhurst Feb 24, 2022
fe3408d
Coverage complete on definitions
peterbroadhurst Feb 24, 2022
47bae25
Orchestrator updates for identity
peterbroadhurst Feb 24, 2022
29a227c
Identity APIs
peterbroadhurst Feb 24, 2022
e13538c
E2E test compiling
peterbroadhurst Feb 24, 2022
596fc8a
E2E passing
peterbroadhurst Feb 24, 2022
fed88b2
Allow asset manager to be configured with/without key resolution
peterbroadhurst Feb 25, 2022
8b1b94a
Only do DB lookups in sync/async for in-flight requests
peterbroadhurst Feb 25, 2022
70249c1
Emit events for identity confirmation/update
peterbroadhurst Feb 25, 2022
991f5bd
Identity created/updated events and making confirm wait for identity …
peterbroadhurst Feb 25, 2022
c09a149
Add fix for timing related UT failure
peterbroadhurst Feb 25, 2022
d65741a
Various refinement from E2E identity testing
peterbroadhurst Feb 25, 2022
e1514dc
Fix disconnecting
peterbroadhurst Feb 26, 2022
a05cc1a
Update CLI to avoid unlock
peterbroadhurst Feb 26, 2022
0505ffb
Improvements to suite
peterbroadhurst Feb 26, 2022
b1559ce
Add DID Document endpoint
peterbroadhurst Feb 28, 2022
f551f46
Correct query factory
peterbroadhurst Feb 28, 2022
875e881
Add private test to custom identities
peterbroadhurst Feb 28, 2022
4be2d61
Tweaks to private test
peterbroadhurst Feb 28, 2022
5461898
Undo disable of test
peterbroadhurst Feb 28, 2022
65952c2
Fix test custom2 identity parent
peterbroadhurst Feb 28, 2022
02e6221
Need `requestConflictEmptyResult` for all upsert optimization cases
peterbroadhurst Feb 28, 2022
bf3a2bb
Wrong type of quotes for PSQL
peterbroadhurst Feb 28, 2022
37b54a6
Added namespace to verifiers requires migration change
peterbroadhurst Feb 28, 2022
0618e13
Fix migrations to the new constant names
peterbroadhurst Feb 28, 2022
0c991fe
Move verifiers to be identitied deterministically across nodes via hash
peterbroadhurst Mar 1, 2022
2959263
Update to key normalization internally within the identity manager
peterbroadhurst Mar 1, 2022
ee3686d
Update to key normalization in blockchain plugin interface
peterbroadhurst Mar 1, 2022
802b309
Combine Action and CustomCorrelator into HandlerResult
peterbroadhurst Mar 1, 2022
1145279
Address review comments
peterbroadhurst Mar 1, 2022
c6614aa
Tweaks from review
peterbroadhurst Mar 2, 2022
75f63be
Swagger
peterbroadhurst Mar 2, 2022
88da6d6
PSQL requires UUID to text
peterbroadhurst Mar 2, 2022
0bda768
Double up UUIDs to fill 32b hash values in migration
peterbroadhurst Mar 2, 2022
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
74 changes: 37 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,43 @@ mocks-$(strip $(1))-$(strip $(2)): ${MOCKERY}
${MOCKERY} --case underscore --dir $(1) --name $(2) --outpkg $(3) --output mocks/$(strip $(3))
endef

$(eval $(call makemock, pkg/blockchain, Plugin, blockchainmocks))
$(eval $(call makemock, pkg/blockchain, Callbacks, blockchainmocks))
$(eval $(call makemock, pkg/database, Plugin, databasemocks))
$(eval $(call makemock, pkg/database, Callbacks, databasemocks))
$(eval $(call makemock, pkg/publicstorage, Plugin, publicstoragemocks))
$(eval $(call makemock, pkg/publicstorage, Callbacks, publicstoragemocks))
$(eval $(call makemock, pkg/events, Plugin, eventsmocks))
$(eval $(call makemock, pkg/events, PluginAll, eventsmocks))
$(eval $(call makemock, pkg/events, Callbacks, eventsmocks))
$(eval $(call makemock, pkg/identity, Plugin, identitymocks))
$(eval $(call makemock, pkg/identity, Callbacks, identitymocks))
$(eval $(call makemock, pkg/dataexchange, Plugin, dataexchangemocks))
$(eval $(call makemock, pkg/dataexchange, Callbacks, dataexchangemocks))
$(eval $(call makemock, pkg/tokens, Plugin, tokenmocks))
$(eval $(call makemock, pkg/tokens, Callbacks, tokenmocks))
$(eval $(call makemock, pkg/wsclient, WSClient, wsmocks))
$(eval $(call makemock, internal/txcommon, Helper, txcommonmocks))
$(eval $(call makemock, internal/identity, Manager, identitymanagermocks))
$(eval $(call makemock, internal/batchpin, Submitter, batchpinmocks))
$(eval $(call makemock, internal/sysmessaging, SystemEvents, sysmessagingmocks))
$(eval $(call makemock, internal/sysmessaging, MessageSender, sysmessagingmocks))
$(eval $(call makemock, internal/sysmessaging, LocalNodeInfo, sysmessagingmocks))
$(eval $(call makemock, internal/syncasync, Bridge, syncasyncmocks))
$(eval $(call makemock, internal/data, Manager, datamocks))
$(eval $(call makemock, internal/batch, Manager, batchmocks))
$(eval $(call makemock, internal/broadcast, Manager, broadcastmocks))
$(eval $(call makemock, internal/privatemessaging, Manager, privatemessagingmocks))
$(eval $(call makemock, internal/definitions, DefinitionHandlers, definitionsmocks))
$(eval $(call makemock, internal/events, EventManager, eventmocks))
$(eval $(call makemock, internal/networkmap, Manager, networkmapmocks))
$(eval $(call makemock, internal/assets, Manager, assetmocks))
$(eval $(call makemock, internal/contracts, Manager, contractmocks))
$(eval $(call makemock, internal/oapiffi, FFISwaggerGen, oapiffimocks))
$(eval $(call makemock, internal/orchestrator, Orchestrator, orchestratormocks))
$(eval $(call makemock, internal/apiserver, Server, apiservermocks))
$(eval $(call makemock, internal/apiserver, IServer, apiservermocks))
$(eval $(call makemock, internal/metrics, Manager, metricsmocks))
$(eval $(call makemock, pkg/blockchain, Plugin, blockchainmocks))
$(eval $(call makemock, pkg/blockchain, Callbacks, blockchainmocks))
$(eval $(call makemock, pkg/database, Plugin, databasemocks))
$(eval $(call makemock, pkg/database, Callbacks, databasemocks))
$(eval $(call makemock, pkg/publicstorage, Plugin, publicstoragemocks))
$(eval $(call makemock, pkg/publicstorage, Callbacks, publicstoragemocks))
$(eval $(call makemock, pkg/events, Plugin, eventsmocks))
$(eval $(call makemock, pkg/events, PluginAll, eventsmocks))
$(eval $(call makemock, pkg/events, Callbacks, eventsmocks))
$(eval $(call makemock, pkg/identity, Plugin, identitymocks))
$(eval $(call makemock, pkg/identity, Callbacks, identitymocks))
$(eval $(call makemock, pkg/dataexchange, Plugin, dataexchangemocks))
$(eval $(call makemock, pkg/dataexchange, Callbacks, dataexchangemocks))
$(eval $(call makemock, pkg/tokens, Plugin, tokenmocks))
$(eval $(call makemock, pkg/tokens, Callbacks, tokenmocks))
$(eval $(call makemock, pkg/wsclient, WSClient, wsmocks))
$(eval $(call makemock, internal/txcommon, Helper, txcommonmocks))
$(eval $(call makemock, internal/identity, Manager, identitymanagermocks))
$(eval $(call makemock, internal/batchpin, Submitter, batchpinmocks))
$(eval $(call makemock, internal/sysmessaging, SystemEvents, sysmessagingmocks))
$(eval $(call makemock, internal/sysmessaging, MessageSender, sysmessagingmocks))
$(eval $(call makemock, internal/sysmessaging, LocalNodeInfo, sysmessagingmocks))
$(eval $(call makemock, internal/syncasync, Bridge, syncasyncmocks))
$(eval $(call makemock, internal/data, Manager, datamocks))
$(eval $(call makemock, internal/batch, Manager, batchmocks))
$(eval $(call makemock, internal/broadcast, Manager, broadcastmocks))
$(eval $(call makemock, internal/privatemessaging, Manager, privatemessagingmocks))
$(eval $(call makemock, internal/contracts, Manager, contractmocks))
$(eval $(call makemock, internal/assets, Manager, assetmocks))
$(eval $(call makemock, internal/definitions, DefinitionHandlers, definitionsmocks))
$(eval $(call makemock, internal/metrics, Manager, metricsmocks))
$(eval $(call makemock, internal/events, EventManager, eventmocks))
$(eval $(call makemock, internal/networkmap, Manager, networkmapmocks))
$(eval $(call makemock, internal/oapiffi, FFISwaggerGen, oapiffimocks))
$(eval $(call makemock, internal/orchestrator, Orchestrator, orchestratormocks))
$(eval $(call makemock, internal/apiserver, Server, apiservermocks))
$(eval $(call makemock, internal/apiserver, IServer, apiservermocks))

firefly-nocgo: ${GOFILES}
CGO_ENABLED=0 $(VGO) build -o ${BINARY_NAME}-nocgo -ldflags "-X main.buildDate=`date -u +\"%Y-%m-%dT%H:%M:%SZ\"` -X main.buildVersion=$(BUILD_VERSION)" -tags=prod -tags=prod -v
Expand Down
97 changes: 97 additions & 0 deletions db/migrations/postgres/000063_create_identities_table.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
BEGIN;

CREATE TABLE orgs (
seq SERIAL PRIMARY KEY,
id UUID NOT NULL,
message_id UUID NOT NULL,
name VARCHAR(64) NOT NULL,
parent VARCHAR(1024),
identity VARCHAR(1024) NOT NULL,
description VARCHAR(4096) NOT NULL,
profile TEXT,
created BIGINT NOT NULL
);

CREATE UNIQUE INDEX orgs_id ON orgs(id);
CREATE UNIQUE INDEX orgs_identity ON orgs(identity);
CREATE UNIQUE INDEX orgs_name ON orgs(name);

CREATE TABLE nodes (
seq SERIAL PRIMARY KEY,
id UUID NOT NULL,
message_id UUID NOT NULL,
owner VARCHAR(1024) NOT NULL,
name VARCHAR(64) NOT NULL,
description VARCHAR(4096) NOT NULL,
dx_peer VARCHAR(256),
dx_endpoint TEXT,
created BIGINT NOT NULL
);

CREATE UNIQUE INDEX nodes_id ON nodes(id);
CREATE UNIQUE INDEX nodes_owner ON nodes(owner,name);
CREATE UNIQUE INDEX nodes_peer ON nodes(dx_peer);

-- We only reconstitute orgs that were dropped during the original up migration.
-- These have the UUID of the verifier set to the same UUID as the org.
INSERT INTO orgs (
id,
parent,
message_id,
name,
description,
profile,
created,
identity
) SELECT
i.id,
COALESCE(pv.value, '') as parent,
i.messages_claim,
i.name,
i.description,
i.profile,
i.created,
v.value as identity
FROM identities as i
LEFT JOIN verifiers v ON v.hash = REPLACE(i.id::text,'-','') || REPLACE(i.id::text,'-','')
LEFT JOIN verifiers pv ON pv.hash = REPLACE(i.parent::text,'-','') || REPLACE(i.parent::text,'-','')
WHERE i.did LIKE 'did:firefly:org/%' AND v.hash IS NOT NULL;

-- We only reconstitute nodes that were dropped during the original up migration.
-- These have the Hash of the verifier set to the bytes from the UUID of the node (by taking the string and removing the dashes).
INSERT INTO nodes (
id,
owner,
message_id,
name,
description,
dx_endpoint,
created,
dx_peer
) SELECT
i.id,
COALESCE(pv.value, '') as owner,
i.messages_claim,
i.name,
i.description,
i.profile,
i.created,
v.value as dx_peer
FROM identities as i
LEFT JOIN verifiers v ON v.hash = REPLACE(i.id::text,'-','') || REPLACE(i.id::text,'-','')
LEFT JOIN verifiers pv ON pv.hash = REPLACE(i.parent::text,'-','') || REPLACE(i.parent::text,'-','')
WHERE i.did LIKE 'did:firefly:node/%' AND v.hash IS NOT NULL;

DROP INDEX identities_id;
DROP INDEX identities_did;
DROP INDEX identities_name;

DROP TABLE IF EXISTS identities;

DROP INDEX verifiers_hash;
DROP INDEX verifiers_value;
DROP INDEX verifiers_identity;

DROP TABLE IF EXISTS verifiers;

COMMIT;
143 changes: 143 additions & 0 deletions db/migrations/postgres/000063_create_identities_table.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
BEGIN;

CREATE TABLE identities (
seq SERIAL PRIMARY KEY,
id UUID NOT NULL,
did VARCHAR(256) NOT NULL,
parent UUID,
messages_claim UUID NOT NULL,
messages_verification UUID,
messages_update UUID,
itype VARCHAR(64) NOT NULL,
namespace VARCHAR(64) NOT NULL,
name VARCHAR(64) NOT NULL,
description VARCHAR(4096) NOT NULL,
profile TEXT,
created BIGINT NOT NULL,
updated BIGINT NOT NULL
);

CREATE UNIQUE INDEX identities_id ON identities(id);
CREATE UNIQUE INDEX identities_did ON identities(did);
CREATE UNIQUE INDEX identities_name ON identities(itype, namespace, name);

CREATE TABLE verifiers (
seq SERIAL PRIMARY KEY,
hash CHAR(64) NOT NULL,
identity UUID NOT NULL,
vtype VARCHAR(256) NOT NULL,
namespace VARCHAR(64) NOT NULL,
value TEXT NOT NULL,
created BIGINT NOT NULL
);

CREATE UNIQUE INDEX verifiers_hash ON verifiers(hash);
CREATE UNIQUE INDEX verifiers_value ON verifiers(vtype, namespace, value);
CREATE INDEX verifiers_identity ON verifiers(identity);

INSERT INTO identities (
id,
did,
parent,
messages_claim,
itype,
namespace,
name,
description,
profile,
created,
updated
) SELECT
o1.id,
'did:firefly:org/' || o1.name,
o2.id,
o1.message_id,
'org',
'ff_system',
o1.name,
o1.description,
o1.profile,
o1.created,
o1.created
FROM orgs as o1
LEFT JOIN orgs o2 ON o2.identity = o1.parent;

INSERT INTO identities (
id,
did,
parent,
messages_claim,
itype,
namespace,
name,
description,
profile,
created,
updated
) SELECT
n.id,
'did:firefly:node/' || n.name,
o.id,
n.message_id,
'node',
'ff_system',
n.name,
n.description,
n.dx_endpoint,
n.created,
n.created
FROM nodes as n
LEFT JOIN orgs o ON o.identity = n.owner;

INSERT INTO verifiers (
hash,
namespace,
identity,
vtype,
value,
created
) SELECT
REPLACE(o.id::text, '-', '') || REPLACE(o.id::text, '-', ''), -- to avoid the need for hashing in the migration, use the convenient fact the UUID is known hex - have to write it twice to fill the 32B --
'ff_system',
o.id,
'ethereum_address',
o.identity,
o.created
FROM orgs as o WHERE o.identity LIKE '0x%';

INSERT INTO verifiers (
hash,
namespace,
identity,
vtype,
value,
created
) SELECT
REPLACE(o.id::text, '-', '') || REPLACE(o.id::text, '-', ''), -- to avoid the need for hashing in the migration, use the convenient fact the UUID is known hex - have to write it twice to fill the 32B --
'ff_system',
o.id,
'fabric_msp_id',
o.identity,
o.created
FROM orgs as o WHERE o.identity NOT LIKE '0x%';

INSERT INTO verifiers (
hash,
namespace,
identity,
vtype,
value,
created
) SELECT
REPLACE(n.id::text, '-', '') || REPLACE(n.id::text, '-', ''), -- to avoid the need for hashing in the migration, use the convenient fact the UUID is known hex - have to write it twice to fill the 32B --
'ff_system',
n.id,
'dx_peer_id',
n.dx_peer,
n.created
FROM nodes as n;

DROP TABLE orgs;
DROP TABLE nodes;

COMMIT;
1 change: 1 addition & 0 deletions db/migrations/postgres/000064_allow_null_data.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- No down migration for this one
5 changes: 5 additions & 0 deletions db/migrations/postgres/000064_allow_null_data.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BEGIN;

ALTER TABLE data ALTER COLUMN value DROP NOT NULL;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BEGIN;
ALTER TABLE pins DROP COLUMN signer;
ALTER TABLE events DROP COLUMN cid;
COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BEGIN;
ALTER TABLE pins ADD COLUMN signer TEXT;
UPDATE pins SET signer = '';

ALTER TABLE events ADD COLUMN cid UUID;
COMMIT;
Loading