Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ contract PreconfWhitelist is EssentialContract, IPreconfWhitelist {
LibPreconfUtils.getEpochTimestamp() - LibPreconfConstants.SECONDS_IN_EPOCH;
// Use the beacon block root at the first block of the last epoch as the
// source of randomness
bytes32 randomness = LibPreconfUtils.getBeaconBlockRoot(timestampOfLastEpoch);
//bytes32 randomness = LibPreconfUtils.getBeaconBlockRoot(timestampOfLastEpoch);

// CHAINBOUND: use weak randomness for the devnet environment
bytes32 randomness = keccak256(abi.encodePacked(block.timestamp, block.difficulty));

uint256 index = uint256(randomness) % _operatorCount;
return operatorIndexToOperator[index];
}
Expand Down
10 changes: 10 additions & 0 deletions packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error {
if c.PacayaClients.ForkHeight == 0 {
stateVars, err := c.GetProtocolStateVariablesPacaya(&bind.CallOpts{Context: ctxWithTimeout})
if err != nil {
log.Error(fmt.Sprintf("failed to fetch Pacaya protocol state variables: %w", err))
return err
}

genesisHeight = stateVars.Stats1.GenesisHeight
} else {
slotA, _, err := c.GetProtocolStateVariablesOntake(&bind.CallOpts{Context: ctxWithTimeout})
if err != nil {
log.Error(fmt.Sprintf("failed to fetch Ontake protocol state variables: %w", err))
return err
}

Expand All @@ -84,6 +86,7 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error {
// Fetch the node's genesis block.
nodeGenesis, err := c.L2.HeaderByNumber(ctxWithTimeout, common.Big0)
if err != nil {
log.Error(fmt.Sprintf("failed to fetch L2 genesis block: %w", err))
return err
}

Expand All @@ -98,6 +101,7 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error {

protocolConfigs, err := c.GetProtocolConfigs(&bind.CallOpts{Context: ctxWithTimeout})
if err != nil {
log.Error(fmt.Sprintf("failed to fetch protocol configs: %w", err))
return err
}

Expand All @@ -106,36 +110,42 @@ func (c *Client) ensureGenesisMatched(ctx context.Context) error {
// Fetch the genesis `BatchesVerified` event.
iter, err := c.PacayaClients.TaikoInbox.FilterBatchesVerified(filterOpts)
if err != nil {
log.Error(fmt.Sprintf("failed to fetch TaikoInbox.BatchesVerified event: %w", err))
return err
}
if iter.Next() {
l2GenesisHash = iter.Event.BlockHash
}
if iter.Error() != nil {
log.Error(fmt.Sprintf("failed to fetch TaikoInbox.BatchesVerified event (iter error): %w", iter.Error()))
return iter.Error()
}
} else if protocolConfigs.ForkHeightsOntake() == 0 {
// Fetch the genesis `BlockVerifiedV2` event.
iter, err := c.OntakeClients.TaikoL1.FilterBlockVerifiedV2(filterOpts, []*big.Int{common.Big0}, nil)
if err != nil {
log.Error(fmt.Sprintf("failed to fetch TaikoL1.BlockVerifiedV2 event: %w", err))
return err
}
if iter.Next() {
l2GenesisHash = iter.Event.BlockHash
}
if iter.Error() != nil {
log.Error(fmt.Sprintf("failed to fetch TaikoL1.BlockVerifiedV2 event (iter error): %w", iter.Error()))
return iter.Error()
}
} else {
// Fetch the genesis `BlockVerified` event.
iter, err := c.OntakeClients.TaikoL1.FilterBlockVerified(filterOpts, []*big.Int{common.Big0}, nil)
if err != nil {
log.Error(fmt.Sprintf("failed to fetch TaikoL1.BlockVerified event: %w", err))
return err
}
if iter.Next() {
l2GenesisHash = iter.Event.BlockHash
}
if iter.Error() != nil {
log.Error(fmt.Sprintf("failed to fetch TaikoL1.BlockVerified event (iter error): %w", iter.Error()))
return iter.Error()
}
}
Expand Down