diff --git a/deployment/migrations/versions/0023_add_trusted_execution_fields_to_vms_.py b/deployment/migrations/versions/0023_add_trusted_execution_fields_to_vms_.py index bfba96add..f8a3461f6 100644 --- a/deployment/migrations/versions/0023_add_trusted_execution_fields_to_vms_.py +++ b/deployment/migrations/versions/0023_add_trusted_execution_fields_to_vms_.py @@ -27,6 +27,10 @@ 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 ### @@ -34,4 +38,6 @@ 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") + # ### end Alembic commands ### diff --git a/src/aleph/db/models/vms.py b/src/aleph/db/models/vms.py index ece32701d..7a17bfa2a 100644 --- a/src/aleph/db/models/vms.py +++ b/src/aleph/db/models/vms.py @@ -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) diff --git a/src/aleph/handlers/content/vm.py b/src/aleph/handlers/content/vm.py index 04e78ba85..dea24c771 100644 --- a/src/aleph/handlers/content/vm.py +++ b/src/aleph/handlers/content/vm.py @@ -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, @@ -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 ) diff --git a/tests/message_processing/test_process_confidential.py b/tests/message_processing/test_process_confidential.py index 768c62eb3..09718b782 100644 --- a/tests/message_processing/test_process_confidential.py +++ b/tests/message_processing/test_process_confidential.py @@ -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",