Skip to content
Open
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
2 changes: 1 addition & 1 deletion .ckb-debugger-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.1
0.20.0-rc4
2 changes: 1 addition & 1 deletion .ckb-indexer-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.0
0.3.0-rc1
2 changes: 1 addition & 1 deletion .ckb-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.42.0
0.100.0-rc4
11 changes: 10 additions & 1 deletion src/Ckb.Address/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Ckb.Molecule/Type/RawHeaderSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
{ }
Expand Down
14 changes: 13 additions & 1 deletion src/Ckb.Molecule/Type/ScriptSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Ckb.Molecule.Base;
using Ckb.Types;
using System;

namespace Ckb.Molecule.Type
{
Expand All @@ -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}");
}
}
}
12 changes: 11 additions & 1 deletion src/Ckb.Types/CellbaseWitness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/Ckb.Types/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
9 changes: 9 additions & 0 deletions src/Tippy.Ctrl/ChainSpecTemplate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/Tippy.Ctrl/Process/BinariesInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal class BinariesInfo
{
internal string Info { get; private set; } = "";
internal bool HasDebuggerDeps { get; private set; } = false;
readonly List<string> binaries = new() { "ckb", "ckb-indexer", "ckb-debugger"/*, "ckb-cli"*/ };
readonly List<string> binaries = new() { "ckb", "ckb-indexer", "ckb-debugger", "ckb-cli" };

internal void Refresh()
{
Expand Down
6 changes: 4 additions & 2 deletions src/Tippy.Ctrl/Process/Debugger/DebuggerProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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}";
Expand Down
4 changes: 2 additions & 2 deletions src/Tippy.Ctrl/Process/Debugger/ProcessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
12 changes: 10 additions & 2 deletions src/Tippy/Pages/Debugger/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@
<div class="column is-10 is-offset-1">
<form method="post">
<div class="field">
<label class="label">Upload a binary to replace this script.</label>
<label class="label">Fill in the path of a binary to replace this script.</label>
<div class="control">
<input asp-for="FilePath" class="input is-info" type="text" placeholder="Absolute File Path" />
</div>
</div>
<div class="field">
<label class="label">CKB-VM version to use. See <a href="https://github.com/nervosnetwork/rfcs/pull/236">here</a> for more details.</label>
<div class="control">
<button asp-page="./Debugger/Details" class="button is-link is-light">Replace</button>
<div class="select">
<select asp-for="ScriptVersion" asp-items="Model.ScriptVersions"></select>
</div>
</div>
</div>
<div class="field">
<div class="control">
<button asp-page="./Debugger/Details" class="button is-link is-light">Restart</button>
</div>
</div>
</form>
Expand Down
40 changes: 30 additions & 10 deletions src/Tippy/Pages/Debugger/Details.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,17 +26,31 @@ public DetailsModel(Tippy.Core.Data.TippyDbContext context) : base(context)

[BindProperty]
public string? FilePath { get; set; }

public List<SelectListItem> ScriptVersions { get; } = new List<SelectListItem>
{
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);
}

Expand All @@ -45,8 +60,13 @@ public IActionResult OnPostClose()
return Redirect("/Home");
}

public async Task<IActionResult> OnGet(string? txHash, string? ioType, int? ioIndex, int? scriptType, string? filePath, int? txId = null)
public async Task<IActionResult> 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`!");
Expand Down Expand Up @@ -126,7 +146,7 @@ public async Task<IActionResult> 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)
{
Expand All @@ -138,7 +158,7 @@ public async Task<IActionResult> 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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tippy/Tippy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<IsPackable>false</IsPackable>
<DebugType>embedded</DebugType>
<UserSecretsId>6e0dc08b-01f2-47f6-8249-66ed1b18f469</UserSecretsId>
<Version>0.3.2</Version>
<Version>0.4.0-rc2</Version>
<PackageProjectUrl>https://github.com/nervosnetwork/tippy</PackageProjectUrl>
<RepositoryUrl>https://github.com/nervosnetwork/tippy</RepositoryUrl>
<Copyright>Copyright (c) Nervos Foundation</Copyright>
Expand Down
4 changes: 2 additions & 2 deletions tests/Ckb.Molecule.Tests/Fixtures/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"proposals_hash": "0x2ddad1ff8aba40d0aa41a8a12f4ac61a03c1df244501b8650cd702f10f3fcdf3",
"timestamp": "0x1723cfd16c8",
"transactions_root": "0x7b8e8c8951749096f7a1e86b4204655a6e52b381468faa3b6e2dba699dd58686",
"uncles_hash": "0x136b809c54f8612326529ec47945301cb97c442a32e46c7390f9165e31df8ba9",
"extra_hash": "0x136b809c54f8612326529ec47945301cb97c442a32e46c7390f9165e31df8ba9",
"version": "0x0"
},
"proposals": [
Expand Down Expand Up @@ -60,7 +60,7 @@
"proposals_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x1723cfc9cb3",
"transactions_root": "0x9bd730ba9f1c57da5970c737914711156ab921ae205b4855197d7089556a84af",
"uncles_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"version": "0x0"
},
"proposals": []
Expand Down
4 changes: 2 additions & 2 deletions tools/download-binaries.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -33,4 +33,4 @@ function DownloadCkbIndexer() {
GotoFolder
DownloadCkb
DownloadCkbIndexer
Set-Location $RootDir
Set-Location $RootDir
14 changes: 7 additions & 7 deletions tools/download-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tools/osx/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<key>CFBundleIconFile</key>
<string>Tippy.icns</string>
<key>CFBundleVersion</key>
<string>0.3.2</string>
<string>0.4.0-rc2</string>
<key>CFBundleShortVersionString</key>
<string>0.3.2</string>
<string>0.4.0-rc2</string>
<key>CFBundleExecutable</key>
<string>main</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down