Skip to content

Commit

Permalink
Feature: adding node_hash to VmDB
Browse files Browse the repository at this point in the history
  • Loading branch information
1yam authored and Psycojoker committed Jul 12, 2024
1 parent 27331cf commit eee2f5b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ def upgrade() -> None:
"vms",
sa.Column("environment_trusted_execution_firmware", sa.String(), nullable=True),
)
op.add_column(
"vms",
sa.Column("node_hash", sa.String(), nullable=True),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("vms", "environment_trusted_execution_firmware")
op.drop_column("vms", "environment_trusted_execution_policy")
op.drop_column("vms", "node_hash")

Check warning on line 41 in deployment/migrations/versions/0023_add_trusted_execution_fields_to_vms_.py

View check run for this annotation

Codecov / codecov/patch

deployment/migrations/versions/0023_add_trusted_execution_fields_to_vms_.py#L39-L41

Added lines #L39 - L41 were not covered by tests

# ### end Alembic commands ###
1 change: 1 addition & 0 deletions src/aleph/db/models/vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class VmBaseDb(Base):
cpu_vendor: Optional[str] = Column(String, nullable=True)
node_owner: Optional[str] = Column(String, nullable=True)
node_address_regex: Optional[str] = Column(String, nullable=True)
node_hash: Optional[str] = Column(String, nullable=True)

replaces: Optional[str] = Column(ForeignKey(item_hash), nullable=True)
created: dt.datetime = Column(TIMESTAMP(timezone=True), nullable=False)
Expand Down
4 changes: 4 additions & 0 deletions src/aleph/handlers/content/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,13 @@ def _map_content_to_db_model(item_hash, content):

trusted_execution_policy = None
trusted_execution_firmware = None
node_hash = None
if not isinstance(content, ProgramContent):
if content.environment.trusted_execution is not None:
trusted_execution_policy = content.environment.trusted_execution.policy
trusted_execution_firmware = content.environment.trusted_execution.firmware
if hasattr(content.requirements, 'node_hash'):
node_hash = content.requirements.node_hash

return db_cls(
owner=content.address,
Expand All @@ -143,6 +146,7 @@ def _map_content_to_db_model(item_hash, content):
node_address_regex=node_address_regex,
volumes=volumes,
created=timestamp_to_datetime(content.time),
node_hash=node_hash
)


Expand Down
7 changes: 6 additions & 1 deletion tests/message_processing/test_process_confidential.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ def fixture_confidential_vm_message(
"firmware": "e258d248fda94c63753607f7c4494ee0fcbe92f1a76bfdac795c9d84101eb317",
},
},
"payment": {
"chain": "AVAX",
"type": "superfluid",
"receiver": "0x2319Ad3B7A8E0eE24f2E639c40D8eD124C5520Bb"
},
"resources": {"vcpus": 1, "memory": 128, "seconds": 30},
"requirements": {"cpu": {"architecture": "x86_64"}},
"requirements": {"cpu": {"architecture": "x86_64"}, "node_hash": "149ec451d9b099cad112d4aaa2c00ac40fb6729a92ff252ff22eef0b5c3cb6PD"},
"rootfs": {
"parent": {
"ref": "549ec451d9b099cad112d4aaa2c00ac40fb6729a92ff252ff22eef0b5c3cb613",
Expand Down

0 comments on commit eee2f5b

Please sign in to comment.