Skip to content

Commit

Permalink
Merge branch 'main' into read_code_unparam
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed Dec 2, 2024
2 parents 1d842c7 + aa54d1d commit 4fa5650
Show file tree
Hide file tree
Showing 51 changed files with 2,263 additions and 683 deletions.
25 changes: 17 additions & 8 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (b *SimulatedBackend) CodeAt(ctx context.Context, contract libcommon.Addres
}
defer tx.Rollback()
stateDB := b.stateByBlockNumber(tx, blockNumber)
return stateDB.GetCode(contract), nil
return stateDB.GetCode(contract)
}

// BalanceAt returns the wei balance of a certain account in the blockchain.
Expand All @@ -220,7 +220,7 @@ func (b *SimulatedBackend) BalanceAt(ctx context.Context, contract libcommon.Add
}
defer tx.Rollback()
stateDB := b.stateByBlockNumber(tx, blockNumber)
return stateDB.GetBalance(contract), nil
return stateDB.GetBalance(contract)
}

// NonceAt returns the nonce of a certain account in the blockchain.
Expand All @@ -234,7 +234,7 @@ func (b *SimulatedBackend) NonceAt(ctx context.Context, contract libcommon.Addre
defer tx.Rollback()

stateDB := b.stateByBlockNumber(tx, blockNumber)
return stateDB.GetNonce(contract), nil
return stateDB.GetNonce(contract)
}

// StorageAt returns the value of key in the storage of an account in the blockchain.
Expand Down Expand Up @@ -518,7 +518,7 @@ func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract libcommon
b.mu.Lock()
defer b.mu.Unlock()

return b.pendingState.GetCode(contract), nil
return b.pendingState.GetCode(contract)
}

func newRevertError(result *evmtypes.ExecutionResult) *revertError {
Expand Down Expand Up @@ -600,7 +600,7 @@ func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account libcommon
b.mu.Lock()
defer b.mu.Unlock()

return b.pendingState.GetNonce(account), nil
return b.pendingState.GetNonce(account)
}

// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
Expand Down Expand Up @@ -628,7 +628,10 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
}
// Recap the highest gas allowance with account's balance.
if call.GasPrice != nil && !call.GasPrice.IsZero() {
balance := b.pendingState.GetBalance(call.From) // from can't be nil
balance, err := b.pendingState.GetBalance(call.From) // from can't be nil
if err != nil {
return 0, err
}
available := balance.ToBig()
if call.Value != nil {
if call.Value.ToBig().Cmp(available) >= 0 {
Expand Down Expand Up @@ -724,7 +727,10 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
call.Value = new(uint256.Int)
}
// Set infinite balance to the fake caller account.
from := statedb.GetOrNewStateObject(call.From)
from, err := statedb.GetOrNewStateObject(call.From)
if err != nil {
return nil, err
}
from.SetBalance(uint256.NewInt(0).SetAllOne(), tracing.BalanceChangeUnspecified)
// Execute the call.
msg := callMsg{call}
Expand Down Expand Up @@ -752,7 +758,10 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, txn types.Transa
if senderErr != nil {
return fmt.Errorf("invalid transaction: %w", senderErr)
}
nonce := b.pendingState.GetNonce(sender)
nonce, err := b.pendingState.GetNonce(sender)
if err != nil {
return err
}
if txn.GetNonce() != nonce {
return fmt.Errorf("invalid transaction nonce: got %d, want %d", txn.GetNonce(), nonce)
}
Expand Down
5 changes: 4 additions & 1 deletion accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ func TestNewSimulatedBackend(t *testing.T) {
}

statedb := sim.stateByBlockNumber(tx, new(big.Int).SetUint64(num+1))
bal := statedb.GetBalance(testAddr)
bal, err := statedb.GetBalance(testAddr)
if err != nil {
t.Fatal(err)
}
if !bal.Eq(expectedBal) {
t.Errorf("expected balance for test address not received. expected: %v actual: %v", expectedBal, bal)
}
Expand Down
1 change: 1 addition & 0 deletions cl/beacon/handler/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (a *ApiHandler) PostEthV1ValidatorSyncCommitteeSubscriptions(w http.Respons
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
//cn()
}

// subscribe to subnets
Expand Down
1 change: 0 additions & 1 deletion cl/phase1/forkchoice/on_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func (f *ForkChoiceStore) OnAttestation(
return err
}
}

var attestationIndicies []uint64
var err error
target := data.Target
Expand Down
1 change: 0 additions & 1 deletion cl/phase1/forkchoice/on_attester_slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (f *ForkChoiceStore) onProcessAttesterSlashing(attesterSlashing *cltypes.At
if !cltypes.IsSlashableAttestationData(attestation1.Data, attestation2.Data) {
return errors.New("attestation data is not slashable")
}

attestation1PublicKeys, err := getIndexedAttestationPublicKeys(s, attestation1)
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion cl/phase1/network/services/block_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func (b *blockService) ProcessMessage(ctx context.Context, _ *uint64, msg *cltyp
if msg.Block.Body.BlobKzgCommitments.Len() > int(b.beaconCfg.MaxBlobsPerBlock) {
return ErrInvalidCommitmentsCount
}

b.publishBlockGossipEvent(msg)
// the rest of the validation is done in the forkchoice store
if err := b.processAndStoreBlock(ctx, msg); err != nil {
Expand Down
Loading

0 comments on commit 4fa5650

Please sign in to comment.