Conversation
This commit adds a flag to the script engine to use 64 bit integers and updates the ScriptNum class to optionally support 64 bit integers. This is the first part of the May 2022 hardfork.
| tx1 := createSpendTx(outs[0], 0) | ||
| builder := txscript.NewScriptBuilder(). | ||
| AddOp(txscript.OP_1). | ||
| AddOp(txscript.OP_ADD). | ||
| AddInt64(1152921504606846976). | ||
| AddOp(txscript.OP_EQUAL) | ||
| redeemScript, err := builder.Script() | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| addr, err := bchutil.NewAddressScriptHash(redeemScript, &chaincfg.RegressionNetParams) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| script, err := txscript.PayToAddrScript(addr) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| tx1.TxOut[0].PkScript = script | ||
|
|
||
| block.AddTransaction(tx1) | ||
| unsortedTxs = append(unsortedTxs, bchutil.NewTx(tx1)) | ||
|
|
||
| // Spend from tx1 | ||
| so1 := &spendableOut{ | ||
| amount: bchutil.Amount(tx1.TxOut[0].Value), | ||
| prevOut: wire.OutPoint{ | ||
| Hash: tx1.TxHash(), | ||
| Index: 0, | ||
| }, | ||
| } | ||
|
|
||
| tx2 := createSpendTx(so1, 0) | ||
| scriptSig, err := txscript.NewScriptBuilder(). | ||
| AddInt64(1152921504606846975). | ||
| AddData(redeemScript).Script() |
There was a problem hiding this comment.
Ah shit sorry. This suggestion (deleted) just came out as a big red block. It just has 3 line changes:
sixtyBitInt := int64(1152921504606846976)
...
AddInt64(sixtyBitInt).
...
AddInt64(sixtyBitInt - 1).
I suggest it because it took me a while to realize the two scripts are connected.
Could add an op_1 op_mul too (or in replacement of add) if you want to exercise both 64 and the re-enabled op together.
|
Needs OP_MUL to be re-enabled / implemented with appropriate overflow mechanic. (resolved now) |
|
Do you want me to take a shot at re-documenting these two?
Also do these need a documentation update since there is going to be a boundary between 32 vs 64 script int behavior? e.g. in |
|
Finished one pass of review.
|
sure |
Made a first draft only for It's set so you can make commits directly or if you mention any changes, I can make them. |
blockchain/thresholdstate.go
Outdated
| import ( | ||
| "fmt" | ||
| "github.com/gcash/bchd/chaincfg" | ||
|
|
chaincfg/genesis.go
Outdated
| // for the main network. | ||
| var testNet4GenesisMerkleRoot = genesisMerkleRoot | ||
|
|
||
| // testNet3GenesisBlock defines the genesis block of the block chain which |
chaincfg/params.go
Outdated
| } | ||
|
|
||
| // TestNet4Params defines the network parameters for the test Bitcoin network | ||
| // (version 3). Not to be confused with the regression test network, this |
| // Chain parameters | ||
| GenesisBlock: &testNet4GenesisBlock, | ||
| GenesisHash: &testNet4GenesisHash, | ||
| PowLimit: testNet3PowLimit, |
There was a problem hiding this comment.
Should we have another variable for the PowLimit? Odd to use testNet3 values here.
im_uname says it has been tested against testnet4. The problem is that it didn't fail before op_mul was implemented in this PR. So it probably still needs to be synced against some op_mul tx. |
|
Yeah it synced to testnet4 but it was odd that it did because OP_MUL wasn't activated when I did it. Are there OP_MUL transactions on that chain? |
These are supposed to have op_mul:
|
This PR upgrades BCHD to support the May 2022 hardfork
Tasks:
Spec:
64 Bit Integers: https://gitlab.com/GeneralProtocols/research/chips/-/blob/master/CHIP-2021-02-Bigger-Script-Integers.md
Native Introspection Opcodes: https://gitlab.com/GeneralProtocols/research/chips/-/blob/master/CHIP-2021-02-Add-Native-Introspection-Opcodes.md