From 0e140d25520c18c98c82e2da3a14ce89c3c84596 Mon Sep 17 00:00:00 2001 From: fractasy Date: Tue, 22 Aug 2023 11:53:23 +0000 Subject: [PATCH 1/3] Fix FullTracer::getFromMemory() result length --- src/main_sm/fork_5/main/full_tracer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main_sm/fork_5/main/full_tracer.cpp b/src/main_sm/fork_5/main/full_tracer.cpp index 342cf867c..251e07d6c 100644 --- a/src/main_sm/fork_5/main/full_tracer.cpp +++ b/src/main_sm/fork_5/main/full_tracer.cpp @@ -141,6 +141,8 @@ inline zkresult getFromMemory(Context &ctx, mpz_class &offset, mpz_class &length result += hexStringEnd.substr(0, bytesToRetrieve * 2); } + result = result.substr(0, length.get_ui()*2); + return ZKR_SUCCESS; } From 4304ec3dee88d431a0683debfb07b01fc7db6d76 Mon Sep 17 00:00:00 2001 From: fractasy Date: Tue, 22 Aug 2023 11:55:59 +0000 Subject: [PATCH 2/3] Add comment to previous fix --- src/main_sm/fork_5/main/full_tracer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main_sm/fork_5/main/full_tracer.cpp b/src/main_sm/fork_5/main/full_tracer.cpp index 251e07d6c..671fe498c 100644 --- a/src/main_sm/fork_5/main/full_tracer.cpp +++ b/src/main_sm/fork_5/main/full_tracer.cpp @@ -141,8 +141,9 @@ inline zkresult getFromMemory(Context &ctx, mpz_class &offset, mpz_class &length result += hexStringEnd.substr(0, bytesToRetrieve * 2); } + // Limit result memory length in case it is a chunk contained in one single slot result = result.substr(0, length.get_ui()*2); - + return ZKR_SUCCESS; } From b16e11bfae8cdedef4394793f3acbaf84978f769 Mon Sep 17 00:00:00 2001 From: fractasy Date: Tue, 22 Aug 2023 12:03:20 +0000 Subject: [PATCH 3/3] Port previous fix to forks 1, 2, 3, and 4 --- src/main_sm/fork_1/main/full_tracer.cpp | 3 +++ src/main_sm/fork_2/main/full_tracer.cpp | 3 +++ src/main_sm/fork_3/main/full_tracer.cpp | 3 +++ src/main_sm/fork_4/main/full_tracer.cpp | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/main_sm/fork_1/main/full_tracer.cpp b/src/main_sm/fork_1/main/full_tracer.cpp index 8f53e33d2..78d0ba5c8 100644 --- a/src/main_sm/fork_1/main/full_tracer.cpp +++ b/src/main_sm/fork_1/main/full_tracer.cpp @@ -127,6 +127,9 @@ inline void getFromMemory(Context &ctx, mpz_class &offset, mpz_class &length, st uint64_t bytesToRetrieve = (end - double(endFloor)) * 32; result += hexStringEnd.substr(0, bytesToRetrieve * 2); } + + // Limit result memory length in case it is a chunk contained in one single slot + result = result.substr(0, length.get_ui()*2); } // Get a global or context variable diff --git a/src/main_sm/fork_2/main/full_tracer.cpp b/src/main_sm/fork_2/main/full_tracer.cpp index c9c79fa07..572bc3eaa 100644 --- a/src/main_sm/fork_2/main/full_tracer.cpp +++ b/src/main_sm/fork_2/main/full_tracer.cpp @@ -127,6 +127,9 @@ inline void getFromMemory(Context &ctx, mpz_class &offset, mpz_class &length, st uint64_t bytesToRetrieve = (end - double(endFloor)) * 32; result += hexStringEnd.substr(0, bytesToRetrieve * 2); } + + // Limit result memory length in case it is a chunk contained in one single slot + result = result.substr(0, length.get_ui()*2); } // Get a global or context variable diff --git a/src/main_sm/fork_3/main/full_tracer.cpp b/src/main_sm/fork_3/main/full_tracer.cpp index 2844b17ff..0cb85539d 100644 --- a/src/main_sm/fork_3/main/full_tracer.cpp +++ b/src/main_sm/fork_3/main/full_tracer.cpp @@ -127,6 +127,9 @@ inline void getFromMemory(Context &ctx, mpz_class &offset, mpz_class &length, st uint64_t bytesToRetrieve = (end - double(endFloor)) * 32; result += hexStringEnd.substr(0, bytesToRetrieve * 2); } + + // Limit result memory length in case it is a chunk contained in one single slot + result = result.substr(0, length.get_ui()*2); } // Get a global or context variable diff --git a/src/main_sm/fork_4/main/full_tracer.cpp b/src/main_sm/fork_4/main/full_tracer.cpp index acc8a60ab..94e42d558 100644 --- a/src/main_sm/fork_4/main/full_tracer.cpp +++ b/src/main_sm/fork_4/main/full_tracer.cpp @@ -140,6 +140,9 @@ inline zkresult getFromMemory(Context &ctx, mpz_class &offset, mpz_class &length result += hexStringEnd.substr(0, bytesToRetrieve * 2); } + // Limit result memory length in case it is a chunk contained in one single slot + result = result.substr(0, length.get_ui()*2); + return ZKR_SUCCESS; }