Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix: eth get prover data issues (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
atanmarko authored Jul 27, 2023
1 parent a0080d0 commit bfb007e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 12 additions & 3 deletions jsonrpc/eth_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ type Eth struct {
var (
ErrInsufficientFunds = errors.New("insufficient funds for execution")
//Empty code hash is 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
EmptyCodeHash = hex.EncodeToHex([]byte{197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125,
178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112})
EmptyCodeHashBytes = []byte{197, 210, 70, 1, 134, 247, 35, 60, 146, 126, 125,
178, 220, 199, 3, 192, 229, 0, 182, 83, 202, 130, 39, 59, 123, 250, 216, 4, 93, 133, 164, 112}
EmptyCodeHash = hex.EncodeToHex(EmptyCodeHashBytes)
)

// ChainId returns the chain id of the client
Expand Down Expand Up @@ -786,7 +787,15 @@ func (e *Eth) GetProverData(block BlockNumberOrHash) (interface{}, error) {
// Get the full account nonce, balance, state root and code hash of the state before this
// block is executed
acc, err := e.store.GetAccount(previousHeader.StateRoot, accountAddress)
if err != nil {
if errors.Is(err, ErrStateNotFound) {
// Account used for the first time, not yet in storage
acc = &Account{
Nonce: 0,
Balance: big.NewInt(0),
Root: types.Hash{},
CodeHash: EmptyCodeHashBytes, // Empty code hash
}
} else if err != nil {
return nil, err
}

Expand Down
4 changes: 3 additions & 1 deletion prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ func ParseBlockAccounts(block *types.Block) ([]string, error) {
var accounts = make([]string, 0)
for _, tx := range block.Transactions {
accounts = append(accounts, tx.From.String())
accounts = append(accounts, (*tx.To).String())
if tx.To != nil {
accounts = append(accounts, (*tx.To).String())
}
}

return accounts, nil
Expand Down

0 comments on commit bfb007e

Please sign in to comment.