From d88fd3e81f00e8d6a4534f01b885d72c2441e068 Mon Sep 17 00:00:00 2001 From: sdimitrov9 Date: Wed, 27 Nov 2024 11:51:09 +0200 Subject: [PATCH 1/7] Add spotlessCheck job to the security CI workflow Signed-off-by: sdimitrov9 --- .github/workflows/security.yml | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index b9a18f3c1b..2be29ed87a 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -241,3 +241,41 @@ jobs: html-to-markdown ${report}.html -o build/reports && \ cat ${report}.html.md >> $GITHUB_STEP_SUMMARY fi + + spotless-check: + if: github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') + name: Spotless Code Format Check + runs-on: mirror-node-linux-large + steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - name: Checkout Code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: Setup Node + uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: 21 + + - name: Install JDK + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 + with: + distribution: temurin + java-version: 21 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4 + + - name: Execute Gradle + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew spotlessCheck + + - name: Fail on Unformatted Files + if: failure() + run: echo "Spotless check failed. Code formatting issues found. Please run './gradlew spotlessApply' locally and commit the changes." From 5673b436f1135bebc3bbd4bd44ae0bd961468d0e Mon Sep 17 00:00:00 2001 From: sdimitrov9 Date: Fri, 29 Nov 2024 10:44:44 +0200 Subject: [PATCH 2/7] Update spotless-check job in the security CI workflow Signed-off-by: sdimitrov9 --- .github/workflows/security.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 2be29ed87a..dd20457b9f 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -243,9 +243,8 @@ jobs: fi spotless-check: - if: github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') name: Spotless Code Format Check - runs-on: mirror-node-linux-large + runs-on: mirror-node-linux-medium steps: - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 @@ -255,12 +254,7 @@ jobs: - name: Checkout Code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - - name: Setup Node - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 - with: - node-version: 21 + fetch-depth: 1 - name: Install JDK uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 From 7c707aaecee356af4fbbefdc730970649a274378 Mon Sep 17 00:00:00 2001 From: Stoyan Dimitrov Date: Fri, 29 Nov 2024 02:18:23 +0200 Subject: [PATCH 3/7] Apply spotless formatting to the whole project (#9840) --------- Signed-off-by: sdimitrov9 --- .../kotlin/openapi-conventions.gradle.kts | 2 + .../common/SpringApplicationContext.java | 9 +- .../common/EntityIdParameterTest.java | 71 ++++++------ hedera-mirror-rest/__tests__/config.test.js | 4 +- .../middleware/responseCacheHandler.test.js | 104 ++++++++++-------- hedera-mirror-rest/cache.js | 10 +- hedera-mirror-rest/config.js | 4 +- .../middleware/responseCacheHandler.js | 7 +- hedera-mirror-rest/transactions.js | 19 +++- .../viewmodel/contractResultViewModel.js | 4 +- .../k6/src/rest-java/libex/constants.js | 1 - hedera-mirror-test/k6/src/web3/test/common.js | 6 +- ...PrecompileModificationFunctionsTemplate.js | 6 +- hedera-mirror-test/k6/src/web3/test/index.js | 4 +- .../contractCallPrecompileApprove.js | 19 ++-- .../contractCallPrecompileAssociate.js | 23 ++-- ...ntractCallPrecompileCryptoTransferHbars.js | 38 ++++--- ...ntractCallPrecompileCryptoTransferToken.js | 53 +++++---- .../contractCallPrecompileDeleteToken.js | 17 +-- .../contractCallPrecompileDissociate.js | 17 +-- .../contractCallPrecompileMintToken.js | 22 ++-- .../contractCallPrecompileNestedAssociate.js | 19 ++-- ...ractCallPrecompileTransferFungibleToken.js | 17 +-- .../contractCallRedirectApprove.js | 19 ++-- .../converter/CustomFeesConverter.java | 3 +- .../web3/common/TransactionHashParameter.java | 2 +- .../web3/common/TransactionIdParameter.java | 6 +- .../repository/ContractResultRepository.java | 4 +- .../EthereumTransactionRepository.java | 3 +- .../web3/repository/RecordFileRepository.java | 6 +- .../mirror/web3/service/OpcodeService.java | 4 +- .../mirror/web3/state/NftReadableKVState.java | 2 +- .../common/TransactionHashParameterTest.java | 3 +- .../service/ContractCallEvmCodesTest.java | 22 ++-- .../web3/state/NftReadableKVStateTest.java | 18 +-- .../HederaCustomCallOperationTest.java | 4 +- .../UsageBasedFeeCalculatorTest.java | 12 +- .../services/txn/token/PauseLogicTest.java | 5 +- .../services/txn/token/UnpauseLogicTest.java | 3 +- 39 files changed, 315 insertions(+), 277 deletions(-) diff --git a/buildSrc/src/main/kotlin/openapi-conventions.gradle.kts b/buildSrc/src/main/kotlin/openapi-conventions.gradle.kts index cbea7bf6fa..5801a5eb78 100644 --- a/buildSrc/src/main/kotlin/openapi-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/openapi-conventions.gradle.kts @@ -23,6 +23,7 @@ plugins { } val openApiPackage = "com.hedera.mirror.rest" + openApiGenerate { apiPackage = "${openApiPackage}.api" configOptions = @@ -58,4 +59,5 @@ openApiGenerate { } tasks.withType { dependsOn("openApiGenerate") } + java.sourceSets["main"].java { srcDir(openApiGenerate.outputDir) } diff --git a/hedera-mirror-rest-java/src/main/java/com/hedera/mirror/restjava/common/SpringApplicationContext.java b/hedera-mirror-rest-java/src/main/java/com/hedera/mirror/restjava/common/SpringApplicationContext.java index 7f1d46f633..9ebb0fe3be 100644 --- a/hedera-mirror-rest-java/src/main/java/com/hedera/mirror/restjava/common/SpringApplicationContext.java +++ b/hedera-mirror-rest-java/src/main/java/com/hedera/mirror/restjava/common/SpringApplicationContext.java @@ -13,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.hedera.mirror.restjava.common; import jakarta.inject.Named; +import java.util.concurrent.atomic.AtomicReference; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import java.util.concurrent.atomic.AtomicReference; - @Named public class SpringApplicationContext implements ApplicationContextAware { - private static final AtomicReference CONTEXT = new AtomicReference<>(); + private static final AtomicReference CONTEXT = new AtomicReference<>(); public static T getBean(Class beanClass) { return CONTEXT.get().getBean(beanClass); @@ -35,5 +35,4 @@ public static T getBean(Class beanClass) { public void setApplicationContext(ApplicationContext context) throws BeansException { CONTEXT.set(context); } - -} \ No newline at end of file +} diff --git a/hedera-mirror-rest-java/src/test/java/com/hedera/mirror/restjava/common/EntityIdParameterTest.java b/hedera-mirror-rest-java/src/test/java/com/hedera/mirror/restjava/common/EntityIdParameterTest.java index 15ae2f928c..eada698cee 100644 --- a/hedera-mirror-rest-java/src/test/java/com/hedera/mirror/restjava/common/EntityIdParameterTest.java +++ b/hedera-mirror-rest-java/src/test/java/com/hedera/mirror/restjava/common/EntityIdParameterTest.java @@ -16,6 +16,10 @@ package com.hedera.mirror.restjava.common; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.when; + import com.google.common.io.BaseEncoding; import com.hedera.mirror.common.domain.entity.EntityId; import com.hedera.mirror.common.exception.InvalidEntityException; @@ -34,14 +38,9 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.when; - @ExtendWith(MockitoExtension.class) class EntityIdParameterTest { - @Mock private RestJavaProperties properties; @@ -92,49 +91,47 @@ void testInvalidEntity(String input) { } @ParameterizedTest - @CsvSource({"0.0.0,0,0,0", - "0,0,0,0", - "0.1,0,0,1", - "0.0.4294967295,0,0,4294967295", - "65535.000000001,0,65535,1", - "32767.65535.4294967295,32767,65535,4294967295", - "4294967295,0,0,4294967295"}) - void valueOfId(String givenEntityId,long expectedShard,long expectedRealm,long expectedNum) { - assertThat(EntityId.of(expectedShard, expectedRealm, expectedNum)).isEqualTo(((EntityIdNumParameter) EntityIdParameter.valueOf(givenEntityId)).id()); + @CsvSource({ + "0.0.0,0,0,0", + "0,0,0,0", + "0.1,0,0,1", + "0.0.4294967295,0,0,4294967295", + "65535.000000001,0,65535,1", + "32767.65535.4294967295,32767,65535,4294967295", + "4294967295,0,0,4294967295" + }) + void valueOfId(String givenEntityId, long expectedShard, long expectedRealm, long expectedNum) { + assertThat(EntityId.of(expectedShard, expectedRealm, expectedNum)) + .isEqualTo(((EntityIdNumParameter) EntityIdParameter.valueOf(givenEntityId)).id()); } @ParameterizedTest - @CsvSource({"0x0000000000000000000000000000000000000001,0,0,0000000000000000000000000000000000000001", - "0000000000000000000000000000000000000001,0,0,0000000000000000000000000000000000000001", - "0x0000000100000000000000020000000000000003,0,0,0000000100000000000000020000000000000003", - "0000000100000000000000020000000000000003,0,0,0000000100000000000000020000000000000003", - "1.2.0000000100000000000000020000000000000003,1,2,0000000100000000000000020000000000000003", - "0x00007fff000000000000ffff00000000ffffffff,0,0,00007fff000000000000ffff00000000ffffffff", - "0.0.000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", - "0.0x000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", - "0.0.0x000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", - "0.000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", - "000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", - "0x000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b" + @CsvSource({ + "0x0000000000000000000000000000000000000001,0,0,0000000000000000000000000000000000000001", + "0000000000000000000000000000000000000001,0,0,0000000000000000000000000000000000000001", + "0x0000000100000000000000020000000000000003,0,0,0000000100000000000000020000000000000003", + "0000000100000000000000020000000000000003,0,0,0000000100000000000000020000000000000003", + "1.2.0000000100000000000000020000000000000003,1,2,0000000100000000000000020000000000000003", + "0x00007fff000000000000ffff00000000ffffffff,0,0,00007fff000000000000ffff00000000ffffffff", + "0.0.000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", + "0.0x000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", + "0.0.0x000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", + "0.000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", + "000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b", + "0x000000000000000000000000000000000186Fb1b,0,0,000000000000000000000000000000000186Fb1b" }) void valueOfEvmAddress(String givenEvmAddress, long expectedShard, long expectedRealm, String expectedEvmAddress) { - var given = ((EntityIdEvmAddressParameter) - EntityIdParameter.valueOf(givenEvmAddress)); - assertThat(Hex.decode(expectedEvmAddress)) - .isEqualTo( given.evmAddress()); + var given = ((EntityIdEvmAddressParameter) EntityIdParameter.valueOf(givenEvmAddress)); + assertThat(Hex.decode(expectedEvmAddress)).isEqualTo(given.evmAddress()); assertThat(expectedShard).isEqualTo(given.shard()); assertThat(expectedRealm).isEqualTo(given.realm()); } @ParameterizedTest - @CsvSource({"AABBCC22,0,0,AABBCC22", - "1.AABBCC22,0,1,AABBCC22", - "1.2.AABBCC22,1,2,AABBCC22" - }) - void valueOfAlias(String givenAlias, long expectedShard,long expectedRealm, String expectedAlias) { + @CsvSource({"AABBCC22,0,0,AABBCC22", "1.AABBCC22,0,1,AABBCC22", "1.2.AABBCC22,1,2,AABBCC22"}) + void valueOfAlias(String givenAlias, long expectedShard, long expectedRealm, String expectedAlias) { var given = ((EntityIdAliasParameter) EntityIdParameter.valueOf(givenAlias)); - assertThat(BaseEncoding.base32().omitPadding().decode(expectedAlias)) - .isEqualTo(given.alias()); + assertThat(BaseEncoding.base32().omitPadding().decode(expectedAlias)).isEqualTo(given.alias()); assertThat(expectedShard).isEqualTo(given.shard()); assertThat(expectedRealm).isEqualTo(given.realm()); } diff --git a/hedera-mirror-rest/__tests__/config.test.js b/hedera-mirror-rest/__tests__/config.test.js index e88ec38fae..4d905df747 100644 --- a/hedera-mirror-rest/__tests__/config.test.js +++ b/hedera-mirror-rest/__tests__/config.test.js @@ -215,8 +215,8 @@ describe('Override query config', () => { strictTimestampParam: true, topicMessageLookup: false, transactions: { - precedingTransactionTypes: [11, 15] - } + precedingTransactionTypes: [11, 15], + }, }; const config = await loadCustomConfig(customConfig(queryConfig)); expect(config.query).toEqual(expected); diff --git a/hedera-mirror-rest/__tests__/middleware/responseCacheHandler.test.js b/hedera-mirror-rest/__tests__/middleware/responseCacheHandler.test.js index b4ee8c30c3..7f311232cc 100644 --- a/hedera-mirror-rest/__tests__/middleware/responseCacheHandler.test.js +++ b/hedera-mirror-rest/__tests__/middleware/responseCacheHandler.test.js @@ -71,9 +71,9 @@ describe('Response cache middleware', () => { route: { path: '/api/v1/accounts', }, - get: function(headerName) { + get: function (headerName) { return this.headers[headerName]; - } + }, }; mockResponse = { @@ -99,7 +99,6 @@ describe('Response cache middleware', () => { }, defaultBeforeAllTimeoutMillis); describe('Cache check', () => { - test('Cache miss', async () => { // The cache is empty, thus a cache miss is expected. await responseCacheCheckHandler(mockRequest, mockResponse, null); @@ -213,26 +212,29 @@ describe('Response cache middleware', () => { expect(cachedResponse).toBeUndefined(); }); - test.each([httpStatusCodes.OK.code, httpStatusCodes.UNMODIFIED.code])('Cache successful response - %d', async (status) => { - const cacheKey = cacheKeyGenerator(mockRequest); - const expectedBody = JSONStringify({a: 'b'}); - - mockResponse.locals[responseBodyLabel] = expectedBody; - mockResponse.locals[responseCacheKeyLabel] = cacheKey; - mockResponse.statusCode = status; - mockResponse.getHeaders.mockImplementation(() => mockResponse.headers); - - await responseCacheUpdateHandler(mockRequest, mockResponse, null); - const cachedResponse = await cache.getSingleWithTtl(cacheKey); - expect(cachedResponse).not.toBeUndefined(); - - expect(cachedResponse.ttl).toBeLessThanOrEqual(cacheControlMaxAge); - expect(cachedResponse.value?.compressed).toEqual(false); - expect(cachedResponse.value?.body).toEqual(expectedBody); - - const expectedHeaders = {'content-type': 'application/json; charset=utf-8'}; - expect(cachedResponse.value?.headers).toEqual(expectedHeaders); - }); + test.each([httpStatusCodes.OK.code, httpStatusCodes.UNMODIFIED.code])( + 'Cache successful response - %d', + async (status) => { + const cacheKey = cacheKeyGenerator(mockRequest); + const expectedBody = JSONStringify({a: 'b'}); + + mockResponse.locals[responseBodyLabel] = expectedBody; + mockResponse.locals[responseCacheKeyLabel] = cacheKey; + mockResponse.statusCode = status; + mockResponse.getHeaders.mockImplementation(() => mockResponse.headers); + + await responseCacheUpdateHandler(mockRequest, mockResponse, null); + const cachedResponse = await cache.getSingleWithTtl(cacheKey); + expect(cachedResponse).not.toBeUndefined(); + + expect(cachedResponse.ttl).toBeLessThanOrEqual(cacheControlMaxAge); + expect(cachedResponse.value?.compressed).toEqual(false); + expect(cachedResponse.value?.body).toEqual(expectedBody); + + const expectedHeaders = {'content-type': 'application/json; charset=utf-8'}; + expect(cachedResponse.value?.headers).toEqual(expectedHeaders); + } + ); }); }); @@ -244,8 +246,8 @@ describe('Response cache middleware', () => { describe('Cache check', () => { test('Cache hit accepts gzip', async () => { // Place the expected response in the cache. - const cachedBody= gzipSync(JSONStringify({a: 'b'})); - const cachedResponse= new CachedApiResponse(httpStatusCodes.OK.code, cachedHeaders, cachedBody, true); + const cachedBody = gzipSync(JSONStringify({a: 'b'})); + const cachedResponse = new CachedApiResponse(httpStatusCodes.OK.code, cachedHeaders, cachedBody, true); const cacheKey = cacheKeyGenerator(mockRequest); await cache.setSingle(cacheKey, cacheControlMaxAge, cachedResponse); @@ -257,10 +259,15 @@ describe('Response cache middleware', () => { }); test('Cache hit does not accept gzip', async () => { - const cachedBody= JSONStringify({a: 'b'}); + const cachedBody = JSONStringify({a: 'b'}); // Place the expected response in the cache. - const cachedResponse = new CachedApiResponse(httpStatusCodes.OK.code, cachedHeaders, gzipSync(cachedBody), true); + const cachedResponse = new CachedApiResponse( + httpStatusCodes.OK.code, + cachedHeaders, + gzipSync(cachedBody), + true + ); const cacheKey = cacheKeyGenerator(mockRequest); await cache.setSingle(cacheKey, cacheControlMaxAge, cachedResponse); @@ -276,26 +283,29 @@ describe('Response cache middleware', () => { }); describe('Cache update', () => { - test.each([httpStatusCodes.OK.code, httpStatusCodes.UNMODIFIED.code])('Cache successful response - %d', async (status) => { - const cacheKey = cacheKeyGenerator(mockRequest); - const expectedBody = JSONStringify({a: 'b'}); - - mockResponse.locals[responseBodyLabel] = expectedBody; - mockResponse.locals[responseCacheKeyLabel] = cacheKey; - mockResponse.statusCode = status; - mockResponse.getHeaders.mockImplementation(() => mockResponse.headers); - - await responseCacheUpdateHandler(mockRequest, mockResponse, null); - const cachedResponse = await cache.getSingleWithTtl(cacheKey); - expect(cachedResponse).not.toBeUndefined(); - - expect(cachedResponse.ttl).toBeLessThanOrEqual(cacheControlMaxAge); - expect(cachedResponse.value?.compressed).toEqual(true); - expect(unzipSync(Buffer.from(cachedResponse.value?.body)).toString()).toEqual(expectedBody); - - const expectedHeaders = {'content-type': 'application/json; charset=utf-8'}; - expect(cachedResponse.value?.headers).toEqual(expectedHeaders); - }); + test.each([httpStatusCodes.OK.code, httpStatusCodes.UNMODIFIED.code])( + 'Cache successful response - %d', + async (status) => { + const cacheKey = cacheKeyGenerator(mockRequest); + const expectedBody = JSONStringify({a: 'b'}); + + mockResponse.locals[responseBodyLabel] = expectedBody; + mockResponse.locals[responseCacheKeyLabel] = cacheKey; + mockResponse.statusCode = status; + mockResponse.getHeaders.mockImplementation(() => mockResponse.headers); + + await responseCacheUpdateHandler(mockRequest, mockResponse, null); + const cachedResponse = await cache.getSingleWithTtl(cacheKey); + expect(cachedResponse).not.toBeUndefined(); + + expect(cachedResponse.ttl).toBeLessThanOrEqual(cacheControlMaxAge); + expect(cachedResponse.value?.compressed).toEqual(true); + expect(unzipSync(Buffer.from(cachedResponse.value?.body)).toString()).toEqual(expectedBody); + + const expectedHeaders = {'content-type': 'application/json; charset=utf-8'}; + expect(cachedResponse.value?.headers).toEqual(expectedHeaders); + } + ); }); }); }); diff --git a/hedera-mirror-rest/cache.js b/hedera-mirror-rest/cache.js index 935ba109e2..81e5a5cd46 100644 --- a/hedera-mirror-rest/cache.js +++ b/hedera-mirror-rest/cache.js @@ -79,11 +79,11 @@ export class Cache { } const result = await this.redis - .multi() - .ttl(key) - .get(key) - .exec() - .catch((err) => logger.warn(`Redis error during ttl/get: ${err.message}`)); + .multi() + .ttl(key) + .get(key) + .exec() + .catch((err) => logger.warn(`Redis error during ttl/get: ${err.message}`)); // result is [[null, ttl], [null, value]], with value === null on cache miss. const rawValue = result[1][1]; diff --git a/hedera-mirror-rest/config.js b/hedera-mirror-rest/config.js index ad4078163e..6e09d1187a 100644 --- a/hedera-mirror-rest/config.js +++ b/hedera-mirror-rest/config.js @@ -175,10 +175,10 @@ const durationQueryConfigKeys = [ const parseQueryConfig = () => { const {query} = getConfig(); - const { precedingTransactionTypes } = query.transactions; + const {precedingTransactionTypes} = query.transactions; if (!Array.isArray(precedingTransactionTypes)) { throw new InvalidConfigError( - `Invalid or missing query.transactions.precedingTransactionTypes: ${precedingTransactionTypes}` + `Invalid or missing query.transactions.precedingTransactionTypes: ${precedingTransactionTypes}` ); } durationQueryConfigKeys.forEach((key) => (query[`${key}Ns`] = parseDurationConfig(`query.${key}`, query[key]))); diff --git a/hedera-mirror-rest/middleware/responseCacheHandler.js b/hedera-mirror-rest/middleware/responseCacheHandler.js index ee2268ed1b..4f8a6e22f3 100644 --- a/hedera-mirror-rest/middleware/responseCacheHandler.js +++ b/hedera-mirror-rest/middleware/responseCacheHandler.js @@ -50,7 +50,7 @@ const responseCacheCheckHandler = async (req, res, next) => { res.status(statusCode); if (isHead || clientCached) { - res.end(); + res.end(); } else { if (cachedResponse.compressed) { cachedResponse.body = Buffer.from(cachedResponse.body); @@ -61,7 +61,7 @@ const responseCacheCheckHandler = async (req, res, next) => { res.setHeader(CONTENT_ENCODING_HEADER, 'gzip'); } } - + res.send(cachedResponse.body); } @@ -79,7 +79,8 @@ const responseCacheUpdateHandler = async (req, res, next) => { const compressionEnabled = config.cache.response.compress; const responseCacheKey = res.locals[responseCacheKeyLabel]; const responseBody = res.locals[responseBodyLabel]; - const isSuccessfulResponse = res.statusCode === httpStatusCodes.UNMODIFIED.code || httpStatusCodes.isSuccess(res.statusCode); + const isSuccessfulResponse = + res.statusCode === httpStatusCodes.UNMODIFIED.code || httpStatusCodes.isSuccess(res.statusCode); if (responseBody && responseCacheKey && isSuccessfulResponse) { const ttl = getCacheControlExpiryOrDefault(res.getHeaders()[CACHE_CONTROL_HEADER]); diff --git a/hedera-mirror-rest/transactions.js b/hedera-mirror-rest/transactions.js index f026ba58e0..7ab2d237b6 100644 --- a/hedera-mirror-rest/transactions.js +++ b/hedera-mirror-rest/transactions.js @@ -41,10 +41,15 @@ import {AssessedCustomFeeViewModel, NftTransferViewModel} from './viewmodel'; const SUCCESS_PROTO_IDS = TransactionResult.getSuccessProtoIds(); -const { query: {maxTransactionConsensusTimestampRangeNs, - transactions: {precedingTransactionTypes}}, - response: { limit: {default: defaultResponseLimit},}, - } = config; +const { + query: { + maxTransactionConsensusTimestampRangeNs, + transactions: {precedingTransactionTypes}, + }, + response: { + limit: {default: defaultResponseLimit}, + }, +} = config; const cache = new Cache(); @@ -343,7 +348,11 @@ const getTransferDistinctTimestampsQuery = ( // the condition to exclude synthetic transactions attached to a user submitted transaction const transactionByPayerExcludeSyntheticCondition = `${Transaction.getFullName(Transaction.NONCE)} = 0 or ${Transaction.getFullName(Transaction.PARENT_CONSENSUS_TIMESTAMP)} is not null -${precedingTransactionTypes.length > 0 ? `or ${Transaction.getFullName(Transaction.TYPE)} in (${precedingTransactionTypes.join(', ')})` : ''}`; +${ + precedingTransactionTypes.length > 0 + ? `or ${Transaction.getFullName(Transaction.TYPE)} in (${precedingTransactionTypes.join(', ')})` + : '' +}`; const getQueryWithEqualValues = (column, params, values) => { if (values.length === 0) { diff --git a/hedera-mirror-rest/viewmodel/contractResultViewModel.js b/hedera-mirror-rest/viewmodel/contractResultViewModel.js index b8ca74624e..5a55b4d6d4 100644 --- a/hedera-mirror-rest/viewmodel/contractResultViewModel.js +++ b/hedera-mirror-rest/viewmodel/contractResultViewModel.js @@ -39,7 +39,9 @@ class ContractResultViewModel { this.contract_id = contractId.toString(); this.created_contract_ids = _.toArray(contractResult.createdContractIds).map((id) => EntityId.parse(id).toString()); this.error_message = _.isEmpty(contractResult.errorMessage) ? null : contractResult.errorMessage; - this.from = EntityId.parse(contractResult.senderId, {isNullable: true}).toEvmAddress() || this.#extractSenderFromFunctionResult(contractResult); + this.from = + EntityId.parse(contractResult.senderId, {isNullable: true}).toEvmAddress() || + this.#extractSenderFromFunctionResult(contractResult); this.function_parameters = toHexString(contractResult.functionParameters, true); this.gas_consumed = contractResult.gasConsumed; this.gas_limit = contractResult.gasLimit; diff --git a/hedera-mirror-test/k6/src/rest-java/libex/constants.js b/hedera-mirror-test/k6/src/rest-java/libex/constants.js index 91d48701e2..d8197b8fae 100644 --- a/hedera-mirror-test/k6/src/rest-java/libex/constants.js +++ b/hedera-mirror-test/k6/src/rest-java/libex/constants.js @@ -16,4 +16,3 @@ export const accountNftAllowanceListName = 'allowances'; export const airdrops = 'airdrops'; - diff --git a/hedera-mirror-test/k6/src/web3/test/common.js b/hedera-mirror-test/k6/src/web3/test/common.js index 9fd3ffdcae..23501ea528 100644 --- a/hedera-mirror-test/k6/src/web3/test/common.js +++ b/hedera-mirror-test/k6/src/web3/test/common.js @@ -93,9 +93,9 @@ function ContractCallTestScenarioBuilder() { } const response = jsonPost(that._url, JSON.stringify(payload)); - check(response, {[`${that._name}`]: (r) => that._shouldRevert - ? !isNonErrorResponse(r) - : isNonErrorResponse(r)}); + check(response, { + [`${that._name}`]: (r) => (that._shouldRevert ? !isNonErrorResponse(r) : isNonErrorResponse(r)), + }); if (sleepSecs > 0) { sleep(sleepSecs); diff --git a/hedera-mirror-test/k6/src/web3/test/commonPrecompileModificationFunctionsTemplate.js b/hedera-mirror-test/k6/src/web3/test/commonPrecompileModificationFunctionsTemplate.js index d7b4b43c7c..68c9894700 100644 --- a/hedera-mirror-test/k6/src/web3/test/commonPrecompileModificationFunctionsTemplate.js +++ b/hedera-mirror-test/k6/src/web3/test/commonPrecompileModificationFunctionsTemplate.js @@ -22,7 +22,11 @@ function PrecompileModificationTestTemplate(key, shouldRevert) { return JSON.parse(open('../resources/modificationFunctions.json'))[key]; }); - const {options, run} = new ContractCallTestScenarioBuilder().name(key).vuData(data).shouldRevert(shouldRevert).build(); + const {options, run} = new ContractCallTestScenarioBuilder() + .name(key) + .vuData(data) + .shouldRevert(shouldRevert) + .build(); return {options, run}; } diff --git a/hedera-mirror-test/k6/src/web3/test/index.js b/hedera-mirror-test/k6/src/web3/test/index.js index d3e6664cad..a40421d072 100644 --- a/hedera-mirror-test/k6/src/web3/test/index.js +++ b/hedera-mirror-test/k6/src/web3/test/index.js @@ -106,7 +106,7 @@ const tests = { rampUp, }; -if (__ENV.RUN_ESTIMATE_TESTS !=="false") { +if (__ENV.RUN_ESTIMATE_TESTS !== 'false') { Object.assign(tests, { contractCallEstimateFungibleTokenCustomFees, contractCallEstimateNftCustomFees, @@ -129,7 +129,7 @@ if (__ENV.RUN_ESTIMATE_TESTS !=="false") { }); } -if (__ENV.RUN_MODIFICATION_TESTS !=="false") { +if (__ENV.RUN_MODIFICATION_TESTS !== 'false') { Object.assign(tests, { contractCallPrecompileApprove, contractCallPrecompileAssociate, diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileApprove.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileApprove.js index ba4974b6f4..f38e86ba76 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileApprove.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileApprove.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -23,16 +22,18 @@ const selector = '0xceda64c4'; //approveExternal const token = __ENV.TOKEN_ADDRESS; const spender = __ENV.RECEIVER_ADDRESS; const amount = __ENV.AMOUNT; -const runMode = __ENV.RUN_WITH_VARIABLES +const runMode = __ENV.RUN_WITH_VARIABLES; const testName = 'contractCallPrecompileApprove'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, false) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([token, spender, amount]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([token, spender, amount]) + .to(contract) + .build(); export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileAssociate.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileAssociate.js index bc320c79d7..12fbf11dda 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileAssociate.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileAssociate.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {PrecompileModificationTestTemplate} from '../commonPrecompileModificationFunctionsTemplate.js'; @@ -21,17 +20,19 @@ import {ContractCallTestScenarioBuilder} from '../common.js'; const contract = __ENV.ESTIMATE_PRECOMPILE_CONTRACT; const account = __ENV.SPENDER_ADDRESS; const token = __ENV.TOKEN_ADDRESS; -const runMode = __ENV.RUN_WITH_VARIABLES +const runMode = __ENV.RUN_WITH_VARIABLES; const selector = '0xd91cfc95'; //associateTokenExternal -const testName = 'contractCallPrecompileAssociate' +const testName = 'contractCallPrecompileAssociate'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, false) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([account, token]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([account, token]) + .to(contract) + .build(); -export {options, run}; \ No newline at end of file +export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileCryptoTransferHbars.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileCryptoTransferHbars.js index f2796855cc..87fd674d44 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileCryptoTransferHbars.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileCryptoTransferHbars.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -25,23 +24,28 @@ const receiver = __ENV.SPENDER_ADDRESS; const runMode = __ENV.RUN_WITH_VARIABLES; const testName = 'contractCallPrecompileCryptoTransferHbars'; //ABI encoded parameters used for crypto transfer of Hbars -const data1 = "0000000000000000000000000000000000000000000000000000000000000040" - + "0000000000000000000000000000000000000000000000000000000000000140" - + "0000000000000000000000000000000000000000000000000000000000000020" - + "0000000000000000000000000000000000000000000000000000000000000002"; -const data2 = "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6" - + "0000000000000000000000000000000000000000000000000000000000000000"; -const data3 = "000000000000000000000000000000000000000000000000000000000000000a" - + "0000000000000000000000000000000000000000000000000000000000000000" - + "0000000000000000000000000000000000000000000000000000000000000000"; +const data1 = + '0000000000000000000000000000000000000000000000000000000000000040' + + '0000000000000000000000000000000000000000000000000000000000000140' + + '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000002'; +const data2 = + 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6' + + '0000000000000000000000000000000000000000000000000000000000000000'; +const data3 = + '000000000000000000000000000000000000000000000000000000000000000a' + + '0000000000000000000000000000000000000000000000000000000000000000' + + '0000000000000000000000000000000000000000000000000000000000000000'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, false) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([data1,sender,data2,receiver,data3]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([data1, sender, data2, receiver, data3]) + .to(contract) + .build(); export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileCryptoTransferToken.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileCryptoTransferToken.js index ad33a87b6b..dd39f43f4c 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileCryptoTransferToken.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileCryptoTransferToken.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -23,30 +22,36 @@ const selector = '0xa6218810'; //cryptoTransferExternal const sender = __ENV.ACCOUNT_ADDRESS; const receiver = __ENV.RECEIVER_ADDRESS; const token = __ENV.TOKEN_ADDRESS; -const runMode = __ENV.RUN_WITH_VARIABLES +const runMode = __ENV.RUN_WITH_VARIABLES; //ABI encoded parameters used for crypto transfer token -const data1 = "0000000000000000000000000000000000000000000000000000000000000040" - + "0000000000000000000000000000000000000000000000000000000000000080" - + "0000000000000000000000000000000000000000000000000000000000000020" - + "0000000000000000000000000000000000000000000000000000000000000000" - + "0000000000000000000000000000000000000000000000000000000000000001" - + "0000000000000000000000000000000000000000000000000000000000000020" -const data2 = "0000000000000000000000000000000000000000000000000000000000000060" - + "0000000000000000000000000000000000000000000000000000000000000140" - + "0000000000000000000000000000000000000000000000000000000000000002" -const data3 = "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd" - + "0000000000000000000000000000000000000000000000000000000000000000" -const data4= "0000000000000000000000000000000000000000000000000000000000000003" - + "0000000000000000000000000000000000000000000000000000000000000000" - + "0000000000000000000000000000000000000000000000000000000000000000"; +const data1 = + '0000000000000000000000000000000000000000000000000000000000000040' + + '0000000000000000000000000000000000000000000000000000000000000080' + + '0000000000000000000000000000000000000000000000000000000000000020' + + '0000000000000000000000000000000000000000000000000000000000000000' + + '0000000000000000000000000000000000000000000000000000000000000001' + + '0000000000000000000000000000000000000000000000000000000000000020'; +const data2 = + '0000000000000000000000000000000000000000000000000000000000000060' + + '0000000000000000000000000000000000000000000000000000000000000140' + + '0000000000000000000000000000000000000000000000000000000000000002'; +const data3 = + 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd' + + '0000000000000000000000000000000000000000000000000000000000000000'; +const data4 = + '0000000000000000000000000000000000000000000000000000000000000003' + + '0000000000000000000000000000000000000000000000000000000000000000' + + '0000000000000000000000000000000000000000000000000000000000000000'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate('contractCallPrecompileCryptoTransferToken', false) - : new ContractCallTestScenarioBuilder().name('contractCallPrecompileCryptoTransferToken') // use unique scenario name among all tests - .selector(selector) - .args([data1,token,data2,sender,data3,receiver,data4]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name('contractCallPrecompileCryptoTransferToken') // use unique scenario name among all tests + .selector(selector) + .args([data1, token, data2, sender, data3, receiver, data4]) + .to(contract) + .build(); -export {options, run}; \ No newline at end of file +export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileDeleteToken.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileDeleteToken.js index 8b4fef0ef5..db17246083 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileDeleteToken.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileDeleteToken.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -25,12 +24,14 @@ const runMode = __ENV.RUN_WITH_VARIABLES; const testName = 'contractCallPrecompileDeleteToken'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, false) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([token]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([token]) + .to(contract) + .build(); export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileDissociate.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileDissociate.js index b19441053a..f058fba7f0 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileDissociate.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileDissociate.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -26,12 +25,14 @@ const runMode = __ENV.RUN_WITH_VARIABLES; const testName = 'contractCallPrecompileDissociate'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, false) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([account, token]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([account, token]) + .to(contract) + .build(); export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileMintToken.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileMintToken.js index 3a15696b26..53b5e9607e 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileMintToken.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileMintToken.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -24,16 +23,19 @@ const token = __ENV.TOKEN_ADDRESS; const amount = __ENV.AMOUNT; const runMode = __ENV.RUN_WITH_VARIABLES; const testName = 'contractCallPrecompileMintToken'; -const emptyByteArray= '0000000000000000000000000000000000000000000000000000000000000060' - + '0000000000000000000000000000000000000000000000000000000000000000'; +const emptyByteArray = + '0000000000000000000000000000000000000000000000000000000000000060' + + '0000000000000000000000000000000000000000000000000000000000000000'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, false) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([token, amount, emptyByteArray]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([token, amount, emptyByteArray]) + .to(contract) + .build(); export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileNestedAssociate.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileNestedAssociate.js index fddd6123f1..ddb863fb64 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileNestedAssociate.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileNestedAssociate.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -26,13 +25,15 @@ const runMode = __ENV.RUN_WITH_VARIABLES; const testName = 'contractCallPrecompileNestedAssociate'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, true) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([account, token]) - .to(contract) - .shouldRevert(true) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([account, token]) + .to(contract) + .shouldRevert(true) + .build(); export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileTransferFungibleToken.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileTransferFungibleToken.js index 4b391e7212..3a9f4b37b5 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileTransferFungibleToken.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallPrecompileTransferFungibleToken.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -28,12 +27,14 @@ const selector = '0x4fd6ce0a'; //transferTokenExternal const testName = 'contractCallPrecompileTransferFungibleToken'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, false) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([token, sender, receiver, amount]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([token, sender, receiver, amount]) + .to(contract) + .build(); export {options, run}; diff --git a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallRedirectApprove.js b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallRedirectApprove.js index 40c7915e3b..d6deb79dcd 100644 --- a/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallRedirectApprove.js +++ b/hedera-mirror-test/k6/src/web3/test/modificationTests/contractCallRedirectApprove.js @@ -5,14 +5,13 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * */ import {ContractCallTestScenarioBuilder} from '../common.js'; @@ -24,15 +23,17 @@ const token = __ENV.TOKEN_ADDRESS; const spender = __ENV.RECEIVER_ADDRESS; const amount = __ENV.AMOUNT; const runMode = __ENV.RUN_WITH_VARIABLES; -const testName = "contractCallRedirectApprove"; +const testName = 'contractCallRedirectApprove'; //If RUN_WITH_VARIABLES=true will run tests with __ENV variables -const {options, run} = runMode==="false" +const {options, run} = + runMode === 'false' ? new PrecompileModificationTestTemplate(testName, false) - : new ContractCallTestScenarioBuilder().name(testName) // use unique scenario name among all tests - .selector(selector) - .args([token, spender, amount]) - .to(contract) - .build(); + : new ContractCallTestScenarioBuilder() + .name(testName) // use unique scenario name among all tests + .selector(selector) + .args([token, spender, amount]) + .to(contract) + .build(); export {options, run}; diff --git a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/converter/CustomFeesConverter.java b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/converter/CustomFeesConverter.java index a812b41d02..35ec9025bd 100644 --- a/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/converter/CustomFeesConverter.java +++ b/hedera-mirror-test/src/test/java/com/hedera/mirror/test/e2e/acceptance/converter/CustomFeesConverter.java @@ -47,7 +47,8 @@ public AssessedCustomFee mirrorAssessedCustomFee(Map entry) { assessedCustomFee.setCollectorAccountId(collector.getAccountId().toString()); if (StringUtils.isNotEmpty(effectivePayer)) { var effectivePayerAccountId = accountClient.getAccount(AccountNameEnum.valueOf(effectivePayer)); - assessedCustomFee.setEffectivePayerAccountIds(List.of(effectivePayerAccountId.getAccountId().toString())); + assessedCustomFee.setEffectivePayerAccountIds( + List.of(effectivePayerAccountId.getAccountId().toString())); } assessedCustomFee.setTokenId(getToken(entry.get("token"))); return assessedCustomFee; diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/TransactionHashParameter.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/TransactionHashParameter.java index f5ba3993a3..ad3125a51e 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/TransactionHashParameter.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/TransactionHashParameter.java @@ -24,7 +24,7 @@ public record TransactionHashParameter(Bytes hash) implements TransactionIdOrHashParameter { private static final Pattern ETH_HASH_PATTERN = Pattern.compile("^(0x)?([0-9A-Fa-f]{64})$"); - + public static TransactionHashParameter valueOf(String hash) { if (!isValidEthHash(hash)) { return null; diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/TransactionIdParameter.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/TransactionIdParameter.java index 06e0c63660..2076fa7fa9 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/TransactionIdParameter.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/common/TransactionIdParameter.java @@ -22,9 +22,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -public record TransactionIdParameter(EntityId payerAccountId, Instant validStart) implements TransactionIdOrHashParameter { +public record TransactionIdParameter(EntityId payerAccountId, Instant validStart) + implements TransactionIdOrHashParameter { - private static final Pattern TRANSACTION_ID_PATTERN = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)-(\\d{1,19})-(\\d{1,9})$"); + private static final Pattern TRANSACTION_ID_PATTERN = + Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)-(\\d{1,19})-(\\d{1,9})$"); public static TransactionIdParameter valueOf(String transactionId) throws InvalidParametersException { if (transactionId == null) { diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/ContractResultRepository.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/ContractResultRepository.java index d21e7f8550..3361881993 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/ContractResultRepository.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/ContractResultRepository.java @@ -21,6 +21,4 @@ import org.springframework.stereotype.Repository; @Repository -public interface ContractResultRepository extends CrudRepository { - -} +public interface ContractResultRepository extends CrudRepository {} diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/EthereumTransactionRepository.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/EthereumTransactionRepository.java index 887afffbe1..c1d8dac29b 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/EthereumTransactionRepository.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/EthereumTransactionRepository.java @@ -25,5 +25,6 @@ @Repository public interface EthereumTransactionRepository extends CrudRepository { - Optional findByConsensusTimestampAndPayerAccountId(long consensusTimestamp, EntityId payerAccountId); + Optional findByConsensusTimestampAndPayerAccountId( + long consensusTimestamp, EntityId payerAccountId); } diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/RecordFileRepository.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/RecordFileRepository.java index f7a23872ea..ab38b0953b 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/RecordFileRepository.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/repository/RecordFileRepository.java @@ -57,7 +57,11 @@ public interface RecordFileRepository extends PagingAndSortingRepository findLatest(); @Caching( - cacheable = @Cacheable(cacheNames = CACHE_NAME, cacheManager = CACHE_MANAGER_RECORD_FILE_TIMESTAMP, unless = "#result == null"), + cacheable = + @Cacheable( + cacheNames = CACHE_NAME, + cacheManager = CACHE_MANAGER_RECORD_FILE_TIMESTAMP, + unless = "#result == null"), put = @CachePut(cacheNames = CACHE_NAME, cacheManager = CACHE_MANAGER_RECORD_FILE_INDEX)) @Query("select r from RecordFile r where r.consensusEnd >= ?1 order by r.consensusEnd asc limit 1") Optional findByTimestamp(long timestamp); diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/OpcodeService.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/OpcodeService.java index b9f7a6540a..c6ee084200 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/OpcodeService.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/service/OpcodeService.java @@ -28,6 +28,6 @@ public interface OpcodeService { * @param options the {@link OpcodeTracerOptions} * @return the {@link OpcodesResponse} holding the result of the opcode call */ - OpcodesResponse processOpcodeCall(@NonNull TransactionIdOrHashParameter transactionIdOrHash, - @NonNull OpcodeTracerOptions options); + OpcodesResponse processOpcodeCall( + @NonNull TransactionIdOrHashParameter transactionIdOrHash, @NonNull OpcodeTracerOptions options); } diff --git a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/NftReadableKVState.java b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/NftReadableKVState.java index a3aeddac56..cdd7c3ddb7 100644 --- a/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/NftReadableKVState.java +++ b/hedera-mirror-web3/src/main/java/com/hedera/mirror/web3/state/NftReadableKVState.java @@ -79,7 +79,7 @@ private Nft mapToNft(final com.hedera.mirror.common.domain.token.Nft nft, final .mintTime(convertToTimestamp(nft.getCreatedTimestamp())) .nftId(new NftID(tokenID, nft.getSerialNumber())) .ownerId(EntityIdUtils.toAccountId(nft.getAccountId())) - .spenderId(EntityIdUtils.toAccountId(nft.getSpender() != null ? nft.getSpender() : EntityId.EMPTY) ) + .spenderId(EntityIdUtils.toAccountId(nft.getSpender() != null ? nft.getSpender() : EntityId.EMPTY)) .build(); } } diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/common/TransactionHashParameterTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/common/TransactionHashParameterTest.java index 76307fa1ed..1c9794c087 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/common/TransactionHashParameterTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/common/TransactionHashParameterTest.java @@ -35,8 +35,7 @@ private static Stream provideEthHashes() { Arguments.of("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", true), Arguments.of("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", true), Arguments.of("0xGHIJKL", false), - Arguments.of(null, false) - ); + Arguments.of(null, false)); } @ParameterizedTest diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallEvmCodesTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallEvmCodesTest.java index 69ee14f39c..46be59836d 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallEvmCodesTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/service/ContractCallEvmCodesTest.java @@ -208,11 +208,11 @@ void getBlockHashAfterTheLatestReturnsZero() throws Exception { @ParameterizedTest @CsvSource({ - // function getCodeHash with parameter hedera system accounts, expected 0 bytes - "0000000000000000000000000000000000000000000000000000000000000167", - "0000000000000000000000000000000000000000000000000000000000000168", - "00000000000000000000000000000000000000000000000000000000000002ee", - "00000000000000000000000000000000000000000000000000000000000002e4", + // function getCodeHash with parameter hedera system accounts, expected 0 bytes + "0000000000000000000000000000000000000000000000000000000000000167", + "0000000000000000000000000000000000000000000000000000000000000168", + "00000000000000000000000000000000000000000000000000000000000002ee", + "00000000000000000000000000000000000000000000000000000000000002e4", }) void testSystemContractCodeHash(String input) throws Exception { final var contract = testWeb3jService.deploy(EvmCodes::deploy); @@ -229,11 +229,11 @@ void testNonSystemContractEthCallCodeHash() throws Exception { final List capturedOutputs = new ArrayList<>(); doAnswer(invocation -> { - HederaEvmTransactionProcessingResult result = - (HederaEvmTransactionProcessingResult) invocation.callRealMethod(); - capturedOutputs.add(result.getOutput()); // Capture the result - return result; - }) + HederaEvmTransactionProcessingResult result = + (HederaEvmTransactionProcessingResult) invocation.callRealMethod(); + capturedOutputs.add(result.getOutput()); // Capture the result + return result; + }) .when(contractExecutionService) .callContract(any(), any()); @@ -313,7 +313,7 @@ void selfDestructCallWithSystemAccount() { // Then assertThatThrownBy(() -> contract.send_destroyContract(systemAccountAddress.toUnprefixedHexString()) - .send()) + .send()) .isInstanceOf(MirrorEvmTransactionException.class) .satisfies(ex -> { MirrorEvmTransactionException exception = (MirrorEvmTransactionException) ex; diff --git a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/NftReadableKVStateTest.java b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/NftReadableKVStateTest.java index f52a9a4256..ec3eaa995a 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/NftReadableKVStateTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/mirror/web3/state/NftReadableKVStateTest.java @@ -138,7 +138,7 @@ void getNftMappedValuesEmptyTokenId() { } @Test - void getNftMappedValuesMissingSpenderWithoutTimestamp(){ + void getNftMappedValuesMissingSpenderWithoutTimestamp() { when(contractCallContext.getTimestamp()).thenReturn(Optional.empty()); Nft nftDomain = setupNftMissingSpender(Optional.empty()); assertThat(nftReadableKVState.readFromDataSource(NFT_ID)).satisfies(nft -> assertThat(nft) @@ -147,10 +147,7 @@ void getNftMappedValuesMissingSpenderWithoutTimestamp(){ EntityIdUtils.toAccountId(nftDomain.getAccountId()), com.hedera.hapi.node.state.token.Nft::ownerId) .returns( - new AccountID( - 0L, - 0L, - new OneOf<>(AccountOneOfType.ACCOUNT_NUM, 0L)), + new AccountID(0L, 0L, new OneOf<>(AccountOneOfType.ACCOUNT_NUM, 0L)), com.hedera.hapi.node.state.token.Nft::spenderId) .returns( convertToTimestamp(nftDomain.getCreatedTimestamp()), @@ -161,7 +158,7 @@ void getNftMappedValuesMissingSpenderWithoutTimestamp(){ } @Test - void getNftMappedValuesMissingSpenderWithTimestamp(){ + void getNftMappedValuesMissingSpenderWithTimestamp() { when(contractCallContext.getTimestamp()).thenReturn(timestamp); Nft nftDomain = setupNftMissingSpender(timestamp); assertThat(nftReadableKVState.readFromDataSource(NFT_ID)).satisfies(nft -> assertThat(nft) @@ -170,10 +167,7 @@ void getNftMappedValuesMissingSpenderWithTimestamp(){ EntityIdUtils.toAccountId(nftDomain.getAccountId()), com.hedera.hapi.node.state.token.Nft::ownerId) .returns( - new AccountID( - 0L, - 0L, - new OneOf<>(AccountOneOfType.ACCOUNT_NUM, 0L)), + new AccountID(0L, 0L, new OneOf<>(AccountOneOfType.ACCOUNT_NUM, 0L)), com.hedera.hapi.node.state.token.Nft::spenderId) .returns( convertToTimestamp(nftDomain.getCreatedTimestamp()), @@ -221,8 +215,7 @@ private Nft setupNft(Optional timestamp) { private Nft setupNftMissingSpender(Optional timestamp) { Nft databaseNft = domainBuilder .nft() - .customize(t -> t.tokenId(entity.getId()) - .serialNumber(NFT_ID.serialNumber())) + .customize(t -> t.tokenId(entity.getId()).serialNumber(NFT_ID.serialNumber())) .get(); if (timestamp.isPresent()) { @@ -236,7 +229,6 @@ private Nft setupNftMissingSpender(Optional timestamp) { return databaseNft; } - private Timestamp convertToTimestamp(long timestamp) { var instant = Instant.ofEpochMilli(timestamp); return new Timestamp(instant.getEpochSecond(), instant.getNano()); diff --git a/hedera-mirror-web3/src/test/java/com/hedera/node/app/service/contract/impl/exec/operations/HederaCustomCallOperationTest.java b/hedera-mirror-web3/src/test/java/com/hedera/node/app/service/contract/impl/exec/operations/HederaCustomCallOperationTest.java index 3b558c019a..99e1a67471 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/node/app/service/contract/impl/exec/operations/HederaCustomCallOperationTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/node/app/service/contract/impl/exec/operations/HederaCustomCallOperationTest.java @@ -58,7 +58,7 @@ void setUp() { @Test void testHappyPath() { - given(frame.getStackItem(anyInt())).willReturn(Bytes.wrap(new byte[]{1})); + given(frame.getStackItem(anyInt())).willReturn(Bytes.wrap(new byte[] {1})); given(frame.getWorldUpdater()).willReturn(worldUpdater); given(frame.getRemainingGas()).willReturn(200L); given(frame.stackSize()).willReturn(7); @@ -72,7 +72,7 @@ void testHappyPath() { @Test void testInsufficientGas() { - given(frame.getStackItem(anyInt())).willReturn(Bytes.wrap(new byte[]{1})); + given(frame.getStackItem(anyInt())).willReturn(Bytes.wrap(new byte[] {1})); given(frame.getWorldUpdater()).willReturn(worldUpdater); given(frame.getRemainingGas()).willReturn(50L); given(subject.cost(frame, false)).willReturn(100L); diff --git a/hedera-mirror-web3/src/test/java/com/hedera/services/fees/calculation/UsageBasedFeeCalculatorTest.java b/hedera-mirror-web3/src/test/java/com/hedera/services/fees/calculation/UsageBasedFeeCalculatorTest.java index a96d2a3e9e..233e62b382 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/services/fees/calculation/UsageBasedFeeCalculatorTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/services/fees/calculation/UsageBasedFeeCalculatorTest.java @@ -58,13 +58,11 @@ import com.hederahashgraph.api.proto.java.Transaction; import com.hederahashgraph.api.proto.java.TransactionBody; import com.hederahashgraph.api.proto.java.TransactionFeeSchedule; - import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -278,15 +276,17 @@ void defaultFeeIfAccountMissing() throws Exception { @Test void failsWithNseeGetTxnUsageEstimator() { - final Exception exception = assertThrows(NoSuchElementException.class, - () -> subject.computeFee(accessor, payerKey, at)); + final Exception exception = + assertThrows(NoSuchElementException.class, () -> subject.computeFee(accessor, payerKey, at)); assertEquals("No estimator exists for the given transaction", exception.getMessage()); } @Test void failsWithNseeGetQueryUsageEstimator() { - final Exception exception = assertThrows(NoSuchElementException.class, - () -> subject.estimatePayment(query, currentPrices.get(SubType.DEFAULT), at, ANSWER_ONLY)); + FeeData usgPrices = currentPrices.get(DEFAULT); + final Exception exception = assertThrows( + NoSuchElementException.class, + () -> subject.estimatePayment(query, usgPrices, at, ANSWER_ONLY)); assertEquals("No estimator exists for the given query", exception.getMessage()); } diff --git a/hedera-mirror-web3/src/test/java/com/hedera/services/txn/token/PauseLogicTest.java b/hedera-mirror-web3/src/test/java/com/hedera/services/txn/token/PauseLogicTest.java index 57cb4d36a6..62d9c990d2 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/services/txn/token/PauseLogicTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/services/txn/token/PauseLogicTest.java @@ -20,7 +20,6 @@ import static com.hedera.services.utils.TxnUtils.assertFailsWith; import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_HAS_NO_PAUSE_KEY; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -29,7 +28,6 @@ import com.hedera.services.store.models.Id; import com.hedera.services.store.models.Token; import com.hedera.services.utils.IdUtils; -import com.hederahashgraph.api.proto.java.ResponseCodeEnum; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -76,7 +74,8 @@ void rejectChangePauseStatusWithoutTokenPauseKey() { final Token emptyToken = Token.getEmptyToken(); // given: - given(store.loadPossiblyPausedToken(asTypedEvmAddress(IdUtils.asToken("1.2.3")))).willReturn(emptyToken); + given(store.loadPossiblyPausedToken(asTypedEvmAddress(IdUtils.asToken("1.2.3")))) + .willReturn(emptyToken); // expect: assertFalse(emptyToken.hasPauseKey()); diff --git a/hedera-mirror-web3/src/test/java/com/hedera/services/txn/token/UnpauseLogicTest.java b/hedera-mirror-web3/src/test/java/com/hedera/services/txn/token/UnpauseLogicTest.java index a56fd5392a..267d08c123 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/services/txn/token/UnpauseLogicTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/services/txn/token/UnpauseLogicTest.java @@ -99,7 +99,8 @@ void rejectChangePauseStatusWithoutTokenPauseKey() { final Token emptyToken = Token.getEmptyToken(); // given: - given(store.loadPossiblyPausedToken(asTypedEvmAddress(IdUtils.asToken("1.2.3")))).willReturn(emptyToken); + given(store.loadPossiblyPausedToken(asTypedEvmAddress(IdUtils.asToken("1.2.3")))) + .willReturn(emptyToken); // expect: assertFalse(emptyToken.hasPauseKey()); From bacb5a3ca41b12e99136345ab344304e9fb7848e Mon Sep 17 00:00:00 2001 From: Vasil Boyadzhiev Date: Fri, 29 Nov 2024 02:22:39 +0200 Subject: [PATCH 4/7] chore: Updating action to step security maintained version. (#9844) Signed-off-by: Vasil Boyadzhiev Signed-off-by: sdimitrov9 --- .github/workflows/release-automation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-automation.yml b/.github/workflows/release-automation.yml index da17e9b20e..93dfc709ed 100644 --- a/.github/workflows/release-automation.yml +++ b/.github/workflows/release-automation.yml @@ -105,7 +105,7 @@ jobs: - name: Close the Milestone if: ${{ steps.version_parser.outputs.prerelease == '' }} id: milestone - uses: Akkjon/close-milestone@88d3cb00ca452cb8d33f18fc0a1e22a730306b61 # v2.1.0 + uses: step-security/close-milestone@2ec61fc36f20d36256b3652d302aa89fd4ca2abf # v2.1.0 with: milestone_name: ${{ steps.version_parser.outputs.release }} env: From 15c40f97d1111d57aa4c988c3af839f960b46b99 Mon Sep 17 00:00:00 2001 From: sdimitrov9 Date: Fri, 29 Nov 2024 11:04:46 +0200 Subject: [PATCH 5/7] style: apply spotless formatting Signed-off-by: sdimitrov9 --- .../services/fees/calculation/UsageBasedFeeCalculatorTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hedera-mirror-web3/src/test/java/com/hedera/services/fees/calculation/UsageBasedFeeCalculatorTest.java b/hedera-mirror-web3/src/test/java/com/hedera/services/fees/calculation/UsageBasedFeeCalculatorTest.java index 233e62b382..68ec5a8023 100644 --- a/hedera-mirror-web3/src/test/java/com/hedera/services/fees/calculation/UsageBasedFeeCalculatorTest.java +++ b/hedera-mirror-web3/src/test/java/com/hedera/services/fees/calculation/UsageBasedFeeCalculatorTest.java @@ -285,8 +285,7 @@ void failsWithNseeGetTxnUsageEstimator() { void failsWithNseeGetQueryUsageEstimator() { FeeData usgPrices = currentPrices.get(DEFAULT); final Exception exception = assertThrows( - NoSuchElementException.class, - () -> subject.estimatePayment(query, usgPrices, at, ANSWER_ONLY)); + NoSuchElementException.class, () -> subject.estimatePayment(query, usgPrices, at, ANSWER_ONLY)); assertEquals("No estimator exists for the given query", exception.getMessage()); } From cb55f33fd2384fb9d37919d3b8c4f9d3824ffc82 Mon Sep 17 00:00:00 2001 From: sdimitrov9 Date: Fri, 29 Nov 2024 12:00:29 +0200 Subject: [PATCH 6/7] style: apply spotlessMiscellaneous formatting Signed-off-by: sdimitrov9 --- README.md | 16 +- docs/configuration.md | 150 +++++++++--------- docs/database/bootstrap.md | 2 +- docs/development.md | 67 ++++---- .../create-disk-snapshot-for-citus-cluster.md | 3 +- .../restore-citus-from-disk-snapshot.md | 1 + .../upgrade-k8s-version-citus-nodepool.md | 9 +- docs/web3/README.md | 2 +- .../results/failed-ethereum-transaction.json | 27 +--- hedera-mirror-test/k6/README.md | 4 +- 10 files changed, 137 insertions(+), 144 deletions(-) diff --git a/README.md b/README.md index 1091fd7d26..44ea6bab91 100644 --- a/README.md +++ b/README.md @@ -96,14 +96,14 @@ documentation for more information. ## Documentation - Components - - [GraphQL API](docs/graphql/README.md) - - [gRPC API](docs/grpc/README.md) - - [Importer](docs/importer/README.md) - - [Monitor](docs/monitor/README.md) - - [REST API](docs/rest/README.md) - - [REST Java API](docs/rest-java/README.md) - - [Rosetta API](docs/rosetta/README.md) - - [Web3 API](docs/web3/README.md) + - [GraphQL API](docs/graphql/README.md) + - [gRPC API](docs/grpc/README.md) + - [Importer](docs/importer/README.md) + - [Monitor](docs/monitor/README.md) + - [REST API](docs/rest/README.md) + - [REST Java API](docs/rest-java/README.md) + - [Rosetta API](docs/rosetta/README.md) + - [Web3 API](docs/web3/README.md) - [Configuration](docs/configuration.md) - [Development Guide](docs/development.md) - [Contributing](docs/contributing.md) diff --git a/docs/configuration.md b/docs/configuration.md index bfd81662e6..4d0993a46e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -502,82 +502,82 @@ recursively merged into) the current configuration: The following table lists the available properties along with their default values. Unless you need to set a non-default value, it is recommended to only populate overridden properties in the custom `application.yml`. -| Name | Default | Description | -|-------------------------------------------------------------------|-------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `hedera.mirror.rest.cache.entityId.maxAge` | 1800 | The number of seconds until the entityId cache entry expires | -| `hedera.mirror.rest.cache.entityId.maxSize` | 100000 | The maximum number of entries in the entityId cache | -| `hedera.mirror.rest.cache.token.maxSize` | 100000 | The maximum number of entries in the token cache | -| `hedera.mirror.rest.cache.response.enabled` | false | Whether or not the Redis based REST API response cache is enabled. If so, Redis itself must be enabled and properly configured. | -| `hedera.mirror.rest.cache.response.compress` | true | Store cached response in gzip format and serve gzipped if supported by client | -| `hedera.mirror.rest.db.host` | 127.0.0.1 | The IP or hostname used to connect to the database | -| `hedera.mirror.rest.db.name` | mirror_node | The name of the database | -| `hedera.mirror.rest.db.password` | mirror_api_pass | The database password the processor uses to connect. | -| `hedera.mirror.rest.db.pool.connectionTimeout` | 20000 | The number of milliseconds to wait before timing out when connecting a new database client | -| `hedera.mirror.rest.db.pool.maxConnections` | 10 | The maximum number of clients the database pool can contain | -| `hedera.mirror.rest.db.pool.statementTimeout` | 20000 | The number of milliseconds to wait before timing out a query statement | -| `hedera.mirror.rest.db.port` | 5432 | The port used to connect to the database | -| `hedera.mirror.rest.db.sslMode` | DISABLE | The ssl level of protection against Eavesdropping, Man-in-the-middle (MITM) and Impersonation on the db connection. Accepts either DISABLE, ALLOW, PREFER, REQUIRE, VERIFY_CA or VERIFY_FULL. | -| `hedera.mirror.rest.db.tls.ca` | "" | The path to the certificate authority used by the database for secure connections | -| `hedera.mirror.rest.db.tls.cert` | "" | The path to the public key the client should use to securely connect to the database | -| `hedera.mirror.rest.db.tls.enabled` | false | Whether TLS should be used for the database connection | -| `hedera.mirror.rest.db.tls.key` | "" | The path to the private key the client should use to securely connect to the database | -| `hedera.mirror.rest.db.username` | mirror_api | The username the processor uses to connect to the database | -| `hedera.mirror.rest.log.level` | info | The logging level. Can be trace, debug, info, warn, error or fatal. | -| `hedera.mirror.rest.metrics.config` | See application.yml | The configuration to pass to Swagger stats (https://swaggerstats.io/guide/conf.html#options) | -| `hedera.mirror.rest.metrics.config.authentication` | true | Whether access to metrics for the REST API is authenticated | -| `hedera.mirror.rest.metrics.config.username` | mirror_api_metrics | The REST API metrics username to access the dashboard | -| `hedera.mirror.rest.metrics.config.password` | mirror_api_metrics_pass | The REST API metrics password to access the dashboard | -| `hedera.mirror.rest.metrics.config.uriPath` | '/swagger' | The REST API metrics uri path | -| `hedera.mirror.rest.metrics.enabled` | true | Whether metrics should be collected and exposed for scraping | -| `hedera.mirror.rest.metrics.ipMetrics` | false | Whether metrics should be associated with a masked client IP label | -| `hedera.mirror.rest.network.unreleasedSupplyAccounts` | [0.0.2, 0.0.42, ...] | An array of account IDs whose aggregated balance subtracted from the total supply is the released supply | -| `hedera.mirror.rest.openapi.specFileName` | 'openapi' | The file name of the OpenAPI spec file | -| `hedera.mirror.rest.openapi.swaggerUIPath` | '/docs' | Swagger UI path for your REST API | -| `hedera.mirror.rest.openapi.validation.enabled` | false | Whether or not the OpenAPI request validation is enabled. | -| `hedera.mirror.rest.port` | 5551 | The REST API port | -| `hedera.mirror.rest.query.bindTimestampRange` | false | Whether to bind the timestamp range to maxTimestampRange | -| `hedera.mirror.rest.query.maxRecordFileCloseInterval` | 10s | The maximum close interval of record files to limit the time partitions to scan. Note the default value is larger than the actual network close interval | -| `hedera.mirror.rest.query.maxRepeatedQueryParameters` | 100 | The maximum number of times any query parameter can be repeated in the uri | -| `hedera.mirror.rest.query.maxTimestampRange` | 7d | The maximum amount of time a timestamp range query param can span for some APIs. | -| `hedera.mirror.rest.query.maxTransactionConsensusTimestampRange` | 35m | The maximum amount of time of a transaction's consensus timestamp from its valid start timestamp. | -| `hedera.mirror.rest.query.maxTransactionsTimestampRange` | 60d | The maximum timestamp range to list transactions. | -| `hedera.mirror.rest.query.strictTimestampParam` | true | Enables strict checking of timestamp query param (currently only effects /api/v1/accounts/{id}?timestamp={timestamp} | -| `hedera.mirror.rest.query.topicMessageLookup` | false | Enables topic message lookup querying | -| 'hedera.mirror.rest.query.transactions.precedingTransactionTypes' | [11, 15] | Array of transaction types to be included in transactions by account id response when there is no parent and nonce is non-zero. | -| `hedera.mirror.rest.redis.commandTimeout` | 10000 | The amount of time in milliseconds to wait before a Redis command will timeout | -| `hedera.mirror.rest.redis.connectTimeout` | 10000 | The amount of time in milliseconds to wait for a connection to Redis | -| `hedera.mirror.rest.redis.enabled` | true | Whether Redis should be used as a caching layer for the database | -| `hedera.mirror.rest.redis.maxBackoff` | 128000 | The maximum amount of time in milliseconds to wait in between retrying Redis connection errors | -| `hedera.mirror.rest.redis.maxMemory` | 250Mb | The maximum amount of memory that Redis should be configured to use for caching | -| `hedera.mirror.rest.redis.maxMemoryPolicy` | allkeys-lfu | The key eviction policy Redis should use when the max memory threshold has been reached | -| `hedera.mirror.rest.redis.maxRetriesPerRequest` | 1 | The maximum number of times that the Redis command should be retried | -| `hedera.mirror.rest.redis.sentinel.enabled` | false | Whether Redis sentinel should be enabled | -| `hedera.mirror.rest.redis.sentinel.host` | 127.0.0.1 | The Redis sentinel host | -| `hedera.mirror.rest.redis.sentinel.name` | "mirror" | The Redis sentinel master group name | -| `hedera.mirror.rest.redis.sentinel.password` | "" | The Redis sentinel password | -| `hedera.mirror.rest.redis.sentinel.port` | 26379 | The Redis sentinel port | -| `hedera.mirror.rest.redis.uri` | redis://127.0.0.1:6379 | The URI to use when connecting to Redis | -| `hedera.mirror.rest.response.compression` | true | Whether content negotiation should occur to compress response bodies if requested | -| `hedera.mirror.rest.response.headers.default` | See application.yml | The default headers to add to every response. | -| `hedera.mirror.rest.response.headers.path` | See application.yml | The per path headers to add to every response. The key is the route name and the value is a header map. | -| `hedera.mirror.rest.response.includeHostInLink` | false | Whether to include the hostname and port in the next link in the response | -| `hedera.mirror.rest.response.limit.default` | 25 | The default value for the limit parameter that controls the REST API response size | -| `hedera.mirror.rest.response.limit.max` | 100 | The maximum size the limit parameter can be that controls the REST API response size | -| `hedera.mirror.rest.response.limit.tokenBalance.multipleAccounts` | 50 | The maximum number of token balances per account for endpoints which return such info for multiple accounts | -| `hedera.mirror.rest.response.limit.tokenBalance.singleAccount` | 1000 | The maximum number of token balances per account for endpoints which return such info for a single account | -| `hedera.mirror.rest.shard` | 0 | The default shard number that this mirror node participates in | -| `hedera.mirror.rest.stateproof.enabled` | false | Whether to enable stateproof REST API or not | -| `hedera.mirror.rest.stateproof.streams.accessKey` | "" | The cloud storage access key | -| `hedera.mirror.rest.stateproof.streams.bucketName` | | The cloud storage bucket name to download streamed files. This value takes priority over network hardcoded bucket names regardless of `hedera.mirror.rest.stateproof.streams.network` | -| `hedera.mirror.rest.stateproof.streams.cloudProvider` | S3 | The cloud provider to download files from. Either `S3` or `GCP` | -| `hedera.mirror.rest.stateproof.streams.endpointOverride` | | Can be specified to download streams from a source other than S3 and GCP. Should be S3 compatible | -| `hedera.mirror.rest.stateproof.streams.gcpProjectId` | | GCP project id to bill for requests to GCS bucket which has Requester Pays enabled. | +| Name | Default | Description | +| ------------------------------------------------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `hedera.mirror.rest.cache.entityId.maxAge` | 1800 | The number of seconds until the entityId cache entry expires | +| `hedera.mirror.rest.cache.entityId.maxSize` | 100000 | The maximum number of entries in the entityId cache | +| `hedera.mirror.rest.cache.token.maxSize` | 100000 | The maximum number of entries in the token cache | +| `hedera.mirror.rest.cache.response.enabled` | false | Whether or not the Redis based REST API response cache is enabled. If so, Redis itself must be enabled and properly configured. | +| `hedera.mirror.rest.cache.response.compress` | true | Store cached response in gzip format and serve gzipped if supported by client | +| `hedera.mirror.rest.db.host` | 127.0.0.1 | The IP or hostname used to connect to the database | +| `hedera.mirror.rest.db.name` | mirror_node | The name of the database | +| `hedera.mirror.rest.db.password` | mirror_api_pass | The database password the processor uses to connect. | +| `hedera.mirror.rest.db.pool.connectionTimeout` | 20000 | The number of milliseconds to wait before timing out when connecting a new database client | +| `hedera.mirror.rest.db.pool.maxConnections` | 10 | The maximum number of clients the database pool can contain | +| `hedera.mirror.rest.db.pool.statementTimeout` | 20000 | The number of milliseconds to wait before timing out a query statement | +| `hedera.mirror.rest.db.port` | 5432 | The port used to connect to the database | +| `hedera.mirror.rest.db.sslMode` | DISABLE | The ssl level of protection against Eavesdropping, Man-in-the-middle (MITM) and Impersonation on the db connection. Accepts either DISABLE, ALLOW, PREFER, REQUIRE, VERIFY_CA or VERIFY_FULL. | +| `hedera.mirror.rest.db.tls.ca` | "" | The path to the certificate authority used by the database for secure connections | +| `hedera.mirror.rest.db.tls.cert` | "" | The path to the public key the client should use to securely connect to the database | +| `hedera.mirror.rest.db.tls.enabled` | false | Whether TLS should be used for the database connection | +| `hedera.mirror.rest.db.tls.key` | "" | The path to the private key the client should use to securely connect to the database | +| `hedera.mirror.rest.db.username` | mirror_api | The username the processor uses to connect to the database | +| `hedera.mirror.rest.log.level` | info | The logging level. Can be trace, debug, info, warn, error or fatal. | +| `hedera.mirror.rest.metrics.config` | See application.yml | The configuration to pass to Swagger stats (https://swaggerstats.io/guide/conf.html#options) | +| `hedera.mirror.rest.metrics.config.authentication` | true | Whether access to metrics for the REST API is authenticated | +| `hedera.mirror.rest.metrics.config.username` | mirror_api_metrics | The REST API metrics username to access the dashboard | +| `hedera.mirror.rest.metrics.config.password` | mirror_api_metrics_pass | The REST API metrics password to access the dashboard | +| `hedera.mirror.rest.metrics.config.uriPath` | '/swagger' | The REST API metrics uri path | +| `hedera.mirror.rest.metrics.enabled` | true | Whether metrics should be collected and exposed for scraping | +| `hedera.mirror.rest.metrics.ipMetrics` | false | Whether metrics should be associated with a masked client IP label | +| `hedera.mirror.rest.network.unreleasedSupplyAccounts` | [0.0.2, 0.0.42, ...] | An array of account IDs whose aggregated balance subtracted from the total supply is the released supply | +| `hedera.mirror.rest.openapi.specFileName` | 'openapi' | The file name of the OpenAPI spec file | +| `hedera.mirror.rest.openapi.swaggerUIPath` | '/docs' | Swagger UI path for your REST API | +| `hedera.mirror.rest.openapi.validation.enabled` | false | Whether or not the OpenAPI request validation is enabled. | +| `hedera.mirror.rest.port` | 5551 | The REST API port | +| `hedera.mirror.rest.query.bindTimestampRange` | false | Whether to bind the timestamp range to maxTimestampRange | +| `hedera.mirror.rest.query.maxRecordFileCloseInterval` | 10s | The maximum close interval of record files to limit the time partitions to scan. Note the default value is larger than the actual network close interval | +| `hedera.mirror.rest.query.maxRepeatedQueryParameters` | 100 | The maximum number of times any query parameter can be repeated in the uri | +| `hedera.mirror.rest.query.maxTimestampRange` | 7d | The maximum amount of time a timestamp range query param can span for some APIs. | +| `hedera.mirror.rest.query.maxTransactionConsensusTimestampRange` | 35m | The maximum amount of time of a transaction's consensus timestamp from its valid start timestamp. | +| `hedera.mirror.rest.query.maxTransactionsTimestampRange` | 60d | The maximum timestamp range to list transactions. | +| `hedera.mirror.rest.query.strictTimestampParam` | true | Enables strict checking of timestamp query param (currently only effects /api/v1/accounts/{id}?timestamp={timestamp} | +| `hedera.mirror.rest.query.topicMessageLookup` | false | Enables topic message lookup querying | +| 'hedera.mirror.rest.query.transactions.precedingTransactionTypes' | [11, 15] | Array of transaction types to be included in transactions by account id response when there is no parent and nonce is non-zero. | +| `hedera.mirror.rest.redis.commandTimeout` | 10000 | The amount of time in milliseconds to wait before a Redis command will timeout | +| `hedera.mirror.rest.redis.connectTimeout` | 10000 | The amount of time in milliseconds to wait for a connection to Redis | +| `hedera.mirror.rest.redis.enabled` | true | Whether Redis should be used as a caching layer for the database | +| `hedera.mirror.rest.redis.maxBackoff` | 128000 | The maximum amount of time in milliseconds to wait in between retrying Redis connection errors | +| `hedera.mirror.rest.redis.maxMemory` | 250Mb | The maximum amount of memory that Redis should be configured to use for caching | +| `hedera.mirror.rest.redis.maxMemoryPolicy` | allkeys-lfu | The key eviction policy Redis should use when the max memory threshold has been reached | +| `hedera.mirror.rest.redis.maxRetriesPerRequest` | 1 | The maximum number of times that the Redis command should be retried | +| `hedera.mirror.rest.redis.sentinel.enabled` | false | Whether Redis sentinel should be enabled | +| `hedera.mirror.rest.redis.sentinel.host` | 127.0.0.1 | The Redis sentinel host | +| `hedera.mirror.rest.redis.sentinel.name` | "mirror" | The Redis sentinel master group name | +| `hedera.mirror.rest.redis.sentinel.password` | "" | The Redis sentinel password | +| `hedera.mirror.rest.redis.sentinel.port` | 26379 | The Redis sentinel port | +| `hedera.mirror.rest.redis.uri` | redis://127.0.0.1:6379 | The URI to use when connecting to Redis | +| `hedera.mirror.rest.response.compression` | true | Whether content negotiation should occur to compress response bodies if requested | +| `hedera.mirror.rest.response.headers.default` | See application.yml | The default headers to add to every response. | +| `hedera.mirror.rest.response.headers.path` | See application.yml | The per path headers to add to every response. The key is the route name and the value is a header map. | +| `hedera.mirror.rest.response.includeHostInLink` | false | Whether to include the hostname and port in the next link in the response | +| `hedera.mirror.rest.response.limit.default` | 25 | The default value for the limit parameter that controls the REST API response size | +| `hedera.mirror.rest.response.limit.max` | 100 | The maximum size the limit parameter can be that controls the REST API response size | +| `hedera.mirror.rest.response.limit.tokenBalance.multipleAccounts` | 50 | The maximum number of token balances per account for endpoints which return such info for multiple accounts | +| `hedera.mirror.rest.response.limit.tokenBalance.singleAccount` | 1000 | The maximum number of token balances per account for endpoints which return such info for a single account | +| `hedera.mirror.rest.shard` | 0 | The default shard number that this mirror node participates in | +| `hedera.mirror.rest.stateproof.enabled` | false | Whether to enable stateproof REST API or not | +| `hedera.mirror.rest.stateproof.streams.accessKey` | "" | The cloud storage access key | +| `hedera.mirror.rest.stateproof.streams.bucketName` | | The cloud storage bucket name to download streamed files. This value takes priority over network hardcoded bucket names regardless of `hedera.mirror.rest.stateproof.streams.network` | +| `hedera.mirror.rest.stateproof.streams.cloudProvider` | S3 | The cloud provider to download files from. Either `S3` or `GCP` | +| `hedera.mirror.rest.stateproof.streams.endpointOverride` | | Can be specified to download streams from a source other than S3 and GCP. Should be S3 compatible | +| `hedera.mirror.rest.stateproof.streams.gcpProjectId` | | GCP project id to bill for requests to GCS bucket which has Requester Pays enabled. | | `hedera.mirror.rest.stateproof.streams.httpOptions.connectTimeout` | 2000 | The number of milliseconds to wait to establish a connection | -| `hedera.mirror.rest.stateproof.streams.httpOptions.timeout` | 5000 | The number of milliseconds a request can take before automatically being terminated | -| `hedera.mirror.rest.stateproof.streams.maxRetries` | 3 | The maximum amount of retries to perform for a cloud storage download request. | -| `hedera.mirror.rest.stateproof.streams.network` | DEMO | Which Hedera network to use. Can be either `DEMO`, `MAINNET`, `TESTNET`, `PREVIEWNET` or `OTHER` | -| `hedera.mirror.rest.stateproof.streams.region` | us-east-1 | The region associated with the bucket | -| `hedera.mirror.rest.stateproof.streams.secretKey` | "" | The cloud storage secret key | +| `hedera.mirror.rest.stateproof.streams.httpOptions.timeout` | 5000 | The number of milliseconds a request can take before automatically being terminated | +| `hedera.mirror.rest.stateproof.streams.maxRetries` | 3 | The maximum amount of retries to perform for a cloud storage download request. | +| `hedera.mirror.rest.stateproof.streams.network` | DEMO | Which Hedera network to use. Can be either `DEMO`, `MAINNET`, `TESTNET`, `PREVIEWNET` or `OTHER` | +| `hedera.mirror.rest.stateproof.streams.region` | us-east-1 | The region associated with the bucket | +| `hedera.mirror.rest.stateproof.streams.secretKey` | "" | The cloud storage secret key | ### Enable State Proof Alpha diff --git a/docs/database/bootstrap.md b/docs/database/bootstrap.md index af7397228c..f3eabde3b4 100644 --- a/docs/database/bootstrap.md +++ b/docs/database/bootstrap.md @@ -295,7 +295,7 @@ If you need to stop the script before it completes: #### **Start the Mirrornode Importer** - - Once the bootstrap process completes without errors, you may start the Mirrornode Importer. +- Once the bootstrap process completes without errors, you may start the Mirrornode Importer. --- diff --git a/docs/development.md b/docs/development.md index 2a557c27c2..c0c533cc44 100644 --- a/docs/development.md +++ b/docs/development.md @@ -14,12 +14,14 @@ Hedera Mirror Node requires **Java 21** or a later version for development. - **Install Java 21**: On Ubuntu and macOS: + ```bash curl -s "https://get.sdkman.io" | bash sdk install java 21-tem ``` - **Verify Installation**: + ```bash java -version ``` @@ -40,6 +42,7 @@ Docker is used to manage and run containerized services (such as databases) for - **Install Docker**: On Ubuntu: + ```bash sudo apt update sudo apt install docker.io @@ -48,6 +51,7 @@ Docker is used to manage and run containerized services (such as databases) for ``` On macOS: + ```bash brew install --cask docker open /Applications/Docker.app @@ -81,38 +85,43 @@ for IntelliJ IDEA. ### IntelliJ IDEA Setup 1. **Install IntelliJ IDEA**: - - Download from [IntelliJ IDEA website](https://www.jetbrains.com/idea/). + + - Download from [IntelliJ IDEA website](https://www.jetbrains.com/idea/). 2. **Set up Project SDK**: - - Go to `File > Project Structure > Project`. - - Set **Project SDK** to `Java 21` (or higher). - - Set **Project language level** to `21 - Record patterns, pattern matching for switch`. + + - Go to `File > Project Structure > Project`. + - Set **Project SDK** to `Java 21` (or higher). + - Set **Project language level** to `21 - Record patterns, pattern matching for switch`. 3. **Gradle Configuration**: - - Ensure **Gradle JVM** is set to **Java 21**: Go to - `File > Settings > Build, Execution, Deployment > Build Tools > Gradle` and set the **Gradle JVM** to Java 21. + + - Ensure **Gradle JVM** is set to **Java 21**: Go to + `File > Settings > Build, Execution, Deployment > Build Tools > Gradle` and set the **Gradle JVM** to Java 21. 4. **Enable Save Actions**: - - Go to `File > Settings > Tools > Actions on Save` - - Enable the following save actions: - - `Reformat code`: Ensures consistent code style by reformatting code on save. - - `Optimize imports`: Automatically removes unused imports and arranges them. - - `Rearrange code`: Arranges code based on predefined rules. - - `Run code cleanup`: Cleans up unnecessary elements in the code. - - `Build project`: Automatically builds the project upon saving if needed. + + - Go to `File > Settings > Tools > Actions on Save` + - Enable the following save actions: + - `Reformat code`: Ensures consistent code style by reformatting code on save. + - `Optimize imports`: Automatically removes unused imports and arranges them. + - `Rearrange code`: Arranges code based on predefined rules. + - `Run code cleanup`: Cleans up unnecessary elements in the code. + - `Build project`: Automatically builds the project upon saving if needed. 5. **Import Java Code Style**: - - `Download` - the Java code file located in the repository at [docs/palantir-style.xml](docs/palantir-style.xml) - - In IntelliJ, go to `File > Settings > Editor > Code Style`. - - Click on `Java` under `Code Style`. - - In the Code Style section for Java, look for an option to import the downloaded code style file. This can - typically be found by clicking on the `gear icon (⚙️)` or the `Scheme dropdown`. - - Choose `Import Scheme > IntelliJ IDEA code style XML` or a similar option. - - `Import` the downloaded Java code style file to ensure consistent formatting across the project. + + - `Download` + the Java code file located in the repository at [docs/palantir-style.xml](docs/palantir-style.xml) + - In IntelliJ, go to `File > Settings > Editor > Code Style`. + - Click on `Java` under `Code Style`. + - In the Code Style section for Java, look for an option to import the downloaded code style file. This can + typically be found by clicking on the `gear icon (⚙️)` or the `Scheme dropdown`. + - Choose `Import Scheme > IntelliJ IDEA code style XML` or a similar option. + - `Import` the downloaded Java code style file to ensure consistent formatting across the project. 6. **Enable Docker Integration**: - - Enable Docker integration in IntelliJ if you are running containerized services directly from the IDE. + - Enable Docker integration in IntelliJ if you are running containerized services directly from the IDE. ## Compiling the Project @@ -126,10 +135,11 @@ The Hedera Mirror Node uses **Gradle** for building and managing dependencies. ``` This command will: - - Clean previous builds. - - Compile the source code. - - Download any required dependencies. - - Run tests. + + - Clean previous builds. + - Compile the source code. + - Download any required dependencies. + - Run tests. 2. **Compile Specific Subprojects**: If you want to build a specific subproject (e.g., `monitor`), run: @@ -212,6 +222,7 @@ For production or deployment, you may need to generate Docker images. -PdockerPlatform=linux/amd64 \ -PdockerRegistry=docker.io \ -PdockerTag=1.0.0-SNAPSHOT - ``` + ``` + NB: Ensure you are logged into the Docker registry if authentication is required. This command will push the image - with the specified tag to the registry. \ No newline at end of file + with the specified tag to the registry. diff --git a/docs/runbook/create-disk-snapshot-for-citus-cluster.md b/docs/runbook/create-disk-snapshot-for-citus-cluster.md index 4c759413ee..909459bff8 100644 --- a/docs/runbook/create-disk-snapshot-for-citus-cluster.md +++ b/docs/runbook/create-disk-snapshot-for-citus-cluster.md @@ -6,7 +6,7 @@ Need to create disk snapshots for Citus cluster(s) ## Prerequisites -- Have access to a running Citus cluster deployed by the `hedera-mirror` chart +- Have access to a running Citus cluster deployed by the `hedera-mirror` chart - Have `jq` installed - All bash commands assume your working directory is `docs/runbook/scripts` - The kubectl context is set to the cluster you want to create snapshots from @@ -14,6 +14,7 @@ Need to create disk snapshots for Citus cluster(s) ## Solution Run script and follow along with all prompts + ```bash ./volume-snapshot.sh ``` diff --git a/docs/runbook/restore-citus-from-disk-snapshot.md b/docs/runbook/restore-citus-from-disk-snapshot.md index ec3770a5b9..4ff33db962 100644 --- a/docs/runbook/restore-citus-from-disk-snapshot.md +++ b/docs/runbook/restore-citus-from-disk-snapshot.md @@ -21,6 +21,7 @@ Need to restore Citus cluster from disk snapshots ## Steps Run script and follow along with all prompts + ```bash ./restore-volume-snapshot.sh ``` diff --git a/docs/runbook/upgrade-k8s-version-citus-nodepool.md b/docs/runbook/upgrade-k8s-version-citus-nodepool.md index 897c939524..a7b510aa9c 100644 --- a/docs/runbook/upgrade-k8s-version-citus-nodepool.md +++ b/docs/runbook/upgrade-k8s-version-citus-nodepool.md @@ -14,7 +14,8 @@ Need to update k8s version for Citus Node Pool(s) 1. Follow the steps to [create a disk snapshot for Citus cluster](./create-disk-snapshot-for-citus-cluster.md) to backup the current cluster data -2. Run - ```bash - ./upgrade-k8s-version-citus.sh - ``` +2. Run + +```bash +./upgrade-k8s-version-citus.sh +``` diff --git a/docs/web3/README.md b/docs/web3/README.md index 63584ab526..3f9d1cda18 100644 --- a/docs/web3/README.md +++ b/docs/web3/README.md @@ -12,7 +12,7 @@ is used for the persistence layer. ## Supported Operations | Estimate | Static | Operation Type | Supported | Historical | Reads | Modifications | -|----------|--------|-------------------------------------------------------------------------------------------|-----------|------------|-------|---------------| +| -------- | ------ | ----------------------------------------------------------------------------------------- | --------- | ---------- | ----- | ------------- | | Y | Y | non precompile functions | Y | Y | Y | Y | | Y | N | non precompile functions with lazy account creation | Y | Y | Y | Y | | Y | Y | operations for ERC precompile functions (balance, symbol, tokenURI, name, decimals, etc.) | Y | Y | Y | N | diff --git a/hedera-mirror-rest/__tests__/specs/contracts/results/failed-ethereum-transaction.json b/hedera-mirror-rest/__tests__/specs/contracts/results/failed-ethereum-transaction.json index 77b07e8f4f..8b387588fd 100644 --- a/hedera-mirror-rest/__tests__/specs/contracts/results/failed-ethereum-transaction.json +++ b/hedera-mirror-rest/__tests__/specs/contracts/results/failed-ethereum-transaction.json @@ -61,30 +61,9 @@ "error_message": "Invalid account", "function_parameters": [3, 3], "function_result": [ - 106, - 22, - 34, - 20, - 88, - 89, - 138, - 112, - 194, - 52, - 135, - 209, - 103, - 53, - 209, - 129, - 39, - 229, - 222, - 239, - 115, - 201, - 76, - 13], + 106, 22, 34, 20, 88, 89, 138, 112, 194, 52, 135, 209, 103, 53, 209, + 129, 39, 229, 222, 239, 115, 201, 76, 13 + ], "gas_limit": 1234556, "gas_used": 987, "sender_id": null, diff --git a/hedera-mirror-test/k6/README.md b/hedera-mirror-test/k6/README.md index 2cff1acf39..e4ea7a3b12 100644 --- a/hedera-mirror-test/k6/README.md +++ b/hedera-mirror-test/k6/README.md @@ -91,7 +91,7 @@ The following parameters can be used to configure a REST test: The following parameters can be used to configure a rest-java test: | Name | Default | Description | -|-------------------------------------------| ------- |-------------------------------------------------| +| ----------------------------------------- | ------- | ----------------------------------------------- | | DEFAULT_ACCOUNT_ID_AIRDROP_RECEIVER | | The account to be used for pending airdrops | | DEFAULT_ACCOUNT_ID_AIRDROP_SENDER | | The account to be used for outstanding airdrops | | DEFAULT_ACCOUNT_ID_NFTS_ALLOWANCE_OWNER | | | @@ -117,7 +117,7 @@ The following parameters can be used to configure a rosetta test: The following parameters can be used to configure a web3 test: | Name | Default | Description | -|------------------------------|---------|----------------------------------------------------------------------------------------------------| +| ---------------------------- | ------- | -------------------------------------------------------------------------------------------------- | | ACCOUNT_ADDRESS | | 64 character hex encoded account address without `0x` prefix | | AMOUNT | | 64 character hex encoded amount without `0x` prefix | | DEFAULT_ACCOUNT_ADDRESS | | 40 character hex encoded account address without `0x` prefix | From 899581124499d3a210aec82fe044ef674caf1eae Mon Sep 17 00:00:00 2001 From: sdimitrov9 Date: Mon, 2 Dec 2024 17:38:44 +0200 Subject: [PATCH 7/7] Remove unused secret Signed-off-by: sdimitrov9 --- .github/workflows/security.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index dd20457b9f..18446e849d 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -266,8 +266,6 @@ jobs: uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4 - name: Execute Gradle - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew spotlessCheck - name: Fail on Unformatted Files