diff --git a/.ckb-debugger-version b/.ckb-debugger-version index 267577d..03d12e9 100644 --- a/.ckb-debugger-version +++ b/.ckb-debugger-version @@ -1 +1 @@ -0.4.1 +0.20.0-rc4 diff --git a/.ckb-indexer-version b/.ckb-indexer-version index 0ea3a94..fbc5196 100644 --- a/.ckb-indexer-version +++ b/.ckb-indexer-version @@ -1 +1 @@ -0.2.0 +0.3.0-rc1 diff --git a/.ckb-version b/.ckb-version index 787ffc3..b07e118 100644 --- a/.ckb-version +++ b/.ckb-version @@ -1 +1 @@ -0.42.0 +0.100.0-rc4 diff --git a/src/Ckb.Address/Address.cs b/src/Ckb.Address/Address.cs index fe38c62..6dadd97 100644 --- a/src/Ckb.Address/Address.cs +++ b/src/Ckb.Address/Address.cs @@ -37,7 +37,16 @@ public static string GenerateAddress(Types.Script script, string prefix) } else { - data.Add(script.HashType == "type" ? 4 : 2); + int? formatType = null; + if (script.HashType == "type") { + formatType = 4; + } else if (script.HashType == "data") { + formatType = 2; + } + if (formatType == null) { + throw new Exception($"Invalid script hash_type: {script.HashType}"); + } + data.Add((int)formatType); foreach (byte c in Types.Convert.HexStringToBytes(script.CodeHash)) { data.Add(Convert.ToInt32(c)); diff --git a/src/Ckb.Molecule/Type/RawHeaderSerializer.cs b/src/Ckb.Molecule/Type/RawHeaderSerializer.cs index 00ab36e..64846ac 100644 --- a/src/Ckb.Molecule/Type/RawHeaderSerializer.cs +++ b/src/Ckb.Molecule/Type/RawHeaderSerializer.cs @@ -16,7 +16,7 @@ public RawHeaderSerializer(Header header) new Byte32Serializer(header.ParentHash), new Byte32Serializer(header.TransactionsRoot), new Byte32Serializer(header.ProposalsHash), - new Byte32Serializer(header.UnclesHash), + new Byte32Serializer(header.ExtraHash), new Byte32Serializer(header.Dao), }) { } diff --git a/src/Ckb.Molecule/Type/ScriptSerializer.cs b/src/Ckb.Molecule/Type/ScriptSerializer.cs index 34c9955..91dedff 100644 --- a/src/Ckb.Molecule/Type/ScriptSerializer.cs +++ b/src/Ckb.Molecule/Type/ScriptSerializer.cs @@ -1,5 +1,6 @@ using Ckb.Molecule.Base; using Ckb.Types; +using System; namespace Ckb.Molecule.Type { @@ -8,9 +9,20 @@ public class ScriptSerializer : TableSerializer public ScriptSerializer(Script script) : base(new BaseSerializer[] { new Byte32Serializer(script.CodeHash), - new ByteSerializer((byte)(script.HashType == "data" ? 0x0 : 0x1)), + new ByteSerializer((byte) serializeHashType(script.HashType)), new BytesSerializer(script.Args), }) { } + + private static byte serializeHashType(string hashType) { + if (hashType == "data") { + return 0x0; + } else if (hashType == "type") { + return 0x1; + } else if (hashType == "data1") { + return 0x2; + } + throw new Exception($"Invalid script hash_type: {hashType}"); + } } } diff --git a/src/Ckb.Types/CellbaseWitness.cs b/src/Ckb.Types/CellbaseWitness.cs index 8637214..cfe86a8 100644 --- a/src/Ckb.Types/CellbaseWitness.cs +++ b/src/Ckb.Types/CellbaseWitness.cs @@ -42,7 +42,17 @@ public static Script Parse(string witness) .ToArray(); string codeHash = Convert.BytesToHexString(codeHashSerialization); - string hashType = Convert.BytesToHexString(hashTypeSerialization) == "0x00" ? "data" : "type"; + string hashTypeBytes = Convert.BytesToHexString(hashTypeSerialization); + string hashType; + if (hashTypeBytes == "0x00") { + hashType = "data"; + } else if (hashTypeBytes == "0x01") { + hashType = "type"; + } else if (hashTypeBytes == "0x02") { + hashType = "data1"; + } else { + throw new Exception($"Invalid hash type value: {hashTypeBytes}"); + } string args = Convert.BytesToHexString(argsSerialization); return new Script() diff --git a/src/Ckb.Types/Types.cs b/src/Ckb.Types/Types.cs index 6e8bb7a..776798c 100644 --- a/src/Ckb.Types/Types.cs +++ b/src/Ckb.Types/Types.cs @@ -51,8 +51,8 @@ public class Header [JsonProperty(PropertyName = "transactions_root")] public string TransactionsRoot { get; set; } - [JsonProperty(PropertyName = "uncles_hash")] - public string UnclesHash { get; set; } + [JsonProperty(PropertyName = "extra_hash")] + public string ExtraHash { get; set; } [JsonProperty(PropertyName = "version")] public string Version { get; set; } diff --git a/src/Tippy.Ctrl/ChainSpecTemplate.txt b/src/Tippy.Ctrl/ChainSpecTemplate.txt index 4569454..a8ca362 100644 --- a/src/Tippy.Ctrl/ChainSpecTemplate.txt +++ b/src/Tippy.Ctrl/ChainSpecTemplate.txt @@ -93,5 +93,14 @@ genesis_epoch_length = 1000 # Keep difficulty be permanent if the pow is Dummy. (default: false) permanent_difficulty_in_dummy = true +[params.hardfork] +rfc_0028 = 0 +rfc_0029 = 0 +rfc_0030 = 0 +rfc_0031 = 0 +rfc_0032 = 0 +rfc_0036 = 0 +rfc_0038 = 0 + [pow] func = "Dummy" diff --git a/src/Tippy.Ctrl/Process/BinariesInfo.cs b/src/Tippy.Ctrl/Process/BinariesInfo.cs index 9425055..6fd8289 100644 --- a/src/Tippy.Ctrl/Process/BinariesInfo.cs +++ b/src/Tippy.Ctrl/Process/BinariesInfo.cs @@ -7,7 +7,7 @@ internal class BinariesInfo { internal string Info { get; private set; } = ""; internal bool HasDebuggerDeps { get; private set; } = false; - readonly List binaries = new() { "ckb", "ckb-indexer", "ckb-debugger"/*, "ckb-cli"*/ }; + readonly List binaries = new() { "ckb", "ckb-indexer", "ckb-debugger", "ckb-cli" }; internal void Refresh() { diff --git a/src/Tippy.Ctrl/Process/Debugger/DebuggerProcess.cs b/src/Tippy.Ctrl/Process/Debugger/DebuggerProcess.cs index c4303f5..35fbede 100644 --- a/src/Tippy.Ctrl/Process/Debugger/DebuggerProcess.cs +++ b/src/Tippy.Ctrl/Process/Debugger/DebuggerProcess.cs @@ -10,15 +10,17 @@ internal class DebuggerProcess : CommandProcess private readonly string TxFilePath; private readonly string IoType; private readonly int IoIndex; + private readonly string ScriptVersion; private readonly string? BinaryPath; - public DebuggerProcess(ProcessInfo info, string scriptGroupType, string scriptHash, string txFilePath, string ioType, int ioIndex, string? binaryPath = null) : base(info) + public DebuggerProcess(ProcessInfo info, string scriptGroupType, string scriptHash, string txFilePath, string ioType, int ioIndex, string scriptVersion, string? binaryPath = null) : base(info) { ScriptHash = scriptHash; ScriptGroupType = scriptGroupType; TxFilePath = txFilePath; IoType = ioType; IoIndex = ioIndex; + ScriptVersion = scriptVersion; BinaryPath = binaryPath; } @@ -30,7 +32,7 @@ protected override void Configure() throw new Exception("No file path found!"); } string debuggerBinaryPath = BinaryFullPath("ckb-debugger"); - string arguments = $"--port 7682 {debuggerBinaryPath} -l 0.0.0.0:2000 -g {ScriptGroupType} -h {ScriptHash} -t {TxFilePath} -e {IoType} -i {IoIndex}"; + string arguments = $"--port 7682 {debuggerBinaryPath} --mode gdb --gdb-listen 0.0.0.0:2000 --script-group-type {ScriptGroupType} --script-hash {ScriptHash} --tx-file {TxFilePath} --cell-type {IoType} --cell-index {IoIndex} --script-version {ScriptVersion}"; if (BinaryPath != null) { arguments += $" -r {BinaryPath}"; diff --git a/src/Tippy.Ctrl/Process/Debugger/ProcessManager.cs b/src/Tippy.Ctrl/Process/Debugger/ProcessManager.cs index ff8cb1c..5c056ec 100644 --- a/src/Tippy.Ctrl/Process/Debugger/ProcessManager.cs +++ b/src/Tippy.Ctrl/Process/Debugger/ProcessManager.cs @@ -7,12 +7,12 @@ public class ProcessManager private static GdbProcess? GdbProcessInstance; private static DebuggerProcess? DebuggerProcessInstance; - public static void Start(Project project, string scriptGroupType, string scriptHash, string txFilePath, string debugFilePath, string ioType, int ioIndex, string? binaryForDebugger) + public static void Start(Project project, string scriptGroupType, string scriptHash, string txFilePath, string debugFilePath, string ioType, int ioIndex, string scriptVersion, string? binaryForDebugger) { Stop(); ProcessInfo processInfo = ProcessInfo.FromProject(project); GdbProcessInstance = new GdbProcess(processInfo, debugFilePath); - DebuggerProcessInstance = new DebuggerProcess(processInfo, scriptGroupType, scriptHash, txFilePath, ioType, ioIndex, binaryForDebugger); + DebuggerProcessInstance = new DebuggerProcess(processInfo, scriptGroupType, scriptHash, txFilePath, ioType, ioIndex, scriptVersion, binaryForDebugger); DebuggerProcessInstance.Start(); GdbProcessInstance.Start(); } diff --git a/src/Tippy/Pages/Debugger/Details.cshtml b/src/Tippy/Pages/Debugger/Details.cshtml index 3e35c07..1741e72 100644 --- a/src/Tippy/Pages/Debugger/Details.cshtml +++ b/src/Tippy/Pages/Debugger/Details.cshtml @@ -20,14 +20,22 @@
- +
+
- +
+ +
+
+
+
+
+
diff --git a/src/Tippy/Pages/Debugger/Details.cshtml.cs b/src/Tippy/Pages/Debugger/Details.cshtml.cs index f3952c1..0602e68 100644 --- a/src/Tippy/Pages/Debugger/Details.cshtml.cs +++ b/src/Tippy/Pages/Debugger/Details.cshtml.cs @@ -8,6 +8,7 @@ using System.IO; using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; using DebuggerProcessManager = Tippy.Ctrl.Process.Debugger.ProcessManager; using TypesConvert = Ckb.Types.Convert; @@ -25,17 +26,31 @@ public DetailsModel(Tippy.Core.Data.TippyDbContext context) : base(context) [BindProperty] public string? FilePath { get; set; } + + public List ScriptVersions { get; } = new List + { + new SelectListItem { Value = "1", Text = "CKB2021" }, + new SelectListItem { Value = "0", Text = "CKB2019" }, + }; + + [BindProperty] + public string? ScriptVersion { get; set; } + public IActionResult OnPost(string? txHash, string? ioType, int? ioIndex, int? scriptType, int? txId = null) { - if (FilePath == null) - { - throw new Exception("No file path provided!"); - } - string url = txId == null ? - $"/Debugger/Details?txHash={txHash}&ioType={ioType}&ioIndex={ioIndex}&scriptType={scriptType}&filePath={FilePath}" + $"/Debugger/Details?txHash={txHash}&ioType={ioType}&ioIndex={ioIndex}&scriptType={scriptType}" : - $"/Debugger/Details?txId={txId}&ioType={ioType}&ioIndex={ioIndex}&scriptType={scriptType}&filePath={FilePath}"; + $"/Debugger/Details?txId={txId}&ioType={ioType}&ioIndex={ioIndex}&scriptType={scriptType}"; + + if (FilePath != null) { + url = url + $"&filePath={FilePath}"; + } + + if (ScriptVersion != null) { + url = url + $"&scriptVersion={ScriptVersion}"; + } + return Redirect(url); } @@ -45,8 +60,13 @@ public IActionResult OnPostClose() return Redirect("/Home"); } - public async Task OnGet(string? txHash, string? ioType, int? ioIndex, int? scriptType, string? filePath, int? txId = null) + public async Task OnGet(string? txHash, string? ioType, int? ioIndex, int? scriptType, string? filePath, string? scriptVersion, int? txId = null) { + if (scriptVersion == null) { + scriptVersion = "1"; + } + ScriptVersion = scriptVersion; + if (ioType != "input" && ioType != "output") { throw new Exception("ioType must be `input` or `output`!"); @@ -126,7 +146,7 @@ public async Task OnGet(string? txHash, string? ioType, int? ioIn string scriptGroupType = scriptType == 0 ? "lock" : "type"; try { - DebuggerProcessManager.Start(ActiveProject!, scriptGroupType, scriptHash, mockTxFilePath, binaryFilePath, ioType, (int)ioIndex, binaryForDebugger); + DebuggerProcessManager.Start(ActiveProject!, scriptGroupType, scriptHash, mockTxFilePath, binaryFilePath, ioType, (int)ioIndex, scriptVersion, binaryForDebugger); } catch (System.InvalidOperationException e) { @@ -138,7 +158,7 @@ public async Task OnGet(string? txHash, string? ioType, int? ioIn private static string GetCellDepData(MockTransaction mockTx, Script script) { - if (script.HashType == "data") + if (script.HashType != "type") { return GetCellDepDataByDataHash(mockTx, script.CodeHash); } diff --git a/src/Tippy/Tippy.csproj b/src/Tippy/Tippy.csproj index 69cf308..75cd806 100644 --- a/src/Tippy/Tippy.csproj +++ b/src/Tippy/Tippy.csproj @@ -8,7 +8,7 @@ false embedded 6e0dc08b-01f2-47f6-8249-66ed1b18f469 - 0.3.2 + 0.4.0-rc2 https://github.com/nervosnetwork/tippy https://github.com/nervosnetwork/tippy Copyright (c) Nervos Foundation diff --git a/tests/Ckb.Molecule.Tests/Fixtures/block.json b/tests/Ckb.Molecule.Tests/Fixtures/block.json index 9fd739b..3677f9e 100644 --- a/tests/Ckb.Molecule.Tests/Fixtures/block.json +++ b/tests/Ckb.Molecule.Tests/Fixtures/block.json @@ -9,7 +9,7 @@ "proposals_hash": "0x2ddad1ff8aba40d0aa41a8a12f4ac61a03c1df244501b8650cd702f10f3fcdf3", "timestamp": "0x1723cfd16c8", "transactions_root": "0x7b8e8c8951749096f7a1e86b4204655a6e52b381468faa3b6e2dba699dd58686", - "uncles_hash": "0x136b809c54f8612326529ec47945301cb97c442a32e46c7390f9165e31df8ba9", + "extra_hash": "0x136b809c54f8612326529ec47945301cb97c442a32e46c7390f9165e31df8ba9", "version": "0x0" }, "proposals": [ @@ -60,7 +60,7 @@ "proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x1723cfc9cb3", "transactions_root": "0x9bd730ba9f1c57da5970c737914711156ab921ae205b4855197d7089556a84af", - "uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "version": "0x0" }, "proposals": [] diff --git a/tools/download-binaries.ps1 b/tools/download-binaries.ps1 index 6ae8f2c..240ce92 100644 --- a/tools/download-binaries.ps1 +++ b/tools/download-binaries.ps1 @@ -12,7 +12,7 @@ function DownloadCkb { Invoke-WebRequest "https://github.com/nervosnetwork/ckb/releases/download/v${CkbVersion}/${CkbFilename}.zip" -OutFile "${CkbFilename}.zip" Expand-Archive -Force "${CkbFilename}.zip" -DestinationPath ./ Copy-Item $CkbFilename/ckb.exe ./ - # Copy-Item $CkbFilename/ckb-cli.exe ./ + Copy-Item $CkbFilename/ckb-cli.exe ./ Remove-Item -Force -Recurse $CkbFilename Remove-Item "${CkbFilename}.zip" } @@ -33,4 +33,4 @@ function DownloadCkbIndexer() { GotoFolder DownloadCkb DownloadCkbIndexer -Set-Location $RootDir \ No newline at end of file +Set-Location $RootDir diff --git a/tools/download-binaries.sh b/tools/download-binaries.sh index 9f8667c..a4b391f 100755 --- a/tools/download-binaries.sh +++ b/tools/download-binaries.sh @@ -14,8 +14,8 @@ function download_ckb_macos() { unzip -o ${CKB_FILENAME}.zip ${CKB_FILENAME}/ckb ${CKB_FILENAME}/ckb-cli cp ${CKB_FILENAME}/ckb ./ chmod +x ./ckb - # cp ${CKB_FILENAME}/ckb-cli ./ - # chmod +x ./ckb-cli + cp ${CKB_FILENAME}/ckb-cli ./ + chmod +x ./ckb-cli rm -rf $CKB_FILENAME rm ${CKB_FILENAME}.zip } @@ -29,8 +29,8 @@ function download_ckb_linux() { tar xvzf ${CKB_FILENAME}.tar.gz ${CKB_FILENAME}/ckb ${CKB_FILENAME}/ckb-cli cp ${CKB_FILENAME}/ckb ./ chmod +x ./ckb - # cp ${CKB_FILENAME}/ckb-cli ./ - # chmod +x ./ckb-cli + cp ${CKB_FILENAME}/ckb-cli ./ + chmod +x ./ckb-cli rm -rf $CKB_FILENAME rm ${CKB_FILENAME}.tar.gz } @@ -43,7 +43,7 @@ function download_ckb_windows() { curl -O -L "https://github.com/nervosnetwork/ckb/releases/download/v${CKB_VERSION}/${CKB_FILENAME}.zip" unzip -o ${CKB_FILENAME}.zip ${CKB_FILENAME}/ckb.exe ${CKB_FILENAME}/ckb-cli.exe cp ${CKB_FILENAME}/ckb.exe ./ - # cp ${CKB_FILENAME}/ckb-cli.exe ./ + cp ${CKB_FILENAME}/ckb-cli.exe ./ rm -rf $CKB_FILENAME rm ${CKB_FILENAME}.zip } @@ -94,7 +94,7 @@ function download_ckb_debugger_macos() { mkdir -p $ROOT_DIR/src/Tippy.Ctrl/BinDeps/mac cd $ROOT_DIR/src/Tippy.Ctrl/BinDeps/mac - curl -O -L "https://github.com/nervosnetwork/ckb-standalone-debugger/releases/download/v${CKB_DEBUGGER_VERSION}/${FILENAME}" + curl -O -L "https://github.com/nervosnetwork/ckb-standalone-debugger/releases/download/${CKB_DEBUGGER_VERSION}/${FILENAME}" tar xvzf $FILENAME ckb-debugger chmod +x ./ckb-debugger rm -rf $FILENAME @@ -105,7 +105,7 @@ function download_ckb_debugger_linux() { mkdir -p $ROOT_DIR/src/Tippy.Ctrl/BinDeps/linux cd $ROOT_DIR/src/Tippy.Ctrl/BinDeps/linux - curl -O -L "https://github.com/nervosnetwork/ckb-standalone-debugger/releases/download/v${CKB_DEBUGGER_VERSION}/${FILENAME}" + curl -O -L "https://github.com/nervosnetwork/ckb-standalone-debugger/releases/download/${CKB_DEBUGGER_VERSION}/${FILENAME}" tar xvzf $FILENAME ckb-debugger chmod +x ./ckb-debugger rm -rf $FILENAME diff --git a/tools/osx/Info.plist b/tools/osx/Info.plist index 74b8c2e..4fdc468 100644 --- a/tools/osx/Info.plist +++ b/tools/osx/Info.plist @@ -9,9 +9,9 @@ CFBundleIconFile Tippy.icns CFBundleVersion - 0.3.2 + 0.4.0-rc2 CFBundleShortVersionString - 0.3.2 + 0.4.0-rc2 CFBundleExecutable main CFBundleInfoDictionaryVersion