Skip to content

Commit

Permalink
squash
Browse files Browse the repository at this point in the history
  • Loading branch information
JSHan94 committed Dec 13, 2023
1 parent bb0d232 commit 11f1496
Show file tree
Hide file tree
Showing 131 changed files with 5,231 additions and 2,907 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @initia-labs/core
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- This issue tracker is only for technical issues related to initia.
General initia questions and/or support requests are best directed to initia support team.
Any report, issue or feature request related to the GUI should be reported to initia support team.
-->

<!-- Describe the issue -->

<!--- What behavior did you expect? Describe what the software should do in response to a specific action or command.-->

<!--- What did the software actually do when you performed the action or command? If you're unsure whether the issue is related to initia, feel free to ask us for clarification." -->

<!--- How reliably can you reproduce the issue, what are the steps to do so? -->

<!-- What version of initia are you using, where did you get it (website, self-compiled, etc)? -->

<!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

<!-- initia-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->

<!-- Any extra information that might be useful in the debugging process. -->
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/Release_notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Release Notes
==================

Initia version 0.45.12 is now available from:

<https://github.com/initia-labs/initia>

This release includes new features, various bug fixes and performance
improvements, as well as updated translations.

Please report bugs using the issue tracker at GitHub:

<https://github.com/initia-labs/initia-labs/issues>

To receive security and update notifications, please join our discord channel.


What's Changed
==============
### Initia
- upgrade to cosmos-sdk v0.45.12 by @zkst in #102

### RPC and other APIs

- #25220 rpc: fix incorrect warning for address type p2sh-segwit in createmultisig
- #25237 rpc: Capture UniValue by ref for rpcdoccheck
- #25983 Prevent data race for pathHandlers
- #26275 Fix crash on deriveaddresses when index is 2147483647 (2^31-1)

### Build system

- #25201 windeploy: Renewed windows code signing certificate
- #25788 guix: patch NSIS to remove .reloc sections from installer stubs
- #25861 guix: use --build={arch}-guix-linux-gnu in cross toolchain
- #25985 Revert "build: Use Homebrew's sqlite package if it is available"

### GUI

- gui#631 Disallow encryption of watchonly wallets
- gui#680 Fixes MacOS 13 segfault by preventing certain notifications

### Tests

- #24454 tests: Fix calculation of external input weights

### Miscellaneous

- #26321 Adjust .tx/config for new Transifex CLI

Full Changelog: Initia-node-v1.0.0...Initia-node-v1.0.1 [link]
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve (use this for suspected bugs only, if not sure, open a regular issue below)
title: ''
labels: Bug
assignees: ''
---

<!-- This issue tracker is only for technical issues related to Initia.
General initia questions and/or support requests are best directed to the initia support team.
-->

<!-- Describe the issue -->

**Expected behavior**

<!--- What behavior did you expect? Describe what the software should do in response to a specific action or command.-->

**Actual behavior**

<!--- What did the software actually do when you performed the action or command? If you're unsure whether the issue is related to Initia, feel free to ask us for clarification."
-->

**To reproduce**

<!--- How reliably can you reproduce the issue, what are the steps to do so? -->

**System information**

<!-- What version of initia are you using, where did you get it (website, self-compiled, etc)? -->

<!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

<!-- initia-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->

<!-- Any extra information that might be useful in the debugging process. -->
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: Feature
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/good_first_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Good first issue
about: '(Regular devs only): Suggest a new good first issue'
title: ''
labels: ''
assignees: ''

---

<!-- Needs the label "good first issue" assigned manually before or after opening -->

<!-- A good first issue is an uncontroversial issue, that has a relatively unique and obvious solution -->

<!-- Motivate the issue and explain the solution briefly -->

#### Useful skills:

<!-- (For example, “basic understanding of the initia RPC interface”.) -->
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/gui_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: An issue or feature request related to the GUI
about: Any report, issue or feature request related to the GUI should be reported to initia support team
title: Any report, issue or feature request related to the GUI should be reported to initia support team
labels: GUI
assignees: ''

---
32 changes: 32 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
*** Please remove the following help text before submitting: ***
Pull requests without a rationale and clear improvement may be closed
immediately.
-->

<!--
Please provide clear motivation for your patch and explain how it improves
initia user experience or initia developer experience
significantly:
* Any test improvements or new tests that improve coverage are always welcome.
* All other changes should have accompanying unit tests (see `src/test/`) or
functional tests (see `test/`). Contributors should note which tests cover
modified code. If no tests exist for a region of modified code, new tests
should accompany the change.
* Bug fixes are most welcome when they come with steps to reproduce or an
explanation of the potential issue as well as reasoning for the way the bug
was fixed.
* Features are welcome, but might be rejected due to design or scope issues.
If a feature is based on a lot of dependencies, contributors should first
consider building the system outside of initia, if possible.
-->

<!--
Initia has a thorough review process and even the most trivial change
needs to pass a lot of eyes and requires non-zero or even substantial time
effort to review. There is a huge lack of active reviewers on the project, so
patches often sit for a long time.
-->
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Test
on:
pull_request:
paths:
- "**.go"
- "**.mv"
- "**.move"
push:
branches:
- main
- "release/*"
paths:
- "**.go"
- "**.mv"
- "**.move"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test-coverage-upload:
name: Run test and upload codecov
env:
# for private repo access
GOPRIVATE: github.com/initia-labs/*
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Install openssl
run: sudo apt-get install libssl-dev
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
# for private repo access
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:[email protected]/.insteadOf https://github.com/
- name: test & coverage report creation
run: |
go test ./... -mod=readonly -timeout 12m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock'
if: ${{ env.GIT_DIFF != '' }}
- name: filter out DONTCOVER
run: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/initia-labs\/initia/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: ${{ env.GIT_DIFF != '' }}
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
fail_ci_if_error: true
if: ${{ env.GIT_DIFF != '' }}
65 changes: 61 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,66 @@
# OPinit CosmosSDK Modules

This repository provides CosmosSDK modules for OPinit. Any app chain can use these modules to integrate OPinit.
Initia Layer 2 solution with Optimistic Rollup.

## How to Integrate
## Optimistic Rollup Architecture

### Host(L1) Chain
![architecture](./specs/architecture.png)

### Child(L2) Chain
### L1 Components

#### [Bridge Module](./specs/l1_bridge.md)

The bridge module triggers a deposit event for the bridge executor, which acts as a relayer between L1 and L2. It has two interfaces: `initialize_deposit` for users and `finalize_withdrawal` for the bridge executor. Both interfaces can be executed by anyone who wants to move the tokens between L1 and L2.

A deposit does not require any proving or confirmation period, but a withdrawal requires [withdrawal proving](./specs/withdrawal_proving.md) and a finalized output root which contains the withdrawal transaction.

#### BatchInbox Module

The batch inbox is the data availability (DA) layer, which can be replaced by other solutions like `Celestia`. The rollup chain can be deterministically derived using the data from the DA layer. This ability to derive the entire rollup chain based on the DA layer is what makes Minitia a rollup.

To reduce gas costs, the batch inbox only exposes an empty function interface that receives arbitrary bytes as an argument. This trick ensures that L2 data is not a part of the state but instead resides in tx db (= calldata).

#### [L2OutputOracle Module](./specs/l2_output_oracle.md)

The L2 output oracle is the component to store the L2 output root for block finalization. The users who withdraw the tokens from L2 to L1 also need to use this output root to prove the withdraw transaction is in the finalized L2 output root.

The challenger always monitor the oracle output and do challenge when the output is different from the value computed from challenger side.

### L2 Components

#### BridgeExecutor

The bridge executor is the core component in minitia rollup, which is charge of following operations via [L2 Bridge Module](./specs/l2_bridge.md):

* Finalize L1 deposit transaction to L2.
* Construct withdraw tx storage Merkle Tree.
* Compute L2 output root.
* Provide the withdrawal proofs (Merkle Proofs) to users.

#### [Minitia](./specs/minitia.md)

The L2 app chain implementation provides rollup-specific interfaces for a bridge executor. The minitia is a minimized version of the initia app chain, so it does not include staking-related modules such as `staking`, `distribution`, `crisis`, and `evidence`. Instead, it has a new module called `opchild`, which provides a permissioned interface for adding and removing validators, as well as executing [bridge messages](./specs/l2_bridge.md) that can be executed by the bridge executor.

#### BatchSubmitter

A background process that submits transaction batches to the `BatchInbox` module of L1.

#### Challenger

A challenger is an entity capable of deleting invalid output proposals from the output oracle. It mimics the output root generation process that a bridge executor does to check the validity of the proposed output root on the oracle module. This process confirms that the proposed output root contains a valid app hash, and all withdrawal transactions are properly relayed to L1.

Additionally, a challenger monitors deposit transactions from L1 to L2 to ensure censorship resistance. If the transactions are not properly relayed to L2 within the timeout (L2 block numbers), the challenger deletes the output root.

In the initia optimistic rollup spec, a challenger is supposed to run an IBC relayer between L1 and L2 to support instant bridge operation. It is the entity that can monitor an invalid state first, so it can prevent invalid IBC operation by stopping the relayer process. To accomplish this, initia is using [a new ibc middleware](https://github.com/initia-labs/initia/pull/86) on the L1 side to restrict the relayer permission to a specific address for each channel.

### Dispute Process

Initia's optimistic rollup uses a simplified version of the dispute mechanism with L1 governance security. This approach is very similar to Cosmos's shared security, but it does not require all validators to run a whole L2 node. Instead, the validators are only required to run an L2 node to decide the valid entity between the `proposer` and `challenger` when a dispute is opened. They do not need to run whole L2 blocks but only need to run a dispute block with the last L2 state on L1.

The dispute process works as follows:

1. A `challenger` deletes the invalid output root from the output oracle module.
2. Both a `challenger` and a `proposer` make a governance proposal to update invalid operator addresses:
* The `challenger` makes a governance proposal to change the `proposer` to another address if the `proposer` keeps submitting an invalid output root.
* The `proposer` makes a governance proposal to change the `challenger` to another address if the `challenger` keeps deleting a valid output root.
3. L1 validators make a validity decision by running an L2 node with L2 state and data inputs.
1 change: 1 addition & 0 deletions bots/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
33 changes: 18 additions & 15 deletions bots/.envrc_sample
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
export TYPEORM_CONNECTION=postgres
export TYPEORM_HOST=localhost
export TYPEORM_USERNAME=jungsuhan
export TYPEORM_PASSWORD=jungsuhan
export TYPEORM_DATABASE=challenger
export TYPEORM_USERNAME=user
export TYPEORM_PASSWORD=password
export TYPEORM_DATABASE=rollup
export TYPEORM_PORT=5432
export TYPEORM_SYNCHRONIZE=true
export TYPEORM_LOGGING=false
export TYPEORM_ENTITIES=src/orm/*Entity.ts
export USE_LOG_FILE=false

export EXECUTOR_PORT=3000
export BATCH_PORT=3001
export EXECUTOR_PORT=5000
export BATCH_PORT=5001

export L1_LCD_URI=https://next-stone-rest.initia.tech
export L1_RPC_URI=https://next-stone-rpc.initia.tech
export L2_LCD_URI=http://localhost:1318
export L2_RPC_URI=http://localhost:26658
export L2ID=0x56ccf33c45b99546cd1da172cf6849395bbf8573::s10r1::Minitia
# l2 setup (need challenger, output, executor mnemonic)
export SUBMISSION_INTERVAL=10000
export FINALIZED_TIME=10000
export IBC_METADATA='channel-1'

export L1_LCD_URI=http://localhost:1317
export L1_RPC_URI=http://localhost:26657
export L2_LCD_URI=http://localhost:1318
export L2_RPC_URI=http://localhost:26667
export BRIDGE_ID=1

# executor config
export EXECUTOR_MNEMONIC='recycle sight world spoon leopard shine dizzy before public use jungle either arctic detail hawk output option august hedgehog menu keen night work become'
export EXECUTOR_MNEMONIC=''

# batch submitter config
export BATCH_SUBMITTER_MNEMONIC='broken umbrella tent include pet simple amount renew insect page sound whip shock dynamic deputy left outside churn lounge raise mirror toss annual fat'
export BATCH_SUBMITTER_MNEMONIC=''

# challenger config
export CHALLENGER_MNEMONIC='purity yard brush wagon note forest athlete seek offer clown surround cover present ski bargain obvious cute admit gloom text shaft super impose rubber'
export CHALLENGER_MNEMONIC=''

# output submitter config
export OUTPUT_SUBMITTER_MNEMONIC='airport hidden cake dry bleak alcohol enough tower charge cash modify feature analyst suffer bus oyster initial coffee wine plug paper damp sock afraid'
export EXECUTOR_URI=http://localhost:3000
export OUTPUT_SUBMITTER_MNEMONIC=''
1 change: 1 addition & 0 deletions bots/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apidoc/
static/

.envrc
.env
build
logs/
testing/
Expand Down
Loading

0 comments on commit 11f1496

Please sign in to comment.