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

feat(eip4844): update blob tx #528

Merged
merged 2 commits into from
Jan 24, 2024
Merged
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
4 changes: 1 addition & 3 deletions internal/testutils/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ func (s *ClientTestSuite) SetupTest() {
glogger := log.NewGlogHandler(log.NewTerminalHandlerWithLevel(os.Stdout, log.LevelInfo, true))
log.SetDefault(log.NewLogger(glogger))

testAddrPrivKey, err := crypto.ToECDSA(
common.Hex2Bytes("ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"),
)
testAddrPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
s.Nil(err)

s.TestAddrPrivKey = testAddrPrivKey
Expand Down
9 changes: 7 additions & 2 deletions pkg/rpc/tx_blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/assert"
)
Expand All @@ -16,7 +17,7 @@ func TestBlockTx(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

url := os.Getenv("L1_NODE_WS_ENDPOINT")
url := "https://rpc.dencun-devnet-12.ethpandaops.io" //os.Getenv("L1_NODE_WS_ENDPOINT")
l1Client, err := NewEthClient(ctx, url, time.Second*20)
assert.NoError(t, err)

Expand All @@ -41,5 +42,9 @@ func TestBlockTx(t *testing.T) {

receipt, err := bind.WaitMined(ctx, l1Client, tx)
assert.NoError(t, err)
t.Log(receipt)
assert.Equal(t, true, receipt.Status == types.ReceiptStatusSuccessful)

t.Log("blob hash: ", tx.BlobHashes()[0].String())
t.Log("block number: ", receipt.BlockNumber.Uint64())
t.Log("tx hash: ", receipt.TxHash.String())
}
64 changes: 29 additions & 35 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,14 @@ func (p *Proposer) sendTxListByBlobTx(ctx context.Context, txListBytes []byte) (
if err != nil {
return nil, err
}
// Wait until blob tx is mined.
if _, err := bind.WaitMined(ctx, p.rpc.L1, tx); err != nil {
return nil, err
}

return tx, nil
}

func (p *Proposer) sendProposeBlockTxWithBlobHash(
ctx context.Context,
blobHash common.Hash,
txListSize *big.Int,
nonce *uint64,
assignment *encoding.ProverAssignment,
assignedProver common.Address,
Expand Down Expand Up @@ -390,7 +387,7 @@ func (p *Proposer) sendProposeBlockTxWithBlobHash(
AssignedProver: assignedProver,
ExtraData: rpc.StringToBytes32(p.ExtraData),
TxListByteOffset: common.Big0,
TxListByteSize: common.Big0,
TxListByteSize: txListSize,
BlobHash: blobHash,
CacheBlobForReuse: false,
ParentMetaHash: parentMetaHash,
Expand Down Expand Up @@ -522,51 +519,42 @@ func (p *Proposer) ProposeTxList(
var (
isReplacement bool
tx *types.Transaction
blobTx *types.Transaction
)
if err := backoff.Retry(
if err = backoff.Retry(
func() error {
if ctx.Err() != nil {
return nil
}

// Send tx list by blob tx.
if p.BlobAllowed {
blobTx, err := p.sendTxListByBlobTx(ctx, txListBytes)
blobTx, err = p.sendTxListByBlobTx(ctx, txListBytes)
if err != nil {
return nil
return err
}
if tx, err = p.sendProposeBlockTxWithBlobHash(
tx, err = p.sendProposeBlockTxWithBlobHash(
ctx,
blobTx.BlobHashes()[0],
big.NewInt(int64(len(txListBytes))),
nonce,
assignment,
proverAddress,
maxFee,
isReplacement,
); err != nil {
log.Warn("Failed to send taikoL1.proposeBlock blob transaction", "error", encoding.TryParsingCustomError(err))
if strings.Contains(err.Error(), core.ErrNonceTooLow.Error()) {
return nil
}
if strings.Contains(err.Error(), txpool.ErrReplaceUnderpriced.Error()) {
isReplacement = true
} else {
isReplacement = false
}
return err
}
return nil
)
} else {
tx, err = p.sendProposeBlockTx(
ctx,
txListBytes,
nonce,
assignment,
proverAddress,
maxFee,
isReplacement,
)
}

if tx, err = p.sendProposeBlockTx(
ctx,
txListBytes,
nonce,
assignment,
proverAddress,
maxFee,
isReplacement,
); err != nil {
if err != nil {
log.Warn("Failed to send taikoL1.proposeBlock transaction", "error", encoding.TryParsingCustomError(err))
if strings.Contains(err.Error(), core.ErrNonceTooLow.Error()) {
return nil
Expand Down Expand Up @@ -597,9 +585,15 @@ func (p *Proposer) ProposeTxList(

ctxWithTimeout, cancel := context.WithTimeout(ctx, p.WaitReceiptTimeout)
defer cancel()

if _, err := rpc.WaitReceipt(ctxWithTimeout, p.rpc.L1, tx); err != nil {
return err
if blobTx != nil {
if _, err = bind.WaitMined(ctxWithTimeout, p.rpc.L1, blobTx); err != nil {
return err
}
}
if tx != nil {
if _, err = rpc.WaitReceipt(ctxWithTimeout, p.rpc.L1, tx); err != nil {
return err
}
}

log.Info("📝 Propose transactions succeeded", "txs", txNum)
Expand Down
1 change: 1 addition & 0 deletions proposer/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func (s *ProposerTestSuite) TestSendProposeBlockTx() {
newTx, err = s.p.sendProposeBlockTxWithBlobHash(
ctx,
blobTx.BlobHashes()[0],
big.NewInt(int64(len(encoded))),
&nonce,
signedAssignment,
proverAddress,
Expand Down
Loading