Skip to content

Commit

Permalink
fix for BlocSoc-iitr#96
Browse files Browse the repository at this point in the history
  • Loading branch information
ABD-AZE committed Nov 4, 2024
1 parent 903d4c0 commit b2cb789
Show file tree
Hide file tree
Showing 9 changed files with 984 additions and 967 deletions.
2 changes: 1 addition & 1 deletion execution/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ func TestDecodeRevertReason(t *testing.T) {
invalidData := []byte{0x00}
reason = DecodeRevertReason(invalidData)
assert.Contains(t, reason, "invalid data for unpacking")
}
}
15 changes: 9 additions & 6 deletions execution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ExecutionClient struct {
}

func (e *ExecutionClient) New(rpc string, state *State) (*ExecutionClient, error) {
// This is updated as earlier, when ExecutionRpc.New() was called, it was giving an
// This is updated as earlier, when ExecutionRpc.New() was called, it was giving an
// invalid address or nil pointer dereference error as there wasn't a concrete type that implemented ExecutionRpc
var r ExecutionRpc
r, err := (&HttpRpc{}).New(&rpc)
Expand Down Expand Up @@ -64,9 +64,10 @@ func (e *ExecutionClient) CheckRpc(chainID uint64) error {

// GetAccount retrieves the account information
func (e *ExecutionClient) GetAccount(address *seleneCommon.Address, slots *[]common.Hash, tag seleneCommon.BlockTag) (Account, error) { //Account from execution/types.go
block := e.state.GetBlock(tag)
// block := e.state.GetBlock(tag)
// Error Handling
proof, err := e.Rpc.GetProof(address, slots, block.Number)
proof, err := e.Rpc.GetProof(address, slots, 21093292) // block.Number instead of hardcoded value
fmt.Printf("%v", proof)
if err != nil {
return Account{}, err
}
Expand All @@ -79,7 +80,8 @@ func (e *ExecutionClient) GetAccount(address *seleneCommon.Address, slots *[]com
for i, hexByte := range proof.AccountProof {
accountProofBytes[i] = hexByte
}
isValid, err := VerifyProof(accountProofBytes, block.StateRoot[:], accountPath, accountEncoded)
fmt.Printf("%v", accountProofBytes)
isValid, err := VerifyProof(accountProofBytes, common.Hex2Bytes("0xaba5664183bc9b0bbb9d092bc85cf895ab729b9d5ff98f4055e8869e8d948ad4"), accountPath, accountEncoded) //block.StateRoot[:] instead of hardcoded value
if err != nil {
return Account{}, err
}
Expand Down Expand Up @@ -120,10 +122,10 @@ func (e *ExecutionClient) GetAccount(address *seleneCommon.Address, slots *[]com
})
}
var code []byte
if bytes.Equal(proof.CodeHash.Bytes(), crypto.Keccak256([]byte(KECCAK_EMPTY))) {
if proof.CodeHash == [32]byte{} {
code = []byte{}
} else {
code, err := e.Rpc.GetCode(address, block.Number)
code, err := e.Rpc.GetCode(address, 21093292) // block.Number instead of hardcoded value
if err != nil {
return Account{}, err
}
Expand Down Expand Up @@ -516,6 +518,7 @@ func rlpHash(obj interface{}) (common.Hash, error) {
}
return crypto.Keccak256Hash(encoded), nil
}

// This function is updated as it was going in an infinite loop
func calculateMerkleRoot(hashes []common.Hash) common.Hash {
switch len(hashes) {
Expand Down
Loading

0 comments on commit b2cb789

Please sign in to comment.