Skip to content
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

feat: ETH compatibility in Filecoin : Support Homestead and EIP-155 Ethereum transactions("legacy" transactions) in Filecoin #11969

Merged
merged 28 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c95d4b3
poc for eth legacy tx
aarshkshah1992 Apr 25, 2024
369787f
print statements
aarshkshah1992 Apr 25, 2024
fca57fc
finished
aarshkshah1992 Apr 25, 2024
440040e
tests work
aarshkshah1992 Apr 25, 2024
6695369
remove print statements
aarshkshah1992 Apr 25, 2024
9e63361
Remove all print statements
aarshkshah1992 Apr 25, 2024
266826d
remove extraneous changes
aarshkshah1992 Apr 26, 2024
4d01481
cleaned up code and interface
aarshkshah1992 Apr 26, 2024
18fd140
run make jen
aarshkshah1992 Apr 26, 2024
ad2ec8f
dont duplicate signature
aarshkshah1992 Apr 26, 2024
07d248f
go mod tidy and remove prints
aarshkshah1992 Apr 26, 2024
2e66b80
clean up tests
aarshkshah1992 Apr 26, 2024
4be21ff
test for conversion
aarshkshah1992 Apr 26, 2024
f867359
changes as per review
aarshkshah1992 Apr 29, 2024
9265211
more unit tests for legacy txns
aarshkshah1992 Apr 29, 2024
af4c2cd
Apply suggestions from code review
aarshkshah1992 May 1, 2024
8807aed
address review comments from Rodd
aarshkshah1992 May 1, 2024
c62a67d
changes as per zen's 2nd review
aarshkshah1992 May 1, 2024
cd9d63e
Merge branch 'master' into feat/add-support-legacy-eth-tx
aarshkshah1992 May 1, 2024
a0e1801
go mod tidy
aarshkshah1992 May 1, 2024
b2a10b4
feat: ETH compatibility in Filecoin : Support EIP-155 Ethereum transa…
aarshkshah1992 May 10, 2024
7d04a26
gate tx by Network Version
aarshkshah1992 May 23, 2024
dfb7b2f
Merge remote-tracking branch 'origin/master' into feat/legacy-homeste…
aarshkshah1992 May 23, 2024
c6ab108
handle arajsek review
aarshkshah1992 May 23, 2024
edf1402
fix imports order
aarshkshah1992 May 23, 2024
d759a72
fix lint
aarshkshah1992 May 23, 2024
c9cdd59
dont lock in mpool for network gating ETH messages
aarshkshah1992 May 27, 2024
270d8ea
sender can be an ID address
aarshkshah1992 May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dont duplicate signature
  • Loading branch information
aarshkshah1992 committed Apr 26, 2024
commit ad2ec8f6e097e4c7d2680290a575ec0df39ece3f
21 changes: 9 additions & 12 deletions chain/types/ethtypes/eth_legacy_homestead_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,29 @@ func (tx *EthLegacyHomesteadTxArgs) ToUnsignedFilecoinMessage(from address.Addre
}

func (tx *EthLegacyHomesteadTxArgs) ToVerifiableSignature(sig []byte) ([]byte, error) {
sigCopy := make([]byte, len(sig))
copy(sigCopy, sig)

if len(sigCopy) != legacyHomesteadTxSignatureLen {
return nil, fmt.Errorf("signature should be %d bytes long, but got %d bytes", legacyHomesteadTxSignatureLen, len(sigCopy))
if len(sig) != legacyHomesteadTxSignatureLen {
return nil, fmt.Errorf("signature should be %d bytes long, but got %d bytes", legacyHomesteadTxSignatureLen, len(sig))
}
if sigCopy[0] != LegacyHomesteadEthTxSignaturePrefix {
return nil, fmt.Errorf("expected signature prefix 0x01, but got 0x%x", sigCopy[0])
if sig[0] != LegacyHomesteadEthTxSignaturePrefix {
return nil, fmt.Errorf("expected signature prefix 0x01, but got 0x%x", sig[0])
}

// Remove the prefix byte as it's only used for legacy transaction identification
sigCopy = sigCopy[1:]
sig = sig[1:]

// Extract the 'v' value from the signature, which is the last byte in Ethereum signatures
vValue := big.NewFromGo(big.NewInt(0).SetBytes(sigCopy[64:]))
vValue := big.NewFromGo(big.NewInt(0).SetBytes(sig[64:]))

// Adjust 'v' value for compatibility with new transactions: 27 -> 0, 28 -> 1
if vValue.Equals(big.NewInt(27)) {
sigCopy[64] = 0
sig[64] = 0
} else if vValue.Equals(big.NewInt(28)) {
sigCopy[64] = 1
sig[64] = 1
} else {
return nil, fmt.Errorf("invalid 'v' value: expected 27 or 28, got %d", vValue.Int64())
}

return sigCopy, nil
return sig, nil
}

func (tx *EthLegacyHomesteadTxArgs) ToRlpUnsignedMsg() ([]byte, error) {
Expand Down
Loading