diff --git a/core/types/data_blob.go b/core/types/data_blob.go index 66bd5a9b5e7b4..7406038b8e0a1 100644 --- a/core/types/data_blob.go +++ b/core/types/data_blob.go @@ -1,33 +1,33 @@ package types import ( + "bytes" "encoding/hex" "errors" "fmt" - "bytes" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/kzg" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/protolambda/go-kzg/bls" "github.com/syscoin/btcd/wire" - "github.com/ethereum/go-ethereum/log" ) - // Compressed BLS12-381 G1 element type KZGCommitment [48]byte type NEVMBlob struct { VersionHash common.Hash - Commitment *bls.G1Point - Blob []bls.Fr + Commitment *bls.G1Point + Blob []bls.Fr } type NEVMBlobs struct { Blobs []*NEVMBlob } + // Verify that the list of `commitments` maps to the list of `blobs` // // This is an optimization over the naive approach (found in the EIP) of iteratively checking each blob against each @@ -123,7 +123,7 @@ func (n *NEVMBlob) FromWire(NEVMBlobWire *wire.NEVMBlob) error { return errors.New("Blob should be a factor of 32") } n.Blob = make([]bls.Fr, params.FieldElementsPerBlob) - numElements := lenBlob/32 + numElements := lenBlob / 32 var inputPoint [32]byte for i := 0; i < numElements; i++ { copy(inputPoint[:32], NEVMBlobWire.Blob[i*32:(i+1)*32]) @@ -149,19 +149,19 @@ func (n *NEVMBlob) FromBytes(blob []byte) error { return errors.New("Blob should be a factor of 32") } n.Blob = make([]bls.Fr, params.FieldElementsPerBlob) - numElements := lenBlob/32 + numElements := lenBlob / 32 var inputPoint [32]byte for i := 0; i < numElements; i++ { copy(inputPoint[:32], blob[i*32:(i+1)*32]) ok := bls.FrFrom32(&n.Blob[i], inputPoint) - if ok != true { + if !ok { return fmt.Errorf("FromBytes: invalid chunk (element %d inputPoint %v)", i, inputPoint) } } // Get versioned hash out of input points n.Commitment = kzg.BlobToKzg(n.Blob) - // need the full field elements array above to properly calculate and validate blob to kzg, + // need the full field elements array above to properly calculate and validate blob to kzg, // can splice it after for network purposes and later when deserializing will again create full elements array to input spliced data from network n.Blob = n.Blob[0:numElements] var compressedCommitment KZGCommitment @@ -188,11 +188,11 @@ func (n *NEVMBlob) Serialize() ([]byte, error) { var err error NEVMBlobWire.VersionHash = n.VersionHash.Bytes() var tmpCommit KZGCommitment - lenBlobData := len(n.Blob)*32 - NEVMBlobWire.Blob = make([]byte, 0, lenBlobData + int(tmpCommit.FixedLength()) ) + lenBlobData := len(n.Blob) * 32 + NEVMBlobWire.Blob = make([]byte, 0, lenBlobData+int(tmpCommit.FixedLength())) NEVMBlobWire.Blob = append(NEVMBlobWire.Blob, bls.ToCompressedG1(n.Commitment)...) - for _, fr := range n.Blob { - bBytes := bls.FrTo32(&fr) + for i := range n.Blob { + bBytes := bls.FrTo32(&n.Blob[i]) NEVMBlobWire.Blob = append(NEVMBlobWire.Blob, bBytes[:]...) } var buffer bytes.Buffer @@ -231,7 +231,6 @@ func (KZGCommitment) FixedLength() uint64 { return 48 } - func (p KZGCommitment) MarshalText() ([]byte, error) { return []byte("0x" + hex.EncodeToString(p[:])), nil } @@ -271,7 +270,6 @@ func (p *BLSFieldElement) UnmarshalText(text []byte) error { // Blob data type Blob [params.FieldElementsPerBlob]BLSFieldElement - func (blob *Blob) ByteLength() (out uint64) { return params.FieldElementsPerBlob * 32 } @@ -361,7 +359,6 @@ func (li BlobKzgs) Parse() ([]*bls.G1Point, error) { return out, nil } - func (li BlobKzgs) ByteLength() uint64 { return uint64(len(li)) * 48 } diff --git a/eth/backend.go b/eth/backend.go index feaa7bab43f59..83ce38561846d 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -374,7 +374,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { eth.lock.Unlock() log.Info("Attempt to start networking/peering...") for { - time.Sleep(100) + time.Sleep(100 * time.Millisecond) eth.lock.Lock() if eth.handler.inited && eth.handler.peers.closed { log.Info("Networking stopped, return without starting peering...") diff --git a/les/client.go b/les/client.go index e39c1edc5a26e..45861db72f3ee 100644 --- a/les/client.go +++ b/les/client.go @@ -21,8 +21,8 @@ import ( // SYSCOIN "errors" "fmt" - "sync" "strings" + "sync" "time" "github.com/ethereum/go-ethereum/accounts" @@ -269,7 +269,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) { eth.lock.Unlock() log.Info("Attempt to start networking/peering...") for { - time.Sleep(100) + time.Sleep(100 * time.Millisecond) eth.lock.Lock() if eth.handler.inited && eth.peers.closed { log.Info("Networking stopped, return without starting peering...") diff --git a/params/config.go b/params/config.go index 1ed5a984f3f6c..f8536446ffa34 100644 --- a/params/config.go +++ b/params/config.go @@ -319,12 +319,12 @@ var ( // NetworkNames are user friendly names to use in the chain spec banner. var NetworkNames = map[string]string{ - MainnetChainConfig.ChainID.String(): "mainnet", - RopstenChainConfig.ChainID.String(): "ropsten", - RinkebyChainConfig.ChainID.String(): "rinkeby", - GoerliChainConfig.ChainID.String(): "goerli", - SepoliaChainConfig.ChainID.String(): "sepolia", - SyscoinChainConfig.ChainID.String(): "syscoin", + MainnetChainConfig.ChainID.String(): "mainnet", + RopstenChainConfig.ChainID.String(): "ropsten", + RinkebyChainConfig.ChainID.String(): "rinkeby", + GoerliChainConfig.ChainID.String(): "goerli", + SepoliaChainConfig.ChainID.String(): "sepolia", + SyscoinChainConfig.ChainID.String(): "syscoin", TanenbaumChainConfig.ChainID.String(): "tanenbaum", }