Commit b799c26c authored by vicotor's avatar vicotor

fix bug for genesis block hash doesn't match.

parent 988bc0a4
......@@ -9,7 +9,7 @@ import (
"github.com/exchain/go-exchain/exchain"
"github.com/exchain/go-exchain/exchain/chaindb"
nebulav1 "github.com/exchain/go-exchain/exchain/protocol/gen/go/nebula/v1"
"github.com/golang/protobuf/proto"
"github.com/exchain/go-exchain/exchain/wrapper"
"github.com/holiman/uint256"
"math/big"
"os"
......@@ -107,7 +107,7 @@ func (g *GenesisBlock) ToBlock() *nebulav1.Block {
tx := &nebulav1.Transaction{
TxType: nebulav1.TxType_SignProxyTx,
User: account.String(),
Nonce: exchain.GetNonce().Bytes(),
Nonce: nil,
Proxy: false,
Tx: &nebulav1.Transaction_SignProxyTx{
SignProxyTx: &nebulav1.SignProxyTransaction{
......@@ -123,7 +123,7 @@ func (g *GenesisBlock) ToBlock() *nebulav1.Block {
tx := &nebulav1.Transaction{
TxType: nebulav1.TxType_DepositTx,
User: account.String(),
Nonce: exchain.GetNonce().Bytes(),
Nonce: nil,
Proxy: false,
Tx: &nebulav1.Transaction_DepositTx{
DepositTx: &nebulav1.DepositTransaction{
......@@ -139,10 +139,6 @@ func (g *GenesisBlock) ToBlock() *nebulav1.Block {
}
}
}
hash := BlockHash(blk)
signature, _ := crypto.Sign(hash.Bytes(), genesisSignerKey)
blk.Header.Signature = signature
return blk
}
......@@ -164,18 +160,8 @@ func NewGenesisBlock(genfile string) (*GenesisBlock, error) {
}
func BlockHash(blk *nebulav1.Block) common.Hash {
data := make([]byte, 0)
data = append(data, uint256.NewInt(blk.Header.Height).Bytes()...)
data = append(data, uint256.NewInt(blk.Header.Timestamp).Bytes()...)
data = append(data, blk.Header.L1Hash...)
data = append(data, uint256.NewInt(blk.Header.L1Height).Bytes()...)
data = append(data, blk.Header.ParentHash...)
data = append(data, blk.Header.AppRoot...)
data = append(data, blk.Header.Proposer...)
txdata, _ := proto.Marshal(blk.Transactions)
data = append(data, txdata...)
return crypto.Keccak256Hash(data)
wblk := wrapper.NewBlkWrapper(blk)
return wblk.Hash()
}
func LoadGenesisAllocs(allocsPath string) (GenesisAlloc, error) {
......
......@@ -256,6 +256,11 @@ func (payload *ExecutionPayload) Transactions() []*nebulav1.Transaction {
return []*nebulav1.Transaction{}
}
func (payload *ExecutionPayload) String() string {
d, _ := json.Marshal(payload.Payload)
return string(d)
}
func (payload *ExecutionPayload) MarshalData(o io.Writer) (int, error) {
d, err := proto.Marshal(payload.Payload)
if err != nil {
......
......@@ -1424,46 +1424,46 @@ contract Deploy is Deployer {
/// @notice Sets the implementation for the `CANNON` game type in the `DisputeGameFactory`
function setCannonFaultGameImplementation(bool _allowUpgrade) public broadcast {
console.log("Setting Cannon FaultDisputeGame implementation");
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
DelayedWETH weth = DelayedWETH(mustGetAddress("DelayedWETHProxy"));
// Set the Cannon FaultDisputeGame implementation in the factory.
_setFaultGameImplementation({
_factory: factory,
_allowUpgrade: _allowUpgrade,
_params: FaultDisputeGameParams({
anchorStateRegistry: AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
weth: weth,
gameType: GameTypes.CANNON,
absolutePrestate: loadMipsAbsolutePrestate(),
faultVm: IBigStepper(mustGetAddress("Mips")),
maxGameDepth: cfg.faultGameMaxDepth(),
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration()))
})
});
// console.log("Setting Cannon FaultDisputeGame implementation");
// DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
// DelayedWETH weth = DelayedWETH(mustGetAddress("DelayedWETHProxy"));
//
// // Set the Cannon FaultDisputeGame implementation in the factory.
// _setFaultGameImplementation({
// _factory: factory,
// _allowUpgrade: _allowUpgrade,
// _params: FaultDisputeGameParams({
// anchorStateRegistry: AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
// weth: weth,
// gameType: GameTypes.CANNON,
// absolutePrestate: loadMipsAbsolutePrestate(),
// faultVm: IBigStepper(mustGetAddress("Mips")),
// maxGameDepth: cfg.faultGameMaxDepth(),
// maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration()))
// })
// });
}
/// @notice Sets the implementation for the `PERMISSIONED_CANNON` game type in the `DisputeGameFactory`
function setPermissionedCannonFaultGameImplementation(bool _allowUpgrade) public broadcast {
console.log("Setting Cannon PermissionedDisputeGame implementation");
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
DelayedWETH weth = DelayedWETH(mustGetAddress("PermissionedDelayedWETHProxy"));
// Set the Cannon FaultDisputeGame implementation in the factory.
_setFaultGameImplementation({
_factory: factory,
_allowUpgrade: _allowUpgrade,
_params: FaultDisputeGameParams({
anchorStateRegistry: AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
weth: weth,
gameType: GameTypes.PERMISSIONED_CANNON,
absolutePrestate: loadMipsAbsolutePrestate(),
faultVm: IBigStepper(mustGetAddress("Mips")),
maxGameDepth: cfg.faultGameMaxDepth(),
maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration()))
})
});
// console.log("Setting Cannon PermissionedDisputeGame implementation");
// DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
// DelayedWETH weth = DelayedWETH(mustGetAddress("PermissionedDelayedWETHProxy"));
//
// // Set the Cannon FaultDisputeGame implementation in the factory.
// _setFaultGameImplementation({
// _factory: factory,
// _allowUpgrade: _allowUpgrade,
// _params: FaultDisputeGameParams({
// anchorStateRegistry: AnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
// weth: weth,
// gameType: GameTypes.PERMISSIONED_CANNON,
// absolutePrestate: loadMipsAbsolutePrestate(),
// faultVm: IBigStepper(mustGetAddress("Mips")),
// maxGameDepth: cfg.faultGameMaxDepth(),
// maxClockDuration: Duration.wrap(uint64(cfg.faultGameMaxClockDuration()))
// })
// });
}
/// @notice Sets the implementation for the `ALPHABET` game type in the `DisputeGameFactory`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment