-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a new RPC endpoint (bor_sendRawTransactionConditional) to support EIP-4337 Bundled Transactions #8229
Changes from all commits
883ed31
b6b5a38
74e53a4
d257b26
6c446e8
0a45d29
7d77722
8a91bea
cc8ddac
afbfb8b
0326018
f67a504
75f7622
f6d97dd
220acfd
3d28edd
cc63de0
254e288
c095f93
5ae1dd4
a6a66ad
3c5c466
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import ( | |
"github.com/ledgerwatch/erigon-lib/chain" | ||
libcommon "github.com/ledgerwatch/erigon-lib/common" | ||
types2 "github.com/ledgerwatch/erigon-lib/types" | ||
"github.com/ledgerwatch/erigon/common" | ||
"github.com/ledgerwatch/erigon/common/u256" | ||
"github.com/ledgerwatch/erigon/core/types" | ||
"github.com/ledgerwatch/erigon/core/types/accounts" | ||
|
@@ -827,3 +828,46 @@ func (sdb *IntraBlockState) AddressInAccessList(addr libcommon.Address) bool { | |
func (sdb *IntraBlockState) SlotInAccessList(addr libcommon.Address, slot libcommon.Hash) (addressPresent bool, slotPresent bool) { | ||
return sdb.accessList.Contains(addr, slot) | ||
} | ||
|
||
// ValidateKnownAccounts validates the knownAccounts passed in the options parameter in the conditional transaction (EIP-4337) | ||
func (sdb *IntraBlockState) ValidateKnownAccounts(knownAccounts types2.KnownAccountStorageConditions) error { | ||
if knownAccounts == nil { | ||
return nil | ||
} | ||
|
||
for address, condition := range knownAccounts { | ||
tempAccount, err := sdb.stateReader.ReadAccountData(address) | ||
if err != nil { | ||
return fmt.Errorf("error reading account data at: %v", address) | ||
} | ||
|
||
if tempAccount == nil { | ||
return fmt.Errorf("Storage Trie is nil for: %v", address) | ||
} | ||
|
||
// check if the value is hex string or an object | ||
switch { | ||
Comment on lines
+848
to
+849
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like now we could move the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
case condition.IsSingle(): | ||
if *condition.StorageRootHash != tempAccount.Root { | ||
return fmt.Errorf("invalid root hash for: %v root hash: %v actual root hash: %v", address, condition.StorageRootHash, tempAccount.Root) | ||
} | ||
case condition.IsStorage(): | ||
for slot, value := range condition.StorageSlotHashes { | ||
slot := slot | ||
tempByte, err := sdb.stateReader.ReadAccountStorage(address, tempAccount.Incarnation, &slot) | ||
if err != nil { | ||
return fmt.Errorf("error reading account storage at: %v slot: %v", address, slot) | ||
} | ||
|
||
actualValue := libcommon.BytesToHash(common.LeftPadBytes(tempByte, 32)) | ||
if value != actualValue { | ||
return fmt.Errorf("invalid slot value at address: %v slot: %v value: %v actual value: %v", address, slot, value, actualValue) | ||
} | ||
} | ||
default: | ||
return fmt.Errorf("impossible to validate known accounts: %v", address) | ||
} | ||
} | ||
|
||
return nil | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -61,6 +61,12 @@ func BigToHash(b *big.Int) Hash { return BytesToHash(b.Bytes()) } | |||||
// If b is larger than len(h), b will be cropped from the left. | ||||||
func HexToHash(s string) Hash { return BytesToHash(hexutility.FromHex(s)) } | ||||||
|
||||||
func HexToRefHash(s string) *Hash { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to match the method above:
Suggested change
|
||||||
v := BytesToHash(FromHex(s)) | ||||||
|
||||||
return &v | ||||||
} | ||||||
|
||||||
// Bytes gets the byte representation of the underlying hash. | ||||||
func (h Hash) Bytes() []byte { return h[:] } | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be decoupled from IntraBlockState, see this thread:
#8229 (comment)