Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(proposer): update oracle proof assignment (#393)
Browse files Browse the repository at this point in the history
Co-authored-by: Roger <[email protected]>
  • Loading branch information
davidtaikocha and RogerLamTd authored Sep 19, 2023
1 parent 5f7f1dd commit 29c2d4b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Install protocol dependencies
working-directory: ${{ env.TAIKO_MONO_DIR }}
run: cd ./packages/protocol && pnpm install --no-frozen-lockfile && ./script/download_solc.sh && forge install
run: cd ./packages/protocol && pnpm install && ./script/download_solc.sh && forge install

- name: Build
working-directory: ${{ env.CLIENT_DIR }}
Expand Down
48 changes: 40 additions & 8 deletions proposer/prover_selector/eth_fee_eoa_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ func (s *ETHFeeEOASelector) AssignProver(
ctx context.Context,
meta *encoding.TaikoL1BlockMetadataInput,
) ([]byte, *big.Int, error) {
oracleProverAddress, err := s.rpc.TaikoL1.Resolve0(
&bind.CallOpts{Context: ctx},
rpc.StringToBytes32("oracle_prover"),
true,
)
if err != nil {
return nil, nil, err
}
// Iterate over each configured endpoint, and see if someone wants to accept this block.
// If it is denied, we continue on to the next endpoint.
// If we do not find a prover, we can increase the fee up to a point, or give up.
Expand All @@ -100,19 +108,29 @@ func (s *ETHFeeEOASelector) AssignProver(
fee.Add(fee, increase)
}
for _, endpoint := range s.shuffleProverEndpoints() {
encodedAssignment, proverAddress, err := assignProver(ctx, meta, endpoint, fee, expiry, s.requestTimeout)
encodedAssignment, proverAddress, err := assignProver(
ctx,
meta,
endpoint,
fee,
expiry,
s.requestTimeout,
oracleProverAddress,
)
if err != nil {
log.Warn("Failed to assign prover", "endpoint", endpoint, "error", err)
continue
}

ok, err := s.checkProverBalance(ctx, proverAddress)
if err != nil {
log.Warn("Failed to check prover balance", "endpoint", endpoint, "error", err)
continue
}
if !ok {
continue
if proverAddress != encoding.OracleProverAddress {
ok, err := s.checkProverBalance(ctx, proverAddress)
if err != nil {
log.Warn("Failed to check prover balance", "endpoint", endpoint, "error", err)
continue
}
if !ok {
continue
}
}

return encodedAssignment, fee, nil
Expand Down Expand Up @@ -169,6 +187,7 @@ func assignProver(
fee *big.Int,
expiry uint64,
timeout time.Duration,
oracleProverAddress common.Address,
) ([]byte, common.Address, error) {
log.Info(
"Attempting to assign prover",
Expand Down Expand Up @@ -228,6 +247,11 @@ func assignProver(
// Convert signature to one solidity can recover by adding 27 to 65th byte
result.SignedPayload[64] = uint8(uint(result.SignedPayload[64])) + 27

// If this assignment is to oracle prover, change prover address in assignment to `LibUtils.ORACLE_PROVER`
if oracleProverAddress != (common.Address{}) && result.Prover == oracleProverAddress {
result.Prover = encoding.OracleProverAddress
}

encoded, err := encoding.EncodeProverAssignment(&encoding.ProverAssignment{
Prover: result.Prover,
Expiry: reqBody.Expiry,
Expand All @@ -237,5 +261,13 @@ func assignProver(
return nil, common.Address{}, err
}

log.Info(
"Prover assigned",
"address", result.Prover,
"endpoint", endpoint,
"fee", fee.String(),
"expiry", expiry,
)

return encoded, result.Prover, nil
}
4 changes: 3 additions & 1 deletion prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,9 @@ func (p *Prover) onBlockProposed(
proofWindowExpiresAt := block.ProposedAt + uint64(p.protocolConfigs.ProofWindow)
proofWindowExpired := uint64(time.Now().Unix()) > proofWindowExpiresAt
// zero address means anyone can prove, proofWindowExpired means anyone can prove even if not zero address
if block.Prover != p.proverAddress && !proofWindowExpired {
if block.Prover != p.proverAddress &&
!proofWindowExpired &&
!(block.Prover == encoding.OracleProverAddress && p.oracleProverAddress == p.proverAddress) {
log.Info(
"Proposed block not provable",
"blockID",
Expand Down

0 comments on commit 29c2d4b

Please sign in to comment.