Skip to content

Commit

Permalink
chore: upgrade aeproject, expose aci
Browse files Browse the repository at this point in the history
  • Loading branch information
thepiwo committed Apr 29, 2024
1 parent 982b11d commit 2f4ef91
Show file tree
Hide file tree
Showing 19 changed files with 302 additions and 2,027 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@master
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.x
- run: npm install -g @aeternity/aeproject
- run: npm install
- run: aeproject env
- run: aeproject test
- run: |
npm run generate-bytecode-aci-hashes
git diff --exit-code
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ package-lock.json
*.iml
.idea

*.aes.js
generated/*.aes.js
89 changes: 89 additions & 0 deletions .scripts/generate-bytecode-aci-hashes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const { utils, networks } = require("@aeternity/aeproject");
const fs = require("fs");
const crypto = require("crypto");
const path = require("path");
const { CompilerHttp, hash, getFileSystem} = require("@aeternity/aepp-sdk");

// add contract paths from base
const CONTRACTS = [
"token-registry.aes",
];

function generateSourceHashes() {
const hashes = CONTRACTS.reduce((acc, contract) => {
const source = fs.readFileSync("./contracts/" + contract, "utf-8");
acc[contract] = Buffer.from(hash(source)).toString("base64");
return acc;
}, {});

fs.writeFileSync(
"./generated/source_hashes.json",
JSON.stringify(hashes, null, 2),
);
}

function writeAci(aci, contract) {
fs.writeFileSync(
`${__dirname}/../generated/${path.basename(contract, ".aes")}.aci.json`,
JSON.stringify(aci, null, 2),
"utf-8",
);
}

async function generateBytecodeAci() {
const aeSdk = await utils.getSdk();

const bytecode_hashes = await CONTRACTS.reduce(
async (promiseAcc, contract) => {
const acc = await promiseAcc;
const fileSystem = await getFileSystem(
"./contracts/" + contract,
);
let sourceCode = utils.getContractContent("./contracts/" + contract);

try {
const compiled = await aeSdk.compilerApi.compileBySourceCode(
sourceCode,
fileSystem,
);

const compilerVersion = await aeSdk.compilerApi.version();
if (!acc[compilerVersion]) acc[compilerVersion] = {};

acc[compilerVersion][contract] = {
hash: crypto
.createHash("sha256")
.update(compiled.bytecode)
.digest("hex"),
bytecode: compiled.bytecode,
};

writeAci(compiled.aci, contract);
} catch (e) {
console.log(
"falling back to just aci generation without compilation for",
contract,
e.message,
);

const compilerHttp = new CompilerHttp(networks.devmode.compilerUrl);
await compilerHttp
.generateAciBySourceCode(sourceCode, fileSystem)
.then((aci) => writeAci(aci, contract))
.catch(console.error);
}

return acc;
},
Promise.resolve({}),
);

fs.writeFileSync(
"./generated/bytecode_hashes.json",
JSON.stringify(bytecode_hashes, null, 2),
"utf-8",
);
}

generateSourceHashes();
void generateBytecodeAci();
5 changes: 1 addition & 4 deletions .scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const fs = require('fs');

const tokenRegistry = fs.readFileSync(__dirname + '/../contracts/token-registry.aes', 'utf-8');
fs.writeFileSync(__dirname + '/../TokenRegistry.aes.js', `module.exports = \`\n${tokenRegistry}\`;\n`, 'utf-8');

const tokenRegistryInterface = fs.readFileSync(__dirname + '/../contracts/token-registry-interface.aes', 'utf-8');
fs.writeFileSync(__dirname + '/../TokenRegistryInterface.aes.js', `module.exports = \`\n${tokenRegistryInterface}\`;\n`, 'utf-8');
fs.writeFileSync(__dirname + '/../generated/TokenRegistry.aes.js', `module.exports = \`\n${tokenRegistry}\`;\n`, 'utf-8');
17 changes: 0 additions & 17 deletions config/network.json

This file was deleted.

44 changes: 0 additions & 44 deletions config/wallets.json

This file was deleted.

10 changes: 0 additions & 10 deletions contracts/token-registry-interface.aes

This file was deleted.

54 changes: 0 additions & 54 deletions deployment/deploy.js

This file was deleted.

7 changes: 0 additions & 7 deletions docker-compose.compiler.yml

This file was deleted.

36 changes: 26 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
version: '3'
version: "3.6"
services:
node:
image: 'aeternity/aeternity:${NODE_TAG}'
aeproject_node:
image: aeternity/aeternity:${NODE_TAG:-v7.0.0}-bundle
hostname: node
# TODO: remove after releasing https://github.com/aeternity/aeternity/pull/4292
healthcheck:
interval: 2s
environment:
AETERNITY_CONFIG: /home/aeternity/aeternity.yaml
command: |
bin/aeternity console -noinput -aehttp enable_debug_endpoints true
AE__SYSTEM__CUSTOM_PREFUNDED_ACCS_FILE: "/home/aeternity/node/data/aecore/.genesis/accounts_test.json"
volumes:
- './docker/aeternity.yaml:/home/aeternity/aeternity.yaml'
proxy:
image: 'nginx:1.13.8'
- "./docker/aeternity.yaml:/home/aeternity/aeternity.yaml"
- "./docker/accounts.json:/home/aeternity/node/data/aecore/.genesis/accounts_test.json"

aeproject_compiler:
image: aeternity/aesophia_http:${COMPILER_TAG:-v8.0.0}
hostname: compiler
# TODO: remove after releasing https://github.com/aeternity/aesophia_http/pull/133
healthcheck:
interval: 2s
ports:
- "3080:3080"

aeproject_proxy:
image: nginx:latest
hostname: proxy
ports:
- '3001:3001'
- "3001:3001"
volumes:
- './docker/nginx.conf:/etc/nginx/conf.d/default.conf'
- "./docker/nginx.conf:/etc/nginx/conf.d/default.conf"
depends_on:
- aeproject_compiler
- aeproject_node
13 changes: 13 additions & 0 deletions docker/accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ak_fUq2NesPXcYZ1CcqBcGC3StpdnQw3iVxMA3YSeCNAwfN4myQk": 100000000000000000000000000000000,
"ak_tWZrf8ehmY7CyB1JAoBmWJEeThwWnDpU4NadUdzxVSbzDgKjP": 100000000000000000000000000000000,
"ak_FHZrEbRmanKUe9ECPXVNTLLpRP2SeQCLCT6Vnvs9JuVu78J7V": 100000000000000000000000000000000,
"ak_RYkcTuYcyxQ6fWZsL2G3Kj3K5WCRUEXsi76bPUNkEsoHc52Wp": 100000000000000000000000000000000,
"ak_2VvB4fFu7BQHaSuW5EkQ7GCaM5qiA5BsFUHjJ7dYpAaBoeFCZi": 100000000000000000000000000000000,
"ak_286tvbfP6xe4GY9sEbuN2ftx1LpavQwFVcPor9H4GxBtq5fXws": 100000000000000000000000000000000,
"ak_f9bmi44rdvUGKDsTLp3vMCMLMvvqsMQVWyc3XDAYECmCXEbzy": 100000000000000000000000000000000,
"ak_23p6pT7bajYMJRbnJ5BsbFUuYGX2PBoZAiiYcsrRHZ1BUY2zSF": 100000000000000000000000000000000,
"ak_gLYH5tAexTCvvQA6NpXksrkPJKCkLnB9MTDFTVCBuHNDJ3uZv": 100000000000000000000000000000000,
"ak_zPoY7cSHy2wBKFsdWJGXM7LnSjVt6cn1TWBDdRBUMC7Tur2NQ": 100000000000000000000000000000000,
"ak_RdoCvwe7kxPu2VBv2gQAc1V81sGyTTuxFv36AcvNQYZN7qgut": 0
}
51 changes: 32 additions & 19 deletions docker/aeternity.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
peers: []

http:
external:
port: 3013
gas_limit: 60000000
internal:
debug_endpoints: true
port: 3113
listen_address: 0.0.0.0
endpoints:
dry-run: true

system:
plugin_path: /home/aeternity/node/plugins
plugins:
- name: aeplugin_dev_mode
config: # keeping the old config style at first to stay backwards compatible
keyblock_interval: 0
microblock_interval: 0
auto_emit_microblocks: true

dev_mode:
keyblock_interval: 0
microblock_interval: 0
auto_emit_microblocks: true

fork_management:
network_id: ae_dev

chain:
persist: true
consensus:
"0":
name: "on_demand" # keeping the old config style at first to stay backwards compatible
type: "on_demand"

mining:
beneficiary: "ak_RdoCvwe7kxPu2VBv2gQAc1V81sGyTTuxFv36AcvNQYZN7qgut"
beneficiary_reward_delay: 2
strictly_follow_top: true

websocket:
channel:
listen_address: 0.0.0.0
port: 3014
listen_address: 0.0.0.0

mining:
autostart: true
beneficiary: "ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU"
beneficiary_reward_delay: 2
expected_mine_rate: 4000
micro_block_cycle: 1000
cuckoo:
miner:
executable: mean15-generic
extra_args: ""
edge_bits: 15

fork_management:
network_id: ae_devnet
logging:
# Controls the overload protection in the logs.
hwm: 50
level: debug
Loading

0 comments on commit 2f4ef91

Please sign in to comment.