Merge branch 'master' of github.com:harmony-one/harmony into verify_headers

pull/1539/head
Dennis Won 5 years ago
commit 128d43f1b5
  1. 26
      .hmy/wallet.ini
  2. 26
      cmd/client/wallet/generated_wallet.ini.go
  3. 4
      cmd/client/wallet/main.go
  4. 26
      cmd/client/wallet_stress_test/generated_wallet.ini.go
  5. 7
      internal/configs/sharding/fixedschedule.go
  6. 6
      internal/configs/sharding/localnet.go
  7. 6
      internal/configs/sharding/mainnet.go
  8. 29
      internal/configs/sharding/pangaea.go
  9. 6
      internal/configs/sharding/shardingconfig.go
  10. 6
      internal/configs/sharding/testnet.go
  11. 5
      node/worker/worker.go
  12. 4
      scripts/node.sh
  13. 75
      scripts/wallet.sh

@ -1,23 +1,23 @@
[default]
[main]
bootnode = /ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv
bootnode = /ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9
bootnode = /ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX
bootnode = /ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj
shards = 4
[default.shard0.rpc]
[main.shard0.rpc]
rpc = l0.t.hmny.io:14555
rpc = s0.t.hmny.io:14555
[default.shard1.rpc]
[main.shard1.rpc]
rpc = l1.t.hmny.io:14555
rpc = s1.t.hmny.io:14555
[default.shard2.rpc]
[main.shard2.rpc]
rpc = l2.t.hmny.io:14555
rpc = s2.t.hmny.io:14555
[default.shard3.rpc]
[main.shard3.rpc]
rpc = l3.t.hmny.io:14555
rpc = s3.t.hmny.io:14555
@ -55,17 +55,17 @@ bootnode = /ip4/52.40.84.2/tcp/9867/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxA
shards = 4
[pangaea.shard0.rpc]
rpc = l0.pga.hmny.io:14555
rpc = s0.pga.hmny.io:14555
rpc = l0.n.hmny.io:14555
rpc = s0.n.hmny.io:14555
[pangaea.shard1.rpc]
rpc = l1.pga.hmny.io:14555
rpc = s1.pga.hmny.io:14555
rpc = l1.n.hmny.io:14555
rpc = s1.n.hmny.io:14555
[pangaea.shard2.rpc]
rpc = l2.pga.hmny.io:14555
rpc = s2.pga.hmny.io:14555
rpc = l2.n.hmny.io:14555
rpc = s2.n.hmny.io:14555
[pangaea.shard3.rpc]
rpc = l3.pga.hmny.io:14555
rpc = s3.pga.hmny.io:14555
rpc = l3.n.hmny.io:14555
rpc = s3.n.hmny.io:14555

@ -1,26 +1,26 @@
package main
const (
defaultWalletIni = `[default]
defaultWalletIni = `[main]
bootnode = /ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv
bootnode = /ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9
bootnode = /ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX
bootnode = /ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj
shards = 4
[default.shard0.rpc]
[main.shard0.rpc]
rpc = l0.t.hmny.io:14555
rpc = s0.t.hmny.io:14555
[default.shard1.rpc]
[main.shard1.rpc]
rpc = l1.t.hmny.io:14555
rpc = s1.t.hmny.io:14555
[default.shard2.rpc]
[main.shard2.rpc]
rpc = l2.t.hmny.io:14555
rpc = s2.t.hmny.io:14555
[default.shard3.rpc]
[main.shard3.rpc]
rpc = l3.t.hmny.io:14555
rpc = s3.t.hmny.io:14555
@ -58,19 +58,19 @@ bootnode = /ip4/52.40.84.2/tcp/9867/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxA
shards = 4
[pangaea.shard0.rpc]
rpc = l0.pga.hmny.io:14555
rpc = s0.pga.hmny.io:14555
rpc = l0.n.hmny.io:14555
rpc = s0.n.hmny.io:14555
[pangaea.shard1.rpc]
rpc = l1.pga.hmny.io:14555
rpc = s1.pga.hmny.io:14555
rpc = l1.n.hmny.io:14555
rpc = s1.n.hmny.io:14555
[pangaea.shard2.rpc]
rpc = l2.pga.hmny.io:14555
rpc = s2.pga.hmny.io:14555
rpc = l2.n.hmny.io:14555
rpc = s2.n.hmny.io:14555
[pangaea.shard3.rpc]
rpc = l3.pga.hmny.io:14555
rpc = s3.pga.hmny.io:14555
rpc = l3.n.hmny.io:14555
rpc = s3.n.hmny.io:14555
`
)

@ -59,7 +59,7 @@ type AccountState struct {
const (
rpcRetry = 3
defaultConfigFile = ".hmy/wallet.ini"
defaultProfile = "default"
defaultProfile = "main"
keystoreDir = ".hmy/keystore"
)
@ -144,7 +144,7 @@ func main() {
if len(os.Args) < 2 {
fmt.Println("Usage:")
fmt.Println(" wallet -p profile <action> <params>")
fmt.Println(" -p profile - Specify the profile of the wallet, either testnet/devnet or others configured. Default is: testnet")
fmt.Println(" -p profile - Specify the profile of the wallet, either main, local, beta, or pangaea. Default is main.")
fmt.Println(" The profile is in file:", defaultConfigFile)
fmt.Println()
fmt.Println("Actions:")

@ -1,26 +1,26 @@
package main
const (
defaultWalletIni = `[default]
defaultWalletIni = `[main]
bootnode = /ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv
bootnode = /ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9
bootnode = /ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX
bootnode = /ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj
shards = 4
[default.shard0.rpc]
[main.shard0.rpc]
rpc = l0.t.hmny.io:14555
rpc = s0.t.hmny.io:14555
[default.shard1.rpc]
[main.shard1.rpc]
rpc = l1.t.hmny.io:14555
rpc = s1.t.hmny.io:14555
[default.shard2.rpc]
[main.shard2.rpc]
rpc = l2.t.hmny.io:14555
rpc = s2.t.hmny.io:14555
[default.shard3.rpc]
[main.shard3.rpc]
rpc = l3.t.hmny.io:14555
rpc = s3.t.hmny.io:14555
@ -58,19 +58,19 @@ bootnode = /ip4/52.40.84.2/tcp/9867/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxA
shards = 4
[pangaea.shard0.rpc]
rpc = l0.pga.hmny.io:14555
rpc = s0.pga.hmny.io:14555
rpc = l0.n.hmny.io:14555
rpc = s0.n.hmny.io:14555
[pangaea.shard1.rpc]
rpc = l1.pga.hmny.io:14555
rpc = s1.pga.hmny.io:14555
rpc = l1.n.hmny.io:14555
rpc = s1.n.hmny.io:14555
[pangaea.shard2.rpc]
rpc = l2.pga.hmny.io:14555
rpc = s2.pga.hmny.io:14555
rpc = l2.n.hmny.io:14555
rpc = s2.n.hmny.io:14555
[pangaea.shard3.rpc]
rpc = l3.pga.hmny.io:14555
rpc = s3.pga.hmny.io:14555
rpc = l3.n.hmny.io:14555
rpc = s3.n.hmny.io:14555
`
)

@ -77,6 +77,10 @@ func (s fixedSchedule) RecentTxDuration() time.Duration {
return mainnetRecentTxDuration
}
func (s fixedSchedule) EnableTxnThrottling() bool {
return mainnetEnableTxnThrottling
}
func (s fixedSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: s.MaxTxAmountLimit(),
@ -84,6 +88,7 @@ func (s fixedSchedule) TxsThrottleConfig() *TxsThrottleConfig {
MaxTxPoolSizeLimit: s.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: s.MaxNumTxsPerBlockLimit(),
RecentTxDuration: s.RecentTxDuration(),
EnableTxnThrottling: s.EnableTxnThrottling(),
}
}
@ -92,7 +97,7 @@ func (s fixedSchedule) GetNetworkID() NetworkID {
}
// GetShardingStructure is the sharding structure for fixed schedule.
func (fixedSchedule) GetShardingStructure(numShard, shardID int) []map[string]interface{} {
func (s fixedSchedule) GetShardingStructure(numShard, shardID int) []map[string]interface{} {
return genShardingStructure(numShard, shardID, TestNetHTTPPattern, TestNetHTTPPattern)
}

@ -32,6 +32,7 @@ const (
localnetMaxTxPoolSizeLimit = 8000
localnetMaxNumTxsPerBlockLimit = 1000
localnetRecentTxDuration = time.Hour
localnetEnableTxnThrottling = true
)
func (localnetSchedule) InstanceForEpoch(epoch *big.Int) Instance {
@ -118,6 +119,10 @@ func (ls localnetSchedule) RecentTxDuration() time.Duration {
return localnetRecentTxDuration
}
func (ls localnetSchedule) EnableTxnThrottling() bool {
return localnetEnableTxnThrottling
}
func (ls localnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ls.MaxTxAmountLimit(),
@ -125,6 +130,7 @@ func (ls localnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
MaxTxPoolSizeLimit: ls.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: ls.MaxNumTxsPerBlockLimit(),
RecentTxDuration: ls.RecentTxDuration(),
EnableTxnThrottling: ls.EnableTxnThrottling(),
}
}

@ -31,6 +31,7 @@ const (
mainnetMaxTxPoolSizeLimit = 8000
mainnetMaxNumTxsPerBlockLimit = 1000
mainnetRecentTxDuration = time.Hour
mainnetEnableTxnThrottling = true
// MainNetHTTPPattern is the http pattern for mainnet.
MainNetHTTPPattern = "http://s%d.t.hmny.io:9500"
@ -144,6 +145,10 @@ func (ms mainnetSchedule) RecentTxDuration() time.Duration {
return mainnetRecentTxDuration
}
func (ms mainnetSchedule) EnableTxnThrottling() bool {
return mainnetEnableTxnThrottling
}
func (ms mainnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ms.MaxTxAmountLimit(),
@ -151,6 +156,7 @@ func (ms mainnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
MaxTxPoolSizeLimit: ms.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: ms.MaxNumTxsPerBlockLimit(),
RecentTxDuration: ms.RecentTxDuration(),
EnableTxnThrottling: ms.EnableTxnThrottling(),
}
}

@ -15,6 +15,8 @@ const (
PangaeaHTTPPattern = "http://s%d.pga.hmny.io:9500"
// PangaeaWSPattern is the websocket pattern for pangaea.
PangaeaWSPattern = "ws://s%d.pga.hmny.io:9800"
// transaction throttling disabled on pangaea network
pangaeaEnableTxnThrottling = false
)
// PangaeaSchedule is the Pangaea sharding configuration schedule.
@ -22,12 +24,12 @@ var PangaeaSchedule pangaeaSchedule
type pangaeaSchedule struct{}
func (pangaeaSchedule) InstanceForEpoch(epoch *big.Int) Instance {
func (ps pangaeaSchedule) InstanceForEpoch(epoch *big.Int) Instance {
return pangaeaV0
}
func (pangaeaSchedule) BlocksPerEpoch() uint64 {
return 10800 // 1 day with 8 seconds/block
func (ps pangaeaSchedule) BlocksPerEpoch() uint64 {
return 2700 // 6 hours with 8 seconds/block
}
func (ps pangaeaSchedule) CalcEpochNumber(blockNum uint64) *big.Int {
@ -43,11 +45,11 @@ func (ps pangaeaSchedule) EpochLastBlock(epochNum uint64) uint64 {
return blocks*(epochNum+1) - 1
}
func (pangaeaSchedule) VdfDifficulty() int {
func (ps pangaeaSchedule) VdfDifficulty() int {
return testnetVdfDifficulty
}
func (pangaeaSchedule) ConsensusRatio() float64 {
func (ps pangaeaSchedule) ConsensusRatio() float64 {
return mainnetConsensusRatio
}
@ -58,32 +60,36 @@ var pangaeaV0 = MustNewInstance(
// TODO: remove it after randomness feature turned on mainnet
//RandonnessStartingEpoch returns starting epoch of randonness generation
func (pangaeaSchedule) RandomnessStartingEpoch() uint64 {
func (ps pangaeaSchedule) RandomnessStartingEpoch() uint64 {
return mainnetRandomnessStartingEpoch
}
func (pangaeaSchedule) MaxTxAmountLimit() *big.Int {
func (ps pangaeaSchedule) MaxTxAmountLimit() *big.Int {
amountBigInt := big.NewInt(mainnetMaxTxAmountLimit)
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.One))
return amountBigInt
}
func (pangaeaSchedule) MaxNumRecentTxsPerAccountLimit() uint64 {
func (ps pangaeaSchedule) MaxNumRecentTxsPerAccountLimit() uint64 {
return mainnetMaxNumRecentTxsPerAccountLimit
}
func (pangaeaSchedule) MaxTxPoolSizeLimit() int {
func (ps pangaeaSchedule) MaxTxPoolSizeLimit() int {
return mainnetMaxTxPoolSizeLimit
}
func (pangaeaSchedule) MaxNumTxsPerBlockLimit() int {
func (ps pangaeaSchedule) MaxNumTxsPerBlockLimit() int {
return mainnetMaxNumTxsPerBlockLimit
}
func (pangaeaSchedule) RecentTxDuration() time.Duration {
func (ps pangaeaSchedule) RecentTxDuration() time.Duration {
return mainnetRecentTxDuration
}
func (ps pangaeaSchedule) EnableTxnThrottling() bool {
return pangaeaEnableTxnThrottling
}
func (ps pangaeaSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ps.MaxTxAmountLimit(),
@ -91,6 +97,7 @@ func (ps pangaeaSchedule) TxsThrottleConfig() *TxsThrottleConfig {
MaxTxPoolSizeLimit: ps.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: ps.MaxNumTxsPerBlockLimit(),
RecentTxDuration: ps.RecentTxDuration(),
EnableTxnThrottling: ps.EnableTxnThrottling(),
}
}

@ -52,6 +52,9 @@ type Schedule interface {
// How long "recent" means for transaction in time Duration unit
RecentTxDuration() time.Duration
// EnableTxnThrottling is the switch for transaction throttling
EnableTxnThrottling() bool
// configuration for throttling pending transactions
TxsThrottleConfig() *TxsThrottleConfig
@ -127,6 +130,9 @@ type TxsThrottleConfig struct {
// Max total number of transactions allowed to be processed per block
MaxNumTxsPerBlockLimit int
// EnableTxnThrottling is the switch for transaction throttling
EnableTxnThrottling bool
}
// genShardingStructure return sharding structure, given shard number and its patterns.

@ -28,6 +28,7 @@ const (
testnetMaxTxPoolSizeLimit = 8000
testnetMaxNumTxsPerBlockLimit = 1000
testnetRecentTxDuration = time.Hour
testnetEnableTxnThrottling = true
// TestNetHTTPPattern is the http pattern for testnet.
TestNetHTTPPattern = "http://s%d.b.hmny.io:9500"
@ -120,6 +121,10 @@ func (ts testnetSchedule) RecentTxDuration() time.Duration {
return testnetRecentTxDuration
}
func (ts testnetSchedule) EnableTxnThrottling() bool {
return testnetEnableTxnThrottling
}
func (ts testnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
return &TxsThrottleConfig{
MaxTxAmountLimit: ts.MaxTxAmountLimit(),
@ -127,6 +132,7 @@ func (ts testnetSchedule) TxsThrottleConfig() *TxsThrottleConfig {
MaxTxPoolSizeLimit: ts.MaxTxPoolSizeLimit(),
MaxNumTxsPerBlockLimit: ts.MaxNumTxsPerBlockLimit(),
RecentTxDuration: ts.RecentTxDuration(),
EnableTxnThrottling: ts.EnableTxnThrottling(),
}
}

@ -72,6 +72,11 @@ func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.R
return sender, shardingconfig.TxUnselect
}
// do not throttle transactions if disabled
if !txsThrottleConfig.EnableTxnThrottling {
return sender, shardingconfig.TxSelect
}
// throttle a single sender sending too many transactions in one block
if tx.Value().Cmp(txsThrottleConfig.MaxTxAmountLimit) > 0 {
utils.Logger().Info().Str("txId", tx.Hash().Hex()).Uint64("MaxTxAmountLimit", txsThrottleConfig.MaxTxAmountLimit.Uint64()).Uint64("txAmount", tx.Value().Uint64()).Msg("Throttling tx with max amount limit")

@ -173,7 +173,7 @@ beta)
)
REL=testnet
network_type=testnet
dns_zone=
dns_zone=b.hmny.io
;;
pangaea)
bootnodes=(
@ -182,7 +182,7 @@ pangaea)
)
REL=master
network_type=pangaea
dns_zone=pga.hmny.io
dns_zone=n.hmny.io
;;
*)
err 64 "${network}: invalid network"

@ -2,30 +2,15 @@
BUCKET=pub.harmony.one
OS=$(uname -s)
REL=mainnet
case "$OS" in
Darwin)
FOLDER=release/darwin-x86_64/${REL}/
BIN=( wallet libbls384_256.dylib libcrypto.1.0.0.dylib libgmp.10.dylib libgmpxx.4.dylib libmcl.dylib )
;;
Linux)
FOLDER=release/linux-x86_64/${REL}/
BIN=( wallet libbls384_256.so libcrypto.so.10 libgmp.so.10 libgmpxx.so.4 libmcl.so )
;;
*)
echo "${OS} not supported."
exit 2
;;
esac
# formatted with 4 spaces indentation for consistency with wallet binary
usage () {
cat << EOT
Usage: $0 [option] command
Options:
-d download all the binaries/config files (do it when updated)
-p profile use the profile for the given network (default [main], beta, pangaea)
-d download all the binaries/config files (must come after network flag)
-p profile use the profile for the given network (main, local, beta, pangaea; default: main)
-t equivalent to -p pangaea (deprecated)
-h print this help
@ -44,7 +29,10 @@ Commands:
--to - The receiver account's address
--amount - The amount of token to transfer
--shardID - The shard Id for the transfer
--toShardID - The destination shard Id for the transfer"
--inputData - Base64-encoded input data to embed in the transaction
--pass - Passphrase of sender's private key
--waitThenBal - Wait after the transfer with colored balances output
8. export - Export account key to a new file
--account - Specify the account to export. Empty will export every key.
9. exportPriKey - Export account private key
@ -64,27 +52,60 @@ Commands:
EOT
}
set_download () {
case "${network}" in
main)
REL=mainnet
;;
beta)
REL=testnet
;;
pangaea)
REL=master
;;
*)
err 64 "${network}: invalid network"
;;
esac
case "$OS" in
Darwin)
FOLDER=release/darwin-x86_64/${REL}/
BIN=( wallet libbls384_256.dylib libcrypto.1.0.0.dylib libgmp.10.dylib libgmpxx.4.dylib libmcl.dylib )
;;
Linux)
FOLDER=release/linux-x86_64/${REL}/
BIN=( wallet libbls384_256.so libcrypto.so.10 libgmp.so.10 libgmpxx.so.4 libmcl.so )
;;
*)
echo "${OS} not supported."
exit 2
;;
esac
}
do_download () {
# clean up old files
for bin in "${BIN[@]}"; do
rm -f ${bin}
done
for bin in "${BIN[@]}"; do
rm -f ${bin}
done
# download all the binaries
for bin in "${BIN[@]}"; do
curl http://${BUCKET}.s3.amazonaws.com/${FOLDER}${bin} -o ${bin}
done
for bin in "${BIN[@]}"; do
curl http://${BUCKET}.s3.amazonaws.com/${FOLDER}${bin} -o ${bin}
done
mkdir -p .hmy/keystore
chmod +x wallet
mkdir -p .hmy/keystore
chmod +x wallet
}
unset network
network=default
network=main
while getopts "dp:th" opt; do
case ${opt} in
d)
set_download
do_download
exit 0
;;

Loading…
Cancel
Save