Initial commit

This commit is contained in:
Jinho Jang 2024-03-12 03:11:16 +09:00 committed by GitHub
commit 2b10d5086b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 15501 additions and 0 deletions

26
.gitignore vendored Normal file
View File

@ -0,0 +1,26 @@
# Dependencies
/node_modules
# Production
/build
# Generated files
.docusaurus
.cache-loader
# Misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.yalc
yalc.lock
.idea
static/search-index.json

2
.husky/commit-msg Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

5
.husky/pre-commit Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# yarn prettier:staged
yarn typecheck

2
.prettierignore Normal file
View File

@ -0,0 +1,2 @@
*.mdx
*.md

6
.prettierrc Normal file
View File

@ -0,0 +1,6 @@
{
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}

61
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,61 @@
pipeline {
agent { label 'linux' }
options {
disableConcurrentBuilds()
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '20',
daysToKeepStr: '30',
))
}
environment {
GIT_COMMITTER_NAME = 'status-im-auto'
GIT_COMMITTER_EMAIL = 'auto@status.im'
PROD_SITE = 'docs.codex.storage'
DEV_SITE = 'dev-docs.codex.storage'
DEV_HOST = 'jenkins@node-01.do-ams3.sites.misc.statusim.net'
SCP_OPTS = 'StrictHostKeyChecking=no'
}
stages {
stage('Install') {
steps {
sh "yarn install"
}
}
stage('Build') {
steps {
sh 'yarn build'
sh "echo ${env.PROD_SITE} > build/CNAME"
}
}
stage('Publish Prod') {
when { expression { env.GIT_BRANCH ==~ /.*master/ } }
steps {
sshagent(credentials: ['status-im-auto-ssh']) {
sh "ghp-import -p build"
}
}
}
stage('Publish Devel') {
when { expression { env.GIT_BRANCH ==~ /.*develop/ } }
steps {
sshagent(credentials: ['jenkins-ssh']) {
sh """
rsync -e 'ssh -o ${SCP_OPTS}' -r --delete build/. \
${env.DEV_HOST}:/var/www/${env.DEV_SITE}/
"""
}
}
}
}
post {
cleanup { cleanWs() }
}
}

138
README.md Normal file
View File

@ -0,0 +1,138 @@
# Logos Docs Template
The template repository for docs using [logos-docusaurus-plugins](https://github.com/acid-info/logos-docusaurus-plugins).
## Use Cases
- [Codex docs](https://docs.codex.storage/)
## How to Run Locally
1. Clone this repository
```bash
$ git clone https://github.com/acid-info/logos-docs-template.git
```
2. Install the dependencies:
```bash
$ yarn install
```
3. Start the website:
```bash
$ yarn start
```
4. Visit `http://localhost:3000` in your browser
## Configuration
Edit the `docusaurus.config.js` file in the repository's root directory, and update the value of the `businessUnit` field in presets section; below is a list of valid values:
- Logos
- Codex
- Waku
- Nimbus
- Nomos
- VacResearch
- Acid.info
Example:
```js
presets: [
[
'@acid-info/logos-docusaurus-preset',
{
businessUnit: 'Codex',
},
],
],
```
This is typically sufficient for most cases, as the Logos plugins will automatically populate other configurations related to the specified business unit. If you encounter any errors in the information provided by Logos Plugins, please visit the [Logos Docusaurus Plugins](https://github.com/acid-info/logos-docusaurus-plugins) repository and open an issue.
## Docs Setup
This template does not include a landing page. Please review the `routeBasePath: '/'` setting in the `docusaurus.config.js` file.
```js
presets: [
[
'@acid-info/logos-docusaurus-preset',
/** @type {import('@acid-info/logos-docusaurus-preset').PluginOptions} */
({
businessUnit: 'Codex',
theme: {
name: 'default',
options: {
customCss: [require.resolve('./src/css/custom.scss')],
docs: {
default: {
sidebar: {
hide: false,
},
},
},
},
},
docs: {
routeBasePath: '/', // the index.md becomes the index page
},
og: {},
}),
]
]
```
The content in `docs/index.md` will serve as the root page for your documentation.
For additional customization options, please refer to the [Docusaurus Configuration](https://docusaurus.io/docs/configuration).
## Adding docs
To add a document, create a `.md` or `mdx` file within the `docs` directory. You can use [Frontmatter](https://docusaurus.io/docs/markdown-features#front-matter) to add metadata to your markdown file.
## Docusaurus Config
You can find instructions for adding additional documentation sections, implementing localization, and managing versioning on the [Docusaurus](https://docusaurus.io/docs) website.
> Please note that theme customization is somewhat restricted; for more detailed instructions on customizing your theme, visit the [Logos Docusaurus Theme](https://github.com/acid-info/logos-docusaurus-plugins/tree/main/packages/logos-docusaurus-theme/) repository.
## Custom CSS
By default, this template utilizes the CSS styles defined in the [logos-docusaurus-plugins](https://github.com/acid-info/logos-docusaurus-plugins/tree/main/packages/logos-docusaurus-theme/src/client/css) package. You have the option to define custom CSS in `src/css/custom.scss`.
## How to Run a Static Build (Production Build)
1. Generate static files for production:
```bash
$ yarn build
```
The static files will be created in the `build` directory.
2. Serve the static build:
```bash
$ yarn serve
```
## CI/CD
- The `master` branch is automatically deployed to the production server (e.g., logos.co) through [CI](https://ci.infra.status.im)
- The `develop` branch is automatically deployed to the staging server (e.g., dev.logos.co) through [CI](https://ci.infra.status.im)
## Change Process
1. Create a new working branch from `develop`: `git checkout develop; git checkout -b my-changes`.
2. Make your changes, push them to the `origin`, and open a Pull Request against the `develop` branch.
3. After approval, merge the pull request, and verify the changes on the staging server (e.g., https://dev.vac.dev).
4. When ready to promote changes to the live website, rebase the `master` branch on the staging changes: `git checkout master; git pull origin master; git rebase origin/develop; git push`.

3
babel.config.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
};

147
docs/index.md Normal file
View File

@ -0,0 +1,147 @@
---
sidebar_position: 1
description: Codex is building a decentralised durability storage engine
---
# How to Use Codex
> The Codex project aims to create a decentralised durability engine that allows persisting data in p2p networks. In other words, it allows storing files and data with predictable durability guarantees for later retrieval.
> WARNING: This project is under active development and is considered pre-alpha.
[![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg)](#stability)
[![CI](https://github.com/status-im/nim-codex/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/status-im/nim-codex/actions?query=workflow%3ACI+branch%3Amain)
[![Codecov](https://codecov.io/gh/status-im/nim-codex/branch/main/graph/badge.svg?token=XFmCyPSNzW)](https://codecov.io/gh/status-im/nim-codex)
[![Discord](https://img.shields.io/discord/895609329053474826)](https://discord.gg/CaJTh24ddQ)
## Build and run
For detailed instructions on preparing to build nim-codex see [*Building Codex*](BUILDING.md).
To build the project, clone it, and run:
```bash
make update && make exec
```
The executable will be placed under the `build` directory under the project root.
Run the client with:
```bash
build/codex
```
### CLI options
```
build/codex --help
Usage:
codex [OPTIONS]... command
The following options are available:
--log-level Sets the log level [=LogLevel.INFO].
--metrics Enable the metrics server [=false].
--metrics-address Listening address of the metrics server [=127.0.0.1].
--metrics-port Listening HTTP port of the metrics server [=8008].
-d, --data-dir The directory where codex will store configuration and data..
-l, --listen-port Specifies one or more listening ports for the node to listen on. [=0].
-i, --listen-ip The public IP [=0.0.0.0].
--udp-port Specify the discovery (UDP) port [=8090].
--net-privkey Source of network (secp256k1) private key file (random|<path>) [=random].
-b, --bootstrap-node Specifies one or more bootstrap nodes to use when connecting to the network..
--max-peers The maximum number of peers to connect to [=160].
--agent-string Node agent string which is used as identifier in network [=Codex].
-p, --api-port The REST Api port [=8080].
-c, --cache-size The size in MiB of the block cache, 0 disables the cache [=100].
--persistence Enables persistence mechanism, requires an Ethereum node [=false].
--eth-provider The URL of the JSON-RPC API of the Ethereum node [=ws://localhost:8545].
--eth-account The Ethereum account that is used for storage contracts [=EthAddress.none].
--eth-deployment The json file describing the contract deployment [=string.none].
Available sub-commands:
codex initNode
```
### Example: Running two Codex clients
```bash
build/codex --data-dir="$(pwd)/Codex1" -i=127.0.0.1
```
This will start Codex with a data directory pointing to `Codex1` under the current execution directory and announce itself on the DHT under `127.0.0.1`.
To run a second client that automatically discovers nodes on the network, we need to get the Signed Peer Record (SPR) of first client, Client1. We can do this by querying the `/info` endpoint of the node's REST API.
`curl http://127.0.0.1:8080/api/codex/v1/info`
This should output information about Client1, including its PeerID, TCP/UDP addresses, data directory, and SPR:
```json
{
"id": "16Uiu2HAm92LGXYTuhtLaZzkFnsCx6FFJsNmswK6o9oPXFbSKHQEa",
"addrs": [
"/ip4/0.0.0.0/udp/8090",
"/ip4/0.0.0.0/tcp/49336"
],
"repo": "/repos/status-im/nim-codex/Codex1",
"spr": "spr:CiUIAhIhAmqg5fVU2yxPStLdUOWgwrkWZMHW2MHf6i6l8IjA4tssEgIDARpICicAJQgCEiECaqDl9VTbLE9K0t1Q5aDCuRZkwdbYwd_qLqXwiMDi2ywQ5v2VlAYaCwoJBH8AAAGRAh-aGgoKCAR_AAABBts3KkcwRQIhAPOKl38CviplVbMVnA_9q3N1K_nk5oGuNp7DWeOqiJzzAiATQ2acPyQvPxLU9YS-TiVo4RUXndRcwMFMX2Yjhw8k3A"
}
```
Now, let's start a second client, Client2. Because we're already using the default ports TCP (:8080) and UDP (:8090) for the first client, we have to specify new ports to avoid a collision. Additionally, we can specify the SPR from Client1 as the bootstrap node for discovery purposes, allowing Client2 to determine where content is located in the network.
```bash
build/codex --data-dir="$(pwd)/Codex2" -i=127.0.0.1 --api-port=8081 --udp-port=8091 --bootstrap-node=spr:CiUIAhIhAmqg5fVU2yxPStLdUOWgwrkWZMHW2MHf6i6l8IjA4tssEgIDARpICicAJQgCEiECaqDl9VTbLE9K0t1Q5aDCuRZkwdbYwd_qLqXwiMDi2ywQ5v2VlAYaCwoJBH8AAAGRAh-aGgoKCAR_AAABBts3KkcwRQIhAPOKl38CviplVbMVnA_9q3N1K_nk5oGuNp7DWeOqiJzzAiATQ2acPyQvPxLU9YS-TiVo4RUXndRcwMFMX2Yjhw8k3A
```
There are now two clients running. We could upload a file to Client1 and download that file (given its CID) using Client2, by using the clients' REST API.
## Interacting with the client
The client exposes a REST API that can be used to interact with the clients. These commands could be invoked with any HTTP client, however the following endpoints assume the use of the `curl` command.
### `/api/codex/v1/connect/{peerId}`
Connect to a peer identified by its peer id. Takes an optional `addrs` parameter with a list of valid [multiaddresses](https://multiformats.io/multiaddr/). If `addrs` is absent, the peer will be discovered over the DHT.
Example:
```bash
curl "127.0.0.1:8080/api/codex/v1/connect/<peer id>?addrs=<multiaddress>"
```
### `/api/codex/v1/download/{id}`
Download data identified by a `Cid`.
Example:
```bash
curl -vvv "127.0.0.1:8080/api/codex/v1/download/<Cid of the content>" --output <name of output file>
```
### `/api/codex/v1/upload`
Upload a file, upon success returns the `Cid` of the uploaded file.
Example:
```bash
curl -vvv -H "content-type: application/octet-stream" -H Expect: -T "<path to file>" "127.0.0.1:8080/api/codex/v1/upload" -X POST
```
### `/api/codex/v1/info`
Get useful node info such as its peer id, address, and SPR.
Example:
```bash
curl -vvv "127.0.0.1:8080/api/codex/v1/info"
```

75
docs/terms.md Normal file
View File

@ -0,0 +1,75 @@
---
displayed_sidebar: null
sidebar_class_name: hidden
---
# Terms of Use
These terms of use ('**Website Terms of Use**') are entered into by you and us, and they govern your access and use of the Website, including any content and functionality contained in the Website.
It is your responsibility to read the Website Terms of Use carefully before your use of the Website and your use of the Website means you have agreed to be bound and comply with these Website Terms of Use.
If you do not agree with these Website Terms of Use, you must not access or use the Website.
### Content provided for informational purposes only
Content available on the Website is for informational purposes only and is not intended to address the specific circumstances of any particular individual or entity. Such content may not always be entirely accurate, complete, or up to date, and may also include inaccuracies or typographical errors. You are solely responsible for verifying their adequacy, completeness, and accuracy, and any reliance you place on such content is at your own risk.
None of the content on this Website should be considered by you as legal, tax, investment, financial, professional, or any other type of advice. You should always conduct your own research and seek independent professional advice if necessary. You are solely responsible for the decisions or actions you might take in this respect. We are not liable for any loss resulting from your action (or inaction) and decisions based on the content on this Website.
Additionally, we are not responsible for any information, content, or services contained in any third-party content or on any third-party websites accessible or linked through this Website.
### Intellectual property rights
The Website and its contents are made available under free and open-source licences. This means that anyone can use, share, and modify such content, as long as they follow the terms of the applicable licence.
### Third-party website links
To the extent the Website provides any links to a third-party website, then its terms and conditions, including privacy policies, govern your use of those third-party websites. We have no control over such third-party websites and will not be liable for your use of or activities on any third-party websites accessed through the Website. If you access such third-party websites through the Website, it is at your own risk and you are solely responsible for your activities on such third-party websites.
The Website may embed videos from Youtube, a service provided by Google LLC, using Youtubes privacy-enhanced mode. When you interact with such videos, Youtube may place cookies on your personal device which do not directly identify individual users. Unless you are logged in to a Google account, Youtube will not store information to personalise your experience. We do not have any control over these cookies set by Youtube and it is recommended that you review YouTubes embedding videos information page.
### Disclaimer
The Website is provided by us on an as is basis, and you use the Website at your own sole discretion and risk.
We disclaim all warranties of any kind, express or implied, including without limitation the warranties of merchantability, fitness for a particular purpose, and non-infringement of intellectual property or other violation of rights. We do not warrant or make any representations concerning the completeness, accuracy, legality, utility, reliability, suitability, or availability of the use of the Website, the content on this Website, or otherwise relating to the Website, such content, or on any sites linked to this site.
We make no claims that the Website or any of its content is accessible, legally compliant or appropriate in your jurisdiction. Your access or use of the Website is at your own sole discretion and you are solely responsible for complying with any applicable local laws. These disclaimers will apply to the maximum extent permitted by applicable law.
### Limitation of liability
We will not be held liable to you under any contract, negligence, strict liability, or other legal or equitable theory for any lost profits, cost of procurement for substitute services, or any special, incidental, or consequential damages related to, arising from, or in any way connected with these Website Terms of Use, the Website, the content on the Website, or your use of the Website, even if we have been advised of the possibility of such damages. In any event, our aggregate liability for such claims is limited to EUR 100 (one hundred euros). This limitation of liability will apply to the maximum extent permitted by applicable law.
### Indemnity
You shall indemnify us and hold us harmless from and against any and all claims, damages, and expenses, including attorneys fees arising from or related to your use of the Website and the content on the Website, including without limitation your violation of these Website Terms of Use.
### Modifications
We may modify or replace any part of this Website Terms of Use at any time and without notice. You are responsible for checking the Website periodically for any changes. The new Website Terms of Use will be effective immediately upon its posting on the Website.
### Governing law
Swiss law governs these Website Terms of Use and any disputes between you and us, whether in court or arbitration, without regard to conflict of laws provisions.
### Disputes
In these terms, dispute has the broadest meaning enforceable by law and includes any claim you make against or controversy you may have in relation to these Website Terms of Use, the Website, the content on the Website, or your use of the Website.
We prefer arbitration over litigation as we believe it meets our principle of resolving disputes in the most effective and cost-effective manner. You are bound by the following arbitration clause, which waives your right to litigation and to be heard by a judge. Please note that court review of an arbitration award is limited. You also waive all your rights to a jury trial (if any) in any and all jurisdictions.
If a (potential) dispute arises, you must first use your reasonable efforts to resolve it amicably with us. If these efforts do not result in a resolution of such dispute, you shall then send us a written notice of dispute setting out (i) the nature of the dispute and the claim you are making; and (ii) the remedy you are seeking.
If we and you are unable to further resolve this dispute within sixty (60) calendar days of us receiving this notice of dispute, then any such dispute will be referred to and finally resolved by you and us through arbitration administered by the Swiss Chambers Arbitration Institution in accordance with the Swiss Rules of International Arbitration for the time being in force, the rules of which are deemed to be incorporated herein by reference. The arbitral decision may be enforced in any court. The arbitration will be held in Zug, Switzerland, and may be conducted via video conference virtual/online methods if possible. The tribunal will consist of one arbitrator, and all proceedings as well as communications between the parties will be kept confidential. The language of the arbitration will be in English. Payment of all relevant fees in respect of the arbitration, including filing, administration, and arbitrator fees, will be in accordance with the Swiss Rules of International Arbitration.
Regardless of any applicable statute of limitations, you must bring any claims within one year after the claim arose or the time when you should have reasonably known about the claim. You also waive the right to participate in a class action lawsuit or a classwide arbitration against us.
### About these Website Terms of Use
These Website Terms of Use cover the entire agreement between you and us regarding the Website and supersede all prior and contemporaneous understandings, agreements, representations, and warranties, both written and oral, with respect to the Website.
The captions and headings identifying sections and subsections of these Website Terms of Use are for reference only and do not define, modify, expand, limit, or affect the interpretation of any provisions of these Website Terms of Use.
If any part of these Website Terms of Use is held invalid or unenforceable, that part will be severable from these Website Terms of Use, and the remaining portions will remain in full force and effect. If we fail to enforce any of these Website Terms of Use, that does not mean that we have waived our right to enforce them.

107
docusaurus.config.js Normal file
View File

@ -0,0 +1,107 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
require('dotenv').config()
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Codex',
url: 'https://docs.codex.storage/',
baseUrl: '/',
customFields: {},
markdown: {
mermaid: true,
},
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
presets: [
[
'@acid-info/logos-docusaurus-preset',
/** @type {import('@acid-info/logos-docusaurus-preset').PluginOptions} */
({
businessUnit: 'Codex',
theme: {
name: 'default',
options: {
customCss: [require.resolve('./src/css/custom.scss')],
docs: {
default: {
sidebar: {
hide: false,
},
},
},
},
},
docs: {
routeBasePath: '/',
},
og: {},
}),
],
],
themeConfig:
/** @type {import('@acid-info/logos-docusaurus-preset').ThemeConfig} */
({
navbar: {
hideOnScroll: true,
items: [
{
type: 'search',
},
],
},
footer: {
copyright: 'Codex @2023<br/>All Rights Reserved.',
links: [
{
items: [
{
href: 'https://twitter.com/Codex_storage',
label: 'Twitter',
},
{
href: 'https://discord.gg/2NXGrsqmDq',
label: 'Discord',
},
{
href: '/',
label: 'Docs',
},
{
href: 'https://github.com/codex-storage',
label: 'Github',
},
],
},
{
items: [
{
href: '/',
label: 'Contact us',
},
{
href: 'https://jobs.status.im/',
label: 'Work with us',
},
{
href: '/terms',
label: 'Terms & conditions',
},
],
},
],
},
}),
}
module.exports = config

53
package.json Normal file
View File

@ -0,0 +1,53 @@
{
"name": "logos-docs-template",
"version": "0.0.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc"
},
"dependencies": {
"@acid-info/logos-docusaurus-preset": "^1.0.0-alpha.14",
"@docusaurus/core": "2.4.1",
"@docusaurus/preset-classic": "2.4.1",
"@docusaurus/theme-mermaid": "^2.4.1",
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@mdx-js/react": "^1.6.22",
"clsx": "^1.2.1",
"dotenv": "^16.0.3",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sass": "^1.62.1",
"tsdx": "^0.14.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.4.1",
"@tsconfig/docusaurus": "^1.0.5",
"typescript": "^4.7.4"
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"engines": {
"node": ">=16.14"
}
}

33
sidebars.js Normal file
View File

@ -0,0 +1,33 @@
/**
* Creating a sidebar enables you to:
- create an ordered group of docs
- render a sidebar for each doc of that group
- provide next/previous navigation
The sidebars can be generated from the filesystem, or explicitly defined here.
Create as many sidebars as you want.
*/
// @ts-check
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
// By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{ type: 'autogenerated', dirName: '.' }],
// But you can create a sidebar manually
/*
tutorialSidebar: [
'intro',
'hello',
{
type: 'category',
label: 'Tutorial',
items: ['tutorial-basics/create-a-document'],
},
],
*/
}
module.exports = sidebars

View File

@ -0,0 +1 @@
export * from '@acid-info/logos-docusaurus-theme/lib/client/components/mdx'

6
src/css/custom.scss Normal file
View File

@ -0,0 +1,6 @@
:root {
}
.hidden {
display: none;
}

Binary file not shown.

4
tsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
// This file is not used in compilation. It is here just for a nice editor experience.
"extends": "@tsconfig/docusaurus/tsconfig.json"
}

14832
yarn.lock Normal file

File diff suppressed because it is too large Load Diff