显示软件包…

1 个不稳定版本

0.0.0 2021年5月27日

#8 in #witness

Apache-2.0

9KB

WOA - 权威见证 - Vapory桥

软件,用Rust编写,由WOA桥验证者使用,以实现基于权威的WOA原生代币与另一个基于Vapory的区块链上的代币之间的桥接。验证者与WOA桥合约合作,将一条链上的以太币转换为另一条链上相同数量的VRC20代币,反之亦然。此软件旨在与以下项目协同工作。当前兼容性未知。* WOA桥UI * WOA桥智能合约 * WOA桥监控服务 * WOA桥部署脚本

功能

该桥接连接了两条链(homeforeign)。当用户在home上的桥接合约中存入以太币时,他们在foreign上获得相同数量的VRC20代币,并且他们也可以将其转换回来。

存款

deposit

提款

withdraw

与Parity桥的区别

尽管WOA桥最初基于Parity桥,但它经过了重新设计,包括:* 引入了一个气价预言机;* 使用RPC而不是IPC;* 优化了桥接批准的发送,大大提高了性能;* 改进了错误处理,以兼容Linux systemd功能;* 桥接配置参数从桥接合约中获取,因此不需要在多个桥接实例之间同步;* 桥接合约被分割到独立的项目中,其部署独立于桥接的Rust部分。现在桥接合约:* 与VRC20分开;* 可升级;您不需要重新配置桥接实例和DApps以使用合约的新版本;* 允许更改一组验证者,而无需重新部署桥接合约。

如何构建

需要 rustcargo:请参阅安装说明。 需要 solc 被添加到 $PATH:请参阅安装说明。 假设你已经克隆了桥接程序(git clone [email protected]:poanetwork/poa-bridge.git),运行 cd woa-bridge make 并将 ../target/release/bridge 安装到你的 $PATH 中。

运行

bridge --config config.toml --database db.toml - --config - 配置文件的位置。配置文件必须存在 - --database - 数据库文件的位置。桥接程序默认强制使用 TLS 进行 RPC 连接。然而,在某些有限场景(如本地测试)中,这可能会不希望如此。在这种情况下,你可以使用 --allow-insecure-rpc-endpoints 选项来允许使用非 TLS 端点。但是,请确保此选项不会在生产中使用。

退出状态码

| 码 | 含义 | ------|----------------------| 0 | 成功 | 1 | 未知错误 | 2 | I/O 错误 | 3 | 请求关闭 | 4 | 资金不足 | 5 | 气价过低 | 6 | 气价过低 | 7 | 非重复使用 | | 10 | 无法连接 | 11 | 连接丢失 | 12 | 桥接程序崩溃 | 20 | RPC 错误 |

配置文件示例

required_confirmations = 0 poll_interval = 5 request_timeout = 60 default_gas_price = 1_000_000_000 # 1 GWEI [foreign] account = "0x006e27b6a72e1f34c626762f3c4761547aff1421" password = 
"foreign_password.txt" rpc_host = "https://127.0.0.1" rpc_port = 9545 required_confirmations = 8 poll_interval = 15 request_timeout = 60 gas_price_oracle_url = "https://gasprice.poa.network" 
gas_price_speed = "instant" gas_price_timeout = 10 default_gas_price = 10_000_000_000 # 10 GWEI [authorities] [transactions] deposit_relay = { gas = 300000 } withdraw_relay = { gas = 300000 
}
withdraw_confirm = { gas = 300000 } ```
#### Options
- `keystore` - path to a keystore directory with JSON keys
#### home/foreign options
- `home/foreign.account` - authority address on the home (**required**) - `home/foreign.password` - path to the file containing a password for the validator's account (to decrypt the key 
from the keystore) - `home/foreign.rpc_host` - RPC host (**required**) - `home/foreign.rpc_port` - RPC port (**defaults to 8545**) - `home/foreign.required_confirmations` - number of 
confirmations required to consider transaction final on home (default: **12**) - `home/foreign.poll_interval` - specify how often home node should be polled for changes (in seconds, 
default: **1**) - `home/foreign.request_timeout` - specify request timeout (in seconds, default: **3600**) - `home/foreign.gas_price_oracle_url` - the URL used to query the current 
gas-price for the home and foreign nodes, this service is known as the gas-price Oracle. This config option defaults to `None` if not supplied in the User's config TOML file. If this config 
value is `None`, no Oracle gas-price querying will occur, resulting in the config value for `home/foreign.default_gas_price` being used for all gas-prices. - 
`home/foreign.gas_price_timeout` - the number of seconds to wait for an HTTP response from the gas price oracle before using the default gas price. Defaults to `10 seconds`. - 
`home/foreign.gas_price_speed` - retrieve the gas-price corresponding to this speed when querying from an Oracle. Defaults to `fast`. The available values are: "instant", "fast", 
"standard", and "slow". - `home/foreign.default_gas_price` - the default gas price (in WEI) used in transactions with the home or foreign nodes. The `default_gas_price` is used when the 
Oracle cannot be reached. The default value is `15_000_000_000` WEI (ie. 15 GWEI). - `home/foreign.concurrent_http_requests` - the number of concurrent HTTP requests allowed in-flight 
(default: **64**)
#### transaction options
- `transaction.deposit_relay.gas` - specify how much gas should be consumed by deposit relay - `transaction.withdraw_confirm.gas` - specify how much gas should be consumed by withdraw 
confirm - `transaction.withdraw_relay.gas` - specify how much gas should be consumed by withdraw relay
### Database file format
```toml home_contract_address = "0x49edf201c1e139282643d5e7c6fb0c7219ad1db7" foreign_contract_address = "0x49edf201c1e139282643d5e7c6fb0c7219ad1db8" checked_deposit_relay = 120 
checked_withdraw_relay = 121 checked_withdraw_confirm = 121 ``` **all fields are required** - `home_contract_address` - address of the bridge contract on home chain - 
`foreign_contract_address` - address of the bridge contract on foreign chain - `checked_deposit_relay` - number of the last block for which an authority has relayed deposits to the foreign 
- `checked_withdraw_relay` - number of the last block for which an authority has relayed withdraws to the home - `checked_withdraw_confirm` - number of the last block for which an authority 
has confirmed withdraw

无运行时依赖