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

Foundry breaks chainId on optimism mainnet deployment #4362

Closed
2 tasks done
sakulstra opened this issue Feb 15, 2023 · 23 comments
Closed
2 tasks done

Foundry breaks chainId on optimism mainnet deployment #4362

sakulstra opened this issue Feb 15, 2023 · 23 comments
Labels
T-bug Type: bug

Comments

@sakulstra
Copy link
Contributor

sakulstra commented Feb 15, 2023

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (550c548 2023-02-13T00:11:18.976721967Z)

What command(s) is the bug in?

forge script

Operating System

Linux

Describe the bug

For certain transactions on optimism network - i can't determine what is the condition, but managed to create a reliable reproduction - foundry sends chainId 0.

Things I tried:

  • ensure the chainId in the correct inside the script - checked via require(block.chainId)
  • I checked with multiple RPCs to eliminate RPC issues
  • tried different systems (linux, macos)
  • tried different ledgers

Reproduction:

References:

  • this issue is part of resume not working #4346 but dedicated a new issue as the other reported problems are ux issues while this one seems to be a real blocker for using foundry with optimism.
@sakulstra sakulstra added the T-bug Type: bug label Feb 15, 2023
@gakonst gakonst added this to Foundry Feb 15, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Feb 15, 2023
@mattsse
Copy link
Member

mattsse commented Feb 15, 2023

ptal @joshieDo

@sakulstra
Copy link
Contributor Author

@mattsse do you have any idea what could be the issue here?
Dug a little in the codebase, but didn't anything suspicious that might lead to arbitrum/fantom/etc running this without problems, but optimism failing.

Was first thinking might be related to chainId de/serialization, but as it's not always wrong seems unlikely.

Sadly, there's bit of time pressure here so will probably port back deploy scripts to hardhat for the time being. That said, would be super interested to figure out what the issue was/so in the future we can use foundry also with optimism 😅

@tynes
Copy link
Contributor

tynes commented Feb 24, 2023

Try sending legacy transactions with the --legacy flag

@sakulstra
Copy link
Contributor Author

@tynes tried, but no difference

@mattsse
Copy link
Member

mattsse commented Feb 24, 2023

nothing stuck out to me as well,

can you please run with RUST_LOG=forge,foundry_cli and share the logs,
this should print the entire tx object

@sakulstra
Copy link
Contributor Author

Log of a failing txn showing as network 0 on ledger

2023-02-24T09:06:01.968468Z DEBUG foundry_cli::cmd::forge::script::broadcast: sending transaction: Legacy(TransactionRequest { from: Some(0x076d6da60aaac6c97a8a0fe8057f9564203ee545), to: Some(Address(0x3cd1dfb81c50a5300c60a181ed145a7286d81e0a)), gas: Some(132533), gas_price: Some(1025500), value: Some(0), data: Some(Bytes(0x183fb413000000000000000000000000794a61358d6845594f94dc1db02a252b5b4814ad0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000b41544f4b454e5f494d504c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b41544f4b454e5f494d504c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000)), nonce: Some(25), chain_id: Some(10) })

Log of a txn showing as network optimism (correct) on ledger:

2023-02-24T09:10:27.977944Z DEBUG foundry_cli::cmd::forge::script::broadcast: sending transaction: Legacy(TransactionRequest { from: Some(0x076d6da60aaac6c97a8a0fe8057f9564203ee545), to: None, gas: Some(5471242), gas_price: Some(1025500), value: Some(0), data: Some(Bytes(0x60a0604052600080553480156200001557600080fd5b5060405162004c2338038062004c2383398101604081905262000038916200004a565b6001600160a01b03166080526200007c565b6000602082840312156200005d57600080fd5b81516001600160a01b03811681146200007557600080fd5b9392505050565b608051614b29620000fa600039600081816103cf01528181610ad301528181610b9201528181610f36015281816114ac015281816117a101528181611dd301528181611e7e01528181612082015281816122d7015281816124cc0152818161294501528181612e670152818161305801526132080152614b296000f3fe608060405234801561001057600080fd5b50600436106103825760003560e01c80637a708e92116101de578063d1946dbc1161010f578063e82fec2f116100ad578063f51e435b1161007c578063f51e435b14610a06578063f7a7384014610a19578063f8119d5114610a2c578063fd21ecff14610a3b57600080fd5b8063e82fec2f146109b5578063e8eda9df14610731578063eddf1b79146109c7578063ee3e210b146109f357600080fd5b8063d5eed868116100e9578063d5eed86814610969578063d65dc7a11461097c578063dc7c0bff1461098f578063e43e88a1146109a257600080fd5b8063d1946dbc1461092e578063d579ea7d14610943578063d5ed39331461095657600080fd5b8063bcb6e5221161017c578063c4d66de811610156578063c4d66de8146108e2578063cd112382146108f5578063cea9d26f14610908578063d15e00531461091b57600080fd5b8063bcb6e5221461084d578063bf92857c14610860578063c44b11f7146108a057600080fd5b806394ba89a2116101b857806394ba89a2146108015780639cd1999614610814578063a415bcad14610827578063ab9c4b5d1461083a57600080fd5b80637a708e92146107c85780638e19899e146107db57806394b576de146107ee57600080fd5b806342b0b77c116102b8578063617ba0371161025657806369328dec1161023057806369328dec1461076a57806369a933a51461077d5780636a99c036146107905780636c6f6ae1146107a857600080fd5b8063617ba0371461073157806363c9b86014610744578063680dd47c1461075757600080fd5b8063527517971161029257806352751797146106cb578063563dd613146106f8578063573ade811461070b5780635a3b74b91461071e57600080fd5b806342b0b77c146106545780634417a583146106675780634d013f03146106b857600080fd5b8063272d9072116103255780633036b439116102ff5780633036b4391461048257806335ea6a7514610495578063386497fd1461062e578063427da1771461064157600080fd5b8063272d90721461045457806328530a471461045c5780632dad97d41461046f57600080fd5b80630542975c116103615780630542975c146103ca578063074b2e43146104095780631d2118f91461042e5780631fe3c6f31461044157600080fd5b8062a718a9146103875780630148170e1461039c57806302c205f0146103b7575b600080fd5b61039a6103953660046136cb565b610a4e565b005b6103a4600281565b6040519081526020015b60405180910390f35b61039a6103c5366004613756565b610c62565b6103f17f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016103ae565b603a546001600160801b03165b6040516001600160801b0390911681526020016103ae565b61039a61043c3660046137d5565b610d81565b61039a61044f36600461380e565b610ea7565b6039546103a4565b61039a61046a366004613827565b610ec8565b6103a461047d366004613842565b611066565b61039a61049036600461380e565b61116b565b6106216104a3366004613877565b604080516102008101825260006101e08201818152825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081018290526101c0810191909152506001600160a01b0390811660009081526034602090815260409182902082516102008101845281546101e08201908152815260018201546001600160801b0380821694830194909452600160801b908190048416948201949094526002820154808416606083015284900483166080820152600382015480841660a083015284810464ffffffffff1660c0830152600160a81b900461ffff1660e0820152600482015485166101008201526005820154851661012082015260068201548516610140820152600782015490941661016085015260088101548083166101808601529290920481166101a0840152600990910154166101c082015290565b6040516103ae9190613894565b6103a461063c366004613877565b611178565b61039a61064f36600461380e565b61119f565b61039a610662366004613a10565b6111cf565b6106a9610675366004613877565b60408051602080820183526000918290526001600160a01b0393909316815260358352819020815192830190915254815290565b604051905181526020016103ae565b61039a6106c636600461380e565b6112f3565b6103f16106d9366004613a92565b61ffff166000908152603660205260409020546001600160a01b031690565b6103a461070636600461380e565b611322565b6103a4610719366004613aad565b61134e565b61039a61072c366004613af7565b611452565b61039a61073f366004613b25565b6115db565b61039a610752366004613877565b61168c565b61039a610765366004613b76565b6116e2565b6103a4610778366004613ba2565b61170f565b61039a61078b366004613b25565b6118c8565b603a54600160801b90046001600160801b0316610416565b6107bb6107b6366004613827565b61194f565b6040516103ae9190613c31565b61039a6107d6366004613c86565b611a7c565b61039a6107e936600461380e565b611bc2565b6103a46107fc366004613b76565b611be5565b61039a61080f366004613ce9565b611c20565b61039a610822366004613d5a565b611c94565b61039a610835366004613d9c565b611cd0565b61039a610848366004613ddb565b611f17565b61039a61085b366004613eec565b612229565b61087361086e366004613877565b61224a565b604080519687526020870195909552938501929092526060840152608083015260a082015260c0016103ae565b6106a96108ae366004613877565b60408051602080820183526000918290526001600160a01b0393909316815260348352819020815192830190915254815290565b61039a6108f0366004613877565b612429565b61039a6109033660046137d5565b612568565b61039a610916366004613f1f565b6125cb565b6103a4610929366004613877565b612652565b610936612673565b6040516103ae9190613f60565b61039a61095136600461401d565b612776565b61039a610964366004614137565b61285f565b61039a61097736600461380e565b612a4b565b6103a461098a366004613842565b612aac565b6103a461099d36600461380e565b612b26565b61039a6109b0366004613877565b612b48565b603b5467ffffffffffffffff166103a4565b6103a46109d5366004613877565b6001600160a01b031660009081526038602052604090205460ff1690565b6103a4610a0136600461419c565b612b97565b61039a610a143660046141e2565b612cff565b61039a610a2736600461380e565b612e0e565b604051608081526020016103ae565b61039a610a49366004614223565b612e30565b73398808db36da6ba4e30d4fb88d72c3473921bc6e6383c1087d6034603660356037604051806101200160405280603b60089054906101000a900461ffff1661ffff1681526020018981526020018c6001600160a01b031681526020018b6001600160a01b031681526020018a6001600160a01b0316815260200188151581526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663fca513a86040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b539190614245565b6001600160a01b0390811682528b81166000908152603860209081526040918290205460ff16818501528151635eb88d3d60e01b8152825192909401937f000000000000000000000000000000000000000000000000000000000000000090931692635eb88d3d92600480830193928290030181865afa158015610bdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff9190614245565b6001600160a01b03168152506040518663ffffffff1660e01b8152600401610c2b959493929190614262565b60006040518083038186803b158015610c4357600080fd5b505af4158015610c57573d6000803e3d6000fd5b505050505050505050565b60405163d505accf60e01b81526001600160a01b0389169063d505accf90610c9a90339030908c908a908a908a908a9060040161431b565b600060405180830381600087803b158015610cb457600080fd5b505af1158015610cc8573d6000803e3d6000fd5b5050506001600160a01b038088166000818152603560209081526040918290208251608081018452948e1685529084018c90528382019290925261ffff8916606084015251631913f16160e01b815273b04280b09f47cfd81906817505f24cefe1ba86d29350631913f16192610d47926034926036929060040161435c565b60006040518083038186803b158015610d5f57600080fd5b505af4158015610d73573d6000803e3d6000fd5b505050505050505050505050565b610d89612e5b565b604080518082019091526002815261373760f01b60208201526001600160a01b038316610dd25760405162461bcd60e51b8152600401610dc991906143ad565b60405180910390fd5b506001600160a01b038216600090815260346020526040902060030154600160a81b900461ffff16151580610e3c57506000805260366020527f4cb2b152c1b54ce671907a93c300fd5aa72383a9d4ec19a81e3333632ae92e00546001600160a01b038381169116145b604051806040016040528060028152602001611c1960f11b81525090610e755760405162461bcd60e51b8152600401610dc991906143ad565b506001600160a01b03918216600090815260346020526040902060070180546001600160a01b03191691909216179055565b600080610eb5603684612f2d565b91509150610ec38282611c20565b505050565b7370bf6ec6fca41a7d08dcbb9909985ac0a4510b5e635d5dc313603460366037603860356000336001600160a01b03166001600160a01b031681526020019081526020016000206040518060600160405280603b60089054906101000a900461ffff1661ffff1681526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663fca513a86040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb69190614245565b6001600160a01b031681526020018960ff168152506040518763ffffffff1660e01b81526004016110339695949392919095865260208087019590955260408087019490945260608601929092526080850152805160a0850152918201516001600160a01b031660c0840152015160ff1660e08201526101000190565b60006040518083038186803b15801561104b57600080fd5b505af415801561105f573d6000803e3d6000fd5b5050505050565b600073d1b3e25fd7c8ae7caddc6f71b461b79cd4ddcfa36340e95de66034603660356000336001600160a01b03166001600160a01b031681526020019081526020016000206040518060a001604052808a6001600160a01b031681526020018981526020018860028111156110dd576110dd6143c0565b60028111156110ee576110ee6143c0565b81523360208201526001604091820152516001600160e01b031960e087901b16815261112094939291906004016143f8565b602060405180830381865af415801561113d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611161919061445e565b90505b9392505050565b611173612e5b565b603955565b6001600160a01b038116600090815260346020526040812061119990612f5a565b92915050565b61ffff81166000908152603660205260409020546001600160a01b0390811690601083901c16610ec38282612568565b60006040518060e00160405280886001600160a01b03168152602001876001600160a01b0316815260200186815260200185858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525093855250505061ffff8516602080840191909152603a546001600160801b03600160801b8204811660408087019190915291166060909401939093526001600160a01b038a16825260349052819020905163a1fe0e8d60e01b8152919250731d69c48a35ddd241e72a31db0e637676d89fc5539163a1fe0e8d916112ba918590600401614477565b60006040518083038186803b1580156112d257600080fd5b505af41580156112e6573d6000803e3d6000fd5b5050505050505050505050565b61ffff81166000908152603660205260409020546001600160a01b0316601082901c600116610ec38282611452565b600080600080611333603686612fbe565b9250925092506113458383833361134e565b95945050505050565b600073d1b3e25fd7c8ae7caddc6f71b461b79cd4ddcfa36340e95de66034603660356000876001600160a01b03166001600160a01b031681526020019081526020016000206040518060a001604052808b6001600160a01b031681526020018a81526020018960028111156113c5576113c56143c0565b60028111156113d6576113d66143c0565b81526001600160a01b03891660208201526000604091820152516001600160e01b031960e087901b16815261141194939291906004016143f8565b602060405180830381865af415801561142e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611345919061445e565b73b04280b09f47cfd81906817505f24cefe1ba86d263bf697a2660346036603760356000336001600160a01b03166001600160a01b031681526020019081526020016000208787603b60089054906101000a900461ffff167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663fca513a86040518163ffffffff1660e01b8152600401602060405180830381865afa158015611508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152c9190614245565b336000908152603860205260409081902054905160e08b901b6001600160e01b031916815260048101999099526024890197909752604488019590955260648701939093526001600160a01b039182166084870152151560a486015261ffff90911660c48501521660e483015260ff16610104820152610124015b60006040518083038186803b1580156115bf57600080fd5b505af41580156115d3573d6000803e3d6000fd5b505050505050565b6001600160a01b03808316600081815260356020908152604091829020825160808101845294891685529084018790528382019290925261ffff8416606084015251631913f16160e01b815273b04280b09f47cfd81906817505f24cefe1ba86d292631913f16192611656926034926036929160040161435c565b60006040518083038186803b15801561166e57600080fd5b505af4158015611682573d6000803e3d6000fd5b5050505050505050565b611694612e5b565b604051639cf5702360e01b815260346004820152603660248201526001600160a01b0382166044820152738be473dcfa93132658821e67cbeb684ec8ea2e7490639cf5702390606401611033565b60008060008060006116f5603689613018565b945094509450945094506116828585338686868d8d610c62565b600073b04280b09f47cfd81906817505f24cefe1ba86d263186dea4460346036603760356000336001600160a01b03166001600160a01b031681526020019081526020016000206040518060c001604052808b6001600160a01b031681526020018a8152602001896001600160a01b03168152602001603b60089054906101000a900461ffff1661ffff1681526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663fca513a86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118219190614245565b6001600160a01b039081168252336000908152603860209081526040918290205460ff90811694820194909452815160e08b901b6001600160e01b031916815260048101999099526024890197909752604488019590955260648701939093528151831660848701529381015160a486015291820151811660c4850152606082015160e485015260808201511661010484015260a001511661012482015261014401611120565b6118d0613056565b6001600160a01b03828116600081815260356020526040908190209051630413c86f60e01b81526034600482015260366024820152604481019190915291861660648301526084820185905260a482015261ffff821660c482015273fe76366a986b72c3f2923e05e6ba07b7de5401e490630413c86f9060e401611656565b6040805160a081018252600080825260208201819052918101829052606080820192909252608081019190915260ff8216600090815260376020908152604091829020825160a081018452815461ffff808216835262010000820481169483019490945264010000000081049093169381019390935266010000000000009091046001600160a01b031660608301526001810180546080840191906119f3906144f4565b80601f0160208091040260200160405190810160405280929190818152602001828054611a1f906144f4565b8015611a6c5780601f10611a4157610100808354040283529160200191611a6c565b820191906000526020600020905b815481529060010190602001808311611a4f57829003601f168201915b5050505050815250509050919050565b611a84612e5b565b738be473dcfa93132658821e67cbeb684ec8ea2e746369fc1bdf603460366040518060e001604052808a6001600160a01b03168152602001896001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b03168152602001603b60089054906101000a900461ffff1661ffff168152602001611b1a608090565b61ffff168152506040518463ffffffff1660e01b8152600401611b3f93929190614529565b602060405180830381865af4158015611b5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8091906145ab565b1561105f57603b8054600160401b900461ffff16906008611ba0836145de565b91906101000a81548161ffff021916908361ffff160217905550505050505050565b600080611bd060368461317a565b91509150611bdf82823361170f565b50505050565b600080600080600080611bf960368a6131c6565b94509450945094509450611c138585853386868e8e612b97565b9998505050505050505050565b6001600160a01b0382166000908152603460209081526040808320338452603590925290912073d1b3e25fd7c8ae7caddc6f71b461b79cd4ddcfa39163eac4d7039185856002811115611c7557611c756143c0565b6040518563ffffffff1660e01b81526004016115a79493929190614600565b604051631230b2a360e21b8152738be473dcfa93132658821e67cbeb684ec8ea2e74906348c2ca8c906115a7906034908690869060040161462a565b73d1b3e25fd7c8ae7caddc6f71b461b79cd4ddcfa3631e6473f960346036603760356000876001600160a01b03166001600160a01b031681526020019081526020016000206040518061018001604052808c6001600160a01b03168152602001336001600160a01b03168152602001886001600160a01b031681526020018b81526020018a6002811115611d6657611d666143c0565b6002811115611d7757611d776143c0565b815261ffff808b166020808401919091526001604080850191909152603b5467ffffffffffffffff81166060860152600160401b900490921660808401528151631f94a27560e31b8152915160a0909301926001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169263fca513a89260048083019391928290030181865afa158015611e1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3f9190614245565b6001600160a01b0390811682528981166000908152603860209081526040918290205460ff16818501528151635eb88d3d60e01b8152825192909401937f000000000000000000000000000000000000000000000000000000000000000090931692635eb88d3d92600480830193928290030181865afa158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190614245565b6001600160a01b03168152506040518663ffffffff1660e01b8152600401610c2b959493929190614682565b6000604051806101c001604052808d6001600160a01b031681526020018c8c808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040805160208c810282810182019093528c82529283019290918d918d9182918501908490808284376000920191909152505050908252506040805160208a810282810182019093528a82529283019290918b918b9182918501908490808284376000920191909152505050908252506001600160a01b03871660208083019190915260408051601f88018390048302810183018252878152920191908790879081908401838280828437600092018290525093855250505061ffff808616602080850191909152603a546001600160801b03600160801b8204811660408088019190915291166060860152603b5467ffffffffffffffff81166080870152600160401b900490921660a08501526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660c08601819052908b16845260388252928290205460ff1660e0850152815163383e6b8b60e11b815291516101009094019363707cd7169260048082019392918290030181865afa1580156120fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121209190614245565b60405163fa50f29760e01b81523360048201526001600160a01b03919091169063fa50f29790602401602060405180830381865afa158015612166573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218a91906145ab565b151590526001600160a01b03861660009081526035602052604090819020905163173931f560e11b8152919250731d69c48a35ddd241e72a31db0e637676d89fc55391632e7263ea916121eb916034916036916037919088906004016147ea565b60006040518083038186803b15801561220357600080fd5b505af4158015612217573d6000803e3d6000fd5b50505050505050505050505050505050565b612231612e5b565b6001600160801b03908116600160801b02911617603a55565b604080516001600160a01b0383811660008181526035602090815285822060c0860187525460a086019081528552603b54600160401b900461ffff1681860152848601929092528451631f94a27560e31b81529451909485948594859485948594738be473dcfa93132658821e67cbeb684ec8ea2e74946326ec273f9460349460369460379460608501937f0000000000000000000000000000000000000000000000000000000000000000169263fca513a8926004808401938290030181865afa15801561231d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123419190614245565b6001600160a01b0390811682528e81166000908152603860209081526040918290205460ff90811694820194909452815160e08a901b6001600160e01b0319168152600481019890985260248801969096526044870194909452825151606487015293820151608486015291810151831660a4850152606081015190921660c48401526080909101511660e48201526101040160c060405180830381865af41580156123f1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612415919061494b565b949c939b5091995097509550909350915050565b60015460029060ff168061243c5750303b155b80612448575060005481115b6124ab5760405162461bcd60e51b815260206004820152602e60248201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560448201526d195b881a5b9a5d1a585b1a5e995960921b6064820152608401610dc9565b60015460ff161580156124ca576001805460ff19168117905560008290555b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161460405180604001604052806002815260200161189960f11b815250906125385760405162461bcd60e51b8152600401610dc991906143ad565b50603b805467ffffffffffffffff19166109c41790556009603a558015610ec3576001805460ff19169055505050565b6001600160a01b03828116600081815260346020526040908190209051631a5cfdd160e21b815260048101919091526024810191909152908216604482015273d1b3e25fd7c8ae7caddc6f71b461b79cd4ddcfa390636973f744906064016115a7565b6125d3613206565b6040516343d9915960e11b81526001600160a01b0380851660048301528316602482015260448101829052738be473dcfa93132658821e67cbeb684ec8ea2e74906387b322b29060640160006040518083038186803b15801561263557600080fd5b505af4158015612649573d6000803e3d6000fd5b50505050505050565b6001600160a01b03811660009081526034602052604081206111999061332a565b603b54606090600160401b900461ffff166000808267ffffffffffffffff8111156126a0576126a0613fad565b6040519080825280602002602001820160405280156126c9578160200160208202803683370190505b50905060005b8381101561276c576000818152603660205260409020546001600160a01b03161561274c576000818152603660205260409020546001600160a01b0316826127178584614995565b81518110612727576127276149ac565b60200260200101906001600160a01b031690816001600160a01b03168152505061275a565b82612756816149c2565b9350505b80612764816149c2565b9150506126cf565b5091038152919050565b61277e612e5b565b604080518082019091526002815261189b60f11b602082015260ff83166127b85760405162461bcd60e51b8152600401610dc991906143ad565b5060ff821660009081526037602090815260409182902083518154838601519486015160608701516001600160a01b03166601000000000000026601000000000000600160d01b031961ffff9283166401000000000216640100000000600160d01b0319978316620100000263ffffffff1990941692909416919091179190911794909416179290921782556080830151805184939261105f9260018501929101906135ff565b6001600160a01b038681166000908152603460209081526040918290206004015482518084019093526002835261313160f01b9183019190915290911633146128bb5760405162461bcd60e51b8152600401610dc991906143ad565b5073b04280b09f47cfd81906817505f24cefe1ba86d2638a5dadd160346036603760356040518061012001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018b6001600160a01b031681526020018a8152602001898152602001888152602001603b60089054906101000a900461ffff1661ffff1681526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663fca513a86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c59190614245565b6001600160a01b0390811682528d166000908152603860209081526040918290205460ff16920191909152516001600160e01b031960e088901b168152612a139594939291906004016149dd565b60006040518083038186803b158015612a2b57600080fd5b505af4158015612a3f573d6000803e3d6000fd5b50505050505050505050565b600080600080612a9760368661ffff81811660009081526020939093526040909220546001600160a01b0316926001600160801b03601083901c169260ff609084901c169260981c1690565b935093509350935061105f8484848433611cd0565b6000612ab6613056565b6001600160a01b0384166000818152603460205260409081902060395491516311ce864960e31b8152600481019190915260248101929092526044820185905260648201849052608482015273fe76366a986b72c3f2923e05e6ba07b7de5401e490638e7432489060a401611120565b600080600080612b37603686612fbe565b925092509250611345838383611066565b612b50612e5b565b604051631e3b414560e01b8152603460048201526001600160a01b0382166024820152738be473dcfa93132658821e67cbeb684ec8ea2e7490631e3b414590604401611033565b60405163d505accf60e01b81526000906001600160a01b038a169063d505accf90612bd290339030908d908b908b908b908b9060040161431b565b600060405180830381600087803b158015612bec57600080fd5b505af1158015612c00573d6000803e3d6000fd5b5050505060006040518060a001604052808b6001600160a01b031681526020018a8152602001896002811115612c3857612c386143c0565b6002811115612c4957612c496143c0565b81526001600160a01b038916602080830182905260006040938401819052918252603590528190209051632074aef360e11b815291925073d1b3e25fd7c8ae7caddc6f71b461b79cd4ddcfa3916340e95de691612cb09160349160369187906004016143f8565b602060405180830381865af4158015612ccd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cf1919061445e565b9a9950505050505050505050565b612d07612e5b565b604080518082019091526002815261373760f01b60208201526001600160a01b038316612d475760405162461bcd60e51b8152600401610dc991906143ad565b506001600160a01b038216600090815260346020526040902060030154600160a81b900461ffff16151580612db157506000805260366020527f4cb2b152c1b54ce671907a93c300fd5aa72383a9d4ec19a81e3333632ae92e00546001600160a01b038381169116145b604051806040016040528060028152602001611c1960f11b81525090612dea5760405162461bcd60e51b8152600401610dc991906143ad565b506001600160a01b0382166000908152603460205260409020813581558190611bdf565b6000806000612e1e603685613382565b925092509250611bdf838333846115db565b6000806000806000612e44603688886133bd565b945094509450945094506126498585858585610a4e565b336001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663631adfca6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ec3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ee79190614245565b6001600160a01b03161460405180604001604052806002815260200161031360f41b81525090612f2a5760405162461bcd60e51b8152600401610dc991906143ad565b50565b61ffff81166000908152602083905260409020546001600160a01b0316601082901c60ff165b9250929050565b6003810154600090600160801b900464ffffffffff1642811415612f8a575050600201546001600160801b031690565b6002830154611164906001600160801b0380821691612fb291600160801b9091041684613440565b9061344d565b50919050565b6000808061ffff84166001600160801b03601086901c81169060ff609088901c1690821415612fed5760001991505b61ffff9092166000908152602088905260409020546001600160a01b03169450925090509250925092565b60008080808060a086901c63ffffffff1660c087901c60ff1682808061303e8c8c613382565b919e909d50909b509499509297509295505050505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663707cd7166040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130d89190614245565b604051633933006760e11b81523360048201526001600160a01b03919091169063726600ce90602401602060405180830381865afa15801561311e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061314291906145ab565b604051806040016040528060018152602001601b60f91b81525090612f2a5760405162461bcd60e51b8152600401610dc991906143ad565b60008061ffff83166001600160801b03601085901c81169081141561319e57506000195b61ffff9190911660009081526020959095526040909420546001600160a01b03169492505050565b6000806000806000806000806000806131df8c8c612fbe565b919e909d50909b609881901c63ffffffff169b5060b81c60ff169950975050505050505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663707cd7166040518163ffffffff1660e01b8152600401602060405180830381865afa158015613264573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132889190614245565b604051637be53ca160e01b81523360048201526001600160a01b039190911690637be53ca190602401602060405180830381865afa1580156132ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132f291906145ab565b604051806040016040528060018152602001603160f81b81525090612f2a5760405162461bcd60e51b8152600401610dc991906143ad565b6003810154600090600160801b900464ffffffffff164281141561335a575050600101546001600160801b031690565b6001830154611164906001600160801b0380821691612fb291600160801b9091041684613491565b61ffff8181166000908152602084905260409020546001600160a01b031690601083901c6001600160801b031690609084901c169250925092565b60008080808061ffff87811690601089901c16602089901c6001600160a01b03166001600160801b038981169060808b901c600116908214156134005760001991505b61ffff948516600090815260209d909d526040808e2054949095168d5293909b20546001600160a01b039283169c92169a90995097509095509350505050565b60006111648383426134d6565b600081156b019d971e4fe8401e74000000198390048411151761346f57600080fd5b506b033b2e3c9fd0803ce800000091026b019d971e4fe8401e74000000010490565b6000806134a564ffffffffff841642614995565b6134af9085614a84565b6301e13380900490506134ce816b033b2e3c9fd0803ce8000000614ab9565b949350505050565b6000806134ea64ffffffffff851684614995565b905080613506576b033b2e3c9fd0803ce8000000915050611164565b6000198101600080806002851161351e576000613523565b600285035b925066038882915c40006135378a8061344d565b8161354457613544614aa3565b0491506301e13380613556838b61344d565b8161356357613563614aa3565b0490506000826135738688614a84565b61357d9190614a84565b60029004905060008285613591888a614a84565b61359b9190614a84565b6135a59190614a84565b60069004905080826301e133806135bc8a8f614a84565b6135c69190614ad1565b6135dc906b033b2e3c9fd0803ce8000000614ab9565b6135e69190614ab9565b6135f09190614ab9565b9b9a5050505050505050505050565b82805461360b906144f4565b90600052602060002090601f01602090048101928261362d5760008555613673565b82601f1061364657805160ff1916838001178555613673565b82800160010185558215613673579182015b82811115613673578251825591602001919060010190613658565b5061367f929150613683565b5090565b5b8082111561367f5760008155600101613684565b6001600160a01b0381168114612f2a57600080fd5b80356136b881613698565b919050565b8015158114612f2a57600080fd5b600080600080600060a086880312156136e357600080fd5b85356136ee81613698565b945060208601356136fe81613698565b9350604086013561370e81613698565b9250606086013591506080860135613725816136bd565b809150509295509295909350565b803561ffff811681146136b857600080fd5b803560ff811681146136b857600080fd5b600080600080600080600080610100898b03121561377357600080fd5b883561377e81613698565b975060208901359650604089013561379581613698565b95506137a360608a01613733565b9450608089013593506137b860a08a01613745565b925060c0890135915060e089013590509295985092959890939650565b600080604083850312156137e857600080fd5b82356137f381613698565b9150602083013561380381613698565b809150509250929050565b60006020828403121561382057600080fd5b5035919050565b60006020828403121561383957600080fd5b61116482613745565b60008060006060848603121561385757600080fd5b833561386281613698565b95602085013595506040909401359392505050565b60006020828403121561388957600080fd5b813561116481613698565b81515181526101e0810160208301516138b860208401826001600160801b03169052565b5060408301516138d360408401826001600160801b03169052565b5060608301516138ee60608401826001600160801b03169052565b50608083015161390960808401826001600160801b03169052565b5060a083015161392460a08401826001600160801b03169052565b5060c083015161393d60c084018264ffffffffff169052565b5060e083015161395360e084018261ffff169052565b50610100838101516001600160a01b039081169184019190915261012080850151821690840152610140808501518216908401526101608085015190911690830152610180808401516001600160801b03908116918401919091526101a0808501518216908401526101c09384015116929091019190915290565b60008083601f8401126139e057600080fd5b50813567ffffffffffffffff8111156139f857600080fd5b602083019150836020828501011115612f5357600080fd5b60008060008060008060a08789031215613a2957600080fd5b8635613a3481613698565b95506020870135613a4481613698565b945060408701359350606087013567ffffffffffffffff811115613a6757600080fd5b613a7389828a016139ce565b9094509250613a86905060808801613733565b90509295509295509295565b600060208284031215613aa457600080fd5b61116482613733565b60008060008060808587031215613ac357600080fd5b8435613ace81613698565b935060208501359250604085013591506060850135613aec81613698565b939692955090935050565b60008060408385031215613b0a57600080fd5b8235613b1581613698565b91506020830135613803816136bd565b60008060008060808587031215613b3b57600080fd5b8435613b4681613698565b9350602085013592506040850135613b5d81613698565b9150613b6b60608601613733565b905092959194509250565b600080600060608486031215613b8b57600080fd5b505081359360208301359350604090920135919050565b600080600060608486031215613bb757600080fd5b8335613bc281613698565b9250602084013591506040840135613bd981613698565b809150509250925092565b6000815180845260005b81811015613c0a57602081850181015186830182015201613bee565b81811115613c1c576000602083870101525b50601f01601f19169290920160200192915050565b60208152600061ffff8084511660208401528060208501511660408401528060408501511660608401525060018060a01b036060840151166080830152608083015160a0808401526134ce60c0840182613be4565b600080600080600060a08688031215613c9e57600080fd5b8535613ca981613698565b94506020860135613cb981613698565b93506040860135613cc981613698565b92506060860135613cd981613698565b9150608086013561372581613698565b60008060408385031215613cfc57600080fd5b8235613d0781613698565b946020939093013593505050565b60008083601f840112613d2757600080fd5b50813567ffffffffffffffff811115613d3f57600080fd5b6020830191508360208260051b8501011115612f5357600080fd5b60008060208385031215613d6d57600080fd5b823567ffffffffffffffff811115613d8457600080fd5b613d9085828601613d15565b90969095509350505050565b600080600080600060a08688031215613db457600080fd5b8535613dbf81613698565b94506020860135935060408601359250613cd960608701613733565b600080600080600080600080600080600060e08c8e031215613dfc57600080fd5b613e058c6136ad565b9a5067ffffffffffffffff8060208e01351115613e2157600080fd5b613e318e60208f01358f01613d15565b909b50995060408d0135811015613e4757600080fd5b613e578e60408f01358f01613d15565b909950975060608d0135811015613e6d57600080fd5b613e7d8e60608f01358f01613d15565b9097509550613e8e60808e016136ad565b94508060a08e01351115613ea157600080fd5b50613eb28d60a08e01358e016139ce565b9093509150613ec360c08d01613733565b90509295989b509295989b9093969950565b80356001600160801b03811681146136b857600080fd5b60008060408385031215613eff57600080fd5b613f0883613ed5565b9150613f1660208401613ed5565b90509250929050565b600080600060608486031215613f3457600080fd5b8335613f3f81613698565b92506020840135613f4f81613698565b929592945050506040919091013590565b6020808252825182820181905260009190848201906040850190845b81811015613fa15783516001600160a01b031683529284019291840191600101613f7c565b50909695505050505050565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff81118282101715613fe657613fe6613fad565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561401557614015613fad565b604052919050565b6000806040838503121561403057600080fd5b61403983613745565b915060208084013567ffffffffffffffff8082111561405757600080fd5b9085019060a0828803121561406b57600080fd5b614073613fc3565b61407c83613733565b8152614089848401613733565b8482015261409960408401613733565b604082015260608301356140ac81613698565b60608201526080830135828111156140c357600080fd5b80840193505087601f8401126140d857600080fd5b8235828111156140ea576140ea613fad565b6140fc601f8201601f19168601613fec565b9250808352888582860101111561411257600080fd5b8085850186850137600085828501015250816080820152809450505050509250929050565b60008060008060008060c0878903121561415057600080fd5b863561415b81613698565b9550602087013561416b81613698565b9450604087013561417b81613698565b959894975094956060810135955060808101359460a0909101359350915050565b600080600080600080600080610100898b0312156141b957600080fd5b88356141c481613698565b9750602089013596506040890135955060608901356137a381613698565b60008082840360408112156141f657600080fd5b833561420181613698565b92506020601f198201121561421557600080fd5b506020830190509250929050565b6000806040838503121561423657600080fd5b50508035926020909101359150565b60006020828403121561425757600080fd5b815161116481613698565b60006101a08201905086825285602083015284604083015283606083015282516080830152602083015160a0830152604083015160018060a01b0380821660c08501528060608601511660e0850152505060808301516101006142cf818501836001600160a01b03169052565b60a0850151151561012085015260c08501516001600160a01b0390811661014086015260e086015160ff166101608601529085015190811661018085015290505b509695505050505050565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b93845260208085019390935260408085019290925280516001600160a01b039081166060808701919091529382015160808601529181015190911660a0840152015161ffff1660c082015260e00190565b6020815260006111646020830184613be4565b634e487b7160e01b600052602160045260246000fd5b600381106143f457634e487b7160e01b600052602160045260246000fd5b9052565b8481526020808201859052604080830185905283516001600160a01b0390811660608501529184015160808401528301516101008301919061443d60a08501826143d6565b5060608401511660c0830152608090920151151560e0909101529392505050565b60006020828403121561447057600080fd5b5051919050565b82815260406020820152600060018060a01b038084511660408401528060208501511660608401525060408301516080830152606083015160e060a08401526144c4610120840182613be4565b905061ffff60808501511660c084015260a084015160e084015260c0840151610100840152809150509392505050565b600181811c9082168061450857607f821691505b60208210811415612fb857634e487b7160e01b600052602260045260246000fd5b60006101208201905084825283602083015260018060a01b038084511660408401528060208501511660608401528060408501511660808401528060608501511660a08401528060808501511660c08401525060a083015161459160e084018261ffff169052565b5060c083015161ffff811661010084015250949350505050565b6000602082840312156145bd57600080fd5b8151611164816136bd565b634e487b7160e01b600052601160045260246000fd5b600061ffff808316818114156145f6576145f66145c8565b6001019392505050565b848152602081018490526001600160a01b03831660408201526080810161134560608301846143d6565b83815260406020808301829052908201839052600090849060608401835b8681101561467657833561465b81613698565b6001600160a01b031682529282019290820190600101614648565b50979650505050505050565b85815260208101859052604081018490526060810183905281516001600160a01b03166080820152610200810160208301516001600160a01b03811660a08401525060408301516001600160a01b03811660c084015250606083015160e083015260808301516101006146f7818501836143d6565b60a085015191506101206147108186018461ffff169052565b60c086015192506101406147278187018515159052565b60e08701516101608781019190915292870151610180870152908601516001600160a01b039081166101a08701529086015160ff166101c0860152908501519081166101e08501529050614310565b600081518084526020808501945080840160005b838110156147af5781516001600160a01b03168752958201959082019060010161478a565b509495945050505050565b600081518084526020808501945080840160005b838110156147af578151875295820195908201906001016147ce565b85815284602082015283604082015282606082015260a0608082015261481c60a0820183516001600160a01b03169052565b600060208301516101c08060c085015261483a610260850183614776565b91506040850151609f19808685030160e087015261485884836147ba565b93506060870151915061010081878603018188015261487785846147ba565b945060808801519250610120614897818901856001600160a01b03169052565b60a089015193506101408389880301818a01526148b48786613be4565b965060c08a0151945061016093506148d1848a018661ffff169052565b60e08a0151945061018085818b0152838b015195506101a0935085848b0152828b0151878b0152818b01516101e08b0152848b0151965061491e6102008b01886001600160a01b03169052565b8a015160ff81166102208b01529550614935915050565b8701518015156102408801529250614676915050565b60008060008060008060c0878903121561496457600080fd5b865195506020870151945060408701519350606087015192506080870151915060a087015190509295509295509295565b6000828210156149a7576149a76145c8565b500390565b634e487b7160e01b600052603260045260246000fd5b60006000198214156149d6576149d66145c8565b5060010190565b858152602080820186905260408083018690526060830185905283516001600160a01b03908116608085015291840151821660a084015283015190811660c08301526101a082019050606083015160e08301526080830151610100818185015260a085015161012085015260c085015161014085015260e08501519150614a706101608501836001600160a01b03169052565b84015160ff81166101808501529050614310565b6000816000190483118215151615614a9e57614a9e6145c8565b500290565b634e487b7160e01b600052601260045260246000fd5b60008219821115614acc57614acc6145c8565b500190565b600082614aee57634e487b7160e01b600052601260045260246000fd5b50049056fea2646970667358221220f6769d32e0ac31119d7b10dd21f594f43b5c200cbb0caa8918fcd35da891a0f464736f6c634300080a0033000000000000000000000000a97684ead0e402dc232d5a977953df7ecbab3cdb)), nonce: Some(25), chain_id: Some(10) })

I don't really see any difference, both shows chain_id: Some(10).
I asked someone else from the team to try on their ledger, and it's reproducible for them as well.
With make recover-optimism-ledger you can reproduce (you don't need to submit the txn, but will see the error on your device).

@mattsse
Copy link
Member

mattsse commented Feb 24, 2023

okay this looks like an rlp issue for legacy tx, giga cursed.

checking rn

@mattsse
Copy link
Member

mattsse commented Feb 24, 2023

oh I think I've found it

@mattsse
Copy link
Member

mattsse commented Feb 24, 2023

oh nevermind, I did not.
rlp encoding seems okay when we hand it over to ledger

I does not make any sense why ledger would see the chain id as 0

@mattsse
Copy link
Member

mattsse commented Feb 24, 2023

this is the relevant ledger code. doesn't make sense if chain_id is already set to 10 why it would suddenly be 0

https://github.com/gakonst/ethers-rs/blob/7e12f3ba363158a2d0e2598523e92ead7beb9386/ethers-signers/src/ledger/app.rs#L121-L126

any ideas @prestwich ?

@prestwich
Copy link
Contributor

🤔 this behavior would make sense if neither the Signer nor the TypedTransaction had a chain id set. That would cause the RLP logic to serialize the transaction as non-EIP-155

Where is the Signer chain_id set in the forge setup logic?

@mattsse
Copy link
Member

mattsse commented Feb 24, 2023

this is the relevant section

tracing::debug!("sending transaction: {:?}", legacy_or_1559);
// Chains which use `eth_estimateGas` are being sent sequentially and require their gas
// to be re-estimated right before broadcasting.
if has_different_gas_calc(signer.signer().chain_id()) || self.skip_simulation {
// if already set, some RPC endpoints might simply return the gas value that is
// already set in the request and omit the estimate altogether, so
// we remove it here
let _ = legacy_or_1559.gas_mut().take();
self.estimate_gas(&mut legacy_or_1559, signer.provider()).await?;
}
// Signing manually so we skip `fill_transaction` and its `eth_createAccessList`
// request.
let signature = signer
.sign_transaction(
&legacy_or_1559,
*legacy_or_1559.from().expect("Tx should have a `from`."),
)
.await
.wrap_err_with(|| "Failed to sign transaction")?;
// Submit the raw transaction
let pending =
signer.provider().send_raw_transaction(legacy_or_1559.rlp_signed(&signature)).await?;
Ok(pending.tx_hash())

what's weird is, the trace posted above clearly contains the chain id before when hand this over to ledger

@mattsse
Copy link
Member

mattsse commented Feb 24, 2023

I first thought there's an issue with legacy_or_1559.rlp_signed(&signature) but this is of course after ledger signed it

and the rlp function used during signing does set chain id

https://github.com/gakonst/ethers-rs/blob/7e12f3ba363158a2d0e2598523e92ead7beb9386/ethers-core/src/types/transaction/request.rs#L164-L169

@prestwich
Copy link
Contributor

@prestwich
Copy link
Contributor

@sakulstra when you run with RUST_LOG=forge=trace,foundry_cli=trace, does this log line show:

trace!(?chain_id, "Creating new ledger signer");

@prestwich
Copy link
Contributor

prestwich commented Feb 24, 2023

Have reproduced. Setting RUST_LOG=coins_ledger=trace shows the following RLP blob being sent to the device in 2 packets

f901e980830f4240830205b5943cd1dfb81c50a5300c60a181ed145a7286d81e0a80b901c4183fb413000000000000000000000000794a61358d6845594f94dc1db02a252b5b4814ad0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000b41544f4b454e5f494d504c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b41544f4b454e5f494d504c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000

2023-02-24T21:23:32.068933Z DEBUG coins_ledger::transports: dispatching APDU to device command=APDUCommand { ins: 4, p1: 0, p2: 0, data: "058000002c8000003c800000000000000000000000f901e980830f4240830205b5943cd1dfb81c50a5300c60a181ed145a7286d81e0a80b901c4183fb413000000000000000000000000794a61358d6845594f94dc1db02a252b5b4814ad0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000", response_len: None }
2023-02-24T21:23:32.094669Z DEBUG coins_ledger::transports: Received response from device retcode=36864 response=""
2023-02-24T21:23:32.094733Z DEBUG coins_ledger::transports: dispatching APDU to device command=APDUCommand { ins: 4, p1: 128, p2: 0, data: "000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000180000000000000000000000000000000000000000000000000000000000000000b41544f4b454e5f494d504c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b41544f4b454e5f494d504c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043078303000000000000000000000000000000000000000000000000000000000", response_len: None }

this RLP string is exactly 3 bytes shorter than you would expect for a valid RLP-serialized tx. The three bytes that are missing would correspond to chain_id, r, and s. This could explain why chain_id is 0. If Ledger has permissive deser for these fields (code is here, but i haven't analyzed it at all) then they might be 0 after deser of the invalid RLP

have to leave my desk, but will dig deeper re why the RLP is being generated invalid in the first place when i get back

@prestwich
Copy link
Contributor

looks like this is a bug in the app on the ledger device. Optimism was a red herring

LedgerHQ/app-ethereum#409

@prestwich
Copy link
Contributor

Just tested, and have confirmed that gakonst/ethers-rs#2192 will mitigate. Device now shows Optimism :)

@rkrasiuk
Copy link
Collaborator

rkrasiuk commented Mar 6, 2023

should be closed by #4477

@mattsse mattsse closed this as completed Mar 6, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Mar 6, 2023
@sakulstra
Copy link
Contributor Author

@mattsse is this released? Tried to verify, but for me on latest nightly the issue still persists.

@mattsse
Copy link
Member

mattsse commented Mar 6, 2023

not in nightly yet, triggering release now, should be available in ~45min

@sakulstra
Copy link
Contributor Author

Possible this issue was somehow reintroduced?
Ppl reporting same behavior (chainId turning 0) when deploying via ledger on metis (pk deployment is fine).

Will try to provide a reproduction next week 😅

@prestwich
Copy link
Contributor

there haven't been any changes to these codepaths in the ledger signer, so it seems unlikely the issue was reintroduced

this is, ofc, an issue with the ledger ethereum app, not with ethers-rs, so no amount of mitigation we do can fix it 😮‍💨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants