Add indexed ASL store ops and tests

This commit is contained in:
Carl Niklas Rydberg 2026-01-17 12:44:33 +01:00
parent 20f092606d
commit a91ab91e39
4 changed files with 110 additions and 6 deletions

View file

@ -310,6 +310,17 @@ target_link_libraries(amduat_test_asl_ref_derive
) )
add_test(NAME asl_ref_derive COMMAND amduat_test_asl_ref_derive) add_test(NAME asl_ref_derive COMMAND amduat_test_asl_ref_derive)
add_executable(amduat_test_asl_store_indexed_ops
tests/asl/test_asl_store_indexed_ops.c)
target_include_directories(amduat_test_asl_store_indexed_ops
PRIVATE ${AMDUAT_INTERNAL_DIR}
PRIVATE ${AMDUAT_INCLUDE_DIR}
)
target_link_libraries(amduat_test_asl_store_indexed_ops
PRIVATE amduat_asl
)
add_test(NAME asl_store_indexed_ops COMMAND amduat_test_asl_store_indexed_ops)
add_executable(amduat_test_pel_program_dag_exec add_executable(amduat_test_pel_program_dag_exec
tests/pel/test_pel_program_dag_exec.c) tests/pel/test_pel_program_dag_exec.c)
target_include_directories(amduat_test_pel_program_dag_exec target_include_directories(amduat_test_pel_program_dag_exec

View file

@ -489,6 +489,30 @@ static amduat_asl_store_error_t amduat_asl_store_fs_put_impl(
return AMDUAT_ASL_STORE_OK; return AMDUAT_ASL_STORE_OK;
} }
static void amduat_asl_store_fs_fill_index_state(
amduat_asl_index_state_t *out_state) {
if (out_state == NULL) {
return;
}
out_state->snapshot_id = 0u;
out_state->log_position = 0u;
}
static amduat_asl_store_error_t amduat_asl_store_fs_put_indexed_impl(
void *ctx,
amduat_artifact_t artifact,
amduat_reference_t *out_ref,
amduat_asl_index_state_t *out_state) {
amduat_asl_store_error_t err;
err = amduat_asl_store_fs_put_impl(ctx, artifact, out_ref);
if (err != AMDUAT_ASL_STORE_OK) {
return err;
}
amduat_asl_store_fs_fill_index_state(out_state);
return AMDUAT_ASL_STORE_OK;
}
static amduat_asl_store_error_t amduat_asl_store_fs_validate_config( static amduat_asl_store_error_t amduat_asl_store_fs_validate_config(
void *ctx, void *ctx,
amduat_asl_store_config_t config) { amduat_asl_store_config_t config) {
@ -511,6 +535,16 @@ static amduat_asl_store_error_t amduat_asl_store_fs_validate_config(
return AMDUAT_ASL_STORE_OK; return AMDUAT_ASL_STORE_OK;
} }
static bool amduat_asl_store_fs_current_state_impl(
void *ctx,
amduat_asl_index_state_t *out_state) {
if (ctx == NULL) {
return false;
}
amduat_asl_store_fs_fill_index_state(out_state);
return true;
}
static amduat_asl_store_error_t amduat_asl_store_fs_get_impl( static amduat_asl_store_error_t amduat_asl_store_fs_get_impl(
void *ctx, void *ctx,
amduat_reference_t ref, amduat_reference_t ref,
@ -672,6 +706,15 @@ static amduat_asl_store_error_t amduat_asl_store_fs_get_impl(
return AMDUAT_ASL_STORE_OK; return AMDUAT_ASL_STORE_OK;
} }
static amduat_asl_store_error_t amduat_asl_store_fs_get_indexed_impl(
void *ctx,
amduat_reference_t ref,
amduat_asl_index_state_t state,
amduat_artifact_t *out_artifact) {
(void)state;
return amduat_asl_store_fs_get_impl(ctx, ref, out_artifact);
}
bool amduat_asl_store_fs_init(amduat_asl_store_fs_t *fs, bool amduat_asl_store_fs_init(amduat_asl_store_fs_t *fs,
amduat_asl_store_config_t config, amduat_asl_store_config_t config,
const char *root_path) { const char *root_path) {
@ -696,6 +739,9 @@ amduat_asl_store_ops_t amduat_asl_store_fs_ops(void) {
amduat_asl_store_ops_init(&ops); amduat_asl_store_ops_init(&ops);
ops.put = amduat_asl_store_fs_put_impl; ops.put = amduat_asl_store_fs_put_impl;
ops.get = amduat_asl_store_fs_get_impl; ops.get = amduat_asl_store_fs_get_impl;
ops.put_indexed = amduat_asl_store_fs_put_indexed_impl;
ops.get_indexed = amduat_asl_store_fs_get_indexed_impl;
ops.current_state = amduat_asl_store_fs_current_state_impl;
ops.validate_config = amduat_asl_store_fs_validate_config; ops.validate_config = amduat_asl_store_fs_validate_config;
return ops; return ops;
} }

View file

@ -0,0 +1,48 @@
#include "amduat/asl/store.h"
#include "amduat/enc/asl1_core.h"
#include "amduat/hash/asl1.h"
#include <stdio.h>
static int test_indexed_ops_unsupported(void) {
amduat_asl_store_ops_t ops;
amduat_asl_store_config_t config;
amduat_asl_store_t store;
amduat_asl_store_error_t err;
amduat_asl_index_state_t state;
amduat_artifact_t artifact;
amduat_reference_t ref;
amduat_asl_store_ops_init(&ops);
config.encoding_profile_id = AMDUAT_ENC_ASL1_CORE_V1;
config.hash_id = AMDUAT_HASH_ASL1_ID_SHA256;
amduat_asl_store_init(&store, config, ops, NULL);
artifact = amduat_artifact(amduat_octets(NULL, 0u));
ref = amduat_reference(0u, amduat_octets(NULL, 0u));
state.snapshot_id = 0u;
state.log_position = 0u;
err = amduat_asl_store_put_indexed(&store, artifact, &ref, &state);
if (err != AMDUAT_ASL_STORE_ERR_UNSUPPORTED) {
fprintf(stderr, "put_indexed missing ops should be unsupported: %d\n", err);
return 1;
}
err = amduat_asl_store_get_indexed(&store, ref, state, &artifact);
if (err != AMDUAT_ASL_STORE_ERR_UNSUPPORTED) {
fprintf(stderr, "get_indexed missing ops should be unsupported: %d\n", err);
return 1;
}
if (amduat_asl_index_current_state(&store, &state)) {
fprintf(stderr, "current_state missing ops should be false\n");
return 1;
}
return 0;
}
int main(void) {
return test_indexed_ops_unsupported();
}

View file

@ -38,16 +38,15 @@ static const uint8_t k_expected_receipt_bytes[] = {
0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x01, 0x60, 0x60, 0x60, 0x60, 0x60, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x01, 0x60, 0x60, 0x60, 0x60, 0x60,
0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
0x60, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x03, 0xaa, 0xbb, 0xcc, 0x00, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x03, 0xaa, 0xbb, 0xcc, 0x00, 0x00,
0x00, 0x00, 0x22, 0x00, 0x01, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x00, 0x22, 0x00, 0x01, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51,
0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51,
0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x51,
0x51, 0x00, 0x00, 0x00, 0x22, 0x00, 0x01, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, 0x22, 0x00, 0x01, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
0x44, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14
0x00, 0x14,
}; };
static const uint8_t k_expected_receipt_helper_bytes[] = { static const uint8_t k_expected_receipt_helper_bytes[] = {