From 642beeb20ce7eb3a0258f44b30e1e339421d7b0d Mon Sep 17 00:00:00 2001 From: Yanbo Li Date: Mon, 8 May 2017 15:28:46 +0800 Subject: [PATCH 1/3] Change the default readme to pure English Remove the Chinese characters from the default readme file the CN version will be created in another file Signed-off-by: Yanbo Li --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 3544c4c6..e0eb1f19 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,20 @@ DNA is the golang implementation of a decentralized and distributed network prot ## Highlight Features -* 可扩展通用智能合约平台 / Extendable Generalduty Lightweight Smart Contract -* 跨链协议 / Crosschain Interactive Protocol -* 抗量子攻击 / Quantum-Resistant Cryptography (optional module) -* 国密算法支持SM系列 / China National Crypto Standard (optional module) -* 零配置组网出块 / Zero Configuration Kickoff Networks (Ongoing) -* 高度优化交易处理速度 / High Optimization of TPS -* 分布式数据存储IPFS集成方案 / IPFS Dentralizaed Storing & Sharing files solution integration (TBD) -* 链接通道加密,CA节点认证可控 / P2P link layer encryption, node access privilege controlling -* 可插拔共识模块 / Multiple Consensus Algorithm(DBFT/RBFT/SBFT) support -* 动态区块生成时间 / Telescopic Block Generation Time -* 数字资产管理 / Digtal Asset Management -* 可配置化经济激励模型 / Configurable Economic Incentive -* 可配置分区共识机制 / Configable sharding Consensus -* 可配置策略控制 / Configable Policy Management +* Extendable Generalduty Lightweight Smart Contract +* Crosschain Interactive Protocol +* Quantum-Resistant Cryptography (optional module) +* China National Crypto Standard (optional module) +* Zero Configuration Kickoff Networks (Ongoing) +* High Optimization of TPS +* IPFS Dentralizaed Storing & Sharing files solution integration (TBD) +* P2P link layer encryption, node access privilege controlling +* Multiple Consensus Algorithm(DBFT/RBFT/SBFT) support +* Telescopic Block Generation Time +* Digtal Asset Management +* Configurable Economic Incentive +* Configable sharding Consensus +* Configable Policy Management # Building The requirements to build DNA are: From 69a1c9f01b8279aef3072f80d9d382acbd42792f Mon Sep 17 00:00:00 2001 From: "luodan.wg" Date: Fri, 5 May 2017 22:54:11 +0800 Subject: [PATCH 2/3] bug fixed of OpCode set when -1 compare with the ScriptBuilder.cs of Antshares. it should be PUSHM1. Signed-off-by: luodanwg --- core/contract/program/ProgramBuilder.go | 31 ++++++++------------ core/contract/program/ProgramBuilder_test.go | 17 +++++++++++ 2 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 core/contract/program/ProgramBuilder_test.go diff --git a/core/contract/program/ProgramBuilder.go b/core/contract/program/ProgramBuilder.go index 07b6143b..39149ebb 100644 --- a/core/contract/program/ProgramBuilder.go +++ b/core/contract/program/ProgramBuilder.go @@ -1,50 +1,48 @@ package program import ( - "bytes" + . "DNA/common" "DNA/vm" + "bytes" "math/big" - . "DNA/common" ) type ProgramBuilder struct { buffer bytes.Buffer - } -func NewProgramBuilder() *ProgramBuilder{ +func NewProgramBuilder() *ProgramBuilder { return &ProgramBuilder{ - //TODO: add sync pool for create ProgramBuilder + //TODO: add sync pool for create ProgramBuilder } } -func (pb *ProgramBuilder) AddOp(op vm.OpCode){ +func (pb *ProgramBuilder) AddOp(op vm.OpCode) { pb.buffer.WriteByte(byte(op)) } -func (pb *ProgramBuilder) AddCodes(codes []byte){ +func (pb *ProgramBuilder) AddCodes(codes []byte) { pb.buffer.Write(codes) } -func (pb *ProgramBuilder) PushNumber(number *big.Int){ +func (pb *ProgramBuilder) PushNumber(number *big.Int) { if number.Cmp(big.NewInt(-1)) == 0 { - pb.AddOp(vm.NEGATE) + pb.AddOp(vm.PUSHM1) return } - if number.Cmp(big.NewInt(0)) == 0{ + if number.Cmp(big.NewInt(0)) == 0 { pb.AddOp(vm.PUSH0) return } - if number.Cmp(big.NewInt(0)) == 1 && number.Cmp(big.NewInt(16)) <= 0{ + if number.Cmp(big.NewInt(0)) == 1 && number.Cmp(big.NewInt(16)) <= 0 { pb.AddOp(vm.OpCode(byte(vm.PUSH1) - 1 + number.Bytes()[0])) return } pb.PushData(number.Bytes()) } - -func (pb *ProgramBuilder) PushData(data []byte){ - if data == nil{ +func (pb *ProgramBuilder) PushData(data []byte) { + if data == nil { return //TODO: add error } @@ -68,9 +66,6 @@ func (pb *ProgramBuilder) PushData(data []byte){ } } -func (pb *ProgramBuilder) ToArray() []byte{ +func (pb *ProgramBuilder) ToArray() []byte { return pb.buffer.Bytes() } - - - diff --git a/core/contract/program/ProgramBuilder_test.go b/core/contract/program/ProgramBuilder_test.go new file mode 100644 index 00000000..a9e89f03 --- /dev/null +++ b/core/contract/program/ProgramBuilder_test.go @@ -0,0 +1,17 @@ +package program + +import ( + "fmt" + "math/big" + "testing" +) + +func TestProgramBuilder_PushData(t *testing.T) { + for i := int64(-20); i <= 26; i++ { + pb := NewProgramBuilder() + testx := big.NewInt(i) + pb.PushNumber(testx) + fmt.Printf("%d=%#v\n", i, pb.ToArray()) + } + +} From 0ab4c7dc3554bbae44404bd82228c274e850313f Mon Sep 17 00:00:00 2001 From: "luodan.wg" Date: Wed, 10 May 2017 01:02:37 +0800 Subject: [PATCH 3/3] BugFix of nil set of input/output utxo when transfer. BugFix of nil set of input/output utxo when transfer. have test with full test (reg/issue/transfer) Signed-off-by: luodanwg --- core/transaction/TransactionBuilder.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/transaction/TransactionBuilder.go b/core/transaction/TransactionBuilder.go index 4e4ec422..03aa75b0 100644 --- a/core/transaction/TransactionBuilder.go +++ b/core/transaction/TransactionBuilder.go @@ -52,14 +52,15 @@ func NewTransferAssetTransaction(inputs []*UTXOTxInput, outputs []*TxOutput) (*T assetRegPayload := &payload.TransferAsset{} - return &Transaction{ - UTXOInputs: []*UTXOTxInput{}, - BalanceInputs: []*BalanceTxInput{}, - Attributes: []*TxAttribute{}, - TxType: TransferAsset, - Payload: assetRegPayload, - Programs: []*program.Program{}, - }, nil + return &Transaction{ + TxType: TransferAsset, + Payload: assetRegPayload, + Attributes: []*TxAttribute{}, + UTXOInputs: inputs, + BalanceInputs: []*BalanceTxInput{}, + Outputs: outputs, + Programs: []*program.Program{}, + }, nil } //initial a new transaction with record payload