Skip to content
Open
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
7 changes: 5 additions & 2 deletions tasks/pdp/task_init_pp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"math/big"
"strings"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -191,6 +192,8 @@ func (ipp *InitProvingPeriodTask) Do(taskID harmonytask.TaskID, stillOwned func(
return false, xerrors.Errorf("failed to send transaction: %w", err)
}

txHashLower := strings.ToLower(txHash.Hex())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a gopher, but some quick snooping through source seems to show that txHash.Hex() should always produce lowercase hex strings?

txHash.Hex() definition seems to be here:

https://github.com/ethereum/go-ethereum/blob/ea28346f91b65c9882e942d2fcad9cdbaa09d706/common/types.go#L86C1-L87C1

which uses go-ethereum hex util:

https://github.com/ethereum/go-ethereum/blob/ea28346f91b65c9882e942d2fcad9cdbaa09d706/common/hexutil/hexutil.go#L83-L88

which uses encoding/hex stdlib's Encode, which should only ever produce lowercase based on the hextable="0123456789abcdef"? https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/encoding/hex/hex.go;l=17

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same understanding but I remember that DB was complaining about serialization. This lead to basically ppInit never properly working. Curio keept spawning new ppInit tasks. If that is not the case anymore with the pdpv0 branch then feel free to close this. I don't have the error handy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we were focusing on different things. Actual fix is .Hex(). strings.ToLower() is there only due to historical context. Perhaps, we can clean that up in other places as well later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe it's just addresses we need to be careful with, not necessarily transaction hashes. I'd still be more comfortable doing a tolower on all of these things just to be sure. EIP-55 shows up in weird places so I trust none of this.


// Update the database in a transaction
_, err = ipp.db.BeginTransaction(ctx, func(tx *harmonydb.Tx) (bool, error) {
// Update pdp_data_sets
Expand All @@ -200,7 +203,7 @@ func (ipp *InitProvingPeriodTask) Do(taskID harmonytask.TaskID, stillOwned func(
prev_challenge_request_epoch = $2,
prove_at_epoch = $3
WHERE id = $4
`, txHash.Hex(), ts.Height(), init_prove_at.Uint64(), dataSetId)
`, txHashLower, ts.Height(), init_prove_at.Uint64(), dataSetId)
if err != nil {
return false, xerrors.Errorf("failed to update pdp_data_sets: %w", err)
}
Expand All @@ -212,7 +215,7 @@ func (ipp *InitProvingPeriodTask) Do(taskID harmonytask.TaskID, stillOwned func(
_, err = tx.Exec(`
INSERT INTO message_waits_eth (signed_tx_hash, tx_status)
VALUES ($1, 'pending') ON CONFLICT DO NOTHING
`, txHash.Hex())
`, txHashLower)
if err != nil {
return false, xerrors.Errorf("failed to insert into message_waits_eth: %w", err)
}
Expand Down