From b3f867ea769497bd722b26200599f31e0bfeac50 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Sun, 21 Apr 2024 22:27:23 +1000 Subject: [PATCH 1/2] chore(compiler): update to 8.0.0 --- docker-compose.yml | 2 +- test/integration/compiler.ts | 4 ++-- test/integration/transaction.ts | 2 +- tooling/autorest/compiler-prepare.mjs | 2 +- tooling/fetch-aesophia-cli-8.mjs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2375e524b1..7d63264f18 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: condition: service_healthy compiler: - image: aeternity/aesophia_http:v8.0.0-rc1 + image: aeternity/aesophia_http:v8.0.0 ports: [3080:3080] # TODO: remove after releasing https://github.com/aeternity/aesophia_http/pull/133 healthcheck: diff --git a/test/integration/compiler.ts b/test/integration/compiler.ts index b886552b81..9f3049627f 100644 --- a/test/integration/compiler.ts +++ b/test/integration/compiler.ts @@ -13,7 +13,7 @@ function testCompiler(compiler: CompilerBase, isAesophia7: boolean): void { let inclFileSystem: Record; const inclBytecode = isAesophia7 ? 'cb_+QEGRgOg7BH1sCv+p2IrS0Pn3/i6AfE8lOGUuC71lLPn6mbUm9PAuNm4cv4AWolkAjcCBwcHFBQAAgD+RNZEHwA3ADcAGg6CPwEDP/5Nt4A5AjcCBwcHDAECDAEABAMRAFqJZP6SiyA2ADcBBwcMAwgMAQAEAxFNt4A5/pSgnxIANwF3BwwBAAQDEarAwob+qsDChgI3AXcHPgQAALhgLwYRAFqJZD0uU3VibGlicmFyeS5zdW0RRNZEHxFpbml0EU23gDkxLkxpYnJhcnkuc3VtEZKLIDYRdGVzdBGUoJ8SJWdldExlbmd0aBGqwMKGOS5TdHJpbmcubGVuZ3Rogi8AhTcuNC4xABzDzFw=' - : 'cb_+QEKRgOg7BH1sCv+p2IrS0Pn3/i6AfE8lOGUuC71lLPn6mbUm9PAuNm4cv4AWolkAjcCBwcHFBQAAgD+RNZEHwA3ADcAGg6CPwEDP/5Nt4A5AjcCBwcHDAECDAEABAMRAFqJZP6SiyA2ADcBBwcMAwgMAQAEAxFNt4A5/pSgnxIANwF3BwwBAAQDEarAwob+qsDChgI3AXcHPgQAALhgLwYRAFqJZD0uU3VibGlicmFyeS5zdW0RRNZEHxFpbml0EU23gDkxLkxpYnJhcnkuc3VtEZKLIDYRdGVzdBGUoJ8SJWdldExlbmd0aBGqwMKGOS5TdHJpbmcubGVuZ3Rogi8AiTguMC4wLXJjMQCfQIbH'; + : 'cb_+QEGRgOg7BH1sCv+p2IrS0Pn3/i6AfE8lOGUuC71lLPn6mbUm9PAuNm4cv4AWolkAjcCBwcHFBQAAgD+RNZEHwA3ADcAGg6CPwEDP/5Nt4A5AjcCBwcHDAECDAEABAMRAFqJZP6SiyA2ADcBBwcMAwgMAQAEAxFNt4A5/pSgnxIANwF3BwwBAAQDEarAwob+qsDChgI3AXcHPgQAALhgLwYRAFqJZD0uU3VibGlicmFyeS5zdW0RRNZEHxFpbml0EU23gDkxLkxpYnJhcnkuc3VtEZKLIDYRdGVzdBGUoJ8SJWdldExlbmd0aBGqwMKGOS5TdHJpbmcubGVuZ3Rogi8AhTguMC4wAIUiDfs='; const testBytecode = 'cb_+GhGA6BgYgXqYB9ctBcQ8mJ0+we5OXhb9PpsSQWP2DhPx9obn8C4O57+RNZEHwA3ADcAGg6CPwEDP/6AeCCSADcBd3cBAQCYLwIRRNZEHxFpbml0EYB4IJIZZ2V0QXJngi8AhTcuMC4xAMXqWXc='; const interfaceSourceCodePath = './test/integration/contracts/Interface.aes'; @@ -63,7 +63,7 @@ function testCompiler(compiler: CompilerBase, isAesophia7: boolean): void { }); it('returns version', async () => { - expect(await compiler.version()).to.be.equal(isAesophia7 ? '7.4.1' : '8.0.0-rc1'); + expect(await compiler.version()).to.be.equal(isAesophia7 ? '7.4.1' : '8.0.0'); }); it('compiles and generates aci by path', async () => { diff --git a/test/integration/transaction.ts b/test/integration/transaction.ts index 8c79ad303b..b0f5915be1 100644 --- a/test/integration/transaction.ts +++ b/test/integration/transaction.ts @@ -202,7 +202,7 @@ describe('Transaction', () => { if (consensusProtocolVersion === ConsensusProtocolVersion.Iris) { return 'tx_+LAqAaEBhAyXS5cWR3ZFS6EZ2E7cTWBYqN7JK27cV4qy0wtMQgABuGr4aEYDoKEijZbj/w2AeiWwAbldusME5pm3ZgPuomnZ3TbUbYgrwLg7nv5E1kQfADcANwAaDoI/AQM//oB4IJIANwEHBwEBAJgvAhFE1kQfEWluaXQRgHggkhlnZXRBcmeCLwCFNy40LjEAgwcAA4ZHcyzkwAAAAACDTEtAhDuaygCHKxFE1kQfP+mk9Ac='; } - return 'tx_+LQqAaEBhAyXS5cWR3ZFS6EZ2E7cTWBYqN7JK27cV4qy0wtMQgABuG74bEYDoKEijZbj/w2AeiWwAbldusME5pm3ZgPuomnZ3TbUbYgrwLg7nv5E1kQfADcANwAaDoI/AQM//oB4IJIANwEHBwEBAJgvAhFE1kQfEWluaXQRgHggkhlnZXRBcmeCLwCJOC4wLjAtcmMxAIMIAAOGR4XNQ+AAAAAAg0xLQIQ7msoAhysRRNZEHz+l4Zcy'; + return 'tx_+LAqAaEBhAyXS5cWR3ZFS6EZ2E7cTWBYqN7JK27cV4qy0wtMQgABuGr4aEYDoKEijZbj/w2AeiWwAbldusME5pm3ZgPuomnZ3TbUbYgrwLg7nv5E1kQfADcANwAaDoI/AQM//oB4IJIANwEHBwEBAJgvAhFE1kQfEWluaXQRgHggkhlnZXRBcmeCLwCFOC4wLjAAgwgAA4ZHcyzkwAAAAACDTEtAhDuaygCHKxFE1kQfP6UPXo4='; }, async () => aeSdk.buildTx({ tag: Tag.ContractCreateTx, diff --git a/tooling/autorest/compiler-prepare.mjs b/tooling/autorest/compiler-prepare.mjs index 1ebdb20dc8..1c67a1f8f9 100644 --- a/tooling/autorest/compiler-prepare.mjs +++ b/tooling/autorest/compiler-prepare.mjs @@ -1,6 +1,6 @@ import fs from 'fs'; -const swaggerUrl = 'https://raw.githubusercontent.com/aeternity/aesophia_http/v8.0.0-rc1/config/swagger.yaml'; +const swaggerUrl = 'https://raw.githubusercontent.com/aeternity/aesophia_http/v8.0.0/config/swagger.yaml'; const response = await fetch(swaggerUrl); console.assert(response.status === 200, 'Invalid response code', response.status); diff --git a/tooling/fetch-aesophia-cli-8.mjs b/tooling/fetch-aesophia-cli-8.mjs index c2b3f5106f..0b82a71565 100644 --- a/tooling/fetch-aesophia-cli-8.mjs +++ b/tooling/fetch-aesophia-cli-8.mjs @@ -3,11 +3,11 @@ import { writeFileSync } from 'fs'; import restoreFile from './restore-file.mjs'; const path = './bin/aesophia_cli_8'; -const hash = 'Xm+NIrI8S/u/mL4d5ZPcGJ+L+i3DfyKfvRY3iEXY+Or8dN8dGzupWcxlD2CJ3I2SRg/EzPwWIYPZCREC4RSgXA=='; +const hash = 'RYAgt3BbPt4UlANdcOff68hca0p1q2dK+H1b5BSMNUl6+zb9JjoJIn2/MlMxJAF0WdpjJKlVTkocXY7pMVIzCg=='; await restoreFile(path, hash, async () => { const request = await fetch( - 'https://github.com/aeternity/aesophia_cli/releases/download/v8.0.0-rc1/aesophia_cli', + 'https://github.com/aeternity/aesophia_cli/releases/download/v8.0.0/aesophia_cli', ); const body = Buffer.from(await request.arrayBuffer()); writeFileSync(path, body); From 8b18b845fecba25f196ece1677368efab59f8699 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Mon, 22 Apr 2024 00:02:43 +1000 Subject: [PATCH 2/2] refactor: make last argument optional in `semverSatisfies` --- src/tx/builder/field-types/gas-price.ts | 5 +---- src/utils/semver-satisfies.ts | 27 +++++++++++++------------ test/unit/semver-satisfies.ts | 1 + 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/tx/builder/field-types/gas-price.ts b/src/tx/builder/field-types/gas-price.ts index 18f3efed59..1623260d05 100644 --- a/src/tx/builder/field-types/gas-price.ts +++ b/src/tx/builder/field-types/gas-price.ts @@ -16,10 +16,7 @@ export async function getCachedIncreasedGasPrice(node: Node): Promise { // TODO: remove after requiring node@6.13.0 const { nodeVersion } = await node._getCachedStatus(); - // TODO: remove remove '6.12.0+' check after releasing 6.13.0 - if (!nodeVersion.startsWith('6.12.0+') && !semverSatisfies(nodeVersion, '6.13.0', '8.0.0')) { - return 0n; - } + if (!semverSatisfies(nodeVersion, '6.13.0')) return 0n; const { minGasPrice, utilization } = (await node.getRecentGasPrices())[0]; let gasPrice = utilization < 70 ? 0n : BigInt( diff --git a/src/utils/semver-satisfies.ts b/src/utils/semver-satisfies.ts index 0ecfb9efff..697a76deae 100644 --- a/src/utils/semver-satisfies.ts +++ b/src/utils/semver-satisfies.ts @@ -1,21 +1,22 @@ -export default function semverSatisfies( - version: string, - geVersion: string, - ltVersion: string, -): boolean { +function verCmp(a: string, b: string): number { const getComponents = (v: string): number[] => v .split(/[-+]/)[0].split('.').map((i) => +i); - const versionComponents = getComponents(version); - const geComponents = getComponents(geVersion); - const ltComponents = getComponents(ltVersion); + const aComponents = getComponents(a); + const bComponents = getComponents(b); - const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1; + const base = Math.max(...aComponents, ...bComponents) + 1; const componentsToNumber = (components: number[]): number => components.reverse() .reduce((acc, n, idx) => acc + n * base ** idx, 0); - const vNumber = componentsToNumber(versionComponents); - const geNumber = componentsToNumber(geComponents); - const ltNumber = componentsToNumber(ltComponents); - return vNumber >= geNumber && vNumber < ltNumber; + return componentsToNumber(aComponents) - componentsToNumber(bComponents); +} + +export default function semverSatisfies( + version: string, + geVersion: string, + ltVersion?: string, +): boolean { + return verCmp(version, geVersion) >= 0 + && (ltVersion == null || verCmp(version, ltVersion) < 0); } diff --git a/test/unit/semver-satisfies.ts b/test/unit/semver-satisfies.ts index 051815919a..e22b626385 100644 --- a/test/unit/semver-satisfies.ts +++ b/test/unit/semver-satisfies.ts @@ -13,5 +13,6 @@ describe('semverSatisfies', () => { expect(semverSatisfies('5.0.0', '3.0.0', '5.0.0')).to.equal(false); expect(semverSatisfies('6.0.0-rc4', '6.0.0', '7.0.0')).to.equal(true); expect(semverSatisfies('6.3.0+2.0f7ce80e', '6.0.0', '7.0.0')).to.equal(true); + expect(semverSatisfies('7.0.0', '6.13.0')).to.equal(true); }); });