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

EIP4844 support & Other misc issues fix #2

Merged
merged 12 commits into from
Nov 27, 2024

Conversation

dumdumgoose
Copy link
Contributor

@dumdumgoose dumdumgoose commented Nov 4, 2024

  • Upgraded go-ethereum to v1.14.11 to support EIP4844 transaction signing
  • Added a new signing type for blob data
  • Allows to start servers with different ports (added some extra flags to control that)

This is still under testing, do not merge for now.

@dumdumgoose dumdumgoose changed the title EIP4844 support & Other misc issues fix WIP: EIP4844 support & Other misc issues fix Nov 4, 2024
metis/selection.go Outdated Show resolved Hide resolved

// GenerateRandomInt generates a random integer from min to max (inclusive), based on a provided seed.
// This simulates a normal distribution by summing multiple uniform random variables.
func (g *CLTGenerator) GenerateRandomInt(seed int64, min, max uint64) (int64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any difference from randomRangeInclusive?

Copy link
Contributor Author

@dumdumgoose dumdumgoose Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aiden069 told me that the numbers generated by randomRangeInclusive are not in a normal distribution manner, so I rewrote the random generation part with CLT (since this is the only stateless random generation method I can find that will most likely provide a normal distribution result).

Here is the test result:

telegram-cloud-photo-size-5-6073483992117657275-y

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss it first.

It's still unfair for a validator with higher power.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, shall we setup a quick meeting for this? And @aiden069 what's your opinion here?

@ericlee42
Copy link
Contributor

Please move the selection change to a new PR.

@dumdumgoose
Copy link
Contributor Author

Please move the selection change to a new PR.

Removed, will create a separate PR for selection soon.

@dumdumgoose
Copy link
Contributor Author

Please move the selection change to a new PR.

@ericlee42 PR for new selection is here

@@ -0,0 +1,167 @@
package types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some differences in RLP decoding in go-ethereum 1.14 and 1.10. The binary data of unsigned transaction does not have r, s and v encoded, if we use tx.UnmarshalBinary provided in go-ethereum 1.14, it will cause an error (too many elements) when decoding. So I copied over the data structures from go-ethereum and set the r, s, v to optional to avoid this error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so.

Please give an example for it.

Copy link
Contributor Author

@dumdumgoose dumdumgoose Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Create a dynamic fee tx
image
  1. Decode the transaction with tx.UnmarshalBinary
image image

Also that one thing to notice, I played with different transaction types, it seems that this error will only happens on typed transactions (access list / dynamic fee / blob), not on legacy tx. I guess that's why the previous themis code works, since the txs submitted to MPC were only legacy txs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same tx data with the optional decoding:
image
image

Copy link
Contributor Author

@dumdumgoose dumdumgoose Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this might be the reason? But I'm not sure the relation between gencodec tag and RLP decode.

image image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked the code of the ether.js, it doesn't add the sig fields to the rlp bytes

https://github.com/ethers-io/ethers.js/blob/9e7e7f3e2f2d51019aaa782e6290e079c38332fb/src.ts/transaction/transaction.ts#L386-L389

But it should work for geth

package main

import (
	"math/big"

	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/types"
)

func main() {
	var a common.Address
	tx1 := types.NewTx(&types.DynamicFeeTx{
		ChainID:   big.NewInt(1),
		GasTipCap: big.NewInt(1e9),
		GasFeeCap: big.NewInt(1e9),
		Gas:       1e5,
		To:        &a,
		Value:     big.NewInt(0),
	})

	tx1Raw, err := tx1.MarshalBinary()
	if err != nil {
		panic(err)
	}

	var tx2 types.Transaction
	if err := tx2.UnmarshalBinary(tx1Raw); err != nil {
		panic(err)
	}
}

Fair enough, we can accept the change.

@dumdumgoose dumdumgoose changed the title WIP: EIP4844 support & Other misc issues fix EIP4844 support & Other misc issues fix Nov 27, 2024
@ericlee42 ericlee42 merged commit 9d666f1 into MetisProtocol:main Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants