Skip to content

Commit

Permalink
golangci-lint run --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jagdeep sidhu committed Jun 13, 2022
1 parent ad71ca3 commit ed00f9f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
29 changes: 13 additions & 16 deletions 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
Expand Down Expand Up @@ -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])
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -231,7 +231,6 @@ func (KZGCommitment) FixedLength() uint64 {
return 48
}


func (p KZGCommitment) MarshalText() ([]byte, error) {
return []byte("0x" + hex.EncodeToString(p[:])), nil
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -361,7 +359,6 @@ func (li BlobKzgs) Parse() ([]*bls.G1Point, error) {
return out, nil
}


func (li BlobKzgs) ByteLength() uint64 {
return uint64(len(li)) * 48
}
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Expand Up @@ -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...")
Expand Down
4 changes: 2 additions & 2 deletions les/client.go
Expand Up @@ -21,8 +21,8 @@ import (
// SYSCOIN
"errors"
"fmt"
"sync"
"strings"
"sync"
"time"

"github.com/ethereum/go-ethereum/accounts"
Expand Down Expand Up @@ -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...")
Expand Down
12 changes: 6 additions & 6 deletions params/config.go
Expand Up @@ -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",
}

Expand Down

0 comments on commit ed00f9f

Please sign in to comment.