diff --git a/core/core_test.go b/core/core_test.go index 594e1c1a0..36ddde25b 100644 --- a/core/core_test.go +++ b/core/core_test.go @@ -10,13 +10,12 @@ import ( ) func TestIsEpochBlock(t *testing.T) { - block1 := types.NewBlock(blockfactory.NewTestHeader().With().Number(big.NewInt(10)).Header(), nil, nil, nil, nil, nil) - block2 := types.NewBlock(blockfactory.NewTestHeader().With().Number(big.NewInt(0)).Header(), nil, nil, nil, nil, nil) - block3 := types.NewBlock(blockfactory.NewTestHeader().With().Number(big.NewInt(344064)).Header(), nil, nil, nil, nil, nil) - block4 := types.NewBlock(blockfactory.NewTestHeader().With().Number(big.NewInt(77)).Header(), nil, nil, nil, nil, nil) - block5 := types.NewBlock(blockfactory.NewTestHeader().With().Number(big.NewInt(78)).Header(), nil, nil, nil, nil, nil) - block6 := types.NewBlock(blockfactory.NewTestHeader().With().Number(big.NewInt(188)).Header(), nil, nil, nil, nil, nil) - block7 := types.NewBlock(blockfactory.NewTestHeader().With().Number(big.NewInt(189)).Header(), nil, nil, nil, nil, nil) + blockNumbered := func(n int64) *types.Block { + return types.NewBlock( + blockfactory.NewTestHeader().With().Number(big.NewInt(n)).Header(), + nil, nil, nil, nil, nil, + ) + } tests := []struct { schedule shardingconfig.Schedule block *types.Block @@ -24,37 +23,37 @@ func TestIsEpochBlock(t *testing.T) { }{ { shardingconfig.MainnetSchedule, - block1, + blockNumbered(10), false, }, { shardingconfig.MainnetSchedule, - block2, + blockNumbered(0), true, }, { shardingconfig.MainnetSchedule, - block3, + blockNumbered(344064), true, }, { shardingconfig.TestnetSchedule, - block4, + blockNumbered(74), false, }, { shardingconfig.TestnetSchedule, - block5, + blockNumbered(75), true, }, { shardingconfig.TestnetSchedule, - block6, + blockNumbered(149), false, }, { shardingconfig.TestnetSchedule, - block7, + blockNumbered(150), true, }, } diff --git a/internal/configs/sharding/testnet.go b/internal/configs/sharding/testnet.go index 1ee650fa1..74f93ece3 100644 --- a/internal/configs/sharding/testnet.go +++ b/internal/configs/sharding/testnet.go @@ -15,11 +15,8 @@ var TestnetSchedule testnetSchedule type testnetSchedule struct{} const ( - testnetV1Epoch = 1 - testnetV2Epoch = 2 - - testnetEpochBlock1 = 78 - threeOne = 111 + // 10 minutes per epoch (at 8s/block) + testnetBlocksPerEpoch = 75 testnetVdfDifficulty = 10000 // This takes about 20s to finish the vdf @@ -38,50 +35,26 @@ const ( func (testnetSchedule) InstanceForEpoch(epoch *big.Int) Instance { switch { - case epoch.Cmp(big.NewInt(testnetV2Epoch)) >= 0: - return testnetV2 - case epoch.Cmp(big.NewInt(testnetV1Epoch)) >= 0: - return testnetV1 default: // genesis return testnetV0 } } func (testnetSchedule) BlocksPerEpoch() uint64 { - // 8 seconds per block, roughly 86400 blocks, around one day - return threeOne + return testnetBlocksPerEpoch } func (ts testnetSchedule) CalcEpochNumber(blockNum uint64) *big.Int { - blocks := ts.BlocksPerEpoch() - switch { - case blockNum >= testnetEpochBlock1: - return big.NewInt(int64((blockNum-testnetEpochBlock1)/blocks) + 1) - default: - return big.NewInt(0) - } + epoch := blockNum % ts.BlocksPerEpoch() + return big.NewInt(int64(epoch)) } func (ts testnetSchedule) IsLastBlock(blockNum uint64) bool { - blocks := ts.BlocksPerEpoch() - switch { - case blockNum < testnetEpochBlock1-1: - return false - case blockNum == testnetEpochBlock1-1: - return true - default: - return ((blockNum-testnetEpochBlock1)%blocks == blocks-1) - } + return (blockNum+1)%ts.BlocksPerEpoch() == 0 } func (ts testnetSchedule) EpochLastBlock(epochNum uint64) uint64 { - blocks := ts.BlocksPerEpoch() - switch { - case epochNum == 0: - return testnetEpochBlock1 - 1 - default: - return testnetEpochBlock1 - 1 + blocks*epochNum - } + return ts.BlocksPerEpoch()*(epochNum+1) - 1 } func (ts testnetSchedule) VdfDifficulty() int { @@ -145,8 +118,8 @@ func (ts testnetSchedule) GetShardingStructure(numShard, shardID int) []map[stri return genShardingStructure(numShard, shardID, TestNetHTTPPattern, TestNetWSPattern) } -var testnetReshardingEpoch = []*big.Int{big.NewInt(0), big.NewInt(testnetV1Epoch), big.NewInt(testnetV2Epoch)} +var testnetReshardingEpoch = []*big.Int{ + big.NewInt(0), +} -var testnetV0 = MustNewInstance(2, 150, 150, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch) -var testnetV1 = MustNewInstance(2, 160, 150, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch) -var testnetV2 = MustNewInstance(2, 170, 150, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch) +var testnetV0 = MustNewInstance(3, 100, 80, genesis.TNHarmonyAccounts, genesis.TNFoundationalAccounts, testnetReshardingEpoch) diff --git a/internal/hmyapi/blockchain.go b/internal/hmyapi/blockchain.go index 2a25fda0e..a46fe37c6 100644 --- a/internal/hmyapi/blockchain.go +++ b/internal/hmyapi/blockchain.go @@ -271,7 +271,7 @@ func (s *PublicBlockChainAPI) GetValidatorInformation(ctx context.Context, addre "address": validator.Address.String(), "stake": hexutil.Uint64(validator.Stake.Uint64()), "name": validator.Description.Name, - "validatingPublicKey": validator.ValidatingPubKey.SerializeToHexStr(), + "validatingPublicKey": validator.SlotPubKeys, "unbondingHeight": hexutil.Uint64(validator.UnbondingHeight.Uint64()), "minSelfDelegation": hexutil.Uint64(validator.MinSelfDelegation.Uint64()), "active": validator.Active, @@ -311,7 +311,6 @@ func (s *PublicBlockChainAPI) GetDelegatorsInformation(ctx context.Context, addr for _, delegator := range delegators { fields := map[string]interface{}{ "delegator": delegator.DelegatorAddress.String(), - "validator": delegator.ValidatorAddress.String(), "amount": hexutil.Uint64(delegator.Amount.Uint64()), } delegatorsFields = append(delegatorsFields, fields) diff --git a/internal/params/config.go b/internal/params/config.go index ef747050b..9cc33d551 100644 --- a/internal/params/config.go +++ b/internal/params/config.go @@ -34,9 +34,9 @@ var ( // TestnetChainConfig contains the chain parameters to run a node on the harmony test network. TestnetChainConfig = &ChainConfig{ ChainID: TestnetChainID, - CrossTxEpoch: big.NewInt(1), - CrossLinkEpoch: big.NewInt(2), - StakingEpoch: big.NewInt(3), + CrossTxEpoch: big.NewInt(0), + CrossLinkEpoch: EpochTBD, + StakingEpoch: EpochTBD, EIP155Epoch: big.NewInt(0), S3Epoch: big.NewInt(0), }