Skip to content

Commit

Permalink
Merge pull request #1977 from aeternity/feature/update-compiler
Browse files Browse the repository at this point in the history
Update cli compiler to 8.0.0
  • Loading branch information
davidyuk authored Apr 22, 2024
2 parents 0e1038b + 8b18b84 commit 1b3f105
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions src/tx/builder/field-types/gas-price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ export async function getCachedIncreasedGasPrice(node: Node): Promise<bigint> {

// TODO: remove after requiring [email protected]
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(
Expand Down
27 changes: 14 additions & 13 deletions src/utils/semver-satisfies.ts
Original file line number Diff line number Diff line change
@@ -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);
}
4 changes: 2 additions & 2 deletions test/integration/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function testCompiler(compiler: CompilerBase, isAesophia7: boolean): void {
let inclFileSystem: Record<string, string>;
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';
Expand Down Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions test/unit/semver-satisfies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion tooling/autorest/compiler-prepare.mjs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tooling/fetch-aesophia-cli-8.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1b3f105

Please sign in to comment.