Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
387e085
Update for Dencun
yrong Sep 21, 2023
846065a
build geth&lodestar from source
yrong Sep 25, 2023
65272d4
Fix makeTrie
yrong Sep 25, 2023
d2f0d66
Merge branch 'main' into ron/dencun
yrong Nov 21, 2023
63b0f07
Update go ethereum to v1.13.5
yrong Nov 21, 2023
faf5d01
Update packages & Speedup e2e setup
yrong Nov 21, 2023
c179311
Update lodestar to v1.12.0
yrong Nov 21, 2023
d728f48
Remove unused
yrong Nov 21, 2023
28f23dd
Remove unrelated changes
yrong Nov 21, 2023
cce7714
Ignore build geth when binary exist
yrong Nov 21, 2023
48cc44f
Cleanup for deprecated ethashproof
yrong Nov 22, 2023
fe1e191
Update with VersionedExecutionPayloadHeader
yrong Nov 22, 2023
d37a736
Fix breaking tests
yrong Nov 22, 2023
1aa5a0a
Merge branch 'main' into ron/dencun
yrong Dec 1, 2023
545e267
Update node package
yrong Dec 1, 2023
1c5b33d
Update git modules
yrong Dec 1, 2023
647f57e
Sync packages with nix
yrong Dec 1, 2023
40daff1
Merge branch 'main' of https://github.com/Snowfork/snowbridge into ro…
yrong Dec 4, 2023
565cd83
Update sdk
yrong Dec 4, 2023
7414746
Update contract binding
yrong Dec 5, 2023
70d017b
More cleanup
yrong Dec 5, 2023
585dc78
For deneb(1)
yrong Dec 5, 2023
ba67bf3
For deneb(2)
yrong Dec 5, 2023
f9f7458
Update sdk
yrong Dec 5, 2023
d542799
For deneb(3)
yrong Dec 5, 2023
904e97a
Update sdk
yrong Dec 5, 2023
99c0304
For deneb(4)
yrong Dec 5, 2023
8a50ced
Enable deneb for local setup
yrong Dec 5, 2023
e5c2381
Fix tests
yrong Dec 5, 2023
29a2afe
Fix BeaconStateDeneb & more tests
yrong Dec 6, 2023
3f6cb38
Merge branch 'main' into ron/dencun
yrong Dec 6, 2023
4aae19a
Generate test fixture for Deneb and more tests accordingly
yrong Dec 7, 2023
79e79dd
Merge branch 'main' into ron/dencun
yrong Dec 7, 2023
ed69a35
Fix parse empty field
yrong Dec 7, 2023
1c1ca20
Setup for switchover test
yrong Dec 7, 2023
8f95e8a
Test workflow specific for deneb
yrong Dec 7, 2023
ba5957e
Ignore change detect building polkadot binary
yrong Dec 11, 2023
9673b21
Encode with error handling
yrong Dec 11, 2023
e767e6e
Fix format
yrong Dec 11, 2023
e5120e8
Merge branch 'main' into ron/dencun
yrong Dec 13, 2023
6a38f79
Update lodestar
yrong Dec 14, 2023
c246f70
Improve scripts setting up nodes for production
yrong Dec 14, 2023
6892678
Merge branch 'main' into ron/dencun
yrong Dec 27, 2023
b76a4dd
Sync execution update on demand
yrong Dec 31, 2023
bdec747
Merge branch 'main' into ron/dencun
yrong Jan 11, 2024
99f5a6d
Fix import
yrong Jan 11, 2024
3580c4d
Reorganize deneb primitives
yrong Jan 11, 2024
d1a5b86
Update go mod
yrong Jan 12, 2024
ad65ebd
Fix format
yrong Jan 12, 2024
53e4fa6
Remove obsolete
yrong Jan 12, 2024
d069f97
Fix import
yrong Jan 12, 2024
da3d338
Merge branch 'main' into ron/dencun
yrong Jan 12, 2024
58a28bd
Merge branch 'main' into ron/dencun
yrong Jan 17, 2024
61dadc9
Fix the deneb ForkVersion
yrong Jan 17, 2024
328d541
Upgrade geth and lodestar
yrong Jan 17, 2024
9d633e2
Merge branch 'ron/dencun' into ron/execution-update-on-demand
yrong Jan 18, 2024
d37ee40
Download geth release to replace the nix default
yrong Jan 18, 2024
d4bc62b
Naming consistently
yrong Jan 18, 2024
0c14e49
Update lodestar with the mock hack
yrong Jan 18, 2024
0ed243a
Fix generate mainnet fixture
yrong Jan 18, 2024
810fa47
Merge branch 'ron/dencun' into ron/execution-update-on-demand
yrong Jan 18, 2024
53c6fb8
Remove fixture unused
yrong Jan 18, 2024
4cdfa96
Backward compatible
yrong Jan 18, 2024
b5ea6b2
Check execution_branch
yrong Jan 18, 2024
6bd6723
Remove build geth
yrong Jan 18, 2024
b892f77
Remove cross check
yrong Jan 18, 2024
a646a4e
sync all lagging periods
yrong Jan 18, 2024
ee71d1a
Clean up
yrong Jan 18, 2024
79247a2
More refactoring
yrong Jan 18, 2024
49800bd
Cleanup scripts
yrong Jan 18, 2024
cdc7165
Update sdk
yrong Jan 18, 2024
072c3f0
Merge branch 'main' into ron/execution-update-on-demand
yrong Jan 19, 2024
c42d0af
Ignore go.work
yrong Jan 19, 2024
5bc2526
Rename function
yrong Jan 19, 2024
f465995
Merge branch 'main' into ron/execution-update-on-demand
yrong Jan 24, 2024
dd866bb
Fix test
yrong Jan 24, 2024
afe2b43
Fix populate checkpoint
yrong Jan 24, 2024
018c565
Fix smoke test
yrong Jan 24, 2024
775e56a
Merge branch 'main' into ron/execution-update-on-demand
yrong Jan 28, 2024
3f0f027
Merge branch 'main' into ron/execution-update-on-demand
yrong Jan 30, 2024
1d67967
Merge branch 'main' into ron/execution-update-on-demand
yrong Feb 6, 2024
7b5e1e3
Update lodestar & polkadot-sdk
yrong Feb 6, 2024
e8557c7
Merge branch 'main' into ron/execution-update-on-demand
yrong Mar 12, 2024
af93289
Check execution already exist before submit
yrong Mar 12, 2024
888ce4d
Update relayer/cmd/generate_beacon_data.go
yrong Mar 12, 2024
5213ba8
Update relayer/relays/beacon/header/header.go
yrong Mar 12, 2024
ddf7e6a
Rename to OptionalExecutionHeader
yrong Mar 12, 2024
cd85cb9
Rename import alias
yrong Mar 12, 2024
03bdb5c
Improve logs
yrong Mar 12, 2024
ef8c27a
Fetch checkpoint on chain from history
yrong Mar 12, 2024
ab191f9
Remove LastExecutionHeaderState & Remove execution header from update
yrong Mar 13, 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
Merge branch 'main' into ron/dencun
  • Loading branch information
yrong committed Dec 13, 2023
commit e5120e8fa9f21e3f09781b87edd91e180f953830
16 changes: 8 additions & 8 deletions parachain/pallets/inbound-queue/src/benchmarking/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub struct InboundQueueTest {
pub fn make_create_message() -> InboundQueueTest {
InboundQueueTest{
execution_header: CompactExecutionHeader{
parent_hash: hex!("8f69b84ec2fe39b299005cf30e855a2bcdd997dd1e5f79777271160015db6ae3").into(),
block_number: 188,
state_root: hex!("3f744f5e0322312fbcd6ea06e4e3db6cf8ff8a6258ee4f621df57165c3964806").into(),
receipts_root: hex!("b4e733e6a4545303220f9954b9e895ecf31e5d6fe1557f27a0254a01132f38a7").into(),
parent_hash: hex!("b5608f0af7c3b6fe5c593772fc25436b8d6549eb236adb0855c6ad33e0004e04").into(),
block_number: 115,
state_root: hex!("47ed174789836c622499d9659a4ac32c3b91a7b15642d39b0a11b82ff23995c1").into(),
receipts_root: hex!("42c08b5303fcdf9e49c833fe5f1182cdbc8206bf8aec581125fc34aba11e1f1a").into(),
},
message: Message {
event_log: Log {
Expand All @@ -24,15 +24,15 @@ pub fn make_create_message() -> InboundQueueTest {
hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539").into(),
hex!("5f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0").into(),
],
data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e000f000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000").into(),
data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e00a736aa00000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000").into(),
},
proof: Proof {
block_hash: hex!("7ce27351fff56e7f0f28774766ad46dcf9c05e5cc5cf2c1914de08b34da3d0c9").into(),
block_hash: hex!("add15f439c8a57fe375d0a679870b1359921d70cb0e3e44f0dd3e272849f4097").into(),
tx_index: 0,
data: (vec![
hex!("b4e733e6a4545303220f9954b9e895ecf31e5d6fe1557f27a0254a01132f38a7").to_vec(),
hex!("42c08b5303fcdf9e49c833fe5f1182cdbc8206bf8aec581125fc34aba11e1f1a").to_vec(),
], vec![
hex!("f9026d822080b9026702f9026301830150dfb9010000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010f90158f85894eda338e4dc46038493b885327842fd3e301cab39e1a0f78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7ea000000000000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7df8fc94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539a05f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0b88000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001e000f000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d0000").to_vec(),
hex!("f9028e822080b9028802f90284018301ed20b9010000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010f90179f85894eda338e4dc46038493b885327842fd3e301cab39e1a0f78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7ea000000000000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7df9011c94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539a05f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0b8a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e00a736aa00000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000").to_vec(),
]),
},
},
Expand Down
77 changes: 77 additions & 0 deletions relayer/cmd/generate_beacon_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,34 @@ func generateBeaconCheckpointCmd() *cobra.Command {
return cmd
}

func generateExecutionUpdateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "generate-execution-update",
Short: "Generate execution update.",
Args: cobra.ExactArgs(0),
RunE: generateExecutionUpdate,
}

cmd.Flags().String("spec", "", "Valid values are mainnet or minimal")
err := cmd.MarkFlagRequired("spec")
if err != nil {
return nil
}

cmd.Flags().Uint32("slot", 1, "slot number")
err = cmd.MarkFlagRequired("slot")
if err != nil {
return nil
}

cmd.Flags().String("url", "http://127.0.0.1:9596", "Beacon URL")
if err != nil {
return nil
}

return cmd
}

type Data struct {
CheckpointUpdate beaconjson.CheckPoint
SyncCommitteeUpdate beaconjson.Update
Expand Down Expand Up @@ -351,3 +379,52 @@ func writeBenchmarkDataFile(filename, fileContents string) error {

return nil
}

func generateExecutionUpdate(cmd *cobra.Command, _ []string) error {
err := func() error {
spec, err := cmd.Flags().GetString("spec")
if err != nil {
return fmt.Errorf("get active spec: %w", err)
}
activeSpec, err := config.ToSpec(spec)
if err != nil {
return fmt.Errorf("get spec: %w", err)
}

endpoint, _ := cmd.Flags().GetString("url")
beaconSlot, _ := cmd.Flags().GetUint32("slot")

viper.SetConfigFile("web/packages/test/config/beacon-relay.json")
if err := viper.ReadInConfig(); err != nil {
return err
}
var conf config.Config
err = viper.Unmarshal(&conf)
if err != nil {
return err
}
specSettings := conf.GetSpecSettingsBySpec(activeSpec)
log.WithFields(log.Fields{"spec": activeSpec, "endpoint": endpoint}).Info("connecting to beacon API")

// generate executionUpdate
s := syncer.New(endpoint, specSettings, activeSpec)
blockRoot, err := s.Client.GetBeaconBlockRoot(uint64(beaconSlot))
if err != nil {
return fmt.Errorf("fetch block: %w", err)
}
headerUpdateScale, err := s.GetHeaderUpdate(blockRoot, nil)
if err != nil {
return fmt.Errorf("get header update: %w", err)
}
headerUpdate := headerUpdateScale.ToJSON()
writeJSONToFile(headerUpdate, fmt.Sprintf("execution-header-update.%s.json", activeSpec.ToString()))
log.Info("created execution update file")

return nil
}()
if err != nil {
log.WithError(err).Error("error generating beacon execution update")
}

return nil
}
2 changes: 2 additions & 0 deletions relayer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ func init() {
rootCmd.AddCommand(getBlockCmd())
//rootCmd.AddCommand(fetchMessagesCmd())
rootCmd.AddCommand(subBeefyCmd())
rootCmd.AddCommand(scanBeefyCmd())
rootCmd.AddCommand(leafCmd())
rootCmd.AddCommand(basicChannelLeafProofCmd())
rootCmd.AddCommand(parachainHeadProofCmd())
rootCmd.AddCommand(importExecutionHeaderCmd())
rootCmd.AddCommand(generateBeaconDataCmd())
rootCmd.AddCommand(generateBeaconCheckpointCmd())
rootCmd.AddCommand(generateExecutionUpdateCmd())
}

func Execute() {
Expand Down
107 changes: 107 additions & 0 deletions relayer/cmd/scan_beefy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package cmd

import (
"context"
"log"
"os"
"os/signal"
"syscall"

"github.com/sirupsen/logrus"
"github.com/snowfork/snowbridge/relayer/chain/relaychain"
"github.com/snowfork/snowbridge/relayer/relays/beefy"
"github.com/spf13/cobra"
"golang.org/x/sync/errgroup"
)

func scanBeefyCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "scan-beefy",
Short: "Scan beefy messages like the beefy relayer would.",
Args: cobra.ExactArgs(0),
RunE: ScanBeefyFn,
}

cmd.Flags().StringP("polkadot-url", "p", "ws://127.0.0.1:9944", "Polkadot URL.")
cmd.MarkFlagRequired("polkadot-url")
cmd.Flags().Uint64P("beefy-block", "b", 0, "Beefy block.")
cmd.MarkFlagRequired("beefy-block")
cmd.Flags().Uint64P("validator-set-id", "v", 0, "Validator set id.")
cmd.MarkFlagRequired("validator-set-id")
cmd.Flags().Uint64P("fast-forward-depth", "f", 100, "Fast forward depth.")
return cmd
}

func ScanBeefyFn(cmd *cobra.Command, _ []string) error {
ctx := cmd.Context()
ctx, cancel := context.WithCancel(context.Background())
eg, ctx := errgroup.WithContext(ctx)

log.SetOutput(logrus.WithFields(logrus.Fields{"logger": "stdlib"}).WriterLevel(logrus.InfoLevel))
logrus.SetLevel(logrus.DebugLevel)

polkadotUrl, _ := cmd.Flags().GetString("polkadot-url")
relaychainConn := relaychain.NewConnection(polkadotUrl)
relaychainConn.Connect(ctx)

fastForwardDepth, _ := cmd.Flags().GetUint64("fast-forward-depth")
config := beefy.SourceConfig{
FastForwardDepth: fastForwardDepth,
}
polkadotListener := beefy.NewPolkadotListener(
&config,
relaychainConn,
)

beefyBlock, _ := cmd.Flags().GetUint64("beefy-block")
validatorSetID, _ := cmd.Flags().GetUint64("validator-set-id")
logrus.WithFields(logrus.Fields{
"polkadot-url": polkadotUrl,
"fast-forward-depth": fastForwardDepth,
"beefy-block": beefyBlock,
"validator-set-id": validatorSetID,
}).Info("Connected to relaychain.")

commitments, err := polkadotListener.Start(ctx, eg, beefyBlock, validatorSetID)
if err != nil {
logrus.WithError(err).Fatalf("could not start")
}

eg.Go(func() error {
for {
select {
case <-ctx.Done():
return nil
case commitment, ok := <-commitments:
if !ok {
return nil
}
logrus.WithField("commitment", commitment).Info("scanned commitment")
}
}
})

// Ensure clean termination upon SIGINT, SIGTERM
eg.Go(func() error {
notify := make(chan os.Signal, 1)
signal.Notify(notify, syscall.SIGINT, syscall.SIGTERM)

select {
case <-ctx.Done():
return ctx.Err()
case sig := <-notify:
logrus.WithField("signal", sig.String()).Info("Received signal")
cancel()
}

return nil
})

err = eg.Wait()
if err != nil {
logrus.WithError(err).Fatal("Unhandled error")
return err
}

return nil
}
11 changes: 8 additions & 3 deletions relayer/relays/beacon/header/syncer/api/api_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package api

import (
"fmt"
"github.com/snowfork/snowbridge/relayer/relays/beacon/config"
"math/big"
"strconv"

"github.com/snowfork/snowbridge/relayer/relays/beacon/config"

"github.com/ethereum/go-ethereum/common"
"github.com/snowfork/go-substrate-rpc-client/v4/types"
beaconjson "github.com/snowfork/snowbridge/relayer/relays/beacon/header/syncer/json"
Expand Down Expand Up @@ -97,7 +98,7 @@ type FinalizedCheckpointResponse struct {

type SignedHeaderResponse struct {
Message HeaderResponse `json:"message"`
Signature []byte `json:"signature"`
Signature string `json:"signature"`
}

type CheckpointResponse struct {
Expand Down Expand Up @@ -993,10 +994,14 @@ func (s SignedHeaderResponse) ToFastSSZ() (*state.SignedBeaconBlockHeader, error
if err != nil {
return nil, err
}
signature, err := util.HexStringToByteArray(s.Signature)
if err != nil {
return nil, err
}

return &state.SignedBeaconBlockHeader{
Header: message,
Signature: s.Signature,
Signature: signature,
}, nil
}

Expand Down
17 changes: 17 additions & 0 deletions relayer/relays/beacon/header/syncer/api/api_response_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package api

import (
"encoding/json"
"github.com/stretchr/testify/assert"
"os"
"testing"
)

func TestUnmarshalBlockResponse(t *testing.T) {
blockResponse := BeaconBlockResponse{}
data, _ := os.ReadFile("web/packages/test/testdata/beacon_block_6815804.json")
if data != nil {
err := json.Unmarshal(data, &blockResponse)
assert.Nil(t, err)
}
}
2 changes: 1 addition & 1 deletion web/packages/test/scripts/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build_binaries() {
cp target/release/polkadot-prepare-worker $output_bin_dir/polkadot-prepare-worker

echo "Building polkadot-parachain binary"
cargo build --release --locked -p polkadot-parachain-bin --bin polkadot-parachain $features
cargo build --release --locked -p polkadot-parachain-bin --bin polkadot-parachain $features --no-default-features
cp target/release/polkadot-parachain $output_bin_dir/polkadot-parachain

popd
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.