-
Notifications
You must be signed in to change notification settings - Fork 107
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
Electra upgrade #1283
Draft
claravanstaden
wants to merge
12
commits into
main
Choose a base branch
from
electra
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Electra upgrade #1283
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a1e12b9
electra upgrade
claravanstaden 934973e
relayer progress
claravanstaden d64e224
more electra work
claravanstaden aaf566b
fix config
claravanstaden 7cfd412
fixes
claravanstaden 5d345b7
fix tests
claravanstaden 51aa8de
update go version
claravanstaden 3a25d81
containers
claravanstaden d5fd515
Merge branch 'main' into electra
claravanstaden 5de9c0e
Merge branch 'main' into electra
claravanstaden b2379ac
electra changes
claravanstaden c1b3e9c
try testing lodestar + electra
claravanstaden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package api | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/snowfork/go-substrate-rpc-client/v4/types" | ||
"github.com/snowfork/snowbridge/relayer/relays/beacon/header/syncer/scale" | ||
"github.com/snowfork/snowbridge/relayer/relays/beacon/state" | ||
"github.com/snowfork/snowbridge/relayer/relays/util" | ||
) | ||
|
||
func ElectraExecutionPayloadToScale(e *state.ExecutionPayloadElectra) (scale.ExecutionPayloadHeaderDeneb, error) { | ||
var payloadHeader scale.ExecutionPayloadHeaderDeneb | ||
transactionsContainer := state.TransactionsRootContainer{} | ||
transactionsContainer.Transactions = e.Transactions | ||
|
||
transactionsRoot, err := transactionsContainer.HashTreeRoot() | ||
if err != nil { | ||
return payloadHeader, err | ||
} | ||
|
||
var withdrawalRoot types.H256 | ||
|
||
withdrawalContainer := state.WithdrawalsRootContainerMainnet{} | ||
withdrawalContainer.Withdrawals = e.Withdrawals | ||
withdrawalRoot, err = withdrawalContainer.HashTreeRoot() | ||
if err != nil { | ||
return payloadHeader, err | ||
} | ||
|
||
baseFeePerGas := big.Int{} | ||
// Change BaseFeePerGas back from little-endian to big-endian | ||
baseFeePerGas.SetBytes(util.ChangeByteOrder(e.BaseFeePerGas[:])) | ||
|
||
return scale.ExecutionPayloadHeaderDeneb{ | ||
ParentHash: types.NewH256(e.ParentHash[:]), | ||
FeeRecipient: e.FeeRecipient, | ||
StateRoot: types.NewH256(e.StateRoot[:]), | ||
ReceiptsRoot: types.NewH256(e.ReceiptsRoot[:]), | ||
LogsBloom: e.LogsBloom[:], | ||
PrevRandao: types.NewH256(e.PrevRandao[:]), | ||
BlockNumber: types.NewU64(e.BlockNumber), | ||
GasLimit: types.NewU64(e.GasLimit), | ||
GasUsed: types.NewU64(e.GasUsed), | ||
Timestamp: types.NewU64(e.Timestamp), | ||
ExtraData: e.ExtraData, | ||
BaseFeePerGas: types.NewU256(baseFeePerGas), | ||
BlockHash: types.NewH256(e.BlockHash[:]), | ||
TransactionsRoot: transactionsRoot, | ||
WithdrawalsRoot: withdrawalRoot, | ||
BlobGasUsed: types.NewU64(e.BlobGasUsed), | ||
ExcessBlobGas: types.NewU64(e.ExcessBlobGas), | ||
}, nil | ||
} | ||
|
||
func (a AttesterSlashingResponse) ToFastSSZElectra() (*state.AttesterSlashingElectra, error) { | ||
attestation1, err := a.Attestation1.ToFastSSZElectra() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
attestation2, err := a.Attestation2.ToFastSSZElectra() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &state.AttesterSlashingElectra{ | ||
Attestation1: attestation1, | ||
Attestation2: attestation2, | ||
}, nil | ||
} | ||
|
||
func (i IndexedAttestationResponse) ToFastSSZElectra() (*state.IndexedAttestationElectra, error) { | ||
data, err := i.Data.ToFastSSZ() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
attestationIndexes := []uint64{} | ||
for _, index := range i.AttestingIndices { | ||
indexInt, err := util.ToUint64(index) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
attestationIndexes = append(attestationIndexes, indexInt) | ||
} | ||
|
||
signature, err := util.HexStringToByteArray(i.Signature) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &state.IndexedAttestationElectra{ | ||
AttestationIndices: attestationIndexes, | ||
Data: data, | ||
Signature: signature, | ||
}, nil | ||
} | ||
|
||
func (a AttestationResponse) ToFastSSZElectra() (*state.AttestationElectra, error) { | ||
data, err := a.Data.ToFastSSZ() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
aggregationBits, err := util.HexStringToByteArray(a.AggregationBits) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
signature, err := util.HexStringTo96Bytes(a.Signature) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
committeeBits, err := util.HexStringToByteArray(a.CommitteeBits) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &state.AttestationElectra{ | ||
AggregationBits: aggregationBits, | ||
Data: data, | ||
Signature: signature, | ||
CommitteeBits: committeeBits, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unused method.