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

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Feb 5, 2024
1 parent 7c117dc commit 6fbc16f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 46 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/ethereum/go-ethereum v1.13.8 => github.com/taikoxyz/taiko-geth v0.0.0-20240118064628-88e3acd1f435
replace github.com/ethereum/go-ethereum v1.13.8 => /Users/huan/projects/taiko/taiko-geth
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,6 @@ github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04=
github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E=
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs=
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
github.com/taikoxyz/taiko-geth v0.0.0-20240118064628-88e3acd1f435 h1:XaAE25G77ghpc2LdID3iVdyi916cMa2ifTQN5Ck7eYE=
github.com/taikoxyz/taiko-geth v0.0.0-20240118064628-88e3acd1f435/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZzNAmIKnceogzsA=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU=
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4=
Expand Down
54 changes: 26 additions & 28 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,22 @@ func (p *Proposer) sendProposeBlockTxWithBlobHash(
ctx context.Context,
txListBytes []byte,
nonce *uint64,
assignment *encoding.ProverAssignment,
assignedProver common.Address,
maxFee *big.Int,
isReplacement bool) (*types.Transaction, error) {
// Make sidecar in order to get blob hash.
sideCar, err := rpc.MakeSidecarWithSingleBlob(txListBytes)
if err != nil {
return nil, err
}

assignment, assignedProver, maxFee, err := p.proverSelector.AssignProver(
ctx,
p.tierFees,
sideCar.BlobHashes()[0],
)
if err != nil {
return nil, err
}

// Propose the transactions list
opts, err := getTxOpts(ctx, p.rpc.L1, p.L1ProposerPrivKey, p.rpc.L1ChainID, maxFee)
if err != nil {
Expand Down Expand Up @@ -368,12 +380,6 @@ func (p *Proposer) sendProposeBlockTxWithBlobHash(
Hook: p.AssignmentHookAddress,
Data: hookInputData,
})

// Make sidecar in order to get blob hash.
sideCar, err := rpc.MakeSidecarWithSingleBlob(txListBytes)
if err != nil {
return nil, err
}
encodedParams, err := encoding.EncodeBlockParams(&encoding.BlockParams{
AssignedProver: assignedProver,
ExtraData: rpc.StringToBytes32(p.ExtraData),
Expand All @@ -400,6 +406,7 @@ func (p *Proposer) sendProposeBlockTxWithBlobHash(

// Create blob tx and send it.
opts.NoSend = false
opts.GasLimit = 0
proposeTx, err := p.rpc.L1.TransactBlobTx(opts, &p.TaikoL1Address, rawTx.Data(), sideCar)
if err != nil {
return nil, err
Expand All @@ -415,11 +422,17 @@ func (p *Proposer) sendProposeBlockTx(
ctx context.Context,
txListBytes []byte,
nonce *uint64,
assignment *encoding.ProverAssignment,
assignedProver common.Address,
maxFee *big.Int,
isReplacement bool,
) (*types.Transaction, error) {
assignment, assignedProver, maxFee, err := p.proverSelector.AssignProver(
ctx,
p.tierFees,
crypto.Keccak256Hash(txListBytes),
)
if err != nil {
return nil, err
}

// Propose the transactions list
opts, err := getTxOpts(ctx, p.rpc.L1, p.L1ProposerPrivKey, p.rpc.L1ChainID, maxFee)
if err != nil {
Expand Down Expand Up @@ -507,44 +520,29 @@ func (p *Proposer) ProposeTxList(
txNum uint,
nonce *uint64,
) error {
assignment, proverAddress, maxFee, err := p.proverSelector.AssignProver(
ctx,
p.tierFees,
crypto.Keccak256Hash(txListBytes),
)
if err != nil {
return err
}

var (
isReplacement bool
tx *types.Transaction
err error
)
if err = backoff.Retry(
func() error {
if ctx.Err() != nil {
return nil
}

// Send tx list by blob tx.
if p.BlobAllowed {
tx, err = p.sendProposeBlockTxWithBlobHash(
ctx,
txListBytes,
nonce,
assignment,
proverAddress,
maxFee,
isReplacement,
)
} else {
tx, err = p.sendProposeBlockTx(
ctx,
txListBytes,
nonce,
assignment,
proverAddress,
maxFee,
isReplacement,
)
}
Expand Down
18 changes: 3 additions & 15 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ func (s *ProposerTestSuite) TestSendProposeBlockTx() {
[]byte{},
)

s.SetL1Automine(false)
defer s.SetL1Automine(true)
//s.SetL1Automine(false)
//defer s.SetL1Automine(true)

signedTx, err := types.SignTx(tx, types.LatestSignerForChainID(s.RPCClient.L1ChainID), s.p.L1ProposerPrivKey)
s.Nil(err)
Expand All @@ -188,34 +188,22 @@ func (s *ProposerTestSuite) TestSendProposeBlockTx() {
encoded, err := rlp.EncodeToBytes(emptyTxs)
s.Nil(err)

signedAssignment, proverAddress, fee, err := s.p.proverSelector.AssignProver(
context.Background(),
s.p.tierFees,
crypto.Keccak256Hash(encoded),
)
s.Nil(err)

var (
ctx = context.Background()
newTx *types.Transaction
)
nonce++
if s.p.BlobAllowed {
newTx, err = s.p.sendProposeBlockTxWithBlobHash(
ctx,
encoded,
&nonce,
signedAssignment,
proverAddress,
fee,
true)
} else {
newTx, err = s.p.sendProposeBlockTx(
context.Background(),
encoded,
&nonce,
signedAssignment,
proverAddress,
fee,
true,
)
}
Expand Down

0 comments on commit 6fbc16f

Please sign in to comment.