Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dummy tx index #298

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ jobs:
- router-pay
- udt-router-pay
release:
- "0.119.0"
- "0.118.0"
- "0.116.1"
test_env:
- "test"
extra_bru_args:
- ""
include:
# We can only override the added matrix variables, so we have to put test_env in the include section.
# Otherwise, the overriding of test_env below will create a new job instead of overriding the existing one.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow
# > Note that the original matrix values will not be overwritten, but added matrix values can be overwritten.
- test_env: "test"
# add an extra workflow to run udt using the env file xudt-test
- workflow: "udt"
test_env: "xudt-test"
release: "0.116.1"
# add an extra workflow to run 3-nodes-transfer with sha256 hash algorithm
- workflow: "3-nodes-transfer"
test_env: "test"
release: "0.116.1"
extra_bru_args: "--env-var HASH_ALGORITHM=sha256"
name: e2e test for ${{ matrix.workflow }} --env ${{ matrix.test_env }} ${{ matrix.extra_bru_args }}
name: e2e test for ${{ matrix.workflow }} ${{ matrix.release }} --env ${{ matrix.test_env }} ${{ matrix.extra_bru_args }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ ckb-cli account export --lock-arg <lock_arg> --extended-privkey-path ./ckb/expor
head -n 1 ./ckb/exported-key > ./ckb/key
```

4. Start the node, by default it will output logs to the console, you may redirect it to a file:
4. (Optional) Start your own CKB node. We need a CKB rpc server to query on chain information. The CKB node should have at least version 0.118.0, and with `indexer` service enabled. See [Run a Testnet Node | Nervos CKB](https://docs.nervos.org/docs/node/run-testnet-node) for how to run a ckb testnet node, and change `rpc_url` (under `ckb` section) in `config.yml` file accordingly. You may also use the testnet RPC services URL provided in `config/testnet/config.yml`.

```
ckb run --indexer
```


5. Start the node, by default it will output logs to the console, you may redirect it to a file:

```
RUST_LOG=info ./fnn -c config.yml -d .
Expand Down
16 changes: 11 additions & 5 deletions src/fiber/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ pub const FIBER_PROTOCOL_ID: ProtocolId = ProtocolId::new(42);

pub const DEFAULT_CHAIN_ACTOR_TIMEOUT: u64 = 300000;

// tx index is not returned on older ckb version, using dummy tx index instead.
// Waiting for https://github.com/nervosnetwork/ckb/pull/4583/ to be released.
const DUMMY_FUNDING_TX_INDEX: u32 = 0;
// tx index is not returned on older ckb version, this is a dummy value to indicate that
// the tx index is not available. It is assumed that normal tx will not have such a large index.
const DUMMY_FUNDING_TX_INDEX: u32 = u32::MAX;

// This is a temporary way to document that we assume the chain actor is always alive.
// We may later relax this assumption. At the moment, if the chain actor fails, we
Expand Down Expand Up @@ -1931,9 +1931,14 @@ where
TxStatus {
status: Status::Committed,
block_number: Some(block_number),
tx_index,
..
},
}) => (tx, block_number.into(), DUMMY_FUNDING_TX_INDEX),
}) => (
tx,
block_number.into(),
tx_index.map(Into::into).unwrap_or(DUMMY_FUNDING_TX_INDEX),
),
err => {
return Err(Error::InvalidParameter(format!(
"Channel announcement transaction {:?} not found or not confirmed, result is: {:?}",
Expand Down Expand Up @@ -3355,6 +3360,7 @@ where
TxStatus {
status: Status::Committed,
block_number: Some(block_number),
tx_index,
..
},
..
Expand All @@ -3363,7 +3369,7 @@ where
NetworkActorEvent::FundingTransactionConfirmed(
outpoint,
block_number.into(),
DUMMY_FUNDING_TX_INDEX,
tx_index.map(Into::into).unwrap_or(DUMMY_FUNDING_TX_INDEX),
)
}
Ok(status) => {
Expand Down
Loading