Skip to content

Commit

Permalink
rename vetumorg to fuxingloh
Browse files Browse the repository at this point in the history
feat: add solana
feat: add hardhat
feat: add ord
feat: add ganache
feat: add defichain
feat: add bitcoin
chore: bump dependencies
  • Loading branch information
fuxingloh committed Jul 12, 2024
1 parent 5f92ed5 commit 37247fe
Show file tree
Hide file tree
Showing 58 changed files with 4,768 additions and 188 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="https://github.com/vetumorg/chainfile">
<a href="https://github.com/fuxingloh/chainfile">
<h3 align="center">Chainfile</h3>
<p align="center">Define, Test, Deploy, Scale<br>Blockchain</p>
</a>
Expand Down Expand Up @@ -125,10 +125,9 @@ class BitcoinK8sChart extends Chart {

## License

This project is divided into two main parts, each with its own licensing:

- **`./packages`:** The source code for packages is licensed under the MIT License. For more details, see the [MIT License](./packages/LICENSE) file.
- **`./definitions`:** The definitions and related components are licensed under the Mozilla Public License 2.0 (MPL-2.0). For more information, refer to the [MPL-2.0 License](./definitions/LICENSE) file.
This project is separately licensed under two different licenses.
MIT for the `./packages` which provided the functionality
and MPL-2.0 for the `./definitions` which hosts how the blockchain nodes are defined.

This dual-licensing approach best accommodates the usage of both the packages and the definitions,
ensuring flexibility for package users while protecting the integrity of the definitions.
Expand Down
373 changes: 373 additions & 0 deletions chainfiles/bitcoin/LICENSE

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions chainfiles/bitcoin/mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"$schema": "https://chainfile.org/schema.json",
"caip2": "bip122:000000000019d6689c085ae165831e93",
"name": "Bitcoin Mainnet",
"params": {
"rpc_user": {
"description": "Username for Basic HTTP authentication to the RPC server.",
"secret": true,
"default": {
"random": {
"bytes": 16,
"encoding": "hex"
}
}
},
"rpc_password": {
"description": "Password for Basic HTTP authentication to the RPC server.",
"secret": true,
"default": {
"random": {
"bytes": 16,
"encoding": "hex"
}
}
}
},
"volumes": {
"data": {
"type": "persistent",
"size": "600Gi",
"expansion": {
"startFrom": "2024-01-01",
"monthlyRate": "20Gi"
}
}
},
"containers": {
"bitcoind": {
"image": "docker.io/kylemanna/bitcoind",
"tag": "latest",
"source": "https://github.com/kylemanna/docker-bitcoind",
"endpoints": {
"p2p": {
"port": 8333
},
"rpc": {
"port": 8332,
"protocol": "HTTP JSON-RPC 2.0",
"authorization": {
"type": "HttpBasic",
"username": {
"$param": "rpc_user"
},
"password": {
"$param": "rpc_password"
}
},
"probes": {
"readiness": {
"method": "getblockchaininfo",
"params": [],
"match": {
"result": {
"type": "object",
"properties": {
"blocks": {
"type": "number"
}
},
"required": ["blocks"]
}
}
}
}
}
},
"resources": {
"cpu": 1,
"memory": 2048
},
"environment": {
"DISABLEWALLET": "1",
"RPCUSER": {
"$param": "rpc_user"
},
"RPCPASSWORD": {
"$param": "rpc_password"
}
},
"mounts": [
{
"volume": "data",
"mountPath": "/bitcoin/.bitcoin"
}
]
}
}
}
138 changes: 138 additions & 0 deletions chainfiles/bitcoin/mainnet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import { CFContainer, CFTestcontainers } from '@chainfile/testcontainers';
import { afterAll, beforeAll, describe, expect, it } from '@workspace/jest/globals';
import waitFor from '@workspace/jest/wait-for';

import mainnet from './mainnet.json';

const testcontainers = new CFTestcontainers(mainnet);

beforeAll(async () => {
await testcontainers.start();
});

afterAll(async () => {
await testcontainers.stop();
});

describe('bitcoind', () => {
let bitcoind: CFContainer;

beforeAll(() => {
bitcoind = testcontainers.get('bitcoind');
});

it('should rpc(getblockchaininfo)', async () => {
const response = await bitcoind.rpc({
method: 'getblockchaininfo',
});

expect(response.status).toStrictEqual(200);

expect(await response.json()).toMatchObject({
result: {
bestblockhash: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
chain: 'main',
},
});
});

it('should rpc(getblockcount)', async () => {
const response = await bitcoind.rpc({
method: 'getblockcount',
});

expect(response.status).toStrictEqual(200);

expect(await response.json()).toMatchObject({
result: 0,
});
});

it('should rpc(getblock)', async () => {
const response = await bitcoind.rpc({
method: 'getblock',
params: ['000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', 2],
});

expect(response.status).toStrictEqual(200);

expect(await response.json()).toEqual({
error: null,
id: expect.any(Number),
result: {
bits: '1d00ffff',
chainwork: '0000000000000000000000000000000000000000000000000000000100010001',
confirmations: 1,
difficulty: 1,
hash: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
height: 0,
mediantime: 1231006505,
merkleroot: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b',
nTx: 1,
nonce: 2083236893,
size: 285,
strippedsize: 285,
time: 1231006505,
tx: [
{
hash: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b',
hex: '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000',
locktime: 0,
size: 204,
txid: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b',
version: 1,
vin: [
{
coinbase:
'04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73',
sequence: 4294967295,
},
],
vout: [
{
n: 0,
scriptPubKey: {
asm: '04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG',
desc: 'pk(04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f)#vlz6ztea',
hex: '4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac',
type: 'pubkey',
},
value: 50,
},
],
vsize: 204,
weight: 816,
},
],
version: 1,
versionHex: '00000001',
weight: 1140,
},
});
});

describe.skip('synchronization', () => {
// Takes too long to run and is not deterministic
beforeAll(async () => {
await waitFor(async () => {
const response = await bitcoind.rpc({
method: 'getblockcount',
params: [],
});

const result = ((await response.json()) as any).result;
expect(result).toBeGreaterThan(1);
}, 30000);
});

it('should bitcoind.rpc getblock(1)', async () => {
const response = await bitcoind.rpc({
method: 'getblock',
params: ['00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048'],
});

expect(response.status).toStrictEqual(200);
expect(await response.json()).toEqual({});
});
});
});
22 changes: 22 additions & 0 deletions chainfiles/bitcoin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "chainfile-bitcoin",
"version": "0.0.0",
"private": false,
"repository": {
"url": "git+https://github.com/fuxingloh/chainfile"
},
"license": "MPL-2.0",
"files": [
"*.json"
],
"scripts": {
"lint": "eslint .",
"test": "jest"
},
"jest": {
"preset": "@workspace/jest"
},
"devDependencies": {
"@chainfile/testcontainers": "workspace:*"
}
}
84 changes: 84 additions & 0 deletions chainfiles/bitcoin/regtest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"$schema": "https://chainfile.org/schema.json",
"caip2": "bip122:0f9188f13cb7b2c71f2a335e3a4fc328",
"name": "Bitcoin Regtest",
"params": {
"rpc_user": {
"description": "Username for Basic HTTP authentication to the RPC server.",
"default": "user"
},
"rpc_password": {
"description": "Password for Basic HTTP authentication to the RPC server.",
"default": "pass"
}
},
"volumes": {
"data": {
"type": "persistent",
"size": "250Mi"
}
},
"containers": {
"bitcoind": {
"image": "docker.io/kylemanna/bitcoind",
"tag": "latest",
"source": "https://github.com/kylemanna/docker-bitcoind",
"command": ["btc_oneshot", "-fallbackfee=0.00000200", "-rpcbind=:8332", "-rpcallowip=0.0.0.0/0"],
"endpoints": {
"p2p": {
"port": 18445
},
"rpc": {
"port": 8332,
"protocol": "HTTP JSON-RPC 2.0",
"authorization": {
"type": "HttpBasic",
"username": {
"$param": "rpc_user"
},
"password": {
"$param": "rpc_password"
}
},
"probes": {
"readiness": {
"method": "getblockchaininfo",
"params": [],
"match": {
"result": {
"type": "object",
"properties": {
"blocks": {
"type": "number"
}
},
"required": ["blocks"]
}
}
}
}
}
},
"resources": {
"cpu": 0.25,
"memory": 256
},
"environment": {
"REGTEST": "1",
"DISABLEWALLET": "0",
"RPCUSER": {
"$param": "rpc_user"
},
"RPCPASSWORD": {
"$param": "rpc_password"
}
},
"mounts": [
{
"volume": "data",
"mountPath": "/bitcoin/.bitcoin"
}
]
}
}
}
Loading

0 comments on commit 37247fe

Please sign in to comment.