Skip to content

Commit

Permalink
remove zion side chain content (#75)
Browse files Browse the repository at this point in the history
* delete useless side chain code

* update miner gas floor and gas ceil

* fix: allow faulty commit seal
  • Loading branch information
dylenfu authored Mar 8, 2022
1 parent 3f91812 commit d698628
Show file tree
Hide file tree
Showing 38 changed files with 25 additions and 3,067 deletions.
3 changes: 1 addition & 2 deletions consensus/hotstuff/signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,10 @@ func checkValidatorQuorum(committers []common.Address, valSet hotstuff.Validator
validSeal++
continue
}
return errInvalidCommittedSeals
}

// The length of validSeal should be larger than number of faulty node + 1
if validSeal <= validators.Q() {
if validSeal < validators.Q() {
return errInvalidCommittedSeals
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion consensus/hotstuff/validator/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (valSet *defaultSet) CheckQuorum(committers []common.Address) error {

func (valSet *defaultSet) F() int { return int(math.Ceil(float64(valSet.Size())/3)) - 1 }

func (valSet *defaultSet) Q() int { return int(math.Ceil(float64(2*valSet.Size()) / 3)) }
func (valSet *defaultSet) Q() int { return valSet.Size() - valSet.F() }

func (valSet *defaultSet) Policy() hotstuff.SelectProposerPolicy { return valSet.policy }

Expand Down
27 changes: 12 additions & 15 deletions consensus/hotstuff/validator/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,16 @@ func testStickyProposer(t *testing.T) {
}

func TestFAndQ(t *testing.T) {
vs := newDefaultSet([]common.Address{
common.HexToAddress("0x1"),
common.HexToAddress("0x2"),
common.HexToAddress("0x3"),
common.HexToAddress("0x4"),
common.HexToAddress("0x5"),
common.HexToAddress("0x6"),
common.HexToAddress("0x7"),
}, hotstuff.RoundRobin)

faultySize := vs.F()
quorumSize := vs.Q()
assert.Equal(t, 2, faultySize)
assert.Equal(t, 5, quorumSize)
t.Logf("faulty size %d, quorum size %d", faultySize, quorumSize)
n := 13

for i := 1; i<=n; i++ {
list := make([]common.Address, 0)
for j := 0; j < i; j ++ {
list = append(list, common.HexToAddress(fmt.Sprintf("0x%d", j + 1)))
}
vs := newDefaultSet(list, hotstuff.RoundRobin)
faultySize := vs.F()
quorumSize := vs.Q()
t.Logf("total size %d, faulty size %d, quorum size %d", i, faultySize, quorumSize)
}
}
16 changes: 2 additions & 14 deletions contracts/native/boot/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package boot

import (
"github.com/ethereum/go-ethereum/contracts/native/cross_chain_manager"
mlp "github.com/ethereum/go-ethereum/contracts/native/cross_chain_manager/zion/mainchain/lock_proxy"
slp "github.com/ethereum/go-ethereum/contracts/native/cross_chain_manager/zion/sidechain/lock_proxy"
"github.com/ethereum/go-ethereum/contracts/native/governance/neo3_state_manager"
"github.com/ethereum/go-ethereum/contracts/native/governance/node_manager"
"github.com/ethereum/go-ethereum/contracts/native/governance/relayer_manager"
Expand All @@ -30,29 +28,19 @@ import (
"github.com/ethereum/go-ethereum/log"
)

func InitMainChainNativeContracts() {
func InitNativeContracts() {
header_sync.InitHeaderSync()
cross_chain_manager.InitCrossChainManager()
neo3_state_manager.InitNeo3StateManager()
node_manager.InitNodeManager()
relayer_manager.InitRelayerManager()
side_chain_manager.InitSideChainManager()
mlp.InitLockProxy()

log.Info("Initialize main chain native contracts",
"header sync", utils.HeaderSyncContractAddress.Hex(),
"cross chain manager", utils.CrossChainManagerContractAddress.Hex(),
"neo3 state manager", utils.Neo3StateManagerContractAddress.Hex(),
"node manager", utils.NodeManagerContractAddress.Hex(),
"relayer manager", utils.RelayerManagerContractAddress.Hex(),
"side chain manager", utils.SideChainManagerContractAddress.Hex(),
"native lock proxy", utils.LockProxyContractAddress.Hex())
}

func InitSideChainNativeContracts() {
node_manager.InitNodeManager()
slp.InitLockProxy()
log.Info("Initialize side chain native contracts",
"node manager", utils.NodeManagerContractAddress.Hex(),
"native lock proxy", utils.LockProxyContractAddress.Hex())
"side chain manager", utils.SideChainManagerContractAddress.Hex())
}
27 changes: 1 addition & 26 deletions contracts/native/cross_chain_manager/entrance.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import (
"github.com/ethereum/go-ethereum/contracts/native/cross_chain_manager/polygon"
"github.com/ethereum/go-ethereum/contracts/native/cross_chain_manager/quorum"
"github.com/ethereum/go-ethereum/contracts/native/cross_chain_manager/zilliqa"
"github.com/ethereum/go-ethereum/contracts/native/cross_chain_manager/zion/mainchain/lock_proxy"
"github.com/ethereum/go-ethereum/contracts/native/cross_chain_manager/zion/sidechain"
"github.com/ethereum/go-ethereum/contracts/native/governance/node_manager"
"github.com/ethereum/go-ethereum/contracts/native/governance/side_chain_manager"
"github.com/ethereum/go-ethereum/contracts/native/utils"
Expand Down Expand Up @@ -92,8 +90,6 @@ func GetChainHandler(router uint64) (scom.ChainHandler, error) {
return cosmos.NewCosmosHandler(), nil
case utils.ZILLIQA_ROUTER:
return zilliqa.NewHandler(), nil
case utils.ZION_ROUTER:
return sidechain.NewHandler(), nil
default:
return nil, fmt.Errorf("not a supported router:%d", router)
}
Expand All @@ -111,10 +107,6 @@ func ImportOuterTransfer(s *native.NativeContract) ([]byte, error) {
}

srcChainID := params.SourceChainID
if native.IsMainChain(srcChainID) {
return nil, fmt.Errorf("ImportExTransfer, source chain CAN'T be main chain")
}

blacked, err := CheckIfChainBlacked(s, srcChainID)
if err != nil {
return nil, fmt.Errorf("ImportExTransfer, CheckIfChainBlacked err: %v", err)
Expand Down Expand Up @@ -146,17 +138,8 @@ func ImportOuterTransfer(s *native.NativeContract) ([]byte, error) {
return utils.PackOutputs(scom.ABI, scom.MethodImportOuterTransfer, true)
}

// transfer outcome for main chain
dstChainID := txParam.ToChainID
if srcChain.Router == utils.ZION_ROUTER && native.IsMainChain(dstChainID) {
if err := lock_proxy.Unlock(s, params.SourceChainID, txParam); err != nil {
return nil, err
} else {
return utils.PackOutputs(scom.ABI, scom.MethodImportOuterTransfer, true)
}
}

//check target chain
dstChainID := txParam.ToChainID
if blacked, err = CheckIfChainBlacked(s, dstChainID); err != nil {
return nil, fmt.Errorf("ImportExTransfer, CheckIfChainBlacked error: %v", err)
}
Expand Down Expand Up @@ -190,10 +173,6 @@ func BlackChain(s *native.NativeContract) ([]byte, error) {
return nil, err
}

if native.IsMainChain(params.ChainID) {
return nil, fmt.Errorf("BlackChain, zion relay chain not supported")
}

// Get current epoch operator
ok, err := node_manager.CheckConsensusSigns(s, scom.MethodBlackChain, utils.GetUint64Bytes(params.ChainID), s.ContractRef().MsgSender())
if err != nil {
Expand All @@ -214,10 +193,6 @@ func WhiteChain(s *native.NativeContract) ([]byte, error) {
return nil, err
}

if native.IsMainChain(params.ChainID) {
return nil, fmt.Errorf("WhiteChain, zion relay chain not supported")
}

// Get current epoch operator
ok, err := node_manager.CheckConsensusSigns(s, scom.MethodWhiteChain, ctx.Payload, s.ContractRef().MsgSender())
if err != nil {
Expand Down
77 changes: 0 additions & 77 deletions contracts/native/cross_chain_manager/zion/delegate/abi.go

This file was deleted.

63 changes: 0 additions & 63 deletions contracts/native/cross_chain_manager/zion/delegate/abi_test.go

This file was deleted.

Loading

0 comments on commit d698628

Please sign in to comment.