Skip to content

Commit

Permalink
Merge pull request #319 from aergoio/develop
Browse files Browse the repository at this point in the history
Release v2.4.9
  • Loading branch information
hayarobi authored Nov 17, 2023
2 parents 446dd13 + 070a10a commit dd28d19
Show file tree
Hide file tree
Showing 223 changed files with 6,124 additions and 1,593 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/full_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:
- opened
- reopened
- synchronize
pull_request_target:
types:
- edited
push:
branches:
- master
Expand Down Expand Up @@ -49,21 +46,24 @@ jobs:
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageCommand: go test -timeout 999s -coverprofile build/c.out -v ./...
coverageCommand: go test -timeout 999s -coverprofile build/c.out ./...
prefix: github.com/aergoio/aergo/v2
coverageLocations: ${{github.workspace}}/build/c.out:gocov
debug: true

# run unit test only in other cases
- name: Unit Tests
if: github.event_name != 'push' || github.ref_name != 'master' || github.ref_type != 'branch'
run: go test -timeout 999s -v ./...
run: go test -timeout 999s ./...

- name: Integration Tests
run: |
if [ -d "tests" ]; then
cd tests
./run_tests.sh
else
echo "The 'tests' folder does not exist."
fi
- name: Integration Tests - brick
run: cd tests && ./run_tests.sh brick

- name: Integration Tests - sbp
run: cd tests && ./run_tests.sh sbp

- name: Integration Tests - dpos
run: cd tests && ./run_tests.sh dpos

- name: Integration Tests - raft
run: cd tests && ./run_tests.sh raft
2 changes: 1 addition & 1 deletion .github/workflows/manual_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
run: make

- name: Unit Tests
run: go test -timeout 999s -v ./...
run: go test -timeout 999s ./...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ MVP based, Forward compatibility, Iteration

### Prerequisites

* Go1.12.5+ - https://golang.org/dl
* Go1.19.1+ - https://golang.org/dl
* Proto Buffers - https://github.com/google/protobuf
* CMake 3.0.0 or higher - https://cmake.org

Expand Down
18 changes: 9 additions & 9 deletions account/key/crypto/v1strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"io"
"reflect"

"github.com/aergoio/aergo/v2/internal/enc/hex"
"github.com/aergoio/aergo/v2/types"
"github.com/btcsuite/btcd/btcec"
"golang.org/x/crypto/scrypt"
Expand Down Expand Up @@ -105,9 +105,9 @@ func (ks *v1Strategy) Encrypt(key *PrivateKey, passphrase string) ([]byte, error
cipher := v1CipherJSON{
Algorithm: cipherAlgorithm,
Params: v1CipherParamsJSON{
Iv: hex.EncodeToString(iv),
Iv: hex.Encode(iv),
},
Ciphertext: hex.EncodeToString(ciphertext),
Ciphertext: hex.Encode(ciphertext),
}
// json: kdf
kdf := v1KdfJson{
Expand All @@ -117,9 +117,9 @@ func (ks *v1Strategy) Encrypt(key *PrivateKey, passphrase string) ([]byte, error
N: scryptN,
P: scryptP,
R: scryptR,
Salt: hex.EncodeToString(salt),
Salt: hex.Encode(salt),
},
Mac: hex.EncodeToString(mac),
Mac: hex.Encode(mac),
}
rawAddress := GenerateAddress(&(key.ToECDSA().PublicKey))
encodedAddress := types.EncodeAddress(rawAddress)
Expand Down Expand Up @@ -155,11 +155,11 @@ func (ks *v1Strategy) Decrypt(encrypted []byte, passphrase string) (*PrivateKey,
}

// check mac
mac, err := hex.DecodeString(kdf.Mac)
mac, err := hex.Decode(kdf.Mac)
if nil != err {
return nil, err
}
cipherText, err := hex.DecodeString(cipher.Ciphertext)
cipherText, err := hex.Decode(cipher.Ciphertext)
if nil != err {
return nil, err
}
Expand All @@ -170,7 +170,7 @@ func (ks *v1Strategy) Decrypt(encrypted []byte, passphrase string) (*PrivateKey,

// decrypt
decryptKey := derivedKey[:16]
iv, err := hex.DecodeString(cipher.Params.Iv)
iv, err := hex.Decode(cipher.Params.Iv)
if nil != err {
return nil, err
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func checkKeyFormat(keyFormat *v1KeyStoreFormat) error {
}

func deriveCipherKey(passphrase []byte, kdf v1KdfJson) ([]byte, error) {
salt, err := hex.DecodeString(kdf.Params.Salt)
salt, err := hex.Decode(kdf.Params.Salt)
if err != nil {
return nil, err
}
Expand Down
22 changes: 11 additions & 11 deletions chain/blockvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"errors"
"fmt"

"github.com/aergoio/aergo/v2/internal/enc"
"github.com/aergoio/aergo/v2/internal/enc/base58"
"github.com/aergoio/aergo/v2/pkg/component"
"github.com/aergoio/aergo/v2/state"
"github.com/aergoio/aergo/v2/types"
Expand Down Expand Up @@ -90,7 +90,7 @@ func (t validateReport) toString() string {
result = "failed"
}

msgStr = fmt.Sprintf("%s : %s. block= %s, computed=%s", t.name, result, enc.ToString(t.src), enc.ToString(t.target))
msgStr = fmt.Sprintf("%s : %s. block= %s, computed=%s", t.name, result, base58.Encode(t.src), base58.Encode(t.target))

return msgStr
}
Expand All @@ -99,7 +99,7 @@ func (bv *BlockValidator) ValidateBody(block *types.Block) error {
txs := block.GetBody().GetTxs()

// TxRootHash
logger.Debug().Int("Txlen", len(txs)).Str("TxRoot", enc.ToString(block.GetHeader().GetTxsRootHash())).
logger.Debug().Int("Txlen", len(txs)).Str("TxRoot", base58.Encode(block.GetHeader().GetTxsRootHash())).
Msg("tx root verify")

hdrRootHash := block.GetHeader().GetTxsRootHash()
Expand All @@ -112,8 +112,8 @@ func (bv *BlockValidator) ValidateBody(block *types.Block) error {

if !ret {
logger.Error().Str("block", block.ID()).
Str("txroot", enc.ToString(hdrRootHash)).
Str("compute txroot", enc.ToString(computeTxRootHash)).
Str("txroot", base58.Encode(hdrRootHash)).
Str("compute txroot", base58.Encode(computeTxRootHash)).
Msg("tx root validation failed")

return ErrorBlockVerifyTxRoot
Expand Down Expand Up @@ -160,13 +160,13 @@ func (bv *BlockValidator) ValidatePost(sdbRoot []byte, receipts *types.Receipts,
}
if !ret {
logger.Error().Str("block", block.ID()).
Str("hdrroot", enc.ToString(hdrRoot)).
Str("sdbroot", enc.ToString(sdbRoot)).
Str("hdrroot", base58.Encode(hdrRoot)).
Str("sdbroot", base58.Encode(sdbRoot)).
Msg("block root hash validation failed")
return ErrorBlockVerifyStateRoot
}

logger.Debug().Str("sdbroot", enc.ToString(sdbRoot)).
logger.Debug().Str("sdbroot", base58.Encode(sdbRoot)).
Msg("block root hash validation succeed")

hdrRoot = block.GetHeader().ReceiptsRootHash
Expand All @@ -177,12 +177,12 @@ func (bv *BlockValidator) ValidatePost(sdbRoot []byte, receipts *types.Receipts,
bv.report(validateReport{name: "Verify receipt merkle root", pass: ret, src: hdrRoot, target: receiptsRoot})
} else if !ret {
logger.Error().Str("block", block.ID()).
Str("hdrroot", enc.ToString(hdrRoot)).
Str("receipts_root", enc.ToString(receiptsRoot)).
Str("hdrroot", base58.Encode(hdrRoot)).
Str("receipts_root", base58.Encode(receiptsRoot)).
Msg("receipts root hash validation failed")
return ErrorBlockVerifyReceiptRoot
}
logger.Debug().Str("receipts_root", enc.ToString(receiptsRoot)).
logger.Debug().Str("receipts_root", base58.Encode(receiptsRoot)).
Msg("receipt root hash validation succeed")

return nil
Expand Down
6 changes: 3 additions & 3 deletions chain/chainanchor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package chain

import (
"github.com/aergoio/aergo/v2/internal/enc"
"github.com/aergoio/aergo/v2/internal/enc/base58"
"github.com/aergoio/aergo/v2/types"
)

Expand Down Expand Up @@ -72,7 +72,7 @@ func (cs *ChainService) getAnchorsFromHash(blockHash []byte) ChainAnchor {
return nil
}

logger.Debug().Uint64("no", latestNo).Str("hash", enc.ToString(blockHash)).Msg("anchor")
logger.Debug().Uint64("no", latestNo).Str("hash", base58.Encode(blockHash)).Msg("anchor")

anchors = append(anchors, blockHash)
if latestNo == 0 {
Expand All @@ -91,7 +91,7 @@ func (cs *ChainService) getAnchorsFromHash(blockHash []byte) ChainAnchor {
return nil
}

logger.Debug().Uint64("no", latestNo).Str("hash", enc.ToString(blockHash)).Msg("anchor")
logger.Debug().Uint64("no", latestNo).Str("hash", base58.Encode(blockHash)).Msg("anchor")

anchors = append(anchors, blockHash)
if latestNo <= dec {
Expand Down
Loading

0 comments on commit dd28d19

Please sign in to comment.