@@ -34,11 +34,9 @@ import (
34
34
"testing"
35
35
"time"
36
36
37
- "github.com/ethereum/go-ethereum/accounts/abi"
38
- "github.com/ethereum/go-ethereum/internal/ethapi/override"
39
-
40
37
"github.com/ethereum/go-ethereum"
41
38
"github.com/ethereum/go-ethereum/accounts"
39
+ "github.com/ethereum/go-ethereum/accounts/abi"
42
40
"github.com/ethereum/go-ethereum/accounts/keystore"
43
41
"github.com/ethereum/go-ethereum/common"
44
42
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -56,6 +54,7 @@ import (
56
54
"github.com/ethereum/go-ethereum/ethdb"
57
55
"github.com/ethereum/go-ethereum/event"
58
56
"github.com/ethereum/go-ethereum/internal/blocktest"
57
+ "github.com/ethereum/go-ethereum/internal/ethapi/override"
59
58
"github.com/ethereum/go-ethereum/params"
60
59
"github.com/ethereum/go-ethereum/rpc"
61
60
"github.com/holiman/uint256"
@@ -2661,19 +2660,53 @@ func TestSendBlobTransaction(t *testing.T) {
2661
2660
2662
2661
func TestFillBlobTransaction (t * testing.T ) {
2663
2662
t .Parallel ()
2663
+
2664
+ testFillBlobTransaction (t , false )
2665
+ testFillBlobTransaction (t , true )
2666
+ }
2667
+
2668
+ func testFillBlobTransaction (t * testing.T , osaka bool ) {
2664
2669
// Initialize test accounts
2670
+ config := * params .MergedTestChainConfig
2671
+ if ! osaka {
2672
+ config .OsakaTime = nil
2673
+ }
2665
2674
var (
2666
2675
key , _ = crypto .HexToECDSA ("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a" )
2667
2676
to = crypto .PubkeyToAddress (key .PublicKey )
2668
2677
genesis = & core.Genesis {
2669
- Config : params . MergedTestChainConfig ,
2678
+ Config : & config ,
2670
2679
Alloc : types.GenesisAlloc {},
2671
2680
}
2672
- emptyBlob = new (kzg4844.Blob )
2673
- emptyBlobs = []kzg4844.Blob {* emptyBlob }
2674
- emptyBlobCommit , _ = kzg4844 .BlobToCommitment (emptyBlob )
2675
- emptyBlobProof , _ = kzg4844 .ComputeBlobProof (emptyBlob , emptyBlobCommit )
2676
- emptyBlobHash common.Hash = kzg4844 .CalcBlobHashV1 (sha256 .New (), & emptyBlobCommit )
2681
+ emptyBlob = new (kzg4844.Blob )
2682
+ emptyBlobs = []kzg4844.Blob {* emptyBlob }
2683
+ emptyBlobCommit , _ = kzg4844 .BlobToCommitment (emptyBlob )
2684
+ emptyBlobProof , _ = kzg4844 .ComputeBlobProof (emptyBlob , emptyBlobCommit )
2685
+ emptyBlobCellProofs , _ = kzg4844 .ComputeCellProofs (emptyBlob )
2686
+ emptyBlobHash common.Hash = kzg4844 .CalcBlobHashV1 (sha256 .New (), & emptyBlobCommit )
2687
+
2688
+ fillEmptyKZGProofs = func (blobs int ) []kzg4844.Proof {
2689
+ if osaka {
2690
+ return make ([]kzg4844.Proof , blobs * kzg4844 .CellProofsPerBlob )
2691
+ }
2692
+ return make ([]kzg4844.Proof , blobs )
2693
+ }
2694
+ expectSidecar = func () * types.BlobTxSidecar {
2695
+ if osaka {
2696
+ return types .NewBlobTxSidecar (
2697
+ types .BlobSidecarVersion1 ,
2698
+ emptyBlobs ,
2699
+ []kzg4844.Commitment {emptyBlobCommit },
2700
+ emptyBlobCellProofs ,
2701
+ )
2702
+ }
2703
+ return types .NewBlobTxSidecar (
2704
+ types .BlobSidecarVersion0 ,
2705
+ emptyBlobs ,
2706
+ []kzg4844.Commitment {emptyBlobCommit },
2707
+ []kzg4844.Proof {emptyBlobProof },
2708
+ )
2709
+ }
2677
2710
)
2678
2711
b := newTestBackend (t , 1 , genesis , beacon .New (ethash .NewFaker ()), func (i int , b * core.BlockGen ) {
2679
2712
b .SetPoS ()
@@ -2733,7 +2766,7 @@ func TestFillBlobTransaction(t *testing.T) {
2733
2766
Commitments : []kzg4844.Commitment {{}, {}},
2734
2767
Proofs : []kzg4844.Proof {{}},
2735
2768
},
2736
- err : `number of blobs and proofs mismatch (have=1, want=2)` ,
2769
+ err : fmt . Sprintf ( `number of blobs and proofs mismatch (have=1, want=%d)` , len ( fillEmptyKZGProofs ( 2 ))) ,
2737
2770
},
2738
2771
{
2739
2772
name : "TestInvalidProofVerification" ,
@@ -2743,7 +2776,7 @@ func TestFillBlobTransaction(t *testing.T) {
2743
2776
Value : (* hexutil .Big )(big .NewInt (1 )),
2744
2777
Blobs : []kzg4844.Blob {{}, {}},
2745
2778
Commitments : []kzg4844.Commitment {{}, {}},
2746
- Proofs : []kzg4844. Proof {{}, {}} ,
2779
+ Proofs : fillEmptyKZGProofs ( 2 ) ,
2747
2780
},
2748
2781
err : `failed to verify blob proof: short buffer` ,
2749
2782
},
@@ -2759,7 +2792,7 @@ func TestFillBlobTransaction(t *testing.T) {
2759
2792
},
2760
2793
want : & result {
2761
2794
Hashes : []common.Hash {emptyBlobHash },
2762
- Sidecar : types . NewBlobTxSidecar ( types . BlobSidecarVersion0 , emptyBlobs , []kzg4844. Commitment { emptyBlobCommit }, []kzg4844. Proof { emptyBlobProof } ),
2795
+ Sidecar : expectSidecar ( ),
2763
2796
},
2764
2797
},
2765
2798
{
@@ -2775,7 +2808,7 @@ func TestFillBlobTransaction(t *testing.T) {
2775
2808
},
2776
2809
want : & result {
2777
2810
Hashes : []common.Hash {emptyBlobHash },
2778
- Sidecar : types . NewBlobTxSidecar ( types . BlobSidecarVersion0 , emptyBlobs , []kzg4844. Commitment { emptyBlobCommit }, []kzg4844. Proof { emptyBlobProof } ),
2811
+ Sidecar : expectSidecar ( ),
2779
2812
},
2780
2813
},
2781
2814
{
@@ -2801,7 +2834,7 @@ func TestFillBlobTransaction(t *testing.T) {
2801
2834
},
2802
2835
want : & result {
2803
2836
Hashes : []common.Hash {emptyBlobHash },
2804
- Sidecar : types . NewBlobTxSidecar ( types . BlobSidecarVersion0 , emptyBlobs , []kzg4844. Commitment { emptyBlobCommit }, []kzg4844. Proof { emptyBlobProof } ),
2837
+ Sidecar : expectSidecar ( ),
2805
2838
},
2806
2839
},
2807
2840
}
0 commit comments