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

client/asset/ltc: work with and require v0.21 #1536

Merged
merged 5 commits into from
Jun 16, 2022
Merged

Conversation

chappjc
Copy link
Member

@chappjc chappjc commented Mar 21, 2022

This updates the client's supported Litecoin Core version to v0.21.
In addition to bumping the version, this means:
- getbalances is supported now
- sendrawtransaction has the new syntax with maxfeerate not allowHighFee

This also adds the missing switches on wallet Type to both ltc and bch.

Trade test with v0.21.1:

2022-03-21 22:56:10.049 [DBG] CORE: Swappable match 05a3f5750314c35301cd42ea1100ff474324b9a05be4bb8423cde7c4500a42bd for order 88faca82d4c56c1f816cb8b406169e9524e15af6d974bfecb786d9eb760672cb (Maker)
2022-03-21 22:56:10.059 [DBG] CORE[ltc]: 1 signature cycles to converge on fees for tx 49bc0869333daf5da6cc04bcb61186114cb093a9e9a6607735cfcfc724df5a7d: min rate = 14, actual fee rate = 32 (6075 for 189 bytes), change = false
2022-03-21 22:56:10.060 [TRC] CORE[ltc]: Obtained local estimate for 2-conf fee rate, 21
2022-03-21 22:56:10.061 [INF] CORE: Broadcasted transaction with 1 swap contracts for order 88faca82d4c56c1f816cb8b406169e9524e15af6d974bfecb786d9eb760672cb. Fee rate = 14. Receipts (ltc): [49bc0869333daf5da6cc04bcb61186114cb093a9e9a6607735cfcfc724df5a7d:0].
2022-03-21 22:56:10.062 [INF] CORE: Contract coin 49bc0869333daf5da6cc04bcb61186114cb093a9e9a6607735cfcfc724df5a7d:0 (ltc), value = 100000000, refundable at 2022-03-22 18:56:10 +0000 UTC (script = 6382012088a82075430824f7abc3e19249e0dcfb3d47d77da940f04511a2b46343c8973ce08deb8876a914e440dde176c94584ec22b86762e96ef69bfd1ccf6704ca1b3a62b17576a914e187d6e1f195e1ac33fc6a9e23effb2dd7dc517e6888ac), match = 05a3f5750314c35301cd42ea1100ff474324b9a05be4bb8423cde7c4500a42bd
2022-03-21 22:56:10.063 [DBG] CORE: notify: |POKE| (order) Swaps initiated - Sent swaps worth 1.00000000 LTC on order 88faca82 - Order: 88faca82d4c56c1f816cb8b406169e9524e15af6d974bfecb786d9eb760672cb
2022-03-21 22:56:18.125 [INF] CORE: Audited contract (ltc: 49bc0869333daf5da6cc04bcb61186114cb093a9e9a6607735cfcfc724df5a7d:0) paying to n2Kr4owiFyN4D1yG3YkxgiwATZM7EP1uTN for order 6fbac4db2c80af3739e29d8db6b27cabd6f1b2a49d611efcb9062f01b5e204de, match 05a3f5750314c35301cd42ea1100ff474324b9a05be4bb8423cde7c4500a42bd, with tx data = true. Script: 6382012088a82075430824f7abc3e19249e0dcfb3d47d77da940f04511a2b46343c8973ce08deb8876a914e440dde176c94584ec22b86762e96ef69bfd1ccf6704ca1b3a62b17576a914e187d6e1f195e1ac33fc6a9e23effb2dd7dc517e6888ac
...
2022-03-21 22:59:47.685 [DBG] CORE: Swappable match 05a3f5750314c35301cd42ea1100ff474324b9a05be4bb8423cde7c4500a42bd for order 6fbac4db2c80af3739e29d8db6b27cabd6f1b2a49d611efcb9062f01b5e204de (Taker)
...
2022-03-21 23:00:00.125 [DBG] CORE: Redeemable match 05a3f5750314c35301cd42ea1100ff474324b9a05be4bb8423cde7c4500a42bd for order 6fbac4db2c80af3739e29d8db6b27cabd6f1b2a49d611efcb9062f01b5e204de (Taker)
2022-03-21 23:00:00.128 [TRC] CORE[ltc]: Obtained local estimate for 2-conf fee rate, 21
2022-03-21 23:00:00.133 [INF] CORE: Broadcasted redeem transaction spending 1 contracts for order 6fbac4db2c80af3739e29d8db6b27cabd6f1b2a49d611efcb9062f01b5e204de, paying to 392589e2ee104d8ceb77b57cc1fe43816efa229907345d6ffa0c7ab01f75220a:0 (ltc)
2022-03-21 23:00:00.133 [INF] CORE: Match 05a3f5750314c35301cd42ea1100ff474324b9a05be4bb8423cde7c4500a42bd complete: sell 200000000 dcr
2022-03-21 23:00:00.134 [INF] CORE: Notifying DEX dex-test.ssgen.io:7232 of our ltc swap redemption 392589e2ee104d8ceb77b57cc1fe43816efa229907345d6ffa0c7ab01f75220a:0 for match 05a3f5750314c35301cd42ea1100ff474324b9a05be4bb8423cde7c4500a42bd
2022-03-21 23:00:00.134 [DBG] CORE: notify: |POKE| (order) Match complete - Redeemed 1.00000000 LTC on order 6fbac4db - Order: 6fbac4db2c80af3739e29d8db6b27cabd6f1b2a49d611efcb9062f01b5e204de

client/asset/ltc/ltc.go Outdated Show resolved Hide resolved
@buck54321
Copy link
Member

They're tagged up to rc7, but it looks like there are still some issues, and estimatesmartfee is busted. Also looks like everyone's testnet will need a manual -reindex. Weird.

@chappjc
Copy link
Member Author

chappjc commented May 4, 2022

Yeah I cannot sync testnet with 0.21.2rc[anything]. 0.21.1 worked fine, but all the subsequent MWEB commits (added in a patch and through RCs!) killed it.

Just gonna hover on this until binaries are released.

@buck54321
Copy link
Member

@chappjc
Copy link
Member Author

chappjc commented May 9, 2022

I STILL cannot get it to sync on testnet.

$ litecoin-cli -testnet -getinfo
{
  "version": 210200,
  "blocks": 2215583,
  "headers": 2323358,

Always stuck at that block, even though it pulls all headers. Fresh or upgrade, no dice. litecoin-project/litecoin#789

@buck54321
Copy link
Member

You need to -reindex testnet.

litecoin-project/litecoin#798

@chappjc
Copy link
Member Author

chappjc commented May 9, 2022

So I had tried that on my issue. But also this is stuck like this with a full fresh resync.
I wonder if I'm stuck on the longer non-mweb chain

@chappjc
Copy link
Member Author

chappjc commented May 9, 2022

This is ridiculous, but the chain is split. 🙄
The dex-test node needs to get on 0.21.2 (yay fork in a friggin patch!) and resync.
This is crazy

@chappjc
Copy link
Member Author

chappjc commented May 10, 2022

Well, the block serialization has changed, possibly the tx serialization too. This is irritating since we just released 0.4.3, and we're using getblock (raw, not verbose json). I'm starting to think we should use the verbose and inefficient versions of these RPCs and leave the deserialization to the node. Too late now though.

I'm also confused about how 0.18 clients/nodes are gonna work with the new blocks. Allegedly they will follow the longer chain, but there's no illustration of this happening since on testnet the mweb miners are on a completely separate fork right now, almost 6 weeks long of blocks. litecoin-project/litecoin#798 (comment)
Might be that depending on the peer, the blocks are serialized with or without mweb based on SERIALIZE_NO_MWEB in node id flags. Yeah, I guess it's a soft fork.

EDIT: It's both block and tx serializations, but the issue is mainly the txn serialization. The block seems to put the mweb pieces at the end, after the transactions (see litecoin-project/litecoin@9d1f530) where its presence is signaled by the 0x20000000 bit of the block version, but a txn itself will have the flag byte (just signals witness in btc) with the bit 3 (1 << 3) set (| 8). This means msgtx decode fails with MsgTx.BtcDecode: witness tx but flag byte is 08.

The pkScript may also be unrecognized, as it can starts with OP_8 and may be of type witness_mweb_hogaddr or witness_mweb_pegin. This may or may not be an issue.

@chappjc chappjc force-pushed the ltc-0.21 branch 2 times, most recently from e1a6935 to 7a16270 Compare May 10, 2022 21:28
@chappjc
Copy link
Member Author

chappjc commented May 10, 2022

I've not tested the last commit, but it looks like a workable resolution, for now.
I'm still thinking about shifting towards the json results despite having generally preferred the raw bytes, but I don't think that's needed to get ltc 0.21.2 working.

@chappjc chappjc marked this pull request as ready for review May 10, 2022 22:05
@chappjc
Copy link
Member Author

chappjc commented May 10, 2022

The only testnet4 explorer that is on the "correct" chain is https://sochain.com/testnet/ltc

@chappjc chappjc force-pushed the ltc-0.21 branch 2 times, most recently from 0c71b21 to cac2f85 Compare May 22, 2022 02:10
Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working well on simnet.

dex/networks/ltc/block.go Outdated Show resolved Hide resolved
dex/networks/ltc/block.go Outdated Show resolved Hide resolved
@buck54321
Copy link
Member

This Litecoin upgrade is a mess. Simnet harness isn't upgrading. Getting a segfault. If I delete harnesschain.tar.gz, the nodes will start fine, but there are all kinds of connection errors with encryptwallet, sendmany, etc. Big API changes?

@chappjc chappjc added this to the 0.5 milestone May 24, 2022
@chappjc
Copy link
Member Author

chappjc commented May 24, 2022

This Litecoin upgrade is a mess. Simnet harness isn't upgrading. Getting a segfault. If I delete harnesschain.tar.gz, the nodes will start fine,

woof

but there are all kinds of connection errors with encryptwallet, sendmany, etc. Big API changes?

Not that I read about. These are crazy hiccups for a patch release.

I'll recreate the harnesschain tarball and see if I can address the harness failures. It was alright in March on 0.21.1 fwiw

@JoeGruffins
Copy link
Member

I delete harnesschain.tar.gz

I did not delete anything and was fine... I have not been building any coins from source though, just using whatever binaries they put out. for litecoind https://litecoin.org/

@chappjc
Copy link
Member Author

chappjc commented May 25, 2022

Until litecoin's testnet mess is sorted out, I feel uneasy about making this change. https://litecointalk.io/t/ltc-testnet-and-mweb/53473

Also, it has been observed that there's a -rpcserialversion=1 switch that will force it to not include the MW junk. Requiring special switches is not appealing, but it's something to consider.

Will keep my eye on the situation. It obviously affects #1607 too.

@chappjc
Copy link
Member Author

chappjc commented Jun 8, 2022

I did not delete anything and was fine... I have not been building any coins from source though, just using whatever binaries they put out. for litecoind https://litecoin.org/

I'm having no trouble either, so I suspect it's the BDB version used in the build.

2022-06-08T15:06:58Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)                                                                            

Maybe it's built with 5.3 for you @buck54321

@chappjc
Copy link
Member Author

chappjc commented Jun 8, 2022

Anyway, it's all working, including find maker's redemption after ghosting, which is the code that pulls and decodes blocks.

2022-06-08 10:24:23.487 [DBG] CORE: Ready to find counter-party redemption for match a80f062deb42791bee28767f37ffe687ac486a960738403594ef657054201913, order c2bb02513ded0d24ba19921cb0797df0e9ea2cef6e9076109ee81617496593b0 (Taker)
2022-06-08 10:24:23.487 [INF] CORE[ltc]: FindRedemption - Checking block 89a9fe50649bd921a6097c89841335aff7930e90d66aeac0fcdadc22f7d025e9 for swap 18e3861e3b95b1abe1e5ace3221b6b18b67e38f42a30588bc760695ea03baaed:0
2022-06-08 10:24:23.489 [INF] CORE[ltc]: tryRedemptionRequests - Checking block 89a9fe50649bd921a6097c89841335aff7930e90d66aeac0fcdadc22f7d025e9 for redemptions...
2022-06-08 10:24:23.490 [INF] CORE[ltc]: tryRedemptionRequests - Checking block 15226ec8b30a09e7c046f652d806d1419f1ae4178cf442e5286366e2d7f2c74c for redemptions...
2022-06-08 10:24:23.491 [INF] CORE[ltc]: tryRedemptionRequests - Checking block 652f70ba5e540d80a1b631b7b8e32be1e18df6e71a74279a009fc395faecd27f for redemptions...
2022-06-08 10:24:23.493 [DBG] CORE: notify: |POKE| (order) Match recovered - Found maker's redemption (ltc: f6bf9e197c6a7429a798867f3d8badd3c28b36431fe8af771edbce876fdbdd53:0) and validated secret for match a80f062deb42791bee28767f37ffe687ac486a960738403594ef657054201913 - Order: c2bb02513ded0d24ba19921cb0797df0e9ea2cef6e9076109ee81617496593b0

@chappjc
Copy link
Member Author

chappjc commented Jun 8, 2022

I do need to regenerate the harnesschain.tar.gz though to get the mweb bip9 softfork to activate...

@chappjc
Copy link
Member Author

chappjc commented Jun 9, 2022

Will be merging this tomorrow if there are no more comments. It works correctly.

Copy link
Member

@buck54321 buck54321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and tests well. I've got a couple of requests for the live test, but otherwise ready.

@@ -20,5 +20,8 @@ export DELTA_WALLET_SEED="cNueSN7jzE9DEQsP8SgyonVvMSWyqk2xjTK3RPh2HAdWrR6zb8Y9"
export DELTA_ADDRESS="QYUukoqupSC86DmWZLj3miArZFcy3eGC4i"
# Signal that the node needs to restart after encrypting wallet
export RESTART_AFTER_ENCRYPT="1"
export EXTRA_ARGS="-blockfilterindex=1 -peerblockfilters=1 -rpcserialversion=2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-peerblockfilters=1

🎉

)

type decoder struct {
buf [8]byte
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice pattern

dex/networks/ltc/tx.go Show resolved Hide resolved
Comment on lines 23 to 45
client, err := rpcclient.New(&rpcclient.ConnConfig{
HTTPPostMode: true,
DisableTLS: true,
Host: "127.0.0.1:19332", // testnet4
User: "user", // set me
Pass: "pass", // set me
}, nil)
if err != nil {
t.Fatalf("error creating RPC client: %v", err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do this like I'm doing ZCash?

cfg := struct {
RPCUser string `ini:"rpcuser"`
RPCPass string `ini:"rpcpassword"`
}{}
usr, _ := user.Current()
if err := config.ParseInto(filepath.Join(usr.HomeDir, ".zcash", "zcash.conf"), &cfg); err != nil {
t.Fatalf("config.Parse error: %v", err)
}
cl, err := rpcclient.New(&rpcclient.ConnConfig{
HTTPPostMode: true,
DisableTLS: true,
Host: "localhost:18232",
User: cfg.RPCUser,
Pass: cfg.RPCPass,
}, nil)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool that's much better than "set me"


// start 1000 blocks prior to mweb testnet blocks
// 2215586 for mainnet, 2214584 for testnet4
for iBlk := int64(2214584); ; iBlk++ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we limit this to -/+ 1000? It's an ever-growing test and it's already quite long.

t.Fatalf("Unmarshal (%d): %v", iBlk, err)
}
if iBlk%500 == 0 {
t.Log(iBlk)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will only be logged with verbose output. Maybe just go to stdout?


type Tx struct {
*wire.MsgTx
IsHogEx bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks god they shortened it to "HogEx". I don't know if I could take it seriously if it said Hogwarts Express everywhere.

This updates the client's supported Litecoin Core version to v0.21.
In addition to bumping the version, this means:
- getbalances is supported now
- sendrawtransaction has the new syntax with maxfeerate not allowHighFee

This also adds the missing switches on wallet Type to both ltc and bch.
On LTC regtest/regnet, the mweb soft fork is not active at genesis.
It is necessary to mine to block 431, send to a mweb address in a
"peg-in" transaction, and then mine the block so that the pegin
and the required hogex may be created when mweb activates at 432.

As of Bitcoin Core 0.21, the default "" wallet is not automatically
created.
https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.21.0.md#automatic-wallet-creation-removed
This adds a CREATE_DEFAULT_WALLET variable to explicitly create
this wallet if needed.  The command also creates it encrypted to start.
@chappjc
Copy link
Member Author

chappjc commented Jun 13, 2022

The ltcdcr trade tests are working fine. Just pushed a minor logging update but otherwise unchanged.

@chappjc chappjc merged commit d57bbb5 into decred:master Jun 16, 2022
@chappjc chappjc deleted the ltc-0.21 branch June 16, 2022 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

evaluate litecoin 0.21 branch
3 participants