update GetDiskRoot

This commit is contained in:
colinlyguo
2025-03-09 00:01:20 +08:00
parent fc6df7f993
commit adf010444e
2 changed files with 3 additions and 5 deletions

View File

@@ -212,7 +212,7 @@ func (r *Layer2Relayer) initializeGenesis() error {
if err = r.commitGenesisBatch(startFinalizedBatch.Hash, startFinalizedBatch.BatchHeader, diskRoot); err != nil {
return fmt.Errorf("commit genesis batch failed: %v", err)
}
log.Info("import genesis transaction successfully", "batch index", startFinalizedBatchIndex, "batch hash", startFinalizedBatch.Hash, "end block number", endChunk.EndBlockNumber, "header root", diskRoot)
log.Info("import genesis transaction successfully", "batch index", startFinalizedBatchIndex, "batch hash", startFinalizedBatch.Hash, "end block number", endChunk.EndBlockNumber, "header root", diskRoot.Hex())
return nil
}

View File

@@ -229,9 +229,7 @@ func measureTime(operation func() error) (time.Duration, error) {
// GetDiskRoot retrieves the disk root for a given block number from the Ethereum node.
func GetDiskRoot(ctx context.Context, cli *rpc.Client, blockNumber uint64) (common.Hash, error) {
type DiskRootResponse struct {
Result struct {
DiskRoot string `json:"diskRoot"`
} `json:"result"`
DiskRoot string `json:"diskRoot"`
}
var response DiskRootResponse
@@ -241,6 +239,6 @@ func GetDiskRoot(ctx context.Context, cli *rpc.Client, blockNumber uint64) (comm
return common.Hash{}, fmt.Errorf("failed to fetch disk root for block %d: %w", blockNumber, err)
}
diskRoot := common.HexToHash(response.Result.DiskRoot)
diskRoot := common.HexToHash(response.DiskRoot)
return diskRoot, nil
}